Skip to content

Commit 2e01428

Browse files
authored
Merge pull request #2 from ZianWang02/feature/Cdn
Add Get/Remove/Update-AzCdnEndpoint test
2 parents 37f785d + 3a61819 commit 2e01428

File tree

4 files changed

+245
-15
lines changed

4 files changed

+245
-15
lines changed

src/Cdn/Cdn.Autorest/test/Get-AzCdnEndpoint.Tests.ps1

Lines changed: 100 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,109 @@ if(($null -eq $TestName) -or ($TestName -contains 'Get-AzCdnEndpoint'))
1515
}
1616

1717
Describe 'Get-AzCdnEndpoint' {
18-
It 'List' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'List' {
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_Microsoft";
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 -Location $location -Origin $origin
41+
$endpoints = Get-AzCdnEndpoint -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
42+
43+
$endpoints.Count | Should -Be 1
44+
} Finally
45+
{
46+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
47+
}
48+
} | Should -Not -Throw
2049
}
2150

22-
It 'Get' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
51+
It 'Get' {
52+
{
53+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
54+
try
55+
{
56+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
57+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
58+
59+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
60+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
61+
62+
$profileSku = "Standard_Microsoft";
63+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
64+
65+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
66+
$origin = @{
67+
Name = "origin1"
68+
HostName = "host1.hello.com"
69+
};
70+
$location = "westus"
71+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
72+
73+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin
74+
$endpoint = Get-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
75+
76+
$endpoint.Name | Should -Be $endpointName
77+
$endpoint.Location | Should -Be $location
78+
$endpoint.Origin.Name | Should -Be $origin.Name
79+
$endpoint.Origin.HostName | Should -Be $origin.HostName
80+
} Finally
81+
{
82+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
83+
}
84+
} | Should -Not -Throw
2485
}
2586

26-
It 'GetViaIdentity' -skip {
27-
{ throw [System.NotImplementedException] } | Should -Not -Throw
87+
It 'GetViaIdentity' {
88+
{
89+
$PSDefaultParameterValues['Disabled'] = $true
90+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
91+
try
92+
{
93+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
94+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
95+
96+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
97+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
98+
99+
$profileSku = "Standard_Microsoft";
100+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
101+
102+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
103+
$origin = @{
104+
Name = "origin1"
105+
HostName = "host1.hello.com"
106+
};
107+
$location = "westus"
108+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
109+
110+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin
111+
$endpoint = Get-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName | Get-AzCdnEndpoint
112+
113+
$endpoint.Name | Should -Be $endpointName
114+
$endpoint.Location | Should -Be $location
115+
$endpoint.Origin.Name | Should -Be $origin.Name
116+
$endpoint.Origin.HostName | Should -Be $origin.HostName
117+
} Finally
118+
{
119+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
120+
}
121+
} | Should -Not -Throw
28122
}
29123
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ Describe 'New-AzCdnEndpoint' {
3434
Name = "origin1"
3535
HostName = "host1.hello.com"
3636
};
37+
$location = "westus"
3738
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
3839

39-
$endpoint = New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $env.location -Origin $origin
40+
$endpoint = New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin
41+
4042
$endpoint.Name | Should -Be $endpointName
41-
$endpoint.Location | Should -Be $env.location
43+
$endpoint.Location | Should -Be $location
4244
$endpoint.Origin.Name | Should -Be $origin.Name
4345
$endpoint.Origin.HostName | Should -Be $origin.HostName
4446
} Finally

src/Cdn/Cdn.Autorest/test/Remove-AzCdnEndpoint.Tests.ps1

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,66 @@ if(($null -eq $TestName) -or ($TestName -contains 'Remove-AzCdnEndpoint'))
1515
}
1616

1717
Describe 'Remove-AzCdnEndpoint' {
18-
It 'Delete' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'Delete' {
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_Microsoft";
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 -Location $location -Origin $origin
41+
Remove-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
42+
} Finally
43+
{
44+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
45+
}
46+
} | Should -Not -Throw
2047
}
2148

22-
It 'DeleteViaIdentity' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
49+
It 'DeleteViaIdentity' {
50+
{
51+
$PSDefaultParameterValues['Disabled'] = $true
52+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
53+
try
54+
{
55+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
56+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
57+
58+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
59+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
60+
61+
$profileSku = "Standard_Microsoft";
62+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
63+
64+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
65+
$origin = @{
66+
Name = "origin1"
67+
HostName = "host1.hello.com"
68+
};
69+
$location = "westus"
70+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
71+
72+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin
73+
Get-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName | Remove-AzCdnEndpoint
74+
} Finally
75+
{
76+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
77+
}
78+
} | Should -Not -Throw
2479
}
2580
}

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

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,89 @@ if(($null -eq $TestName) -or ($TestName -contains 'Update-AzCdnEndpoint'))
1616

1717
Describe 'Update-AzCdnEndpoint' {
1818
It 'UpdateExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
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_Microsoft";
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+
$tags = @{
39+
Tag1 = 1
40+
Tag2 = 2
41+
}
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 -Tag $tags
45+
$tags = @{
46+
Tag1 = 11
47+
Tag2 = 22
48+
}
49+
Update-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName -Tag $tags
50+
$updatedEndpoint = Get-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
51+
52+
$updatedEndpoint.Tag["Tag1"] | Should -Be "11"
53+
$updatedEndpoint.Tag["Tag2"] | Should -Be "22"
54+
} Finally
55+
{
56+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
57+
}
58+
} | Should -Not -Throw
2059
}
2160

22-
It 'UpdateViaIdentityExpanded' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
61+
It 'UpdateViaIdentityExpanded' {
62+
{
63+
$PSDefaultParameterValues['Disabled'] = $true
64+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
65+
try
66+
{
67+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
68+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
69+
70+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
71+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
72+
73+
$profileSku = "Standard_Microsoft";
74+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
75+
76+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
77+
$origin = @{
78+
Name = "origin1"
79+
HostName = "host1.hello.com"
80+
};
81+
$location = "westus"
82+
$tags = @{
83+
Tag1 = 1
84+
Tag2 = 2
85+
}
86+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName), origin.Name : $($origin.Name), origin.HostName : $($origin.HostName)"
87+
88+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location -Origin $origin -Tag $tags
89+
$tags = @{
90+
Tag1 = 11
91+
Tag2 = 22
92+
}
93+
Get-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName | Update-AzCdnEndpoint -Tag $tags
94+
$updatedEndpoint = Get-AzCdnEndpoint -Name $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
95+
96+
$updatedEndpoint.Tag["Tag1"] | Should -Be "11"
97+
$updatedEndpoint.Tag["Tag2"] | Should -Be "22"
98+
} Finally
99+
{
100+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
101+
}
102+
} | Should -Not -Throw
24103
}
25104
}

0 commit comments

Comments
 (0)