-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use identity subscription config and pre script for live tests (#38473)
* Use dedicated identity subscription config for live tests * Move identity variable setting into test-resources-pre.ps1 * Handle local testing mode
- Loading branch information
Showing
2 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] | ||
param ( | ||
# Captures any arguments from eng/New-TestResources.ps1 not declared here (no parameter errors). | ||
[Parameter(ValueFromRemainingArguments = $true)] | ||
$RemainingArguments | ||
) | ||
|
||
if (!$CI) { | ||
# TODO: Remove this once auto-cloud config downloads are supported locally | ||
Write-Host "Skipping cert setup in local testing mode" | ||
return | ||
} | ||
|
||
if ($EnvironmentVariables -eq $null -or $EnvironmentVariables.Count -eq 0) { | ||
throw "EnvironmentVariables must be set in the calling script New-TestResources.ps1" | ||
} | ||
|
||
$tmp = $env:TEMP ? $env:TEMP : [System.IO.Path]::GetTempPath() | ||
$pfxPath = Join-Path $tmp "test.pfx" | ||
$pemPath = Join-Path $tmp "test.pem" | ||
$sniPath = Join-Path $tmp "testsni.pfx" | ||
|
||
Write-Host "Creating identity test files: $pfxPath $pemPath $sniPath" | ||
|
||
[System.Convert]::FromBase64String($EnvironmentVariables['PFX_CONTENTS']) | Set-Content -Path $pfxPath -AsByteStream | ||
Set-Content -Path $pemPath -Value $EnvironmentVariables['PEM_CONTENTS'] | ||
[System.Convert]::FromBase64String($EnvironmentVariables['SNI_CONTENTS']) | Set-Content -Path $sniPath -AsByteStream | ||
|
||
# Set for pipeline | ||
Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_PFX;]$pfxPath" | ||
Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_PEM;]$pemPath" | ||
Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_SNI;]$sniPath" | ||
# Set for local | ||
$env:IDENTITY_SP_CERT_PFX = $pfxPath | ||
$env:IDENTITY_SP_CERT_PEM = $pemPath | ||
$env:IDENTITY_SP_CERT_SNI = $sniPath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
trigger: none | ||
|
||
extends: | ||
template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml | ||
template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml | ||
parameters: | ||
TimeoutInMinutes: 120 | ||
ServiceDirectory: identity | ||
SupportedClouds: 'Public,UsGov,China,Canary' | ||
PreSteps: | ||
- pwsh: | | ||
[System.Convert]::FromBase64String($env:PFX_CONTENTS) | Set-Content -Path $(Agent.TempDirectory)/test.pfx -AsByteStream | ||
Set-Content -Path $(Agent.TempDirectory)/test.pem -Value $env:PEM_CONTENTS | ||
[System.Convert]::FromBase64String($env:SNI_CONTENTS) | Set-Content -Path $(Agent.TempDirectory)/testsni.pfx -AsByteStream | ||
env: | ||
PFX_CONTENTS: $(net-identity-spcert-pfx) | ||
PEM_CONTENTS: $(net-identity-spcert-pem) | ||
SNI_CONTENTS: $(net-identity-spcert-sni) | ||
EnvVars: | ||
IDENTITY_SP_CERT_PFX: $(Agent.TempDirectory)/test.pfx | ||
IDENTITY_SP_CERT_PEM: $(Agent.TempDirectory)/test.pem | ||
IDENTITY_SP_CERT_SNI: $(Agent.TempDirectory)/testsni.pfx | ||
CloudConfig: | ||
Public: | ||
SubscriptionConfigurations: | ||
- $(sub-config-azure-cloud-test-resources) | ||
# Contains alternate tenant, AAD app and cert info for testing | ||
- $(sub-config-identity-test-resources) |