Skip to content

Commit

Permalink
Merge pull request #4 from Azure/master
Browse files Browse the repository at this point in the history
Sync
  • Loading branch information
bashahee authored Oct 28, 2019
2 parents a9f8057 + 5127415 commit c4904fe
Show file tree
Hide file tree
Showing 147 changed files with 40,883 additions and 778 deletions.
1 change: 1 addition & 0 deletions src/Network/Network.Test/Network.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Microsoft.Azure.Management.Redis" Version="4.4.1" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.19.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.10.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.36.0-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,21 @@ public void TestApplicationGatewayCRUDRewriteRuleSetWithConditions()
{
TestRunner.RunTestScript(string.Format("Test-ApplicationGatewayCRUDRewriteRuleSetWithConditions -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev)]
public void TestTopLevelWafResourceWithApplicationGateway()
{
TestRunner.RunTestScript(string.Format("Test-ApplicationGatewayTopLevelFirewallPolicy -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev)]
public void TestApplicationGatewayWithFirewallPolicy()
{
TestRunner.RunTestScript(string.Format("Test-ApplicationGatewayWithFirewallPolicy -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
}
}
}
473 changes: 473 additions & 0 deletions src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions src/Network/Network.Test/ScenarioTests/IpGroupTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Commands.Network.Test.ScenarioTests
{
public class IpGroupTests : NetworkTestRunner
{
public IpGroupTests(Xunit.Abstractions.ITestOutputHelper output)
: base(output)
{
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
public void TestIpGroupBasicOperations()
{
TestRunner.RunTestScript(string.Format("Test-IpGroupsCRUD"));
}
}
}
61 changes: 61 additions & 0 deletions src/Network/Network.Test/ScenarioTests/IpGroupTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#----------------------------------------------------------------------------------

#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

function Check-CmdletReturnType
{
param($cmdletName, $cmdletReturn)

$cmdletData = Get-Command $cmdletName
Assert-NotNull $cmdletData
[array]$cmdletReturnTypes = $cmdletData.OutputType.Name | Foreach-Object { return ($_ -replace "Microsoft.Azure.Commands.Network.Models.","") }
[array]$cmdletReturnTypes = $cmdletReturnTypes | Foreach-Object { return ($_ -replace "System.","") }
$realReturnType = $cmdletReturn.GetType().Name -replace "Microsoft.Azure.Commands.Network.Models.",""
return $cmdletReturnTypes -contains $realReturnType
}

<#
.SYNOPSIS
Test creating new IpGroups
#>
function Test-IpGroupsCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$rglocation = Get-ProviderLocation ResourceManagement "westus"
$location = Get-ProviderLocation ResourceManagement "westus"
$IpGroupsName = Get-ResourceName

try
{
# Create the resource group
New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }

# Create IpGroup
$actualIpGroup = New-AzIpGroup -ResourceGroupName $rgname -location $location -Name $IpGroupsName -IpAddress 10.0.0.0/24,11.9.0.0/24
$expectedIpGroup = Get-AzIpGroup -ResourceGroupName $rgname -Name $IpGroupsName
Assert-AreEqual $expectedIpGroup.ResourceGroupName $actualIpGroup.ResourceGroupName
Assert-AreEqual $expectedIpGroup.Name $actualIpGroup.Name

# Delete IpGroup
$deleteIpGroup = Remove-AzIpGroup -ResourceGroupName $rgname -Name $IpGroupsName -PassThru -Force
Assert-AreEqual true $deleteIpGroup

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,13 @@ public void TestPrivateLinkServiceCRUD()
{
TestRunner.RunTestScript("Test-PrivateLinkServiceCRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestPrivateEndpointConnectionCRUD()
{
TestRunner.RunTestScript("Test-PrivateEndpointConnectionCRUD");
}
}
}
85 changes: 85 additions & 0 deletions src/Network/Network.Test/ScenarioTests/PrivateLinkServiceTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,88 @@ function Test-PrivateLinkServiceCRUD
}
}

<#
.SYNOPSIS
Test operation for PrivateEndpointConnection.
#>
function Test-PrivateEndpointConnectionCRUD
{
# Setup
$rgname = Get-ResourceGroupName;
$rname = Get-ResourceName;
$location = Get-ProviderLocation "Microsoft.Network/privateLinkServices" "westus2";
# Dependency parameters
$IpConfigurationName = "IpConfigurationName";
$vnetName = Get-ResourceName;
$ilbFrontName = "LB-Frontend";
$ilbBackendName = "LB-Backend";
$ilbName = Get-ResourceName;

$serverName = Get-ResourceName
$serverLogin = "testusername"
<#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test passwords only valid for the duration of the test")]#>
$serverPassword = "t357ingP@s5w0rd!Sec"
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
$databaseName = "mySampleDatabase"
$peName = "mype"
$subId = getSubscription

try
{
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location;

if ((Get-NetworkTestMode) -ne 'Playback')
{
# Create Sql Storage Account
$server = New-AzSqlServer -ResourceGroupName $rgname `
-ServerName $serverName `
-Location $location `
-SqlAdministratorCredentials $credentials

$database = New-AzSqlDatabase -ResourceGroupName $rgname `
-ServerName $serverName `
-DatabaseName $databaseName `
-RequestedServiceObjectiveName "Basic" `
-Edition "Basic"

$sqlResourceId = $server.ResourceId
}
else
{
$sqlResourceId = "/subscriptions/$subId/resourceGroups/$rgname/providers/Microsoft.Sql/servers/$serverName"
}

# Create Private Endpoint
$peSubnet = New-AzVirtualNetworkSubnetConfig -Name peSubnet -AddressPrefix "11.0.1.0/24" -PrivateEndpointNetworkPolicies "Disabled"
$vnetPE = New-AzVirtualNetwork -Name "vnetPE" -ResourceGroupName $rgname -Location $location -AddressPrefix "11.0.0.0/16" -Subnet $peSubnet

$plsConnection= New-AzPrivateLinkServiceConnection -Name plsConnection -PrivateLinkServiceId $sqlResourceId -GroupId 'sqlServer'
$privateEndpoint = New-AzPrivateEndpoint -ResourceGroupName $rgname -Name $peName -Location $location -Subnet $vnetPE.subnets[0] -PrivateLinkServiceConnection $plsConnection -ByManualRequest

# Get Private Endpoint Connection
$pecGet = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $sqlResourceId
Assert-NotNull $pecGet;
Assert-AreEqual "Pending" $pecGet.PrivateLinkServiceConnectionState.Status

# Approve Private Endpoint Connection
$pecApprove = Approve-AzPrivateEndpointConnection -ResourceId $pecGet.Id
Assert-NotNull $pecApprove;
Assert-AreEqual "Approved" $pecApprove.PrivateLinkServiceConnectionState.Status

Start-TestSleep 30000

# Remove Private Endpoint Connection
$pecRemove = Remove-AzPrivateEndpointConnection -ResourceId $pecGet.Id -PassThru -Force
Assert-AreEqual true $pecRemove

# Get Private Endpoint Connection again
$pecGet2 = Get-AzPrivateEndpointConnection -PrivateLinkResourceId $sqlResourceId
Assert-Null($pecGet2)

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname;
}
}
Loading

0 comments on commit c4904fe

Please sign in to comment.