diff --git a/src/code/ContainerRegistryServerAPICalls.cs b/src/code/ContainerRegistryServerAPICalls.cs index b7af3b98d..a980eb6b3 100644 --- a/src/code/ContainerRegistryServerAPICalls.cs +++ b/src/code/ContainerRegistryServerAPICalls.cs @@ -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}"); _cmdletPassedIn.WriteDebug($"Is repository unauthenticated: {isRepositoryUnauthenticated}"); @@ -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) diff --git a/test/InstallPSResourceTests/InstallPSResourceRepositorySearching.Tests.ps1 b/test/InstallPSResourceTests/InstallPSResourceRepositorySearching.Tests.ps1 index 86b981a7c..4d6e2ae30 100644 --- a/test/InstallPSResourceTests/InstallPSResourceRepositorySearching.Tests.ps1 +++ b/test/InstallPSResourceTests/InstallPSResourceRepositorySearching.Tests.ps1 @@ -36,9 +36,9 @@ 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 @@ -46,9 +46,9 @@ Describe 'Test Install-PSResource for searching and looping through repositories It "install resources from hightest priority repository where it exists and not write errors for repositories where it does not exist (without -Repository specified)" { # 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 @@ -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] diff --git a/test/PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1 b/test/PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1 index abde6338e..0a5306e4b 100644 --- a/test/PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1 +++ b/test/PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1 @@ -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 } } diff --git a/test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 b/test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 index 3b22f8f9e..205458303 100644 --- a/test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 +++ b/test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 @@ -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 }