@@ -15,19 +15,175 @@ if(($null -eq $TestName) -or ($TestName -contains 'Clear-AzCdnEndpointContent'))
15
15
}
16
16
17
17
Describe ' Clear-AzCdnEndpointContent' {
18
- It ' PurgeExpanded' - skip {
19
- { throw [System.NotImplementedException ] } | Should -Not - Throw
18
+ It ' PurgeExpanded' {
19
+ {
20
+ $ResourceGroupName = ' testps-rg-' + (RandomString - allChars $false - len 6 )
21
+ try
22
+ {
23
+ Write-Host - ForegroundColor Green " Create test group $ ( $ResourceGroupName ) "
24
+ New-AzResourceGroup - Name $ResourceGroupName - Location $env.location ;
25
+
26
+ $cdnProfileName = ' p-' + (RandomString - allChars $false - len 6 );
27
+ Write-Host - ForegroundColor Green " Use cdnProfileName : $ ( $cdnProfileName ) "
28
+
29
+ $profileSku = " Standard_Verizon" ;
30
+ New-AzCdnProfile - SkuName $profileSku - Name $cdnProfileName - ResourceGroupName $ResourceGroupName - Location Global
31
+
32
+ $endpointName = ' e-' + (RandomString - allChars $false - len 6 );
33
+ $origin = @ {
34
+ Name = " origin1"
35
+ HostName = " host1.hello.com"
36
+ };
37
+ $location = " westus"
38
+ Write-Host - ForegroundColor Green " Create endpointName : $ ( $endpointName ) , origin.Name : $ ( $origin.Name ) , origin.HostName : $ ( $origin.HostName ) "
39
+
40
+ New-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName - IsHttpAllowed - IsHttpsAllowed `
41
+ - Location $location - Origin $origin - IsCompressionEnabled - ContentTypesToCompress " text/html" , " text/css" `
42
+ - OriginHostHeader " www.bing.com" - OriginPath " /photos" - QueryStringCachingBehavior " IgnoreQueryString"
43
+ $contentPath = @ (" /movies/*" , " /pictures/pic1.jpg" )
44
+
45
+ # Purge content on endpoint should succeed
46
+ Clear-AzCdnEndpointContent - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentPath $contentPath
47
+ # Purge content on non-existing endpoint should fail
48
+ { Clear-AzCdnEndpointContent - EndpointName " fakeEndpoint" - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentPath $contentPath } | Should - Throw
49
+ # Purge content on endpoint with invalid content paths should fail
50
+ { Clear-AzCdnEndpointContent - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentPath " invalidpath!" } | Should - Throw
51
+ # Purge content on stopped endpoint should fail
52
+ Stop-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName
53
+ { Clear-AzCdnEndpointContent - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentPath $contentPath } | Should - Throw
54
+ } Finally
55
+ {
56
+ Remove-AzResourceGroup - Name $ResourceGroupName - NoWait
57
+ }
58
+ } | Should -Not - Throw
20
59
}
21
60
22
- It ' Purge' - skip {
23
- { throw [System.NotImplementedException ] } | Should -Not - Throw
61
+ It ' Purge' {
62
+ {
63
+ $ResourceGroupName = ' testps-rg-' + (RandomString - allChars $false - len 6 )
64
+ try
65
+ {
66
+ Write-Host - ForegroundColor Green " Create test group $ ( $ResourceGroupName ) "
67
+ New-AzResourceGroup - Name $ResourceGroupName - Location $env.location ;
68
+
69
+ $cdnProfileName = ' p-' + (RandomString - allChars $false - len 6 );
70
+ Write-Host - ForegroundColor Green " Use cdnProfileName : $ ( $cdnProfileName ) "
71
+
72
+ $profileSku = " Standard_Verizon" ;
73
+ New-AzCdnProfile - SkuName $profileSku - Name $cdnProfileName - ResourceGroupName $ResourceGroupName - Location Global
74
+
75
+ $endpointName = ' e-' + (RandomString - allChars $false - len 6 );
76
+ $origin = @ {
77
+ Name = " origin1"
78
+ HostName = " host1.hello.com"
79
+ };
80
+ $location = " westus"
81
+ Write-Host - ForegroundColor Green " Create endpointName : $ ( $endpointName ) , origin.Name : $ ( $origin.Name ) , origin.HostName : $ ( $origin.HostName ) "
82
+
83
+ New-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName - IsHttpAllowed - IsHttpsAllowed `
84
+ - Location $location - Origin $origin - IsCompressionEnabled - ContentTypesToCompress " text/html" , " text/css" `
85
+ - OriginHostHeader " www.bing.com" - OriginPath " /photos" - QueryStringCachingBehavior " IgnoreQueryString"
86
+ $contentPath = @ { ContentPath = @ (" /movies/*" , " /pictures/pic1.jpg" ) }
87
+
88
+ # Purge content on endpoint should succeed
89
+ Clear-AzCdnEndpointContent - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentFilePath $contentPath
90
+ # Purge content on non-existing endpoint should fail
91
+ { Clear-AzCdnEndpointContent - EndpointName " fakeEndpoint" - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentFilePath $contentPath } | Should - Throw
92
+ # Purge content on endpoint with invalid content paths should fail
93
+ { Clear-AzCdnEndpointContent - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentFilePath @ { ContentPath = " invalidpath!" } } | Should - Throw
94
+ # Purge content on stopped endpoint should fail
95
+ Stop-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName
96
+ { Clear-AzCdnEndpointContent - EndpointName $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName - ContentFilePath $contentPath } | Should - Throw
97
+ } Finally
98
+ {
99
+ Remove-AzResourceGroup - Name $ResourceGroupName - NoWait
100
+ }
101
+ } | Should -Not - Throw
24
102
}
25
103
26
- It ' PurgeViaIdentityExpanded' - skip {
27
- { throw [System.NotImplementedException ] } | Should -Not - Throw
104
+ It ' PurgeViaIdentityExpanded' {
105
+ {
106
+ $PSDefaultParameterValues [' Disabled' ] = $true
107
+ $ResourceGroupName = ' testps-rg-' + (RandomString - allChars $false - len 6 )
108
+ try
109
+ {
110
+ Write-Host - ForegroundColor Green " Create test group $ ( $ResourceGroupName ) "
111
+ New-AzResourceGroup - Name $ResourceGroupName - Location $env.location ;
112
+
113
+ $cdnProfileName = ' p-' + (RandomString - allChars $false - len 6 );
114
+ Write-Host - ForegroundColor Green " Use cdnProfileName : $ ( $cdnProfileName ) "
115
+
116
+ $profileSku = " Standard_Verizon" ;
117
+ New-AzCdnProfile - SkuName $profileSku - Name $cdnProfileName - ResourceGroupName $ResourceGroupName - Location Global
118
+
119
+ $endpointName = ' e-' + (RandomString - allChars $false - len 6 );
120
+ $origin = @ {
121
+ Name = " origin1"
122
+ HostName = " host1.hello.com"
123
+ };
124
+ $location = " westus"
125
+ Write-Host - ForegroundColor Green " Create endpointName : $ ( $endpointName ) , origin.Name : $ ( $origin.Name ) , origin.HostName : $ ( $origin.HostName ) "
126
+
127
+ New-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName - IsHttpAllowed - IsHttpsAllowed `
128
+ - Location $location - Origin $origin - IsCompressionEnabled - ContentTypesToCompress " text/html" , " text/css" `
129
+ - OriginHostHeader " www.bing.com" - OriginPath " /photos" - QueryStringCachingBehavior " IgnoreQueryString"
130
+ $contentPath = @ (" /movies/*" , " /pictures/pic1.jpg" )
131
+
132
+ # Purge content on endpoint should succeed
133
+ $endpoint = Get-AzCdnEndpoint - Name $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName
134
+ $endpoint | Clear-AzCdnEndpointContent - ContentPath $contentPath
135
+ # Purge content on endpoint with invalid content paths should fail
136
+ { $endpoint | Clear-AzCdnEndpointContent - ContentPath " invalidpath!" } | Should - Throw
137
+ # Purge content on stopped endpoint should fail
138
+ Stop-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName
139
+ { $endpoint | Clear-AzCdnEndpointContent - ContentPath $contentPath } | Should - Throw
140
+ } Finally
141
+ {
142
+ Remove-AzResourceGroup - Name $ResourceGroupName - NoWait
143
+ }
144
+ } | Should -Not - Throw
28
145
}
29
146
30
- It ' PurgeViaIdentity' - skip {
31
- { throw [System.NotImplementedException ] } | Should -Not - Throw
147
+ It ' PurgeViaIdentity' {
148
+ {
149
+ $PSDefaultParameterValues [' Disabled' ] = $true
150
+ $ResourceGroupName = ' testps-rg-' + (RandomString - allChars $false - len 6 )
151
+ try
152
+ {
153
+ Write-Host - ForegroundColor Green " Create test group $ ( $ResourceGroupName ) "
154
+ New-AzResourceGroup - Name $ResourceGroupName - Location $env.location ;
155
+
156
+ $cdnProfileName = ' p-' + (RandomString - allChars $false - len 6 );
157
+ Write-Host - ForegroundColor Green " Use cdnProfileName : $ ( $cdnProfileName ) "
158
+
159
+ $profileSku = " Standard_Verizon" ;
160
+ New-AzCdnProfile - SkuName $profileSku - Name $cdnProfileName - ResourceGroupName $ResourceGroupName - Location Global
161
+
162
+ $endpointName = ' e-' + (RandomString - allChars $false - len 6 );
163
+ $origin = @ {
164
+ Name = " origin1"
165
+ HostName = " host1.hello.com"
166
+ };
167
+ $location = " westus"
168
+ Write-Host - ForegroundColor Green " Create endpointName : $ ( $endpointName ) , origin.Name : $ ( $origin.Name ) , origin.HostName : $ ( $origin.HostName ) "
169
+
170
+ New-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName - IsHttpAllowed - IsHttpsAllowed `
171
+ - Location $location - Origin $origin - IsCompressionEnabled - ContentTypesToCompress " text/html" , " text/css" `
172
+ - OriginHostHeader " www.bing.com" - OriginPath " /photos" - QueryStringCachingBehavior " IgnoreQueryString"
173
+ $contentPath = @ { ContentPath = @ (" /movies/*" , " /pictures/pic1.jpg" ) }
174
+
175
+ # Purge content on endpoint should succeed
176
+ $endpoint = Get-AzCdnEndpoint - Name $endpointName - ProfileName $cdnProfileName - ResourceGroupName $ResourceGroupName
177
+ $endpoint | Clear-AzCdnEndpointContent - ContentFilePath $contentPath
178
+ # Purge content on endpoint with invalid content paths should fail
179
+ { $endpoint | Clear-AzCdnEndpointContent - ContentFilePath @ { ContentPath = " invalidpath!" } } | Should - Throw
180
+ # Purge content on stopped endpoint should fail
181
+ Stop-AzCdnEndpoint - Name $endpointName - ResourceGroupName $ResourceGroupName - ProfileName $cdnProfileName
182
+ { $endpoint | Clear-AzCdnEndpointContent - ContentFilePath $contentPath } | Should - Throw
183
+ } Finally
184
+ {
185
+ Remove-AzResourceGroup - Name $ResourceGroupName - NoWait
186
+ }
187
+ } | Should -Not - Throw
32
188
}
33
189
}
0 commit comments