Skip to content

Commit 1d6e5a9

Browse files
authored
Merge pull request #30 from ZianWang02/feature/Cdn
Update Test-AzCdnEndpointCustomDomain.Tests.ps1
2 parents 6163552 + 0d2d242 commit 1d6e5a9

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

src/Cdn/Cdn.Autorest/test/Test-AzCdnEndpointCustomDomain.Tests.ps1

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,86 @@ if(($null -eq $TestName) -or ($TestName -contains 'Test-AzCdnEndpointCustomDomai
1515
}
1616

1717
Describe 'Test-AzCdnEndpointCustomDomain' {
18-
It 'ValidateExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'ValidateExpanded' {
19+
{
20+
$subId = "27cafca8-b9a4-4264-b399-45d0c9cca1ab"
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 -SubscriptionId $subId
26+
27+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
28+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
29+
30+
$profileSku = "Standard_Microsoft";
31+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
32+
33+
# Hard-coding host and endpoint names due to requirement for DNS CNAME
34+
$endpointName = 'e-20220418-sec26q'
35+
$customDomainHostName = 'e-20220418-sec26q.ps.cdne2e.azfdtest.xyz'
36+
$customDomainInvalidHostName = 'e-20220418-sec26w.ps.cdne2e.azfdtest.xyz'
37+
$origin = @{
38+
Name = "origin1"
39+
HostName = "host1.hello.com"
40+
};
41+
$location = "westus"
42+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
43+
44+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin -SubscriptionId $subId
45+
$validateResult = Test-AzCdnEndpointCustomDomain -EndpointName $endpointName -HostName $customDomainHostName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName -SubscriptionId $subId
46+
47+
$validateResult.CustomDomainValidated | Should -BeTrue
48+
49+
$validateResult = Test-AzCdnEndpointCustomDomain -EndpointName $endpointName -HostName $customDomainInvalidHostName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName -SubscriptionId $subId
50+
51+
$validateResult.CustomDomainValidated | Should -BeFalse
52+
} Finally
53+
{
54+
Remove-AzResourceGroup -Name $ResourceGroupName -SubscriptionId $subId -NoWait
55+
}
56+
} | Should -Not -Throw
2057
}
2158

22-
It 'ValidateViaIdentityExpanded' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
59+
It 'ValidateViaIdentityExpanded' {
60+
{
61+
$PSDefaultParameterValues['Disabled'] = $true
62+
$subId = "27cafca8-b9a4-4264-b399-45d0c9cca1ab"
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 -SubscriptionId $subId
68+
69+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
70+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
71+
72+
$profileSku = "Standard_Microsoft";
73+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global -SubscriptionId $subId
74+
75+
# Hard-coding host and endpoint names due to requirement for DNS CNAME
76+
$endpointName = 'e-20220418-ems6vw'
77+
$customDomainHostName = 'e-20220418-ems6vw.ps.cdne2e.azfdtest.xyz'
78+
$customDomainInvalidHostName = 'e-20220418-ems5vw.ps.cdne2e.azfdtest.xyz'
79+
$origin = @{
80+
Name = "origin1"
81+
HostName = "host1.hello.com"
82+
};
83+
$location = "westus"
84+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
85+
86+
$endpoint = New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin -SubscriptionId $subId
87+
$validateResult = $endpoint | Test-AzCdnEndpointCustomDomain -HostName $customDomainHostName
88+
89+
$validateResult.CustomDomainValidated | Should -BeTrue
90+
91+
$validateResult = $endpoint | Test-AzCdnEndpointCustomDomain -HostName $customDomainInvalidHostName
92+
93+
$validateResult.CustomDomainValidated | Should -BeFalse
94+
} Finally
95+
{
96+
Remove-AzResourceGroup -Name $ResourceGroupName -SubscriptionId $subId -NoWait
97+
}
98+
} | Should -Not -Throw
2499
}
25100
}

0 commit comments

Comments
 (0)