@@ -77,4 +77,131 @@ function Test-VirtualNetworkGatewayCRUD
7777 # Cleanup
7878 Clean - ResourceGroup $rgname
7979 }
80+ }
81+
82+ <#
83+ . SYNOPSIS
84+ Virtual network gateway tests
85+ #>
86+ function Test-VirtualNetworkGatewayP2SAndSKU
87+ {
88+ # Setup
89+ $rgname = Get-ResourceGroupName
90+ $rname = Get-ResourceName
91+ $domainNameLabel = Get-ResourceName
92+ $vnetName = Get-ResourceName
93+ $publicIpName = Get-ResourceName
94+ $vnetGatewayConfigName = Get-ResourceName
95+ $rglocation = Get-ProviderLocation ResourceManagement
96+ $resourceTypeParent = " Microsoft.Network/virtualNetworkGateways"
97+ $location = Get-ProviderLocation $resourceTypeParent
98+
99+ try
100+ {
101+ # Create the resource group
102+ $resourceGroup = New-AzureRmResourceGroup - Name $rgname - Location $rglocation - Tags @ {Name = " testtag" ; Value = " testval" }
103+
104+ # Create & Get LocalNetworkGateway
105+ $actual = New-AzureRmLocalNetworkGateway - ResourceGroupName $rgname - name $rname - location $location - AddressPrefix 192.168 .0.0 / 16 - GatewayIpAddress 192.168 .4.5
106+ $localnetGateway = Get-AzureRmLocalNetworkGateway - ResourceGroupName $rgname - name $rname
107+ Assert-AreEqual $localnetGateway.ResourceGroupName $actual.ResourceGroupName
108+ Assert-AreEqual $localnetGateway.Name $actual.Name
109+ Assert-AreEqual " 192.168.4.5" $localnetGateway.GatewayIpAddress
110+ Assert-AreEqual " 192.168.0.0/16" $localnetGateway.LocalNetworkAddressSpace.AddressPrefixes [0 ]
111+ $localnetGateway.Location = $location
112+
113+ # Create the Virtual Network
114+ $subnet = New-AzureRmVirtualNetworkSubnetConfig - Name " GatewaySubnet" - AddressPrefix 10.0 .0.0 / 24
115+ $vnet = New-AzureRmvirtualNetwork - Name $vnetName - ResourceGroupName $rgname - Location $location - AddressPrefix 10.0 .0.0 / 16 - Subnet $subnet
116+ $vnet = Get-AzureRmvirtualNetwork - Name $vnetName - ResourceGroupName $rgname
117+ $subnet = Get-AzureRmVirtualNetworkSubnetConfig - Name " GatewaySubnet" - VirtualNetwork $vnet
118+
119+ # Create the publicip
120+ $publicip = New-AzureRmPublicIpAddress - ResourceGroupName $rgname - name $publicIpName - location $location - AllocationMethod Dynamic - DomainNameLabel $domainNameLabel
121+
122+ $clientRootCertName = " BrkLiteTestMSFTRootCA.cer"
123+ $samplePublicCertData = "MIIDUzCCAj+gAwIBAgIQRggGmrpGj4pCblTanQRNUjAJBgUrDgMCHQUAMDQxEjAQBgNVBAoTCU1pY3Jvc29mdDEeMBwGA1UEAxMVQnJrIExpdGUgVGVzdCBSb290IENBMB4XDTEzMDExOTAwMjQxOFoXDTIxMDExOTAwMjQxN1owNDESMBAGA1UEChMJTWljcm9zb2Z0MR4wHAYDVQQDExVCcmsgTGl0ZSBUZXN0IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7SmE+iPULK0Rs7mQBO/6a6B6/G9BaMxHgDGzAmSG0Qsyt5e08aqgFnPdkMl3zRJw3lPKGha/JCvHRNrO8UpeAfc4IXWaqxx2iBipHjwmHPHh7+VB8lU0EJcUe7WBAI2n/sgfCwc+xKtuyRVlOhT6qw/nAi8e5don/iHPU6q7GCcnqoqtceQ/pJ8m66cvAnxwJlBFOTninhb2VjtvOfMQ07zPP+ZuYDPxvX5v3nd6yDa98yW4dZPuiGO2s6zJAfOPT2BrtyvLekItnSgAw3U5C0bOb+8XVKaDZQXbGEtOw6NZvD4L2yLd47nGkN2QXloiPLGyetrj3Z2pZYcrZBo8hAgMBAAGjaTBnMGUGA1UdAQReMFyAEOncRAPNcvJDoe4WP/gH2U+hNjA0MRIwEAYDVQQKEwlNaWNyb3NvZnQxHjAcBgNVBAMTFUJyayBMaXRlIFRlc3QgUm9vdCBDQYIQRggGmrpGj4pCblTanQRNUjAJBgUrDgMCHQUAA4IBAQCGyHhMdygS0g2tEUtRT4KFM+qqUY5HBpbIXNAav1a1dmXpHQCziuuxxzu3iq4XwnWUF1OabdDE2cpxNDOWxSsIxfEBf9ifaoz/O1ToJ0K757q2Rm2NWqQ7bNN8ArhvkNWa95S9gk9ZHZLUcjqanf0F8taJCYgzcbUSp+VBe9DcN89sJpYvfiBiAsMVqGPc/fHJgTScK+8QYrTRMubtFmXHbzBSO/KTAP5rBTxse88EGjK5F8wcedvge2Ksk6XjL3sZ19+Oj8KTQ72wihN900p1WQldHrrnbixSpmHBXbHr9U0NQigrJp5NphfuU5j81C8ixvfUdwyLmTv7rNA7GTAD";
124+ $sampleClientCertName = " sampleClientCert.cer"
125+ $sampleClinentCertThumbprint = " 5405D9A8AB2A303D4E772C444BC88C3B97F55F78"
126+
127+ # Create & Get virtualnetworkgateway
128+ $vnetIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig - Name $vnetGatewayConfigName - PublicIpAddress $publicip - Subnet $subnet
129+ $rootCert = New-AzureRmVpnClientRootCertificate - Name $clientRootCertName - PublicCertData $samplePublicCertData
130+ $clientCert = New-AzureRmVpnClientRevokedCertificate - Name $sampleClientCertName - Thumbprint $sampleClinentCertThumbprint
131+
132+ $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
133+ $expected = Get-AzureRmVirtualNetworkGateway - ResourceGroupName $rgname - name $rname
134+ Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
135+ Assert-AreEqual $expected.Name $actual.Name
136+ Assert-AreEqual " Vpn" $expected.GatewayType
137+ Assert-AreEqual " RouteBased" $expected.VpnType
138+ Assert-AreEqual " Basic" $expected.Sku.Tier
139+ Assert-AreEqual $localnetGateway.Id $expected.GatewayDefaultSite.Id
140+ Assert-AreEqual $localnetGateway.LocalNetworkAddressSpace $expected.VpnClientConfiguration.VpnClientAddressPool
141+ Assert-AreEqual $clientRootCertName $expected.VpnClientConfiguration.VpnClientRevokedCertificates [0 ].name
142+ Assert-AreEqual $sampleClientCertName $expected.VpnClientConfiguration.VpnClientRootCertificates [0 ].name
143+
144+ # Remove default site set for force tunneling
145+ $actual = Remove-AzureRmVirtualNetworkGatewayDefaultSite - VirtualNetworkGateway $expected
146+ $expected = Get-AzureRmVirtualNetworkGateway - ResourceGroupName $rgname - name $rname
147+ Assert-Null $expected.GatewayDefaultSite
148+
149+ # Set default site for force tunneling
150+ Set-AzureRmVirtualNetworkGatewayDefaultSite - VirtualNetworkGateway $expected - GatewayDefaultSite $localnetGateway
151+ $expected = Get-AzureRmVirtualNetworkGateway - ResourceGroupName $rgname - name $rname
152+ Assert-AreEqual $localnetGateway.Id $expected.GatewayDefaultSite.Id
153+
154+ # Resize the virtual network gateway from 'Basic' to 'Standard' SKU
155+ $actual = Resize-AzureRmVirtualNetworkGateway - VirtualNetworkGateway $expected - GatewaySku " Standard"
156+ Assert-AreEqual " Succeeded" $actual.ProvisioningState
157+ $expected = Get-AzureRmVirtualNetworkGateway - ResourceGroupName $rgname - name $rname
158+ Assert-AreEqual " Standard" $expected.Sku.Tier
159+
160+ # Update P2S VPNClient Address Pool
161+ Set-AzureRmVirtualNetworkGatewayVpnClientConfig - VirtualNetworkGateway $expected - VpnClientAddressPool 200.168 .0.0 / 16
162+ $expected = Get-AzureRmVirtualNetworkGateway - ResourceGroupName $rgname - name $rname
163+ Assert-AreEqual " 200.168.0.0/16" $expected.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes
164+
165+ # Get, list client Root certificates
166+ $rootCert = Get-AzureRmVpnClientRootCertificate - VpnClientRootCertificateName $clientRootCertName - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName
167+ Assert-AreEqual $clientRootCertName $rootCert.Name
168+
169+ $rootCerts = Get-AzureRmVpnClientRootCertificate - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName
170+ Assert-AreEqual 1 @ ($rootCerts ).Count
171+
172+ # Generate P2S Vpnclient package
173+ $packageUrl = Get-AzureRmVpnClientPackage - ResourceGroupName $expected.ResourceGroupName - VirtualNetworkGatewayName $expected.Name - ProcessorArchitecture Amd64
174+ # Assert-NotNull $packageUrl
175+
176+ # Delete client Root certificate
177+ $delete = Remove-AzureRmVpnClientRootCertificate - VpnClientRootCertificateName $clientRootCertName - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName - PublicCertData $samplePublicCertData
178+ Assert-AreEqual True $delete
179+ $rootCerts = Get-AzureRmVpnClientRootCertificate - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName
180+ Assert-AreEqual 0 @ ($rootCerts ).Count
181+
182+ # Add client Root certificate
183+ $rootCerts = Add-AzureRmVpnClientRootCertificate - VpnClientRootCertificateName $clientRootCertName - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName - PublicCertData $samplePublicCertData
184+ Assert-AreEqual 1 @ (rootCerts).Count
185+
186+ # Get, list Vpn client revoked certificates
187+ $revokedCerts = Get-AzureRmVpnClientRevokedCertificate - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName
188+ Assert-AreEqual 1 @ ($revokedCerts ).Count
189+
190+ # Unrevoke previously revoked Vpn client certificate
191+ $delete = Remove-AzureRmVpnClientRevokedCertificate - VpnClientRevokedCertificateName $sampleClientCertName - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName - Thumbprint $sampleClinentCertThumbprint
192+ Assert-AreEqual True $delete
193+ $revokedCerts = Get-AzureRmVpnClientRevokedCertificate - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName
194+ Assert-AreEqual 0 @ ($revokedCerts ).Count
195+
196+ # Revoke Vpn client certificate
197+ $revokedCerts = Add-AzureRmVpnClientRevokedCertificate - VpnClientRevokedCertificateName $sampleClientCertName - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName - Thumbprint $sampleClinentCertThumbprint
198+ Assert-AreEqual 1 @ ($revokedCerts ).Count
199+ $revokedCert = Get-AzureRmVpnClientRevokedCertificate - VpnClientRevokedCertificateName $sampleClientCertName - VirtualNetworkGatewayName $expected.Name - ResourceGroupName $expected.ResourceGroupName
200+ Assert-AreEqual $sampleClientCertName $revokedCert.Name
201+ }
202+ finally
203+ {
204+ # Cleanup
205+ Clean - ResourceGroup $rgname
206+ }
80207}
0 commit comments