MF-1678 - Fetching users returns an invalid status code response (#1679)
* fix: get /users authorize err code Signed-off-by: Arvindh <arvindh91@gmail.com> * add: test case for forbidden request in GET /users Signed-off-by: Arvindh <arvindh91@gmail.com> * update: api docs of GET /users Signed-off-by: Arvindh <arvindh91@gmail.com> * add: test case for forbidden request in GET /users Signed-off-by: Arvindh <arvindh91@gmail.com> Signed-off-by: Arvindh <arvindh91@gmail.com>
This commit is contained in:
parent
933b5dedce
commit
47fd646030
|
@ -48,9 +48,9 @@ paths:
|
||||||
'400':
|
'400':
|
||||||
description: Failed due to malformed query parameters.
|
description: Failed due to malformed query parameters.
|
||||||
'401':
|
'401':
|
||||||
description: |
|
description: Missing or invalid access token provided.
|
||||||
Missing or invalid access token provided.
|
'403':
|
||||||
This endpoint is available only for administrators.
|
description: This endpoint is available only for administrators.
|
||||||
'404':
|
'404':
|
||||||
description: A non-existent entity request.
|
description: A non-existent entity request.
|
||||||
'422':
|
'422':
|
||||||
|
|
|
@ -252,7 +252,7 @@ func (svc usersService) ListUsers(ctx context.Context, token string, pm PageMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := svc.authorize(ctx, id.id, "authorities", "member"); err != nil {
|
if err := svc.authorize(ctx, id.id, "authorities", "member"); err != nil {
|
||||||
return UserPage{}, errors.Wrap(errors.ErrAuthentication, err)
|
return UserPage{}, err
|
||||||
}
|
}
|
||||||
return svc.users.RetrieveAll(ctx, pm.Status, pm.Offset, pm.Limit, nil, pm.Email, pm.Metadata)
|
return svc.users.RetrieveAll(ctx, pm.Status, pm.Offset, pm.Limit, nil, pm.Email, pm.Metadata)
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,11 @@ func TestListUsers(t *testing.T) {
|
||||||
size: 0,
|
size: 0,
|
||||||
err: nil,
|
err: nil,
|
||||||
},
|
},
|
||||||
|
"list users with unauthorized token": {
|
||||||
|
token: unauthzToken,
|
||||||
|
size: 0,
|
||||||
|
err: errors.ErrAuthorization,
|
||||||
|
},
|
||||||
"list user with emtpy token": {
|
"list user with emtpy token": {
|
||||||
token: "",
|
token: "",
|
||||||
size: 0,
|
size: 0,
|
||||||
|
@ -257,6 +262,11 @@ func TestListUsers(t *testing.T) {
|
||||||
limit: nUsers,
|
limit: nUsers,
|
||||||
size: nUsers - 6,
|
size: nUsers - 6,
|
||||||
},
|
},
|
||||||
|
"list using non-existent user": {
|
||||||
|
token: token,
|
||||||
|
email: nonExistingUser.Email,
|
||||||
|
err: errors.ErrNotFound,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for desc, tc := range cases {
|
for desc, tc := range cases {
|
||||||
|
|
Loading…
Reference in New Issue