Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions src/code/ContainerRegistryServerAPICalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ internal string GetContainerRegistryAccessToken(bool needCatalogAccess, bool isP
{
// A container registry repository is determined to be unauthenticated if it allows anonymous pull access. However, push operations always require authentication.
bool isRepositoryUnauthenticated = isPushOperation ? false : IsContainerRegistryUnauthenticated(Repository.Uri.ToString(), needCatalogAccess, out errRecord, out accessToken);
_cmdletPassedIn.WriteInformation($"Value of isRepositoryUnauthenticated: {isRepositoryUnauthenticated}", new string[] { "PSRGContainerRegistryUnauthenticatedCheck" });
_cmdletPassedIn.WriteDebug($"Value of isRepositoryUnauthenticated: {isRepositoryUnauthenticated}");
Comment thread
adityapatwardhan marked this conversation as resolved.
Outdated

_cmdletPassedIn.WriteDebug($"Is repository unauthenticated: {isRepositoryUnauthenticated}");
Comment thread
adityapatwardhan marked this conversation as resolved.

Expand Down Expand Up @@ -1002,8 +1002,8 @@ internal JObject GetHttpResponseJObjectUsingDefaultHeaders(string url, HttpMetho
{
errRecord = new ErrorRecord(
exception: e,
"ResourceNotFound",
ErrorCategory.InvalidResult,
"PackageNotFound",
ErrorCategory.ObjectNotFound,
_cmdletPassedIn);
}
catch (UnauthorizedException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ Describe 'Test Install-PSResource for searching and looping through repositories

It "install resources from highest priority repository where it exists (without -Repository specified)" {
# Package "test_module" exists in the following repositories (in this order): localRepo, PSGallery, NuGetGallery
# Package does not exist on MAR to we need to skip when validating that the highest priority repository is used
# Package does not exist on MAR, and should not emit an error when found in a lower priority repository
$res = Install-PSResource -Name $testModuleName -TrustRepository -SkipDependencyCheck -ErrorVariable err -ErrorAction SilentlyContinue -PassThru
$err | Should -HaveCount 1 ## This comes from MAR
$err | Should -HaveCount 0

$res | Should -Not -BeNullOrEmpty
$res.Repository | Should -Be $localRepoName
}

It "install resources from hightest priority repository where it exists and not write errors for repositories where it does not exist (without -Repository specified)" {
Comment thread
adityapatwardhan marked this conversation as resolved.
Outdated
# Package "test_script" exists in the following repositories: PSGallery, NuGetGallery
# Package does not exist on MAR to we need to skip when validating that the highest priority repository is used
# Package does not exist on MAR, and should not emit an error when found in a lower priority repository
Install-PSResource -Name $testScriptName -TrustRepository -SkipDependencyCheck -ErrorVariable err -ErrorAction SilentlyContinue
$err | Should -HaveCount 1 ## This comes from MAR
$err | Should -HaveCount 0

$res = Get-InstalledPSResource $testScriptName
$res | Should -Not -BeNullOrEmpty
Expand All @@ -66,13 +66,13 @@ Describe 'Test Install-PSResource for searching and looping through repositories

It "should not install resource given nonexistent Name (without -Repository specified)" {
Install-PSResource -Name "NonExistentModule" -TrustRepository -SkipDependencyCheck -ErrorVariable err -ErrorAction SilentlyContinue
$err | Should -HaveCount 2 ## One error comes from MAR
$err | Should -HaveCount 1
"InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource" | Should -BeIn $err.FullyQualifiedErrorId
}

It "install multiple resources from highest priority repository where it exists (without -Repository specified)" {
$res = Install-PSResource -Name "test_module","test_module2" -TrustRepository -SkipDependencyCheck -ErrorVariable err -ErrorAction SilentlyContinue -PassThru
$err | Should -HaveCount 2 ## This comes from MAR
$err | Should -HaveCount 0
$res | Should -Not -BeNullOrEmpty

$pkg1 = $res[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ Describe "Test Publish-PSResource" -tags 'CI' {

if ($usingAzAuth)
{
$RegistryUnauthenticated | Should -Not -BeNullOrEmpty
$RegistryUnauthenticated[0].Tags | Should -Be "PSRGContainerRegistryUnauthenticatedCheck"
$RegistryUnauthenticated[0].MessageData | Should -Be "Value of isRepositoryUnauthenticated: False"
$RegistryUnauthenticated | Should -BeNullOrEmpty
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {

It "Save module, should search through all repositories and only install from the first repo containing the package" {
Save-PSResource -Name $moduleName3 -Version "0.0.93" -Path $SaveDir -TrustRepository -ErrorVariable ev -ErrorAction SilentlyContinue
$ev | Should -HaveCount 1 ## This comes from MAR not having the module so the error is thrown from that repository before falling back to the next repository
$ev | Should -HaveCount 0
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq "$moduleName3"
$pkgDir | Should -Not -BeNullOrEmpty
}
Expand Down
Loading