Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
$OidcTokenResponse = Invoke-RestMethod @Params
$OidcToken = $OidcTokenResponse.value

Import-Module ./output/AzAuth
Import-Module ./output/module/AzAuth
Get-AzToken -WorkloadIdentity -ExternalToken $OidcToken -TenantId $env:TENANT_ID -ClientId $env:CLIENT_ID -ErrorAction Stop | Out-Null

Write-Host "Successfully retrieved token for Workload Identity."
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"-NoExit",
"-NoProfile",
"-Command",
"Import-Module ${workspaceFolder}/output/AzAuth -Verbose",
"Import-Module ${workspaceFolder}/output/module/AzAuth -Verbose",
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
Expand Down
61 changes: 35 additions & 26 deletions tests/cases/TestCases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,41 +84,50 @@ function Get-TestCaseByType {
# }
# }
if ('NonInteractiveTests' -in $CaseType) {
# Create or resolve the PEM file path
$PemPath = try {
(New-Item -Name 'azauth.pem' -Value @"
$env:CLIENT_CERTIFICATE
$env:CLIENT_CERTIFICATE_PRIVATE_KEY
"@).FullName
}
catch {
(Resolve-Path 'azauth.pem').Path
}

$TestCases += [ordered]@{
'Client Secret' = @{
'Client Secret' = @{
Tenant = $env:TENANT_ID
ClientId = $env:CLIENT_ID
ClientSecret = $env:CLIENT_SECRET
Resource = 'https://management.azure.com'
Scope = @('.default')
ExpectedScope = 'https://management.azure.com/.default'
}
'Certificate Object' = @{
Tenant = $env:TENANT_ID
ClientId = $env:CLIENT_ID
ClientCertificate = New-ClientCertificateFromPem -Certificate $env:CLIENT_CERTIFICATE -PrivateKey $env:CLIENT_CERTIFICATE_PRIVATE_KEY
Resource = 'https://graph.microsoft.com'
Scope = @('.default')
ExpectedScope = 'https://graph.microsoft.com/.default'
}

$HasCertificateMaterial =
-not [string]::IsNullOrWhiteSpace($env:CLIENT_CERTIFICATE) -and
-not [string]::IsNullOrWhiteSpace($env:CLIENT_CERTIFICATE_PRIVATE_KEY)

if ($HasCertificateMaterial) {
# Create or resolve the PEM file path.
$PemPath = try {
(New-Item -Name 'azauth.pem' -Value @"
$env:CLIENT_CERTIFICATE
$env:CLIENT_CERTIFICATE_PRIVATE_KEY
"@).FullName
}
catch {
(Resolve-Path 'azauth.pem').Path
}
'Certificate Path' = @{
Tenant = $env:TENANT_ID
ClientId = $env:CLIENT_ID
ClientCertificatePath = $PemPath
Resource = 'https://storage.azure.com'
Scope = @('.default')
ExpectedScope = 'https://storage.azure.com/.default'

$TestCases += [ordered]@{
'Certificate Object' = @{
Tenant = $env:TENANT_ID
ClientId = $env:CLIENT_ID
ClientCertificate = New-ClientCertificateFromPem -Certificate $env:CLIENT_CERTIFICATE -PrivateKey $env:CLIENT_CERTIFICATE_PRIVATE_KEY
Resource = 'https://graph.microsoft.com'
Scope = @('.default')
ExpectedScope = 'https://graph.microsoft.com/.default'
}
'Certificate Path' = @{
Tenant = $env:TENANT_ID
ClientId = $env:CLIENT_ID
ClientCertificatePath = $PemPath
Resource = 'https://storage.azure.com'
Scope = @('.default')
ExpectedScope = 'https://storage.azure.com/.default'
}
}
}
}
Expand Down
Loading