@@ -683,6 +683,89 @@ function Test-CortexExpressRouteCRUD
683
683
$delete = Remove-AzVirtualWan - InputObject $virtualWan - Force - PassThru
684
684
Assert-AreEqual $True $delete
685
685
686
+ Clean - ResourceGroup $rgname
687
+ }
688
+ }
689
+
690
+ <#
691
+ . SYNOPSIS
692
+ Disconnect Point to site vpn gateway vpn connection
693
+ #>
694
+ function Test-DisconnectAzP2sVpnGatewayVpnConnection
695
+ {
696
+ param
697
+ (
698
+ $basedir = " .\"
699
+ )
700
+
701
+ # Setup
702
+ $rgname = Get-ResourceGroupName
703
+ $rglocation = " East US"
704
+
705
+ $virtualWanName = Get-ResourceName
706
+ $virtualHubName = Get-ResourceName
707
+ $VpnServerConfiguration1Name = Get-ResourceName
708
+ $P2SVpnGatewayName = Get-ResourceName
709
+
710
+ try
711
+ {
712
+ # Create the resource group
713
+ New-AzResourceGroup - Name $rgname - Location $rglocation
714
+
715
+ # Create the Virtual Wan
716
+ New-AzVirtualWan - ResourceGroupName $rgName - Name $virtualWanName - Location $rglocation
717
+ $virtualWan = Get-AzVirtualWan - ResourceGroupName $rgName - Name $virtualWanName
718
+ Assert-AreEqual $virtualWanName $virtualWan.Name
719
+
720
+ # Create the Virtual Hub
721
+ New-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName - Location $rglocation - AddressPrefix " 192.168.1.0/24" - VirtualWan $virtualWan
722
+ $virtualHub = Get-AzVirtualHub - ResourceGroupName $rgName - Name $virtualHubName
723
+ Assert-AreEqual $virtualHubName $virtualHub.Name
724
+ Assert-AreEqual $virtualWan.Id $virtualhub.VirtualWan.Id
725
+
726
+ # Create the VpnServerConfiguration1 with VpnClient settings using New-AzVpnServerConfiguration
727
+ $VpnServerConfigCertFilePath = Join-Path - Path $basedir - ChildPath " \ScenarioTests\Data\ApplicationGatewayAuthCert.cer"
728
+ $listOfCerts = New-Object " System.Collections.Generic.List[String]"
729
+ $listOfCerts.Add ($VpnServerConfigCertFilePath )
730
+ $vpnclientipsecpolicy1 = New-AzVpnClientIpsecPolicy - IpsecEncryption AES256 - IpsecIntegrity SHA256 - SALifeTime 86471 - SADataSize 429496 - IkeEncryption AES256 - IkeIntegrity SHA384 - DhGroup DHGroup14 - PfsGroup PFS14
731
+ New-AzVpnServerConfiguration - Name $VpnServerConfiguration1Name - ResourceGroupName $rgName - VpnProtocol IkeV2 - VpnAuthenticationType Certificate - VpnClientRootCertificateFilesList $listOfCerts - VpnClientRevokedCertificateFilesList $listOfCerts - VpnClientIpsecPolicy $vpnclientipsecpolicy1 - Location $rglocation
732
+
733
+ # Get created VpnServerConfiguration using Get-AzVpnServerConfiguration
734
+ $vpnServerConfig1 = Get-AzVpnServerConfiguration - ResourceGroupName $rgName - Name $VpnServerConfiguration1Name
735
+ Assert-NotNull $vpnServerConfig1
736
+
737
+ # Create the P2SVpnGateway using New-AzP2sVpnGateway
738
+ $vpnClientAddressSpaces = New-Object string[] 2
739
+ $vpnClientAddressSpaces [0 ] = " 192.168.2.0/24"
740
+ $vpnClientAddressSpaces [1 ] = " 192.168.3.0/24"
741
+ New-AzP2sVpnGateway - ResourceGroupName $rgName - Name $P2SvpnGatewayName - VirtualHub $virtualHub - VpnGatewayScaleUnit 1 - VpnClientAddressPool $vpnClientAddressSpaces - VpnServerConfiguration $vpnServerConfig1
742
+
743
+ # Get the created P2SVpnGateway using Get-AzP2sVpnGateway
744
+ $P2SVpnGateway = Get-AzP2sVpnGateway - ResourceGroupName $rgName - Name $P2SvpnGatewayName
745
+ Assert-AreEqual $P2SvpnGatewayName $P2SVpnGateway.Name
746
+ Assert-AreEqual " Succeeded" $P2SVpnGateway.ProvisioningState
747
+
748
+ $expected = Disconnect-AzP2SVpnGatewayVpnConnection - ResourceGroupName $rgname - ResourceName $P2SvpnGatewayName - VpnConnectionId @ (" IKEv2_1e1cfe59-5c7c-4315-a876-b11fbfdfeed4" )
749
+ Assert-AreEqual $expected.Name $P2SVpnGateway.Name
750
+ }
751
+ finally
752
+ {
753
+ # Delete P2SVpnGateway using Remove-AzP2sVpnGateway
754
+ $delete = Remove-AzP2sVpnGateway - Name $P2SVpnGatewayName - ResourceGroupName $rgName - Force - PassThru
755
+ Assert-AreEqual $True $delete
756
+
757
+ # Delete VpnServerConfiguration1 using Remove-AzVpnServerConfiguration
758
+ $delete = Remove-AzVpnServerConfiguration - ResourceGroupName $rgName - Name $VpnServerConfiguration1Name - Force - PassThru
759
+ Assert-AreEqual $True $delete
760
+
761
+ # Delete Virtual hub
762
+ $delete = Remove-AzVirtualHub - ResourceGroupName $rgname - Name $virtualHubName - Force - PassThru
763
+ Assert-AreEqual $True $delete
764
+
765
+ # Delete Virtual wan
766
+ $delete = Remove-AzVirtualWan - InputObject $virtualWan - Force - PassThru
767
+ Assert-AreEqual $True $delete
768
+
686
769
Clean - ResourceGroup $rgname
687
770
}
688
771
}
0 commit comments