Skip to content

Commit

Permalink
Updated error message and added one more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
pepedocs committed Feb 14, 2025
1 parent 101b018 commit a8f0bfd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/util/steps/refreshing.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func CreateActionableError(err error) error {
)
case azureerrors.IsClientSecretKeysExpired(err):
return newServicePrincipalCloudError(make_one_line_str(
"The provided application client and secret keys are expired.",
"Please create new keys for your application."),
"The provided client secret is expired.",
"Please create a new one for your service principal."),
http.StatusBadRequest,
)
default:
Expand Down
11 changes: 9 additions & 2 deletions pkg/util/steps/refreshing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type expectCloudErrorFields struct {
message string
}

func TestToActionableError(t *testing.T) {
func TestCreateActionableError(t *testing.T) {
for _, tt := range []struct {
testName string
rawErr error
Expand All @@ -32,6 +32,11 @@ func TestToActionableError(t *testing.T) {
nil,
nil,
},
{
"Should return the error if it is not convertible to user actionable one",
errors.New("unknown or unhandled error"),
nil,
},
{
"Should return a CloudError when original error is AADSTS700016",
errors.New("AADSTS700016"),
Expand Down Expand Up @@ -68,7 +73,7 @@ func TestToActionableError(t *testing.T) {
http.StatusBadRequest,
api.CloudErrorCodeInvalidServicePrincipalCredentials,
"properties.servicePrincipalProfile",
"The provided application client and secret keys are expired. Please create new keys for your application.",
"The provided client secret is expired. Please create a new one for your service principal.",
},
},
} {
Expand All @@ -84,6 +89,8 @@ func TestToActionableError(t *testing.T) {
assert.Equal(t, tt.expectCloudError.target, cloudErr.Target)
assert.Equal(t, tt.expectCloudError.message, cloudErr.Message)
}
} else {
assert.Equal(t, err, tt.rawErr)
}
})
}
Expand Down

0 comments on commit a8f0bfd

Please sign in to comment.