Skip to content

Commit

Permalink
Merge pull request #9 from ChenglongLiu/feature/Cdndev
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ChenglongLiu authored Mar 28, 2022
2 parents fa346c9 + a16215f commit 2b1b6fa
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 7 deletions.
66 changes: 64 additions & 2 deletions src/Cdn/Cdn.Autorest/test/New-AzFrontDoorCdnRoute.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,69 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzFrontDoorCdnRoute'))
}

Describe 'New-AzFrontDoorCdnRoute' {
It 'CreateExpanded' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
It 'CreateExpanded' {
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
try
{
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location

$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"

$profileSku = "Standard_AzureFrontDoor";
New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global

$endpointName = 'end-' + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use frontDoorCdnEndpointName : $($endpointName)"
$endpoint = New-AzFrontDoorCdnEndpoint -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global

$originGroupName = 'org' + (RandomString -allChars $false -len 6);
$originGroup = New-AzFrontDoorCdnOriginGroup -OriginGroupName $originGroupName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
-LoadBalancingSettingSampleSize 5 `
-LoadBalancingSettingSuccessfulSamplesRequired 4 `
-LoadBalancingSettingAdditionalLatencyInMillisecond 200 `
-HealthProbeSettingProbeIntervalInSecond 1 `
-HealthProbeSettingProbePath "/" `
-HealthProbeSettingProbeProtocol $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.ProbeProtocol]::Https) `
-HealthProbeSettingProbeRequestType $([Microsoft.Azure.PowerShell.Cmdlets.Cdn.Support.HealthProbeRequestType]::Get) `

Get-AzFrontDoorCdnOriginGroup -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -OriginGroupName $originGroupName

$hostName = "en.wikipedia.org";
$originName = 'ori' + (RandomString -allChars $false -len 6);
New-AzFrontDoorCdnOrigin -ResourceGroupName $ResourceGroupName -ProfileName $frontDoorCdnProfileName -OriginGroupName $originGroupName `
-OriginName $originName -OriginHostHeader $hostName -HostName $hostName `
-HttpPort 80 -HttpsPort 443 -Priority 1 -Weight 1000

$rulesetName = 'rs' + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use rulesetName : $($rulesetName)"
$ruleSet = New-AzFrontDoorCdnRuleSet -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Name $rulesetName
$uriConditon = New-AzCdnDeliveryRuleRequestUriConditionObject -Name "RequestUri" -ParameterOperator "Any"
$conditions = @(
$uriConditon
);
$overrideAction = New-AzCdnDeliveryRuleRouteConfigurationOverrideActionObject -Name "RouteConfigurationOverride" `
-CacheConfigurationQueryStringCachingBehavior "IgnoreSpecifiedQueryStrings" `
-CacheConfigurationQueryParameter "a=test" `
-CacheConfigurationIsCompressionEnabled "Enabled" `
-CacheConfigurationCacheBehavior "HonorOrigin"
$actions = @($overrideAction);

$ruleName = 'r' + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use ruleName : $($ruleName)"
New-AzFrontDoorCdnRule -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -RuleSetName $rulesetName -Name $ruleName `
-Action $actions -Condition $conditions

$ruleSetResoure = [Microsoft.Azure.PowerShell.Cmdlets.Cdn.Models.Api20210601.ResourceReference]::new()
$ruleSetResoure.Id = $ruleSet.Id

$routeName = 'route' + (RandomString -allChars $false -len 6);
New-AzFrontDoorCdnRoute -Name $routeName -EndpointName $endpointName -ProfileName $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName `
-OriginGroupId $originGroup.Id -RuleSet @($ruleSetResoure) -PatternsToMatch "/*" -LinkToDefaultDomain "Enabled" -EnabledState "Enabled"
} Finally
{
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
}
}
}
23 changes: 21 additions & 2 deletions src/Cdn/Cdn.Autorest/test/New-AzFrontDoorCdnSecret.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzFrontDoorCdnSecret'))
}

Describe 'New-AzFrontDoorCdnSecret' {
It 'CreateExpanded' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
It 'CreateExpanded' {
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
try
{
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location

$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"

$profileSku = "Standard_AzureFrontDoor";
$frontDoorCdnProfile = New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global

$secretName = "se-" + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use secretName : $($secretName)"

New-AzFrontDoorCdnSecret -Name $secretName -ProfileName $frontDoorCdnProfile -ResourceGroupName $ResourceGroupName `
} Finally
{
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,25 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzFrontDoorCdnSecurityPol
}

Describe 'New-AzFrontDoorCdnSecurityPolicy' {
It 'CreateExpanded' -skip {
{ throw [System.NotImplementedException] } | Should -Not -Throw
It 'CreateExpanded' {
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
try
{
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location

$frontDoorCdnProfileName = 'fdp-' + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use frontDoorCdnProfileName : $($frontDoorCdnProfileName)"

$profileSku = "Standard_AzureFrontDoor";
$frontDoorCdnProfile = New-AzFrontDoorCdnProfile -SkuName $profileSku -Name $frontDoorCdnProfileName -ResourceGroupName $ResourceGroupName -Location Global

$policyName = "pol-" + (RandomString -allChars $false -len 6);
Write-Host -ForegroundColor Green "Use policyName : $($policyName)"
New-AzFrontDoorCdnSecurityPolicy -Name $policyName -ProfileName $frontDoorCdnProfile -ResourceGroupName $ResourceGroupName
} Finally
{
#Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
}
}
}
2 changes: 1 addition & 1 deletion src/Cdn/Cdn.Autorest/test/localEnv.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"location": "westus",
"Tenant": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"location": "westus",
"SubscriptionId": "d7cfdb98-c118-458d-8bdf-246be66b1f5e"
}

0 comments on commit 2b1b6fa

Please sign in to comment.