(fix) added more context to error details for cli command (#2170)
* (test) added more context to error details for cli commands * (fix) refactor solution to utilize custom error type casting * (test) added api unit test to validate InvalidArgumentError return message * Update internal/types/subtypes/error.go Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> * (refactor) rename InvalidArgumentError into UnknownSubtypeIDError Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
This commit is contained in:
1 parent
1da2cf06b0
commit
3441fa0447
5 files changed
+55
-4
No files matched your search
@@ -362,4 +362,20 @@ func TestErrors(t *testing.T) {
|
||||
apiErr = api.AsServerError(err)
|
||||
require.NotNil(apiErr)
|
||||
assert.EqualValues(http.StatusBadRequest, apiErr.Response().StatusCode())
|
||||
|
||||
// Passing in a invalid authentication method sub-type should return an error
|
||||
_, err = amClient.Authenticate(tc.Context(), "ampwd_1234567890", "login", map[string]interface{}{
|
||||
"login_name": "admin",
|
||||
"password": "password",
|
||||
})
|
||||
require.Error(err)
|
||||
apiErr = api.AsServerError(err)
|
||||
require.NotNil(apiErr)
|
||||
assert.Len(apiErr.Details.RequestFields, 1)
|
||||
assert.EqualValues(apiErr.Details.RequestFields, []*api.FieldError{
|
||||
{
|
||||
Name: "attributes",
|
||||
Description: "unknown subtype in ID: ampwd_1234567890",
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user