From aa6be1a7b2674b423334d88c8ad75185e978d5f1 Mon Sep 17 00:00:00 2001 From: Shahram Kalantari Date: Thu, 3 Oct 2024 14:37:22 +1000 Subject: [PATCH] fix: fix the bugs in the unit tests --- pkg/common/oras/authprovider/azure/azureidentity_test.go | 5 +++++ .../oras/authprovider/azure/azureworkloadidentity_test.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pkg/common/oras/authprovider/azure/azureidentity_test.go b/pkg/common/oras/authprovider/azure/azureidentity_test.go index af33afe44f..11fb48f5f7 100644 --- a/pkg/common/oras/authprovider/azure/azureidentity_test.go +++ b/pkg/common/oras/authprovider/azure/azureidentity_test.go @@ -191,6 +191,11 @@ func TestMIProvide_RefreshAAD(t *testing.T) { func TestMIProvide_Failure_InvalidHostName(t *testing.T) { provider := &MIAuthProvider{ + tenantID: "test_tenant", + clientID: "test_client", + identityToken: azcore.AccessToken{ + Token: "test_token", + }, getRegistryHost: func(_ string) (string, error) { return "", errors.New("invalid hostname") }, diff --git a/pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go b/pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go index bbfd29eb93..1b58e18fe9 100644 --- a/pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go +++ b/pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go @@ -247,6 +247,11 @@ func TestWIProvide_RefreshAAD(t *testing.T) { func TestWIProvide_Failure_InvalidHostName(t *testing.T) { provider := &WIAuthProvider{ + aadToken: confidential.AuthResult{ + AccessToken: "mockToken", + ExpiresOn: time.Now(), + }, + tenantID: "mockTenantID", getRegistryHost: func(_ string) (string, error) { return "", errors.New("invalid hostname") },