Skip to content

Commit b4aea1b

Browse files
committed
test
1 parent 85617b3 commit b4aea1b

File tree

2 files changed

+5838
-1726
lines changed

2 files changed

+5838
-1726
lines changed

src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -644,12 +644,12 @@ function Test-ApplicationGatewayCRUDRewriteRuleSet
644644
# Get Application Gateway
645645
$getgw = Get-AzApplicationGateway -Name $appgwName -ResourceGroupName $rgname
646646

647-
$rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet -Name $rewriteRuleSetName -ApplicationGateway $getgw
647+
$rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet -Name $rewriteRuleSetName -ApplicationGateway $getgw
648648
Assert-NotNull $rewriteRuleSet
649649
Assert-AreEqual $rewriteRuleSet.RewriteRules.Count 1
650650
Assert-NotNull $rewriteRuleSet.RewriteRules[0].ActionSet
651651

652-
$rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw
652+
$rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw
653653
Assert-NotNull $rewriteRuleSet
654654
Assert-AreEqual $rewriteRuleSet.Count 1
655655

@@ -685,8 +685,8 @@ function Test-ApplicationGatewayCRUDRewriteRuleSet
685685
Assert-NotNull $autoscaleConfig01
686686
Assert-AreEqual $autoscaleConfig01.MinCapacity 3
687687

688-
Set-AzureRmApplicationGatewayAutoscaleConfiguration -ApplicationGateway $getgw -MinCapacity 3 -MaxCapacity 10
689-
$autoscaleConfig02 = Get-AzureRmApplicationGatewayAutoscaleConfiguration -ApplicationGateway $getgw
688+
Set-AzApplicationGatewayAutoscaleConfiguration -ApplicationGateway $getgw -MinCapacity 3 -MaxCapacity 10
689+
$autoscaleConfig02 = Get-AzApplicationGatewayAutoscaleConfiguration -ApplicationGateway $getgw
690690
Assert-NotNull $autoscaleConfig02
691691
Assert-AreEqual $autoscaleConfig02.MinCapacity 3
692692
Assert-AreEqual $autoscaleConfig02.MaxCapacity 10
@@ -701,29 +701,29 @@ function Test-ApplicationGatewayCRUDRewriteRuleSet
701701
$getgw01 = Set-AzApplicationGateway -ApplicationGateway $getgw
702702

703703
#Rewrite Rule Set
704-
Assert-ThrowsLike { Add-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw01 -Name $rewriteRuleSetName -RewriteRule $rewriteRule } "*already exists*"
705-
$rewriteRuleSet = Add-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw01 -Name $rewriteRuleSetName2 -RewriteRule $rewriteRule
706-
$getgw = Set-AzureRmApplicationGateway -ApplicationGateway $getgw01
704+
Assert-ThrowsLike { Add-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw01 -Name $rewriteRuleSetName -RewriteRule $rewriteRule } "*already exists*"
705+
$rewriteRuleSet = Add-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw01 -Name $rewriteRuleSetName2 -RewriteRule $rewriteRule
706+
$getgw = Set-AzApplicationGateway -ApplicationGateway $getgw01
707707

708-
$rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw
708+
$rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw
709709
Assert-NotNull $rewriteRuleSet
710710
Assert-AreEqual $rewriteRuleSet.Count 2
711711

712-
$rewriteRuleSet = Remove-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw01 -Name $rewriteRuleSetName2
713-
$getgw = Set-AzureRmApplicationGateway -ApplicationGateway $getgw01
712+
$rewriteRuleSet = Remove-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw01 -Name $rewriteRuleSetName2
713+
$getgw = Set-AzApplicationGateway -ApplicationGateway $getgw01
714714

715-
$rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw
715+
$rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw
716716
Assert-NotNull $rewriteRuleSet
717717
Assert-AreEqual $rewriteRuleSet.Count 1
718718

719-
$headerConfiguration = New-AzureRmApplicationGatewayRewriteRuleHeaderConfiguration -HeaderName "ghi" -HeaderValue "jkl"
720-
$actionSet = New-AzureRmApplicationGatewayRewriteRuleActionSet -RequestHeaderConfiguration $headerConfiguration
721-
$rewriteRule2 = New-AzureRmApplicationGatewayRewriteRule -Name $rewriteRuleName -ActionSet $actionSet
719+
$headerConfiguration = New-AzApplicationGatewayRewriteRuleHeaderConfiguration -HeaderName "ghi" -HeaderValue "jkl"
720+
$actionSet = New-AzApplicationGatewayRewriteRuleActionSet -RequestHeaderConfiguration $headerConfiguration
721+
$rewriteRule2 = New-AzApplicationGatewayRewriteRule -Name $rewriteRuleName -ActionSet $actionSet
722722

723-
Assert-ThrowsLike { Set-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw -Name "fakeName" -RewriteRule $rewriteRule2 } "*does not exist*"
724-
$rewriteRuleSet = Set-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw -Name $rewriteRuleSetName -RewriteRule $rewriteRule2
725-
$getgw = Set-AzureRmApplicationGateway -ApplicationGateway $getgw01
726-
$rewriteRuleSet = Get-AzureRmApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw -Name $rewriteRuleSetName
723+
Assert-ThrowsLike { Set-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw -Name "fakeName" -RewriteRule $rewriteRule2 } "*does not exist*"
724+
$rewriteRuleSet = Set-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw -Name $rewriteRuleSetName -RewriteRule $rewriteRule2
725+
$getgw = Set-AzApplicationGateway -ApplicationGateway $getgw01
726+
$rewriteRuleSet = Get-AzApplicationGatewayRewriteRuleSet -ApplicationGateway $getgw -Name $rewriteRuleSetName
727727
Assert-AreEqual $rewriteRuleSet.RewriteRules[0].Name $rewriteRule2.Name
728728

729729
# check sku
@@ -764,6 +764,7 @@ function Test-ApplicationGatewayCRUD3
764764

765765
$rgname = Get-ResourceGroupName
766766
$appgwName = Get-ResourceName
767+
$identityName = Get-ResourceName
767768
$vnetName = Get-ResourceName
768769
$gwSubnetName = Get-ResourceName
769770
$publicIpName = Get-ResourceName
@@ -791,6 +792,9 @@ function Test-ApplicationGatewayCRUD3
791792
$vnet = Get-AzvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
792793
$gwSubnet = Get-AzVirtualNetworkSubnetConfig -Name $gwSubnetName -VirtualNetwork $vnet
793794

795+
# Create Managed Identity
796+
$identity = New-AzUserAssignedIdentity -Name $identityName -Location $location -ResourceGroup $rgname
797+
794798
# Create public ip
795799
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -sku Standard
796800

@@ -821,8 +825,11 @@ function Test-ApplicationGatewayCRUD3
821825
# security part
822826
$sslPolicy = New-AzApplicationGatewaySslPolicy -PolicyType Custom -MinProtocolVersion TLSv1_1 -CipherSuite "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_GCM_SHA256"
823827

828+
# appgw identity
829+
$appgwIdentity = New-AzApplicationGatewayIdentity -UserAssignedIdentity $identity.Id
830+
824831
# Create Application Gateway
825-
$appgw = New-AzApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Zone 1,2 -Location $location -Probes $probeHttp -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting01 -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01 -HttpListeners $listener01 -RequestRoutingRules $rule01 -Sku $sku -SslPolicy $sslPolicy -TrustedRootCertificate $trustedRoot01 -AutoscaleConfiguration $autoscaleConfig
832+
$appgw = New-AzApplicationGateway -Identity $appgwIdentity -Name $appgwName -ResourceGroupName $rgname -Zone 1,2 -Location $location -Probes $probeHttp -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting01 -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01 -HttpListeners $listener01 -RequestRoutingRules $rule01 -Sku $sku -SslPolicy $sslPolicy -TrustedRootCertificate $trustedRoot01 -AutoscaleConfiguration $autoscaleConfig
826833

827834
# Get Application Gateway
828835
$getgw = Get-AzApplicationGateway -Name $appgwName -ResourceGroupName $rgname
@@ -852,7 +859,7 @@ function Test-ApplicationGatewayCRUD3
852859
Assert-NotNull $autoscaleConfig01
853860
Assert-AreEqual $autoscaleConfig01.MinCapacity 3
854861

855-
# Next setup preparation
862+
# Next: Manual sku gateway
856863

857864
# remove autoscale config
858865
$getgw = Remove-AzApplicationGatewayAutoscaleConfiguration -ApplicationGateway $getgw -Force
@@ -868,6 +875,25 @@ function Test-ApplicationGatewayCRUD3
868875
Assert-AreEqual $sku01.Name Standard_v2
869876
Assert-AreEqual $sku01.Tier Standard_v2
870877

878+
# Next: Set Identity on an existing gateway without identity
879+
# First, Removing identity from the gateway
880+
Remove-AzApplicationGatewayIdentity -ApplicationGateway $getgw01 -Force
881+
882+
# Set Application Gateway
883+
$getgw02 = Set-AzApplicationGateway -ApplicationGateway $getgw01
884+
Assert-Null $(Get-AzApplicationGatewayIdentity -ApplicationGateway $getgw01)
885+
886+
# Set identity
887+
Set-AzApplicationGatewayIdentity -ApplicationGateway $getgw02 -UserAssignedIdentityId $identity.Id
888+
889+
# Set Application Gateway
890+
$getgw03 = Set-AzApplicationGateway -ApplicationGateway $getgw02
891+
$identity01 = Get-AzApplicationGatewayIdentity -ApplicationGateway $getgw03
892+
Assert-AreEqual $identity01.UserAssignedIdentities.Count 1
893+
Assert-NotNull $identity01.UserAssignedIdentities.Values[0].PrincipalId
894+
Assert-NotNull $identity01.UserAssignedIdentities.Values[0].ClientId
895+
896+
871897
# Stop Application Gateway
872898
$getgw1 = Stop-AzApplicationGateway -ApplicationGateway $getgw01
873899

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.ApplicationGatewayTests/TestApplicationGatewayCRUD3.json

Lines changed: 5792 additions & 1706 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)