|
|
@@ -0,0 +1,260 @@ |
|
|
|
<# |
|
|
|
.SYNOPSIS |
|
|
|
Create and run test suite |
|
|
|
.DESCRIPTION |
|
|
|
Submit a multi-case test suite to v3 of the test-center API and execute it |
|
|
|
.PARAMETER UserID |
|
|
|
ID of the user executing the test. Must be the same as that used in your hostname creation previously |
|
|
|
.EXAMPLE |
|
|
|
> .\New-AkaUTests.ps1 -UserID example |
|
|
|
#> |
|
|
|
|
|
|
|
Param( |
|
|
|
[Parameter(Mandatory)] |
|
|
|
[string] |
|
|
|
$UserID, |
|
|
|
|
|
|
|
[Parameter()] |
|
|
|
[string] |
|
|
|
$EdgeRCFile, |
|
|
|
|
|
|
|
[Parameter()] |
|
|
|
[string] |
|
|
|
$Section, |
|
|
|
|
|
|
|
[Parameter()] |
|
|
|
[string] |
|
|
|
$AccountSwitchKey |
|
|
|
) |
|
|
|
|
|
|
|
$CommonParams = @{ |
|
|
|
EdgeRCFile = $EdgeRCFile |
|
|
|
Section = $Section |
|
|
|
AccountSwitchKey = $AccountSwitchKey |
|
|
|
} |
|
|
|
|
|
|
|
# 1. Create test suite with child objects |
|
|
|
|
|
|
|
$TestSuiteJSON = @" |
|
|
|
{ |
|
|
|
"testSuiteName": "AkaULab-$UserID-TestSuite", |
|
|
|
"isLocked": false, |
|
|
|
"isStateful": false, |
|
|
|
"testCases": [ |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response code is one of \"302\"" |
|
|
|
}, |
|
|
|
"testRequest": { |
|
|
|
"requestMethod": "GET", |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response header \"X-Akamai-Staging\" has a value that equals \"ESSL\"" |
|
|
|
}, |
|
|
|
"testRequest": { |
|
|
|
"requestMethod": "GET", |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Caching option is cache with max-age of \"30\" days" |
|
|
|
}, |
|
|
|
"testRequest": { |
|
|
|
"requestMethod": "GET", |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com/assets/public/images/JuiceShop_Logo.png" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response code is one of \"302\"" |
|
|
|
}, |
|
|
|
"testRequest": { |
|
|
|
"requestMethod": "GET", |
|
|
|
"testRequestUrl": "https://{{userId}}tflab-test.akaudevops.com" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response header \"X-Test-Environment\" has a value that equals \"true\"" |
|
|
|
}, |
|
|
|
"testRequest": { |
|
|
|
"requestMethod": "GET", |
|
|
|
"testRequestUrl": "https://{{userId}}tflab-test.akaudevops.com" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response header \"cache-control\" has a value that contains \"no-store\"" |
|
|
|
}, |
|
|
|
"testRequest": { |
|
|
|
"requestMethod": "GET", |
|
|
|
"testRequestUrl": "https://{{userId}}tflab-test.akaudevops.com/style.css" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response code is one of \"403\"" |
|
|
|
}, |
|
|
|
|
|
|
|
"testRequest": { |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com/?pasword='OR%201=1", |
|
|
|
"requestMethod": "GET" |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response code is one of \"403\"" |
|
|
|
}, |
|
|
|
|
|
|
|
"testRequest": { |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com/", |
|
|
|
"requestMethod": "GET", |
|
|
|
"requestHeaders": [ |
|
|
|
{ |
|
|
|
"headerName": "blockme", |
|
|
|
"headerValue": "true", |
|
|
|
"headerAction": "ADD" |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CHROME", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response code is one of \"403\"" |
|
|
|
}, |
|
|
|
|
|
|
|
"testRequest": { |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com/rest/user/login", |
|
|
|
"requestMethod": "POST" |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response code is one of \"403\"" |
|
|
|
}, |
|
|
|
|
|
|
|
"testRequest": { |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com/", |
|
|
|
"requestMethod": "GET", |
|
|
|
"requestHeaders": [ |
|
|
|
{ |
|
|
|
"headerName": "X-Forwarded-For", |
|
|
|
"headerValue": "101.110.112.0", |
|
|
|
"headerAction": "ADD" |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
"clientProfile": { |
|
|
|
"client": "CURL", |
|
|
|
"ipVersion": "IPV4" |
|
|
|
}, |
|
|
|
"condition": { |
|
|
|
"conditionExpression": "Response header \"set-cookie\" has a value that contains \"language=ko_KR\"" |
|
|
|
}, |
|
|
|
|
|
|
|
"testRequest": { |
|
|
|
"testRequestUrl": "https://{{userId}}tflab.akaudevops.com/", |
|
|
|
"requestMethod": "GET", |
|
|
|
"requestHeaders": [ |
|
|
|
{ |
|
|
|
"headerName": "X-Forwarded-For", |
|
|
|
"headerValue": "168.126.63.1", |
|
|
|
"headerAction": "ADD" |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
"variables": [ |
|
|
|
{ |
|
|
|
"variableName": "userId", |
|
|
|
"variableValue": "$UserID" |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
"@ |
|
|
|
|
|
|
|
try { |
|
|
|
$TestSuite = Invoke-AkamaiRestMethod -Method POST -Path '/test-management/v3/functional/test-suites/with-child-objects' -Body $TestSuiteJSON @CommonParams |
|
|
|
} |
|
|
|
catch { |
|
|
|
Write-Error "Error creating test suite. Cannot continue" |
|
|
|
Write-Error $_ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
# 2. Execute Test Suite |
|
|
|
|
|
|
|
$TestExecutionJSON = @" |
|
|
|
{ |
|
|
|
"functional": { |
|
|
|
"testSuiteExecutions": [ |
|
|
|
{ |
|
|
|
"testSuiteId": $($TestSuite.success.testSuiteId) |
|
|
|
} |
|
|
|
] |
|
|
|
}, |
|
|
|
"targetEnvironment": "STAGING", |
|
|
|
"note": "Executing test suite for user $UserID", |
|
|
|
"sendEmailOnCompletion": false |
|
|
|
} |
|
|
|
"@ |
|
|
|
|
|
|
|
try { |
|
|
|
$Run = Invoke-AkamaiRestMethod -Method POST -Path '/test-management/v3/test-runs' -Body $TestExecutionJSON @CommonParams |
|
|
|
} |
|
|
|
catch { |
|
|
|
Write-Error "Error executing test suite $($TestSuite.success.testSuiteId). Cannot continue" |
|
|
|
Write-Error $_ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
Write-Host -ForegroundColor Green "Test suite $($TestSuite.success.testSuiteId) created. Wait a few minutes before retrieving test run results with ID: $($Run.testRunId)" |