Skip to content

Commit

Permalink
change the test order
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuker committed Jan 11, 2024
1 parent 7abfaaa commit 73d576d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions internal/keystore/azure/key-vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,9 @@ func ConnectWithCredentials(_ context.Context, endpoint string, creds Credential
// instance using an Azure managed identity.
func ConnectWithIdentity(_ context.Context, endpoint string, msi ManagedIdentity) (*Store, error) {
if os.Getenv("AZURE_CLIENT_API_VERSION") != "7.2" {
os.Setenv("AZURE_CLIENT_ID", msi.ClientID)
cred, err := azidentity.NewDefaultAzureCredential(nil)
cred, err := azidentity.NewManagedIdentityCredential(&azidentity.ManagedIdentityCredentialOptions{
ID: azidentity.ClientID(msi.ClientID),
})
if err != nil {
return nil, fmt.Errorf("azure: failed to create default Azure credential: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/keystore/azure/key-vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func TestConnectWithCredentials(t *testing.T) {
TenantID := os.Getenv("TenantID")
Secret := os.Getenv("Secret")
EndPoint := os.Getenv("EndPoint")
ManagedIdentityClientID := os.Getenv("ManagedIdentityClientID")
if ClientID == "" || TenantID == "" || Secret == "" || EndPoint == "" {
t.Skip("Skipping test due to missing credentials")
}
Expand All @@ -21,11 +22,11 @@ func TestConnectWithCredentials(t *testing.T) {
return
}
os.Setenv("AZURE_CLIENT_API_VERSION", "7.4")
c3, err := ConnectWithIdentity(ctx, EndPoint, ManagedIdentity{ClientID: ClientID})
c2, err := ConnectWithIdentity(ctx, EndPoint, ManagedIdentity{ClientID: ManagedIdentityClientID})
if err != nil {
return
}
c2, err := ConnectWithCredentials(ctx, EndPoint, Credentials{TenantID: TenantID, ClientID: ClientID, Secret: Secret})
c3, err := ConnectWithCredentials(ctx, EndPoint, Credentials{TenantID: TenantID, ClientID: ClientID, Secret: Secret})
if err != nil {
return
}
Expand Down

0 comments on commit 73d576d

Please sign in to comment.