Skip to content

Commit 9667cd3

Browse files
author
unknown
committed
[AppGW] Re-recording test without ssl
1 parent 4b74aee commit 9667cd3

File tree

2 files changed

+1991
-898
lines changed

2 files changed

+1991
-898
lines changed

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

Lines changed: 80 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,46 +28,34 @@ function Test-ApplicationGatewayCRUD
2828
$appgwName = "appgw01"
2929
$vnetName = "vnet01"
3030
$subnetName = "subnet01"
31-
$publicIpName = "publicip01"
32-
$certName = "cert01"
31+
$publicIpName = "publicip01"
3332
$gipconfigname = "gatewayip01"
3433
$fipconfig01Name = "frontendip01"
3534
$fipconfig02Name = "frontendip02"
3635
$poolName = "pool01"
3736
$frontendPort01Name = "frontendport01"
3837
$frontendPort02Name = "frontendport02"
39-
$frontendPort03Name = "frontendport03"
4038
$poolSetting01Name = "setting01"
4139
$poolSetting02Name = "setting02"
42-
$poolSetting03Name = "setting03"
43-
$probeName ="probe01"
4440
$listener01Name = "listener01"
4541
$listener02Name = "listener02"
46-
$listener03Name = "listener03"
4742
$rule01Name = "rule01"
4843
$rule02Name = "rule02"
49-
$rule03Name = "rule03"
50-
$PathRule01Name = "pathrule01"
51-
$PathRule02Name = "pathrule02"
52-
$urlPathMapName = "urlpathmap01"
5344

5445
try
5546
{
5647
# Create the resource group
57-
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{Name = "testtag"; Value = "PS testing app gw"}
48+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{Name = "testtag"; Value = "APPGw tag"}
5849

5950
# Create the Virtual Network
6051
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
6152
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
6253
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
6354
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet
64-
55+
 
6556
# Create public ip
6657
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic
6758

68-
# Create certificate
69-
$cert = New-AzureRmApplicationGatewaySslCertificate -Name $certName -CertificateFile D:\AppGWe2eTest\GW5000.pfx -Password 1234
70-
7159
# Create application gateway configuration
7260
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name $gipconfigname -Subnet $subnet
7361

@@ -76,41 +64,98 @@ function Test-ApplicationGatewayCRUD
7664

7765
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses 1.1.1.1, 2.2.2.2, 3.3.3.3
7866

79-
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name -Port 80
80-
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name -Port 8080
81-
$fp03 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort03Name -Port 443
67+
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name  -Port 80
68+
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name  -Port 8080
8269

83-
$probe = New-AzureRmApplicationGatewayProbeConfig -Name $probeName -Protocol Http -HostName "probe.com" -Path "/path/path.htm" -Interval 89 -Timeout 88 -UnhealthyThreshold 8
84-
85-
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 66
86-
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
70+
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
71+
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol Http -CookieBasedAffinity Enabled
8772

8873
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol Http -FrontendIPConfiguration $fipconfig01 -FrontendPort $fp01
89-
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol Https -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp02 -SslCertificate $cert
90-
$listener03 = New-AzureRmApplicationGatewayHttpListener -Name $listener03Name -Protocol Https -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp03 -SslCertificate $cert -HostName TestHostName -RequireServerNameIndication true
91-
92-
$imagePathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule01Name -Paths "/image" -BackendAddressPool $pool -BackendHttpSettings $poolSetting02
93-
$videoPathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule02Name -Paths "/video" -BackendAddressPool $pool -BackendHttpSettings $poolSetting02
94-
$urlPathMap = New-AzureRmApplicationGatewayUrlPathMapConfig -Name $urlPathMapName -PathRules $videoPathRule, $imagePathRule -DefaultBackendAddressPool $pool -DefaultBackendHttpSettings $poolSetting02
74+
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol Http -FrontendIPConfiguration $fipconfig02 -FrontendPort $fp02
9575

9676
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule01Name -RuleType basic -BackendHttpSettings $poolSetting01 -HttpListener $listener01 -BackendAddressPool $pool
9777
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -BackendHttpSettings $poolSetting02 -HttpListener $listener02 -BackendAddressPool $pool
98-
$rule03 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule03Name -RuleType PathBasedRouting -HttpListener $listener03 -UrlPathMap $urlPathMap
9978

10079
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2
10180

10281
# Create Application Gateway
103-
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -Probes $probe -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01, $fipconfig02 -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02, $fp03 -SslCertificates $cert -HttpListeners $listener01, $listener02, $listener03 -UrlPathMaps $urlPathMap -RequestRoutingRules $rule01, $rule02, $rule03 -Sku $sku
82+
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig01, $fipconfig02  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RequestRoutingRules $rule01, $rule02 -Sku $sku
10483

10584
# Get Application Gateway
106-
$getgw = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
107-
108-
# Start Application Gateway
109-
Start-AzureRmApplicationGateway -ApplicationGateway $getgw
85+
$getgw =  Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
86+
87+
88+
# Add probe, request timeout, multi-hosting, URL routing to an exisitng gateway
89+
# Probe, request timeout, multi-site and URL routing are optional.
90+
$probeName = "probe01"
91+
$frontendPort03Name = "frontendport03"
92+
$poolSetting03Name = "setting03"
93+
$listener03Name = "listener03"
94+
$rule03Name = "rule03"
95+
$PathRule01Name = "pathrule01"
96+
$PathRule02Name = "pathrule02"
97+
$urlPathMapName = "urlpathmap01"
98+
99+
# Adding new frontend port
100+
$getgw = Add-AzureRmApplicationGatewayFrontendPort -ApplicationGateway $getgw -Name $frontendPort03Name  -Port 8888
101+
$fp = Get-AzureRmApplicationGatewayFrontendPort -ApplicationGateway $getgw -Name $frontendPort03Name 
102+
103+
# Add new probe
104+
$getgw = Add-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeName -Protocol Http -HostName "probe.com" -Path "/path/path.htm" -Interval 89 -Timeout 88 -UnhealthyThreshold 8
105+
$probe = Get-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeName
106+
107+
# Add listener that has hostname. Hostname is used to have multi-site
108+
$fipconfig = Get-AzureRmApplicationGatewayFrontendIPConfig -ApplicationGateway $getgw -Name $fipconfig02Name
109+
$getgw = Add-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $fp -HostName TestHostName
110+
$listener = Get-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name
111+
$pool = Get-AzureRmApplicationGatewayBackendAddressPool -ApplicationGateway $getgw -Name $poolName
112+
113+
# Add new BackendHttpSettings that has probe and request timeout
114+
$getgw = Add-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 66
115+
$poolSetting = Get-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name
116+
117+
# Add new URL routing
118+
$imagePathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule01Name -Paths "/image" -BackendAddressPool $pool -BackendHttpSettings $poolSetting
119+
$videoPathRule = New-AzureRmApplicationGatewayPathRuleConfig -Name $PathRule02Name -Paths "/video" -BackendAddressPool $pool -BackendHttpSettings $poolSetting
120+
$getgw = Add-AzureRmApplicationGatewayUrlPathMapConfig -ApplicationGateway $getgw -Name $urlPathMapName -PathRules $videoPathRule, $imagePathRule -DefaultBackendAddressPool $pool -DefaultBackendHttpSettings $poolSetting
121+
$urlPathMap = Get-AzureRmApplicationGatewayUrlPathMapConfig -ApplicationGateway $getgw -Name $urlPathMapName
122+
123+
# Add new rule with URL routing
124+
$getgw = Add-AzureRmApplicationGatewayRequestRoutingRule -ApplicationGateway $getgw -Name $rule03Name -RuleType PathBasedRouting -HttpListener $listener -UrlPathMap $urlPathMap
125+
126+
# Modify existing application gateway with new configuration
127+
Set-AzureRmApplicationGateway -ApplicationGateway $getgw
128+
129+
# Remove probe, request timeout, multi-site and URL routing from exiting gateway
130+
# Probe, request timeout, multi-site, URL routing are optional
131+
$getgw = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
132+
133+
# Remove probe
134+
$getgw = Remove-AzureRmApplicationGatewayProbeConfig -ApplicationGateway $getgw -Name $probeName
135+
136+
# Remove URL path map
137+
$getgw = Remove-AzureRmApplicationGatewayUrlPathMapConfig -ApplicationGateway $getgw -Name $urlPathMapName
138+
139+
# Modify BackendHttpSettings to remove probe and request timeout
140+
$getgw = Set-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name -Port 80 -Protocol Http -CookieBasedAffinity Disabled
141+
$poolSetting = Get-AzureRmApplicationGatewayBackendHttpSettings -ApplicationGateway $getgw -Name $poolSetting03Name
142+
143+
# Modify listener to remove hostname. Hostname is used to have multi-site.
144+
$fp = Get-AzureRmApplicationGatewayFrontendPort -ApplicationGateway $getgw -Name $frontendPort03Name 
145+
$fipconfig = Get-AzureRmApplicationGatewayFrontendIPConfig -ApplicationGateway $getgw -Name $fipconfig02Name
146+
$getgw = Set-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name -Protocol Http -FrontendIPConfiguration $fipconfig -FrontendPort $fp
147+
$listener = Get-AzureRmApplicationGatewayHttpListener -ApplicationGateway $getgw -Name $listener03Name
148+
149+
# Modify rule to remove URL rotuing
150+
$pool = Get-AzureRmApplicationGatewayBackendAddressPool -ApplicationGateway $getgw -Name $poolName
151+
$getgw = Set-AzureRmApplicationGatewayRequestRoutingRule -ApplicationGateway $getgw -Name $rule03Name -RuleType basic -HttpListener $listener -BackendHttpSettings $poolSetting -BackendAddressPool $pool
152+
153+
# Modify existing application gateway with new configuration
154+
Set-AzureRmApplicationGateway -ApplicationGateway $getgw
110155

111156
# Stop Application Gateway
112157
Stop-AzureRmApplicationGateway -ApplicationGateway $getgw
113-
158+
 
114159
# Delete Application Gateway
115160
Remove-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Force
116161
}

0 commit comments

Comments
 (0)