Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5837394
changes on md files for origins, origingroups, and private link
aijemoj Jul 9, 2020
77e179c
cmdlets for origin and origin groups
aijemoj Jul 20, 2020
6d5a825
Merge branch 'master' into jomejia/origin-ps
aijemoj Jul 30, 2020
d7c02c9
test new-azcdnorigin'
aijemoj Aug 12, 2020
faa5608
Merge remote-tracking branch 'upstream/master' into jomejia/origin-ps
aijemoj Aug 12, 2020
a175dfb
add try / catch block
aijemoj Aug 19, 2020
eb11b37
CRUD operations for origins, origin groups, and private link
aijemoj Aug 31, 2020
9f66844
Merge branch 'master' into jomejia/origin-ps
aijemoj Sep 22, 2020
fba1447
Add tests and small modifications to cmdlets
aijemoj Oct 2, 2020
e9ac001
Merge branch 'master' into jomejia/origin-ps
aijemoj Oct 2, 2020
a70b1af
Update help directory
aijemoj Oct 6, 2020
0a423dc
Add session records for modified tests
aijemoj Oct 7, 2020
d7cf713
update change log
aijemoj Oct 7, 2020
8ddc2f7
Add license headers to files
aijemoj Oct 7, 2020
a9d740f
Update markdown files with synopsis, description, and examples
aijemoj Oct 7, 2020
926bb6f
update online version field for markdown files
aijemoj Oct 7, 2020
1e86f31
Update Get-AzCdnOrigin cmdlet and corresponding md file
aijemoj Oct 8, 2020
46149d5
Update session records with new API version
aijemoj Oct 8, 2020
233761d
Remove extra 's' in origin group test namespace
aijemoj Oct 9, 2020
337dcb8
Change type of ProbeInterval, modify origin group test, revert change…
aijemoj Oct 13, 2020
91c8cb9
Add Skip parameter to Fact attribute
aijemoj Oct 13, 2020
29753be
Add fixes for custom domain test and associated session records
aijemoj Oct 14, 2020
386f534
Remove nuget from local feed
aijemoj Oct 16, 2020
373c3e4
Update ChangeLog.md
isra-fel Oct 16, 2020
41379ef
Delete LocalNugetFeed
isra-fel Oct 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Cdn/Cdn.Test/Cdn.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Cdn" Version="4.2.4-preview" />
<PackageReference Include="Microsoft.Azure.Management.Cdn" Version="4.4.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Cdn/Cdn.Test/ScenarioTests/ChinaCdnProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ChinaCdnProfileTests(Xunit.Abstractions.ITestOutputHelper output)
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Fact(Skip = "Test needs to be run by the China CDN team")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestProfileList()
{
Expand Down
39 changes: 20 additions & 19 deletions src/Cdn/Cdn.Test/ScenarioTests/CustomDomainTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,46 @@ Enables custom domain with running endpoint.
function Test-CustomDomainEnableDisableWithRunningEndpoint
{
# Hard-coding host and endpoint names due to requirement for DNS CNAME
$endpointName = "testVerizonEP"
$hostName = "testVerizon.dustydog.us"
$endpointName = "cdn-ps-test-msft"
$hostName = "a.cdn-ps-test-msft.azfdtest.xyz"

$customDomainName = getAssetName

$profileName = getAssetName
$resourceGroup = TestSetup-CreateResourceGroup
$resourceLocation = "EastUS"
$profileSku = "Standard_Verizon"
$profileSku = "Standard_Microsoft"
$tags = @{"tag1" = "value1"; "tag2" = "value2"}
$createdProfile = New-AzCdnProfile -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Location $resourceLocation -Sku $profileSku -Tag $tags

$originName = getAssetName
$originHostName = "www.microsoft.com"
$createdEndpoint = New-AzCdnEndpoint -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Location $resourceLocation -OriginName $originName -OriginHostName $originHostName

if ($endpoint.HostName -Match "azureedge-test\.net$") {
$hostName = 'a.cdn-ps-test-msft-df.azfdtest.xyz'
}
$endpoint = Get-AzCdnEndpoint -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName
$validateResult = Test-AzCdnCustomDomain -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -CustomDomainHostName $hostName
Assert-True{$validateResult.CustomDomainValidated}
$validateResultbyPiping = Test-AzCdnCustomDomain -CdnEndpoint $endpoint -CustomDomainHostName $hostName
Assert-True{$validateResultbyPiping.CustomDomainValidated}

$createdCustomDomain = $endpoint | New-AzCdnCustomDomain -HostName $hostName -CustomDomainName $customDomainName
$createdCustomDomain = $endpoint | New-AzCdnCustomDomain -HostName $hostName -CustomDomainName $customDomainName
Assert-AreEqual $customDomainName $createdCustomDomain.Name
Assert-AreEqual $hostName $createdCustomDomain.HostName
$customDomain = $endpoint | Get-AzCdnCustomDomain -CustomDomainName $customDomainName

$customDomain = $endpoint | Get-AzCdnCustomDomain -CustomDomainName $customDomainName
Assert-AreEqual $customDomainName $customDomain.Name
Assert-AreEqual $hostName $customDomain.HostName

$enabled = $customDomain | Enable-AzCdnCustomDomainHttps -PassThru
Assert-True{$enabled}
Assert-ThrowsContains { Enable-AzCdnCustomDomainHttps -CustomDomainName $customDomainName -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName } "BadRequest"

Assert-ThrowsContains { Disable-AzCdnCustomDomain -CustomDomainName $customDomainName -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName } "BadRequest"
SleepInRecordMode 900

Disable-AzCdnCustomDomain -CustomDomainName $customDomainName -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName
$customDomain = $endpoint | Get-AzCdnCustomDomain -CustomDomainName $customDomainName
Assert-AreEqual "Disabling" $customDomain.CustomHttpsProvisioningState

Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}
Expand Down Expand Up @@ -199,10 +204,6 @@ function Test-VerizonCustomDomainEnableHttpsWithRunningEndpoint

Assert-AreEqual $customDomain.CustomHttpsProvisioningState "Enabling"

Assert-ThrowsContains { $customDomain | Enable-AzCdnCustomDomainHttps } "BadRequest"

Assert-ThrowsContains { $customDomain | Disable-AzCdnCustomDomainHttps } "BadRequest"

Remove-AzureRmResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

Expand Down Expand Up @@ -241,8 +242,6 @@ function Test-AkamaiCustomDomainEnableHttpsWithRunningEndpoint
$customDomain = Get-AzCdnCustomDomain -CustomDomainName $customDomainName -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName
Assert-AreEqual $customDomain.CustomHttpsProvisioningState "Enabling"

Assert-ThrowsContains { $customDomain | Enable-AzCdnCustomDomainHttps } "BadRequest"

Remove-AzureRmResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

Expand All @@ -253,8 +252,8 @@ Enable Https for custom domain with running endpoint
function Test-MicrosoftCustomDomainEnableHttpsWithRunningEndpoint
{
# Hard-coding host and endpoint names due to requirement for DNS CNAME
$endpointName = "testMicrosoftEP"
$hostName = "testMicrosoft.dustydog.us"
$endpointName = "cdn-ps-test-msft"
$hostName = "a.cdn-ps-test-msft.azfdtest.xyz"

$customDomainName = getAssetName

Expand All @@ -268,6 +267,10 @@ function Test-MicrosoftCustomDomainEnableHttpsWithRunningEndpoint
$originName = getAssetName
$originHostName = "www.microsoft.com"
$endpoint = New-AzCdnEndpoint -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Location $resourceLocation -OriginName $originName -OriginHostName $originHostName
if ($endpoint.HostName -Match "azureedge-test\.net$") {
$hostName = 'a.cdn-ps-test-msft-df.azfdtest.xyz'
}

$validateResult = Test-AzCdnCustomDomain -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -CustomDomainHostName $hostName
Assert-True{$validateResult.CustomDomainValidated}

Expand All @@ -281,7 +284,5 @@ function Test-MicrosoftCustomDomainEnableHttpsWithRunningEndpoint
$customDomain = Get-AzCdnCustomDomain -CustomDomainName $customDomainName -EndpointName $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName
Assert-AreEqual $customDomain.CustomHttpsProvisioningState "Enabling"

Assert-ThrowsContains { $customDomain | Enable-AzCdnCustomDomainHttps } "BadRequest"

Remove-AzureRmResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}
2 changes: 1 addition & 1 deletion src/Cdn/Cdn.Test/ScenarioTests/EndpointTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ function Test-EndpointResourceUsage

$endpointResourceUsage = Get-AzCdnEndpointResourceUsage -EndpointName $endpointName1 -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName

Assert-True {$endpointResourceUsage.Count -eq 2}
Assert-True {$endpointResourceUsage.Count -eq 3}
Assert-True {$endpointResourceUsage[0].CurrentValue -eq 0}
Assert-True {$endpointResourceUsage[1].CurrentValue -eq 0}

Expand Down
53 changes: 53 additions & 0 deletions src/Cdn/Cdn.Test/ScenarioTests/OriginGroupTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Cdn.Test.ScenarioTests.ScenarioTest
{
public class OriginGroupTests
{
private ServiceManagement.Common.Models.XunitTracingInterceptor _logger;

public OriginGroupTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-CreateOriginGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetSetOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-GetSetOriginGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestRemoveOriginGroup()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-RemoveOriginGroup");
}

}
}
192 changes: 192 additions & 0 deletions src/Cdn/Cdn.Test/ScenarioTests/OriginGroupTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Creats an origin group and set the default origin group on a running endpoint
#>
function Test-CreateOriginGroup
{
# Set up required fields
$subId = (Get-AzContext).Subscription.id
$resourceGroup = TestSetup-CreateResourceGroup
$resourceGroupName = $resourceGroup.ResourceGroupName
$profileName = getAssetName

# Profile specific properties
$resourceLocation = "Global"
$profileSku = "Standard_Microsoft"

# Create a Microsoft CDN Profile
$createdProfile = New-AzCdnProfile -ResourceGroupName $resourceGroupName -ProfileName $profileName -Location $resourceLocation -Sku $profileSku

# Endpoint specific properties
$endpointName = getAssetName
$originGroupName = getAssetName
$originName = getAssetName
$originHostName = "www.microsoft.com"
$originGroupResourceId = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origingroups/$originGroupName"
$defaultOriginGroup = $originGroupResourceId

# 1st origin group properties
$probeInterval = 240
$probePath = "/health.aspx"
$probeProtocol = "Https"
$probeRequestType = "GET"
$originId = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origins/$originName"

# Create CDN endpoint, 1st origin group, and establish the default origin group
$createdEndpoint = New-AzCdnEndpoint -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -Location $resourceLocation -OriginName $originName -OriginHostName $originHostName -OriginGroupName $originGroupName -DefaultOriginGroup $defaultOriginGroup -OriginGroupProbeIntervalInSeconds $probeInterval -OriginGroupProbePath $probePath -OriginGroupProbeProtocol $probeProtocol -OriginGroupProbeRequestType $probeRequestType -OriginId $originId

# 2nd origin group properties
$originGroupName2 = getAssetName
$probeInterval2 = 120
$probePath2 = "/check-health.aspx"
$probeProtocol2 = "Http"
$probeRequestType2 = "HEAD"

# create 2nd origin group
$createdOriginGroup = New-AzCdnOriginGroup -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -OriginGroupName $originGroupName2 -OriginId $originId -ProbeIntervalInSeconds $probeInterval2 -ProbePath $probePath2 -ProbeProtocol $probeProtocol2 -ProbeRequestType $probeRequestType2

# Test the default origin group on the endpoint
Assert-AreEqual $defaultOriginGroup $createdEndpoint.DefaultOriginGroup.Id

# Test the properties on the 2nd origin group
Assert-AreEqual $originGroupName2 $createdOriginGroup.Name
Assert-AreEqual $probeInterval2 $createdOriginGroup.ProbeIntervalInSeconds
Assert-AreEqual $probePath2 $createdOriginGroup.ProbePath
Assert-AreEqual $probeProtocol2 $createdOriginGroup.ProbeProtocol
Assert-AreEqual $probeRequestType2 $createdOriginGroup.ProbeRequestType
Assert-AreEqual $originId $createdOriginGroup.Origins[0].Id

Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Gets and sets an origin group with a running endpoint
#>
function Test-GetSetOriginGroup
{
# Set up required fields
$subId = (Get-AzContext).Subscription.id
$resourceGroup = TestSetup-CreateResourceGroup
$resourceGroupName = $resourceGroup.ResourceGroupName
$profileName = getAssetName

# Profile specific properties
$resourceLocation = "Global"
$profileSku = "Standard_Microsoft"

# Create a Microsoft CDN Profile
$createdProfile = New-AzCdnProfile -ResourceGroupName $resourceGroupName -ProfileName $profileName -Location $resourceLocation -Sku $profileSku

# Endpoint specific properties
$endpointName = getAssetName
$originGroupName = getAssetName
$originName = getAssetName
$originHostName = "www.microsoft.com"
$originGroupResourceId = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origingroups/$originGroupName"
$defaultOriginGroup = $originGroupResourceId

# Origin id for the origin group
$originId = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origins/$originName"

# Create CDN endpoint, origin group, and establish the default origin group
$createdEndpoint = New-AzCdnEndpoint -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -Location $resourceLocation -OriginName $originName -OriginHostName $originHostName -OriginGroupName $originGroupName -DefaultOriginGroup $defaultOriginGroup -OriginId $originId

# Get the origin group
$originGroup = Get-AzCdnOriginGroup -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -OriginGroupName $originGroupName

# Test the unmodified origin group
Assert-AreEqual $originGroupResourceId $originGroup.Id
Assert-AreEqual 0 $originGroup.ProbeIntervalInSeconds
Assert-Null $originGroup.ProbePath
Assert-Null $originGroup.ProbeProtocol
Assert-Null $originGroup.ProbeRequestType

# Set new values on the origin group
$probeInterval = 120
$probePath = "/health-status.aspx"
$probeProtocol = "Https"
$probeRequestType = "GET"

# Update properties on origin group
$updatedOriginGroup = Set-AzCdnOriginGroup -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -OriginGroupName $originGroupName -OriginId $originId -ProbeIntervalInSeconds $probeInterval -ProbePath $probePath -ProbeProtocol $probeProtocol -ProbeRequestType $probeRequestType

# Test modified origin group
Assert-AreEqual $probeInterval $updatedOriginGroup.ProbeIntervalInSeconds
Assert-AreEqual $probePath $updatedOriginGroup.ProbePath
Assert-AreEqual $probeProtocol $updatedOriginGroup.ProbeProtocol
Assert-AreEqual $probeRequestType $updatedOriginGroup.ProbeRequestType

Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}

<#
.SYNOPSIS
Creates and removes an origin group with a running endpoint
#>
function Test-RemoveOriginGroup
{
# Set up required fields
$subId = (Get-AzContext).Subscription.id
$resourceGroup = TestSetup-CreateResourceGroup
$resourceGroupName = $resourceGroup.ResourceGroupName
$profileName = getAssetName

# Profile specific properties
$resourceLocation = "Global"
$profileSku = "Standard_Microsoft"

# Create a Microsoft CDN Profile
$createdProfile = New-AzCdnProfile -ResourceGroupName $resourceGroupName -ProfileName $profileName -Location $resourceLocation -Sku $profileSku

# Endpoint specific properties
$endpointName = getAssetName
$originGroupName = getAssetName
$originName = getAssetName
$originHostName = "www.microsoft.com"
$originGroupResourceId = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origingroups/$originGroupName"
$defaultOriginGroup = $originGroupResourceId

# Origin id for the origin group
$originId = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origins/$originName"

# Create CDN endpoint, origin group, and establish the default origin group
$createdEndpoint = New-AzCdnEndpoint -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -Location $resourceLocation -OriginName $originName -OriginHostName $originHostName -OriginGroupName $originGroupName -DefaultOriginGroup $defaultOriginGroup -OriginId $originId

# 2nd origin group properties
$originGroupName2 = getAssetName
$probeInterval2 = 120
$probePath2 = "/check-health.aspx"
$probeProtocol2 = "Http"
$probeRequestType2 = "HEAD"
$originGroupResourceId2 = "/subscriptions/$subId/resourcegroups/$resourceGroupName/providers/Microsoft.Cdn/profiles/$profileName/endpoints/$endpointName/origingroups/$originGroupName2"

# create 2nd origin group
$createdOriginGroup = New-AzCdnOriginGroup -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -OriginGroupName $originGroupName2 -OriginId $originId -ProbeIntervalInSeconds $probeInterval2 -ProbePath $probePath2 -ProbeProtocol $probeProtocol2 -ProbeRequestType $probeRequestType2

# Remove the 2nd origin group
Remove-AzCdnOriginGroup -ResourceId $originGroupResourceId2

# Update a property on the already deleted origin group
$probeIntervalUpdate = 60

# Test origin group was removed correctly
Assert-ThrowsContains { Get-AzCdnOriginGroup -ResourceId $originGroupResourceId2 } "NotFound"
Assert-ThrowsContains { Set-AzCdnOriginGroup -ResourceGroupName $resourceGroupName -ProfileName $profileName -EndpointName $endpointName -OriginGroupName $originGroupName2 -OriginId $originId -ProbeIntervalInSeconds $probeIntervalUpdate } "NotFound"

Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}
7 changes: 7 additions & 0 deletions src/Cdn/Cdn.Test/ScenarioTests/OriginTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@ public void TestOriginGetSetWhenEndpointDoesnotExist()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-OriginGetSetWhenEndpointDoesnotExist");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetOriginProperties()
{
TestController.NewInstance.RunPowerShellTest(_logger, "Test-SetOriginProperties");
}
}
}
Loading