Skip to content

Commit

Permalink
Merge pull request #6 from Azure/dev
Browse files Browse the repository at this point in the history
merge from master
  • Loading branch information
yaakoviyun committed Dec 14, 2015
2 parents 647e298 + df0dc13 commit 489cb2e
Show file tree
Hide file tree
Showing 39 changed files with 14,816 additions and 3,735 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ function Get-ProviderLocation($provider)
return "West US"
} else
{
return $location.Locations[0]
if($location.Locations[0] -eq "West US")
{
return $location.Locations[1]
}
else
{
return $location.Locations[0]
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Commands.Network.Test.ScenarioTests
{
public class LocalNetworkGatewayTests : Microsoft.WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
{
[Fact(Skip = "Rerecord tests")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestLocalNetworkGatewayCRUD()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ namespace Commands.Network.Test.ScenarioTests
{
public class VirtualNetworkGatewayConnectionTests : Microsoft.WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
{
[Fact(Skip = "TODO: Test runs for 40 minutes beforef failing, needs to be fixed")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualNetworkGatewayConnectionCRUD()
{
NetworkResourcesController.NewInstance.RunPsTest("Test-VirtualNetworkGatewayConnectionCRUD");
}

[Fact(Skip = "TODO: Will send another PR after re-recording test")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualNetworkGatewayConnectionSharedKeyCRUD()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Test-VirtualNetworkGatewayConnectionCRUD
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual "IPsec" $expected.ConnectionType
Assert-AreEqual "3" $expected.RoutingWeight
Assert-AreEqual "abc" $expected.SharedKey
#Assert-AreEqual "abc" $expected.SharedKey

# List VirtualNetworkGatewayConnections
$list = Get-AzureRmVirtualNetworkGatewayConnection -ResourceGroupName $rgname
Expand All @@ -81,7 +81,7 @@ function Test-VirtualNetworkGatewayConnectionCRUD
# Assert-AreEqual $list[0].Location $actual.Location
Assert-AreEqual "IPsec" $list[0].ConnectionType
Assert-AreEqual "3" $list[0].RoutingWeight
Assert-AreEqual "abc" $list[0].SharedKey
#Assert-AreEqual "abc" $list[0].SharedKey

# Set/Update VirtualNetworkGatewayConnection
$expected.Location = $location
Expand All @@ -93,7 +93,7 @@ function Test-VirtualNetworkGatewayConnectionCRUD
$actual = Set-AzureRmVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $expected -Force
$expected = Get-AzureRmVirtualNetworkGatewayConnection -ResourceGroupName $rgname -name $vnetConnectionName
Assert-AreEqual "4" $expected.RoutingWeight
Assert-AreEqual "xyz" $expected.SharedKey
#Assert-AreEqual "xyz" $expected.SharedKey

# Delete VirtualNetworkGatewayConnection
$delete = Remove-AzureRmVirtualNetworkGatewayConnection -ResourceGroupName $actual.ResourceGroupName -name $vnetConnectionName -PassThru -Force
Expand Down Expand Up @@ -168,19 +168,23 @@ function Test-VirtualNetworkGatewayConnectionSharedKeyCRUD
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual "IPsec" $expected.ConnectionType
Assert-AreEqual "3" $expected.RoutingWeight
Assert-AreEqual "abc" $expected.SharedKey
#Assert-AreEqual "abc" $expected.SharedKey

# Set VirtualNetworkGatewayConnectionSharedKey
$actual = Set-AzureRmVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName -Value "TestSharedKeyValue" -Force
#Assert-AreEqual "TestSharedKeyValue" $actual

# Get VirtualNetworkGatewayConnectionSharedKey
$expected = Get-AzureRmVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName

#Assert-AreEqual "TestSharedKeyValue" $expected

# Reset VirtualNetworkGatewayConnectionSharedKey
$actual = Reset-AzureRmVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $rname -KeyLength 50 -Force
#$actual = Reset-AzureRmVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName -KeyLength 50 -Force
#Assert-AreNotEqual "TestSharedKeyValue" $actual

# Get VirtualNetworkGatewayConnectionSharedKey after Reset-VirtualNetworkGatewayConnectionSharedKey
$expected = Get-AzureRmVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName
#$expected = Get-AzureRmVirtualNetworkGatewayConnectionSharedKey -ResourceGroupName $rgname -name $vnetConnectionName
#Assert-AreNotEqual "TestSharedKeyValue" $actual
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ namespace Commands.Network.Test.ScenarioTests
{
public class VirtualNetworkGatewayTests : Microsoft.WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
{
[Fact(Skip = "Rerecord tests")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualNetworkGatewayCRUD()
{
NetworkResourcesController.NewInstance.RunPsTest("Test-VirtualNetworkGatewayCRUD");
}

[Fact(Skip = "Need to record afterwards, failing due to product issue.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualNetworkGatewayP2SAndSKU()
{
NetworkResourcesController.NewInstance.RunPsTest("Test-VirtualNetworkGatewayP2SAndSKU");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,131 @@ function Test-VirtualNetworkGatewayCRUD
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Virtual network gateway tests
#>
function Test-VirtualNetworkGatewayP2SAndSKU
{
# Setup
$rgname = Get-ResourceGroupName
$rname = Get-ResourceName
$domainNameLabel = Get-ResourceName
$vnetName = Get-ResourceName
$publicIpName = Get-ResourceName
$vnetGatewayConfigName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
$location = Get-ProviderLocation $resourceTypeParent

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

# Create & Get LocalNetworkGateway
$actual = New-AzureRmLocalNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -AddressPrefix 192.168.0.0/16 -GatewayIpAddress 192.168.4.5
$localnetGateway = Get-AzureRmLocalNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $localnetGateway.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $localnetGateway.Name $actual.Name
Assert-AreEqual "192.168.4.5" $localnetGateway.GatewayIpAddress
Assert-AreEqual "192.168.0.0/16" $localnetGateway.LocalNetworkAddressSpace.AddressPrefixes[0]
$localnetGateway.Location = $location

# Create the Virtual Network
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet

# Create the publicip
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel

$clientRootCertName = "BrkLiteTestMSFTRootCA.cer"
$samplePublicCertData = "MIIDUzCCAj+gAwIBAgIQRggGmrpGj4pCblTanQRNUjAJBgUrDgMCHQUAMDQxEjAQBgNVBAoTCU1pY3Jvc29mdDEeMBwGA1UEAxMVQnJrIExpdGUgVGVzdCBSb290IENBMB4XDTEzMDExOTAwMjQxOFoXDTIxMDExOTAwMjQxN1owNDESMBAGA1UEChMJTWljcm9zb2Z0MR4wHAYDVQQDExVCcmsgTGl0ZSBUZXN0IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7SmE+iPULK0Rs7mQBO/6a6B6/G9BaMxHgDGzAmSG0Qsyt5e08aqgFnPdkMl3zRJw3lPKGha/JCvHRNrO8UpeAfc4IXWaqxx2iBipHjwmHPHh7+VB8lU0EJcUe7WBAI2n/sgfCwc+xKtuyRVlOhT6qw/nAi8e5don/iHPU6q7GCcnqoqtceQ/pJ8m66cvAnxwJlBFOTninhb2VjtvOfMQ07zPP+ZuYDPxvX5v3nd6yDa98yW4dZPuiGO2s6zJAfOPT2BrtyvLekItnSgAw3U5C0bOb+8XVKaDZQXbGEtOw6NZvD4L2yLd47nGkN2QXloiPLGyetrj3Z2pZYcrZBo8hAgMBAAGjaTBnMGUGA1UdAQReMFyAEOncRAPNcvJDoe4WP/gH2U+hNjA0MRIwEAYDVQQKEwlNaWNyb3NvZnQxHjAcBgNVBAMTFUJyayBMaXRlIFRlc3QgUm9vdCBDQYIQRggGmrpGj4pCblTanQRNUjAJBgUrDgMCHQUAA4IBAQCGyHhMdygS0g2tEUtRT4KFM+qqUY5HBpbIXNAav1a1dmXpHQCziuuxxzu3iq4XwnWUF1OabdDE2cpxNDOWxSsIxfEBf9ifaoz/O1ToJ0K757q2Rm2NWqQ7bNN8ArhvkNWa95S9gk9ZHZLUcjqanf0F8taJCYgzcbUSp+VBe9DcN89sJpYvfiBiAsMVqGPc/fHJgTScK+8QYrTRMubtFmXHbzBSO/KTAP5rBTxse88EGjK5F8wcedvge2Ksk6XjL3sZ19+Oj8KTQ72wihN900p1WQldHrrnbixSpmHBXbHr9U0NQigrJp5NphfuU5j81C8ixvfUdwyLmTv7rNA7GTAD";
$sampleClientCertName = "sampleClientCert.cer"
$sampleClinentCertThumbprint = "5405D9A8AB2A303D4E772C444BC88C3B97F55F78"

# Create & Get virtualnetworkgateway
$vnetIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet
$rootCert = New-AzureRmVpnClientRootCertificate -Name $clientRootCertName -PublicCertData $samplePublicCertData
$clientCert = New-AzureRmVpnClientRevokedCertificate -Name $sampleClientCertName -Thumbprint $sampleClinentCertThumbprint

$actual = New-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -GatewaySku Basic -GatewayDefaultSite $localnetGateway -VpnClientAddressPool 201.169.0.0/16 -VpnClientRootCertificates $rootCert -VpnClientRevokedCertificates $clientCert
$expected = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual "Vpn" $expected.GatewayType
Assert-AreEqual "RouteBased" $expected.VpnType
Assert-AreEqual "Basic" $expected.Sku.Tier
Assert-AreEqual $localnetGateway.Id $expected.GatewayDefaultSite.Id
Assert-AreEqual $localnetGateway.LocalNetworkAddressSpace $expected.VpnClientConfiguration.VpnClientAddressPool
Assert-AreEqual $clientRootCertName $expected.VpnClientConfiguration.VpnClientRevokedCertificates[0].name
Assert-AreEqual $sampleClientCertName $expected.VpnClientConfiguration.VpnClientRootCertificates[0].name

# Remove default site set for force tunneling
$actual = Remove-AzureRmVirtualNetworkGatewayDefaultSite -VirtualNetworkGateway $expected
$expected = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-Null $expected.GatewayDefaultSite

# Set default site for force tunneling
Set-AzureRmVirtualNetworkGatewayDefaultSite -VirtualNetworkGateway $expected -GatewayDefaultSite $localnetGateway
$expected = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $localnetGateway.Id $expected.GatewayDefaultSite.Id

# Resize the virtual network gateway from 'Basic' to 'Standard' SKU
$actual = Resize-AzureRmVirtualNetworkGateway -VirtualNetworkGateway $expected -GatewaySku "Standard"
Assert-AreEqual "Succeeded" $actual.ProvisioningState
$expected = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual "Standard" $expected.Sku.Tier

# Update P2S VPNClient Address Pool
Set-AzureRmVirtualNetworkGatewayVpnClientConfig -VirtualNetworkGateway $expected -VpnClientAddressPool 200.168.0.0/16
$expected = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual "200.168.0.0/16" $expected.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes

# Get, list client Root certificates
$rootCert = Get-AzureRmVpnClientRootCertificate -VpnClientRootCertificateName $clientRootCertName -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName
Assert-AreEqual $clientRootCertName $rootCert.Name

$rootCerts = Get-AzureRmVpnClientRootCertificate -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName
Assert-AreEqual 1 @($rootCerts).Count

# Generate P2S Vpnclient package
$packageUrl = Get-AzureRmVpnClientPackage -ResourceGroupName $expected.ResourceGroupName -VirtualNetworkGatewayName $expected.Name -ProcessorArchitecture Amd64
#Assert-NotNull $packageUrl

# Delete client Root certificate
$delete = Remove-AzureRmVpnClientRootCertificate -VpnClientRootCertificateName $clientRootCertName -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName -PublicCertData $samplePublicCertData
Assert-AreEqual True $delete
$rootCerts = Get-AzureRmVpnClientRootCertificate -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName
Assert-AreEqual 0 @($rootCerts).Count

# Add client Root certificate
$rootCerts = Add-AzureRmVpnClientRootCertificate -VpnClientRootCertificateName $clientRootCertName -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName -PublicCertData $samplePublicCertData
Assert-AreEqual 1 @(rootCerts).Count

# Get, list Vpn client revoked certificates
$revokedCerts = Get-AzureRmVpnClientRevokedCertificate -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName
Assert-AreEqual 1 @($revokedCerts).Count

# Unrevoke previously revoked Vpn client certificate
$delete = Remove-AzureRmVpnClientRevokedCertificate -VpnClientRevokedCertificateName $sampleClientCertName -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName -Thumbprint $sampleClinentCertThumbprint
Assert-AreEqual True $delete
$revokedCerts = Get-AzureRmVpnClientRevokedCertificate -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName
Assert-AreEqual 0 @($revokedCerts).Count

# Revoke Vpn client certificate
$revokedCerts = Add-AzureRmVpnClientRevokedCertificate -VpnClientRevokedCertificateName $sampleClientCertName -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName -Thumbprint $sampleClinentCertThumbprint
Assert-AreEqual 1 @($revokedCerts).Count
$revokedCert = Get-AzureRmVpnClientRevokedCertificate -VpnClientRevokedCertificateName $sampleClientCertName -VirtualNetworkGatewayName $expected.Name -ResourceGroupName $expected.ResourceGroupName
Assert-AreEqual $sampleClientCertName $revokedCert.Name
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 489cb2e

Please sign in to comment.