Skip to content

Commit f812154

Browse files
Enable testing against ACR (#1550)
1 parent 58d5940 commit f812154

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

.ci/test.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ jobs:
1111
vmImage: ${{ parameters.imageName }}
1212
displayName: ${{ parameters.displayName }}
1313
steps:
14+
- ${{ parameters.powershellExecutable }}: |
15+
Install-Module -Name 'Microsoft.PowerShell.SecretManagement' -force -SkipPublisherCheck -AllowClobber
16+
Install-Module -Name 'Microsoft.PowerShell.SecretStore' -force -SkipPublisherCheck -AllowClobber
17+
$vaultPassword = ConvertTo-SecureString $("a!!"+ (Get-Random -Maximum ([int]::MaxValue))) -AsPlainText -Force
18+
Set-SecretStoreConfiguration -Authentication None -Interaction None -Confirm:$false -Password $vaultPassword
19+
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
20+
displayName: Install Secret store
21+
1422
- task: DownloadBuildArtifacts@0
1523
displayName: 'Download artifacts'
1624
inputs:
@@ -53,6 +61,24 @@ jobs:
5361
displayName: Install module for test from downloaded artifact
5462
workingDirectory: ${{ parameters.buildDirectory }}
5563
64+
- task: AzurePowerShell@5
65+
inputs:
66+
azureSubscription: PSResourceGetACR
67+
azurePowerShellVersion: LatestVersion
68+
ScriptType: InlineScript
69+
pwsh: true
70+
inline: |
71+
Write-Verbose -Verbose "Getting Azure Container Registry"
72+
Get-AzContainerRegistry -ResourceGroupName 'PSResourceGet' -Name 'psresourcegettest' | Select-Object -Property *
73+
Write-Verbose -Verbose "Setting up secret for Azure Container Registry"
74+
$azt = Get-AzAccessToken
75+
$tenantId = $azt.TenantID
76+
Set-Secret -Name $tenantId -Secret $azt.Token -Verbose
77+
$vstsCommandString = "vso[task.setvariable variable=TenantId]$tenantId"
78+
Write-Host "sending " + $vstsCommandString
79+
Write-Host "##$vstsCommandString"
80+
displayName: 'Setup Azure Container Registry secret'
81+
5682
- ${{ parameters.powershellExecutable }}: |
5783
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
5884
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
@@ -68,4 +94,3 @@ jobs:
6894
workingDirectory: ${{ parameters.buildDirectory }}
6995
errorActionPreference: continue
7096
condition: succeededOrFailed()
71-

test/FindPSResourceTests/FindPSResourceACRServer.Tests.ps1

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
<#
5-
# These tests are working with manual validation but there is currently no automated testing for ACR repositories.
6-
74
$modPath = "$psscriptroot/../PSGetTestUtils.psm1"
85
Import-Module $modPath -Force -Verbose
96

107
Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
118

129
BeforeAll{
13-
$testModuleName = "hello-world"
10+
$testModuleName = "test_local_mod"
1411
$ACRRepoName = "ACRRepo"
15-
$ACRRepoUri = "https://psgetregistry.azurecr.io"
12+
$ACRRepoUri = "https://psresourcegettest.azurecr.io"
1613
Get-NewPSResourceRepositoryFile
17-
Register-PSResourceRepository -Name $ACRRepoName -Uri $ACRepoUri -ApiVersion "ACR"
14+
$psCredInfo = New-Object Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo ("SecretStore", "$env:TENANTID")
15+
Register-PSResourceRepository -Name $ACRRepoName -ApiVersion 'acr' -Uri $ACRRepoUri -CredentialInfo $psCredInfo -Verbose
1816
}
1917

2018
AfterAll {
@@ -138,5 +136,3 @@ Describe 'Test HTTP Find-PSResource for ACR Server Protocol' -tags 'CI' {
138136
$err[0].FullyQualifiedErrorId | Should -BeExactly "FindAllFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource"
139137
}
140138
}
141-
142-
#>

0 commit comments

Comments
 (0)