Skip to content

Commit 24f8ec9

Browse files
authored
Merge pull request #15 from ChenglongLiu/feature/Cdndev
Add Update tests
2 parents abc49fa + 6028800 commit 24f8ec9

File tree

4 files changed

+267
-13
lines changed

4 files changed

+267
-13
lines changed

src/Cdn/Cdn.Autorest/test/Update-AzFrontDoorCdnCustomDomain.Tests.ps1

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,42 @@ if(($null -eq $TestName) -or ($TestName -contains 'Update-AzFrontDoorCdnCustomDo
1515
}
1616

1717
Describe 'Update-AzFrontDoorCdnCustomDomain' {
18-
It 'UpdateExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'UpdateExpanded' {
19+
{
20+
$ResourceGroupName = 'powershelltest'
21+
Write-Host -ForegroundColor Green "Use test group $($ResourceGroupName)"
22+
$frontDoorCdnProfileName = 'fdp-powershelltest'
23+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
24+
$secretName = "se-powershelltest"
25+
Write-Host -ForegroundColor Green "Use secretName : $($secretName)"
26+
27+
$customDomainName = "domain-powershelltest"
28+
Write-Host -ForegroundColor Green "Use custom domain name : $($customDomainName)"
29+
30+
$secret = Get-AzFrontDoorCdnSecret -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Name $secretName
31+
32+
Update-AzFrontDoorCdnCustomDomain -CustomDomainName $customDomainName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
33+
-TlSettingCertificateType "CustomerCertificate" -TlSettingMinimumTlsVersion "TLS10" -SecretId $secret.Id
34+
} | Should -Not -Throw
2035
}
2136

22-
It 'UpdateViaIdentityExpanded' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
37+
It 'UpdateViaIdentityExpanded' {
38+
{
39+
$PSDefaultParameterValues['Disabled'] = $true
40+
$ResourceGroupName = 'powershelltest'
41+
Write-Host -ForegroundColor Green "Use test group $($ResourceGroupName)"
42+
$frontDoorCdnProfileName = 'fdp-powershelltest'
43+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
44+
$secretName = "se-powershelltest"
45+
Write-Host -ForegroundColor Green "Use secretName : $($secretName)"
46+
47+
$customDomainName = "domain-powershelltest"
48+
Write-Host -ForegroundColor Green "Use custom domain name : $($customDomainName)"
49+
50+
$secret = Get-AzFrontDoorCdnSecret -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Name $secretName
51+
52+
Get-AzFrontDoorCdnCustomDomain -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -CustomDomainName $customDomainName `
53+
| Update-AzFrontDoorCdnCustomDomain -TlSettingCertificateType "CustomerCertificate" -TlSettingMinimumTlsVersion "TLS10" -SecretId $secret.Id
54+
} | Should -Not -Throw
2455
}
2556
}

src/Cdn/Cdn.Autorest/test/Update-AzFrontDoorCdnEndpoint.Tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Describe 'Update-AzFrontDoorCdnEndpoint' {
4646
}
4747

4848
It 'UpdateViaIdentityExpanded' {
49+
$PSDefaultParameterValues['Disabled'] = $true
4950
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
5051
try
5152
{

src/Cdn/Cdn.Autorest/test/Update-AzFrontDoorCdnRoute.Tests.ps1

Lines changed: 140 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,147 @@ if(($null -eq $TestName) -or ($TestName -contains 'Update-AzFrontDoorCdnRoute'))
1515
}
1616

1717
Describe 'Update-AzFrontDoorCdnRoute' {
18-
It 'UpdateExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'UpdateExpanded' {
19+
{
20+
$PSDefaultParameterValues['Disabled'] = $true
21+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
22+
try
23+
{
24+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
25+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
26+
27+
$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
28+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
29+
30+
$profileSku = "Standard_AzureFrontDoor";
31+
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
32+
33+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
34+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
35+
$endpoint = New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
36+
37+
$originGroupName = 'org' + (RandomString -allChars $false -len 6);
38+
$originGroup = New-AzFrontDoorCdnOriginGroup -OriginGroupName $originGroupName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
39+
-LoadBalancingSettingSampleSize 5 `
40+
-LoadBalancingSettingSuccessfulSamplesRequired 4 `
41+
-LoadBalancingSettingAdditionalLatencyInMillisecond 200 `
42+
-HealthProbeSettingProbeIntervalInSecond 1 `
43+
-HealthProbeSettingProbePath "/" `
44+
-HealthProbeSettingProbeProtocol $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.ProbeProtocol]::Https) `
45+
-HealthProbeSettingProbeRequestType $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.HealthProbeRequestType]::Get) `
46+
47+
Get-AzFrontDoorCdnOriginGroup -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -OriginGroupName $originGroupName
48+
49+
$hostName = "en.wikipedia.org";
50+
$originName = 'ori' + (RandomString -allChars $false -len 6);
51+
New-AzFrontDoorCdnOrigin -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -OriginGroupName $originGroupName `
52+
-OriginName $originName -OriginHostHeader $hostName -HostName $hostName `
53+
-HttpPort 80 -HttpsPort 443 -Priority 1 -Weight 1000
54+
55+
$rulesetName = 'rs' + (RandomString -allChars $false -len 6);
56+
Write-Host -ForegroundColor Green "Use rulesetName : $($rulesetName)"
57+
$ruleSet = New-AzFrontDoorCdnRuleSet -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Name $rulesetName
58+
$uriConditon = New-AzCdnDeliveryRuleRequestUriConditionObject -Name "RequestUri" -ParameterOperator "Any"
59+
$conditions = @(
60+
$uriConditon
61+
);
62+
$overrideAction = New-AzCdnDeliveryRuleRouteConfigurationOverrideActionObject -Name "RouteConfigurationOverride" `
63+
-CacheConfigurationQueryStringCachingBehavior "IgnoreSpecifiedQueryStrings" `
64+
-CacheConfigurationQueryParameter "a=test" `
65+
-CacheConfigurationIsCompressionEnabled "Enabled" `
66+
-CacheConfigurationCacheBehavior "HonorOrigin"
67+
$actions = @($overrideAction);
68+
69+
$ruleName = 'r' + (RandomString -allChars $false -len 6);
70+
Write-Host -ForegroundColor Green "Use ruleName : $($ruleName)"
71+
New-AzFrontDoorCdnRule -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -RuleSetName $rulesetName -Name $ruleName `
72+
-Action $actions -Condition $conditions
73+
74+
$ruleSetResoure = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.ResourceReference]::new()
75+
$ruleSetResoure.Id = $ruleSet.Id
76+
77+
$routeName = 'route' + (RandomString -allChars $false -len 6);
78+
New-AzFrontDoorCdnRoute -Name $routeName -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
79+
-OriginGroupId $originGroup.Id -RuleSet @($ruleSetResoure) -PatternsToMatch "/*" -LinkToDefaultDomain "Enabled" -EnabledState "Enabled"
80+
81+
Update-AzFrontDoorCdnRoute -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -EndpointName $endpointName -Name $routeName `
82+
-EnabledState "Disabled"
83+
} Finally
84+
{
85+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
86+
}
87+
} | Should -Not -Throw
2088
}
2189

22-
It 'UpdateViaIdentityExpanded' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
90+
It 'UpdateViaIdentityExpanded' {
91+
{
92+
$PSDefaultParameterValues['Disabled'] = $true
93+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
94+
try
95+
{
96+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
97+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
98+
99+
$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
100+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
101+
102+
$profileSku = "Standard_AzureFrontDoor";
103+
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
104+
105+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
106+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
107+
$endpoint = New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
108+
109+
$originGroupName = 'org' + (RandomString -allChars $false -len 6);
110+
$originGroup = New-AzFrontDoorCdnOriginGroup -OriginGroupName $originGroupName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
111+
-LoadBalancingSettingSampleSize 5 `
112+
-LoadBalancingSettingSuccessfulSamplesRequired 4 `
113+
-LoadBalancingSettingAdditionalLatencyInMillisecond 200 `
114+
-HealthProbeSettingProbeIntervalInSecond 1 `
115+
-HealthProbeSettingProbePath "/" `
116+
-HealthProbeSettingProbeProtocol $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.ProbeProtocol]::Https) `
117+
-HealthProbeSettingProbeRequestType $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.HealthProbeRequestType]::Get) `
118+
119+
Get-AzFrontDoorCdnOriginGroup -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -OriginGroupName $originGroupName
120+
121+
$hostName = "en.wikipedia.org";
122+
$originName = 'ori' + (RandomString -allChars $false -len 6);
123+
New-AzFrontDoorCdnOrigin -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -OriginGroupName $originGroupName `
124+
-OriginName $originName -OriginHostHeader $hostName -HostName $hostName `
125+
-HttpPort 80 -HttpsPort 443 -Priority 1 -Weight 1000
126+
127+
$rulesetName = 'rs' + (RandomString -allChars $false -len 6);
128+
Write-Host -ForegroundColor Green "Use rulesetName : $($rulesetName)"
129+
$ruleSet = New-AzFrontDoorCdnRuleSet -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Name $rulesetName
130+
$uriConditon = New-AzCdnDeliveryRuleRequestUriConditionObject -Name "RequestUri" -ParameterOperator "Any"
131+
$conditions = @(
132+
$uriConditon
133+
);
134+
$overrideAction = New-AzCdnDeliveryRuleRouteConfigurationOverrideActionObject -Name "RouteConfigurationOverride" `
135+
-CacheConfigurationQueryStringCachingBehavior "IgnoreSpecifiedQueryStrings" `
136+
-CacheConfigurationQueryParameter "a=test" `
137+
-CacheConfigurationIsCompressionEnabled "Enabled" `
138+
-CacheConfigurationCacheBehavior "HonorOrigin"
139+
$actions = @($overrideAction);
140+
141+
$ruleName = 'r' + (RandomString -allChars $false -len 6);
142+
Write-Host -ForegroundColor Green "Use ruleName : $($ruleName)"
143+
New-AzFrontDoorCdnRule -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -RuleSetName $rulesetName -Name $ruleName `
144+
-Action $actions -Condition $conditions
145+
146+
$ruleSetResoure = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.ResourceReference]::new()
147+
$ruleSetResoure.Id = $ruleSet.Id
148+
149+
$routeName = 'route' + (RandomString -allChars $false -len 6);
150+
New-AzFrontDoorCdnRoute -Name $routeName -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
151+
-OriginGroupId $originGroup.Id -RuleSet @($ruleSetResoure) -PatternsToMatch "/*" -LinkToDefaultDomain "Enabled" -EnabledState "Enabled"
152+
153+
Get-AzFrontDoorCdnRoute -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -EndpointName $endpointName -Name $routeName `
154+
| Update-AzFrontDoorCdnRoute -EnabledState "Disabled"
155+
} Finally
156+
{
157+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
158+
}
159+
} | Should -Not -Throw
24160
}
25161
}

0 commit comments

Comments
 (0)