-
Notifications
You must be signed in to change notification settings - Fork 879
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 test variabl…
…es (#21622)
- Loading branch information
Showing
2 changed files
with
42 additions
and
13 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
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 |