Skip to content

Commit 322b8c2

Browse files
authored
Use identity subscription config and pre script for live tests (Azure#38473)
* Use dedicated identity subscription config for live tests * Move identity variable setting into test-resources-pre.ps1 * Handle local testing mode
1 parent 1173fab commit 322b8c2

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
2+
param (
3+
# Captures any arguments from eng/New-TestResources.ps1 not declared here (no parameter errors).
4+
[Parameter(ValueFromRemainingArguments = $true)]
5+
$RemainingArguments
6+
)
7+
8+
if (!$CI) {
9+
# TODO: Remove this once auto-cloud config downloads are supported locally
10+
Write-Host "Skipping cert setup in local testing mode"
11+
return
12+
}
13+
14+
if ($EnvironmentVariables -eq $null -or $EnvironmentVariables.Count -eq 0) {
15+
throw "EnvironmentVariables must be set in the calling script New-TestResources.ps1"
16+
}
17+
18+
$tmp = $env:TEMP ? $env:TEMP : [System.IO.Path]::GetTempPath()
19+
$pfxPath = Join-Path $tmp "test.pfx"
20+
$pemPath = Join-Path $tmp "test.pem"
21+
$sniPath = Join-Path $tmp "testsni.pfx"
22+
23+
Write-Host "Creating identity test files: $pfxPath $pemPath $sniPath"
24+
25+
[System.Convert]::FromBase64String($EnvironmentVariables['PFX_CONTENTS']) | Set-Content -Path $pfxPath -AsByteStream
26+
Set-Content -Path $pemPath -Value $EnvironmentVariables['PEM_CONTENTS']
27+
[System.Convert]::FromBase64String($EnvironmentVariables['SNI_CONTENTS']) | Set-Content -Path $sniPath -AsByteStream
28+
29+
# Set for pipeline
30+
Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_PFX;]$pfxPath"
31+
Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_PEM;]$pemPath"
32+
Write-Host "##vso[task.setvariable variable=IDENTITY_SP_CERT_SNI;]$sniPath"
33+
# Set for local
34+
$env:IDENTITY_SP_CERT_PFX = $pfxPath
35+
$env:IDENTITY_SP_CERT_PEM = $pemPath
36+
$env:IDENTITY_SP_CERT_SNI = $sniPath

sdk/identity/tests.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
trigger: none
22

33
extends:
4-
template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml
4+
template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml
55
parameters:
66
TimeoutInMinutes: 120
77
ServiceDirectory: identity
8-
SupportedClouds: 'Public,UsGov,China,Canary'
9-
PreSteps:
10-
- pwsh: |
11-
[System.Convert]::FromBase64String($env:PFX_CONTENTS) | Set-Content -Path $(Agent.TempDirectory)/test.pfx -AsByteStream
12-
Set-Content -Path $(Agent.TempDirectory)/test.pem -Value $env:PEM_CONTENTS
13-
[System.Convert]::FromBase64String($env:SNI_CONTENTS) | Set-Content -Path $(Agent.TempDirectory)/testsni.pfx -AsByteStream
14-
env:
15-
PFX_CONTENTS: $(net-identity-spcert-pfx)
16-
PEM_CONTENTS: $(net-identity-spcert-pem)
17-
SNI_CONTENTS: $(net-identity-spcert-sni)
18-
EnvVars:
19-
IDENTITY_SP_CERT_PFX: $(Agent.TempDirectory)/test.pfx
20-
IDENTITY_SP_CERT_PEM: $(Agent.TempDirectory)/test.pem
21-
IDENTITY_SP_CERT_SNI: $(Agent.TempDirectory)/testsni.pfx
8+
CloudConfig:
9+
Public:
10+
SubscriptionConfigurations:
11+
- $(sub-config-azure-cloud-test-resources)
12+
# Contains alternate tenant, AAD app and cert info for testing
13+
- $(sub-config-identity-test-resources)

0 commit comments

Comments
 (0)