Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Apr 23, 2023
1 parent a2c27ff commit 0244e89
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pkg/provider/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,10 @@ func TestNewCloudFromJSON(t *testing.T) {
"vmType": "vmss",
"disableAvailabilitySetNodes": true
}`
os.Setenv("AZURE_FEDERATED_TOKEN_FILE", "--aad-federated-token-file--")
defer func() {
os.Unsetenv("AZURE_FEDERATED_TOKEN_FILE")
}()
validateConfig(t, config)
}

Expand Down Expand Up @@ -2277,14 +2281,9 @@ publicIPCacheTTLInSeconds: 100
plsCacheTTLInSeconds: 100
vmType: vmss
disableAvailabilitySetNodes: true
aadFederatedTokenFile: --aad-federated-token-file--
`
os.Setenv("AZURE_TENANT_ID", "123")
os.Setenv("AZURE_CLIENT_ID", "456")
os.Setenv("AZURE_FEDERATED_TOKEN_FILE", "789")
os.Setenv("AZURE_FEDERATED_TOKEN_FILE", "--aad-federated-token-file--")
defer func() {
os.Unsetenv("AZURE_TENANT_ID")
os.Unsetenv("AZURE_CLIENT_ID")
os.Unsetenv("AZURE_FEDERATED_TOKEN_FILE")
}()
validateConfig(t, config)
Expand All @@ -2293,13 +2292,13 @@ aadFederatedTokenFile: --aad-federated-token-file--
func validateConfig(t *testing.T, config string) { //nolint
azureCloud := getCloudFromConfig(t, config)

if azureCloud.TenantID != "123" {
if azureCloud.TenantID != "--tenant-id--" {
t.Errorf("got incorrect value for TenantID")
}
if azureCloud.SubscriptionID != "--subscription-id--" {
t.Errorf("got incorrect value for SubscriptionID")
}
if azureCloud.AADClientID != "456" {
if azureCloud.AADClientID != "--aad-client-id--" {
t.Errorf("got incorrect value for AADClientID")
}
if azureCloud.AADClientSecret != "--aad-client-secret--" {
Expand Down Expand Up @@ -2401,7 +2400,7 @@ func validateConfig(t *testing.T, config string) { //nolint
if !azureCloud.DisableAvailabilitySetNodes {
t.Errorf("got incorrect value for disableAvailabilitySetNodes")
}
if azureCloud.AADFederatedTokenFile != "789" {
if azureCloud.AADFederatedTokenFile != "--aad-federated-token-file--" {
t.Errorf("got incorrect value for AADFederatedTokenFile")
}
if !azureCloud.UseFederatedWorkloadIdentityExtension {
Expand Down

0 comments on commit 0244e89

Please sign in to comment.