Skip to content

Commit 91ba031

Browse files
author
anamnavi
committed
simply use azAuth indicator bool to check infoRecord
1 parent d285d73 commit 91ba031

File tree

3 files changed

+1
-22
lines changed

3 files changed

+1
-22
lines changed

src/code/ContainerRegistryServerAPICalls.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,6 @@ internal string GetContainerRegistryAccessToken(bool needCatalogAccess, bool isP
399399
else
400400
{
401401
bool isRepositoryUnauthenticated = isPushOperation ? false : IsContainerRegistryUnauthenticated(Repository.Uri.ToString(), needCatalogAccess, out errRecord, out accessToken);
402-
InternalHooks.SetTestHook("IsRegistryUnauthenticatedCheckRequired", true);
403-
InternalHooks.SetTestHook("IsRegistryUnauthenticated", isRepositoryUnauthenticated);
404402
_cmdletPassedIn.WriteInformation($"Value of isRepositoryUnauthenticated: {isRepositoryUnauthenticated}", new string[] { "PSRGContainerRegistryUnauthenticatedCheck" });
405403

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

src/code/InternalHooks.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ public class InternalHooks
1717

1818
internal static string MARPrefix;
1919

20-
internal static bool IsRegistryUnauthenticatedCheckRequired;
21-
22-
internal static bool IsRegistryUnauthenticated;
23-
2420
public static void SetTestHook(string property, object value)
2521
{
2622
var fieldInfo = typeof(InternalHooks).GetField(property, BindingFlags.Static | BindingFlags.NonPublic);
@@ -31,15 +27,5 @@ public static string GetUserString()
3127
{
3228
return Microsoft.PowerShell.PSResourceGet.Cmdlets.UserAgentInfo.UserAgentString();
3329
}
34-
35-
public static bool? GetRegistryAuthenticationStatus()
36-
{
37-
if (IsRegistryUnauthenticatedCheckRequired)
38-
{
39-
return IsRegistryUnauthenticated;
40-
}
41-
42-
return null;
43-
}
4430
}
4531
}

test/PublishPSResourceTests/PublishPSResourceContainerRegistryServer.Tests.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,11 @@ Describe "Test Publish-PSResource" -tags 'CI' {
357357
$results[0].Name | Should -Be $script:PublishModuleName
358358
$results[0].Version | Should -Be $version
359359

360-
$isRegistryUnauthenticatedCheckRequired = [Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::GetRegistryAuthenticationStatus()
361-
if ($isRegistryUnauthenticatedCheckRequired -ne $null)
360+
if ($usingAzAuth)
362361
{
363362
$infoRecord | Should -Not -BeNullOrEmpty
364363
$infoRecord[0].Tags | Should -Be "PSRGContainerRegistryUnauthenticatedCheck"
365364
$infoRecord[0].MessageData | Should -Be "Value of isRepositoryUnauthenticated: $isRegistryUnauthenticatedCheckRequired"
366-
367-
# Reset the test hook after use
368-
[Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("IsRegistryUnauthenticatedCheckRequired", $false)
369-
[Microsoft.PowerShell.PSResourceGet.UtilClasses.InternalHooks]::SetTestHook("IsRegistryUnauthenticated", $false)
370365
}
371366
}
372367

0 commit comments

Comments
 (0)