Skip to content

Commit a8a2d71

Browse files
authored
Suppress MAR not-found noise and remove info-stream unauthenticated logging
1 parent 8a9640d commit a8a2d71

4 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/code/ContainerRegistryServerAPICalls.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ internal string GetContainerRegistryAccessToken(bool needCatalogAccess, bool isP
440440
{
441441
// A container registry repository is determined to be unauthenticated if it allows anonymous pull access. However, push operations always require authentication.
442442
bool isRepositoryUnauthenticated = isPushOperation ? false : IsContainerRegistryUnauthenticated(Repository.Uri.ToString(), needCatalogAccess, out errRecord, out accessToken);
443-
_cmdletPassedIn.WriteInformation($"Value of isRepositoryUnauthenticated: {isRepositoryUnauthenticated}", new string[] { "PSRGContainerRegistryUnauthenticatedCheck" });
443+
_cmdletPassedIn.WriteDebug($"Value of isRepositoryUnauthenticated: {isRepositoryUnauthenticated}");
444444

445445
_cmdletPassedIn.WriteDebug($"Is repository unauthenticated: {isRepositoryUnauthenticated}");
446446

@@ -1002,8 +1002,8 @@ internal JObject GetHttpResponseJObjectUsingDefaultHeaders(string url, HttpMetho
10021002
{
10031003
errRecord = new ErrorRecord(
10041004
exception: e,
1005-
"ResourceNotFound",
1006-
ErrorCategory.InvalidResult,
1005+
"PackageNotFound",
1006+
ErrorCategory.ObjectNotFound,
10071007
_cmdletPassedIn);
10081008
}
10091009
catch (UnauthorizedException e)

test/InstallPSResourceTests/InstallPSResourceRepositorySearching.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ Describe 'Test Install-PSResource for searching and looping through repositories
3636

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

4343
$res | Should -Not -BeNullOrEmpty
4444
$res.Repository | Should -Be $localRepoName
4545
}
4646

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

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

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

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

7878
$pkg1 = $res[0]

test/PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,7 @@ Describe "Test Publish-PSResource" -tags 'CI' {
359359

360360
if ($usingAzAuth)
361361
{
362-
$RegistryUnauthenticated | Should -Not -BeNullOrEmpty
363-
$RegistryUnauthenticated[0].Tags | Should -Be "PSRGContainerRegistryUnauthenticatedCheck"
364-
$RegistryUnauthenticated[0].MessageData | Should -Be "Value of isRepositoryUnauthenticated: False"
362+
$RegistryUnauthenticated | Should -BeNullOrEmpty
365363
}
366364
}
367365

test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
158158

159159
It "Save module, should search through all repositories and only install from the first repo containing the package" {
160160
Save-PSResource -Name $moduleName3 -Version "0.0.93" -Path $SaveDir -TrustRepository -ErrorVariable ev -ErrorAction SilentlyContinue
161-
$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
161+
$ev | Should -HaveCount 0
162162
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq "$moduleName3"
163163
$pkgDir | Should -Not -BeNullOrEmpty
164164
}

0 commit comments

Comments
 (0)