Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move identity live test variables into subscription config #31985

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions sdk/identity/test-resources-pre.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[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()
$pemPath = Join-Path $tmp "test.pem"
$pemPasswordProtectedPath = Join-Path $tmp "testPasswordProtected.pem"

Write-Host "Creating identity test files: $pemPath $pemPasswordProtectedPath"

$pemContent = $EnvironmentVariables['PEM_CONTENT'] -replace "\n","`n"
$pemContentPasswordProtected = $EnvironmentVariables['PEM_CONTENT_PASSWORD_PROTECTED'] -replace "\n","`n"

Set-Content -Path $pemPath -Value $pemContent
Set-Content -Path $pemPasswordProtectedPath -Value $pemContentPasswordProtected

# Set for pipeline
Write-Host "##vso[task.setvariable variable=IDENTITY_CERT_PEM;]$pemPath"
Write-Host "##vso[task.setvariable variable=IDENTITY_CERT_PEM_PASSWORD_PROTECTED;]$pemPasswordProtectedPath"
Write-Host "##vso[task.setvariable variable=CERTIFICATE_PASSWORD;]$($EnvironmentVariables['CERTIFICATE_PASSWORD'])"
Write-Host "##vso[task.setvariable variable=PFX_CONTENT;]$($EnvironmentVariables['PFX_CONTENT'])"
Write-Host "##vso[task.setvariable variable=PFX_CONTENT_PASSWORD_PROTECTED;]$($EnvironmentVariables['PFX_CONTENT_PASSWORD_PROTECTED'])"
# Set for local
$env:IDENTITY_CERT_PEM = $pemPath
$env:IDENTITY_CERT_PEM_PASSWORD_PROTECTED = $pemPasswordProtectedPath
$env:CERTIFICATE_PASSWORD = $EnvironmentVariables['CERTIFICATE_PASSWORD']
$env:PFX_CONTENT = $EnvironmentVariables['PFX_CONTENT']
$env:PFX_CONTENT_PASSWORD_PROTECTED = $EnvironmentVariables['PFX_CONTENT_PASSWORD_PROTECTED']
1 change: 1 addition & 0 deletions sdk/identity/test-resources.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
param baseName string
19 changes: 11 additions & 8 deletions sdk/identity/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ stages:
- template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml
parameters:
ServiceDirectory: identity
CloudConfig:
Public:
SubscriptionConfigurations:
- $(sub-config-azure-cloud-test-resources)
# Contains alternate tenant, AAD app and cert info for testing
- $(sub-config-identity-test-resources)
- $(sub-config-identity-test-resources-python)
EnvVars:
AZURE_CLIENT_ID: $(python-identity-client-id)
AZURE_CLIENT_SECRET: $(python-identity-client-secret)
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
CERTIFICATE_PASSWORD: $(python-identity-certificate-password)
PEM_CONTENT: $(python-identity-certificate)
PEM_CONTENT_PASSWORD_PROTECTED: $(python-identity-certificate-with-password)
PFX_CONTENT: $(python-identity-certificate-pfx)
PFX_CONTENT_PASSWORD_PROTECTED: $(python-identity-certificate-with-password-pfx)
AZURE_CLIENT_ID: $(IDENTITY_CLIENT_ID)
AZURE_CLIENT_SECRET: $(IDENTITY_CLIENT_SECRET)
AZURE_TENANT_ID: $(IDENTITY_TENANT_ID)
AZURE_SUBSCRIPTION_ID: $(IDENTITY_SUBSCRIPTION_ID)
AZURE_TEST_RUN_LIVE: true
AZURE_SKIP_LIVE_RECORDING: 'True'