Skip to content

Commit bed702d

Browse files
authored
Fix azcontainerregistry live test authentication (Azure#24419)
1 parent f5dfe3b commit bed702d

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

sdk/containers/azcontainerregistry/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 0.2.3 (2025-04-08)
3+
## 0.2.3 (2025-04-15)
44

55
### Other Changes
66
* Default audience of Azure Container Registry of all clouds to https://containerregistry.azure.net

sdk/containers/azcontainerregistry/test-resources-post.ps1

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ param (
2727

2828
$ErrorActionPreference = 'Stop'
2929
$PSNativeCommandUseErrorActionPreference = $true
30-
31-
if ($CI) {
32-
az cloud set -n $Environment
33-
az login --federated-token $env:ARM_OIDC_TOKEN --service-principal -t $TenantId -u $TestApplicationId
34-
az account set --subscription $SubscriptionId
35-
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
# IMPORTANT: Do not invoke this file directly. Please instead run eng/common/TestResources/New-TestResources.ps1 from the repository root.
5+
6+
param (
7+
[Parameter(Mandatory = $true)]
8+
[ValidateNotNullOrEmpty()]
9+
[string] $SubscriptionId,
10+
11+
[Parameter(Mandatory = $true)]
12+
[ValidateNotNullOrEmpty()]
13+
[string] $TenantId,
14+
15+
[Parameter(Mandatory = $true)]
16+
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
17+
[string] $TestApplicationId,
18+
19+
[Parameter(Mandatory = $true)]
20+
[ValidateNotNullOrEmpty()]
21+
[string] $Environment,
22+
23+
[Parameter()]
24+
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID),
25+
26+
# Captures any arguments from eng/New-TestResources.ps1 not declared here (no parameter errors).
27+
[Parameter(ValueFromRemainingArguments = $true)]
28+
$RemainingArguments
29+
)
30+
31+
$ErrorActionPreference = 'Stop'
32+
$PSNativeCommandUseErrorActionPreference = $true
33+
34+
if ($CI) {
35+
az cloud set -n $Environment
36+
az login --federated-token $env:ARM_OIDC_TOKEN --service-principal -t $TenantId -u $TestApplicationId
37+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
38+
az account set --subscription $SubscriptionId
39+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
40+
}

sdk/containers/azcontainerregistry/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func buildImage(t *testing.T) (string, string) {
157157
cmd := exec.CommandContext(ctx, "az", "acr", "build", "-r", testConfig.registryName, "--image", repository, "--build-arg", "ID="+repository, ".")
158158
cmd.Dir = "testdata"
159159
out, err = cmd.CombinedOutput()
160-
if err == nil {
160+
if err == nil || strings.Contains(string(out), "az login") {
161161
return
162162
}
163163
}

0 commit comments

Comments
 (0)