Skip to content

Commit 65aae21

Browse files
author
Chenglong Liu
committed
Add tests
1 parent a16215f commit 65aae21

10 files changed

+240
-13
lines changed

src/Cdn/Cdn.Autorest/test/Clear-AzFrontDoorCdnEndpointContent.Tests.ps1

Lines changed: 100 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,111 @@ if(($null -eq $TestName) -or ($TestName -contains 'Clear-AzFrontDoorCdnEndpointC
1515
}
1616

1717
Describe 'Clear-AzFrontDoorCdnEndpointContent' {
18-
It 'PurgeExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'PurgeExpanded' {
19+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
20+
try
21+
{
22+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
23+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
24+
25+
$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
26+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
27+
28+
$profileSku = "Standard_AzureFrontDoor";
29+
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
30+
31+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
32+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
33+
New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
34+
35+
Clear-AzFrontDoorCdnEndpointContent -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
36+
-ContentPath "/a"
37+
} Finally
38+
{
39+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
40+
}
2041
}
2142

22-
It 'Purge' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
43+
It 'Purge' {
44+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
45+
try
46+
{
47+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
48+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
49+
50+
$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
51+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
52+
53+
$profileSku = "Standard_AzureFrontDoor";
54+
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
55+
56+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
57+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
58+
New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
59+
60+
$afdPurgeParameters = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.AfdPurgeParameters]::new()
61+
$afdPurgeParameters.ContentPath = @("/a")
62+
63+
Clear-AzFrontDoorCdnEndpointContent -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
64+
-Content $afdPurgeParameters
65+
} Finally
66+
{
67+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
68+
}
2469
}
2570

26-
It 'PurgeViaIdentityExpanded' -skip {
27-
{ throw [System.NotImplementedException] } | Should -Not -Throw
71+
It 'PurgeViaIdentityExpanded' {
72+
$PSDefaultParameterValues['Disabled'] = $true
73+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
74+
try
75+
{
76+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
77+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
78+
79+
$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
80+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
81+
82+
$profileSku = "Standard_AzureFrontDoor";
83+
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
84+
85+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
86+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
87+
New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
88+
89+
Get-AzFrontdoorCdnEndpoint -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -EndpointName $endpointName `
90+
| Clear-AzFrontDoorCdnEndpointContent -ContentPath "/a"
91+
} Finally
92+
{
93+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
94+
}
2895
}
2996

30-
It 'PurgeViaIdentity' -skip {
31-
{ throw [System.NotImplementedException] } | Should -Not -Throw
97+
It 'PurgeViaIdentity' {
98+
$PSDefaultParameterValues['Disabled'] = $true
99+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
100+
try
101+
{
102+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
103+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
104+
105+
$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
106+
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"
107+
108+
$profileSku = "Standard_AzureFrontDoor";
109+
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
110+
111+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
112+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
113+
New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
114+
115+
$afdPurgeParameters = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.AfdPurgeParameters]::new()
116+
$afdPurgeParameters.ContentPath = @("/a")
117+
118+
Get-AzFrontdoorCdnEndpoint -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -EndpointName $endpointName `
119+
| Clear-AzFrontDoorCdnEndpointContent -Content $afdPurgeParameters
120+
} Finally
121+
{
122+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
123+
}
32124
}
33125
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnAzureFirstPartyManagedCertificateParametersObject'))
2+
{
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCdnAzureFirstPartyManagedCertificateParametersObject.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while(-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'New-AzCdnAzureFirstPartyManagedCertificateParametersObject' {
18+
It '__AllParameterSets' -skip {
19+
{ throw [System.NotImplementedException] } | Should -Not -Throw
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnCustomerCertificateParametersObject'))
2+
{
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCdnCustomerCertificateParametersObject.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while(-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'New-AzCdnCustomerCertificateParametersObject' {
18+
It '__AllParameterSets' -skip {
19+
{ throw [System.NotImplementedException] } | Should -Not -Throw
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnManagedCertificateParametersObject'))
2+
{
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCdnManagedCertificateParametersObject.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while(-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'New-AzCdnManagedCertificateParametersObject' {
18+
It '__AllParameterSets' -skip {
19+
{ throw [System.NotImplementedException] } | Should -Not -Throw
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnSecurityPolicyWebApplicationFirewallAssociationObject'))
2+
{
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCdnSecurityPolicyWebApplicationFirewallAssociationObject.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while(-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'New-AzCdnSecurityPolicyWebApplicationFirewallAssociationObject' {
18+
It '__AllParameterSets' -skip {
19+
{ throw [System.NotImplementedException] } | Should -Not -Throw
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnSecurityPolicyWebApplicationFirewallParametersObject'))
2+
{
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCdnSecurityPolicyWebApplicationFirewallParametersObject.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while(-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'New-AzCdnSecurityPolicyWebApplicationFirewallParametersObject' {
18+
It '__AllParameterSets' -skip {
19+
{ throw [System.NotImplementedException] } | Should -Not -Throw
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnUrlSigningKeyParametersObject'))
2+
{
3+
$loadEnvPath = Join-Path $PSScriptRoot 'loadEnv.ps1'
4+
if (-Not (Test-Path -Path $loadEnvPath)) {
5+
$loadEnvPath = Join-Path $PSScriptRoot '..\loadEnv.ps1'
6+
}
7+
. ($loadEnvPath)
8+
$TestRecordingFile = Join-Path $PSScriptRoot 'New-AzCdnUrlSigningKeyParametersObject.Recording.json'
9+
$currentPath = $PSScriptRoot
10+
while(-not $mockingPath) {
11+
$mockingPath = Get-ChildItem -Path $currentPath -Recurse -Include 'HttpPipelineMocking.ps1' -File
12+
$currentPath = Split-Path -Path $currentPath -Parent
13+
}
14+
. ($mockingPath | Select-Object -First 1).FullName
15+
}
16+
17+
Describe 'New-AzCdnUrlSigningKeyParametersObject' {
18+
It '__AllParameterSets' -skip {
19+
{ throw [System.NotImplementedException] } | Should -Not -Throw
20+
}
21+
}

src/Cdn/Cdn.Autorest/test/New-AzFrontDoorCdnOriginGroup.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Describe 'New-AzFrontDoorCdnOriginGroup' {
3939
-HealthProbeSettingProbeRequestType $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.HealthProbeRequestType]::Get) `
4040
} Finally
4141
{
42-
#Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
42+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
4343
}
4444
}
4545
}

src/Cdn/Cdn.Autorest/test/New-AzFrontDoorCdnSecurityPolicy.Tests.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,21 @@ Describe 'New-AzFrontDoorCdnSecurityPolicy' {
2828
$profileSku = "Standard_AzureFrontDoor";
2929
$frontDoorCdnProfile = New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
3030

31+
$endpointName = 'end-' + (RandomString -allChars $false -len 6);
32+
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
33+
$endpoint = New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
34+
3135
$policyName = "pol-" + (RandomString -allChars $false -len 6);
3236
Write-Host -ForegroundColor Green "Use policyName : $($policyName)"
33-
New-AzFrontDoorCdnSecurityPolicy -Name $policyName -ProfileName $frontDoorCdnProfile -ResourceGroupName $ResourceGroupName
37+
38+
$association = New-AzCdnSecurityPolicyWebApplicationFirewallAssociationObject -PatternsToMatch @("/*") -Domain @(@{"Id"=$($endpoint.Id)})
39+
$parameter = New-AzCdnSecurityPolicyWebApplicationFirewallParametersObject -Association $association `
40+
-WafPolicyId "/subscriptions/4d894474-aa7f-4611-b830-344860c3eb9c/resourcegroups/powershelltest/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/powershelltestwaf"
41+
42+
New-AzFrontDoorCdnSecurityPolicy -Name $policyName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Parameter $parameter
3443
} Finally
3544
{
36-
#Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
45+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
3746
}
3847
}
3948
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Tenant": "72f988bf-86f1-41af-91ab-2d7cd011db47",
32
"location": "westus",
4-
"SubscriptionId": "d7cfdb98-c118-458d-8bdf-246be66b1f5e"
3+
"SubscriptionId": "4d894474-aa7f-4611-b830-344860c3eb9c",
4+
"Tenant": "72f988bf-86f1-41af-91ab-2d7cd011db47"
55
}

0 commit comments

Comments
 (0)