Project

Profile

Help

Issue #1313

closed

Issue #692: 400 should be returned if any of the parameters are invalid in permissions

Wrong error message after granting/revoking permission of unexisting user/role permission

Added by placko over 8 years ago. Updated almost 4 years ago.

Status:
CLOSED - DUPLICATE
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
2.7.0 Beta
Platform Release:
2.7.0
OS:
RHEL 7
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Documentation, Easy Fix, Pulp 2
Sprint:
Quarter:

Description

After granting permission to nonexistent user wrong error message and code are returned from server:

$ curl -X POST -d '{"operations": ["EXECUTE"], "login": "UnexistantLogin", "resource": "/"}'
headers={'content-type': 'application/json'} https://server/pulp/api/v2/permissions/actions/grant_to_user/
--cacert myca.crt -u admin:admin

{"http_request_method": "POST", "exception": null, "error_message": "Invalid properties: ['login']",
"property_names": ["login"], "_href": "/pulp/api/v2/permissions/actions/grant_to_user/", "http_status": 400,
"error": {"code": "PLP0015", "data": {"property_names": ["login"], "properties": "['login']"},
"description": "Invalid properties: ['login']", "sub_errors": []}, "traceback": null}

while expected response is

{"http_request_method": "POST", "exception": null, "error_message": "Missing resource(s): user=UnexistantLogin", 
"_href": "/pulp/api/v2/permissions/actions/grant_to_user/", "http_status": 404, "error": {"code": "PLP0009",
"data": {"resources": {"user": "UnexistantLogin"}}, "description": "Missing resource(s): user=UnexistantLogin", "sub_errors": []},
"traceback": null, "resources": {"user": "UnexistantLogin"}}

Similarly for revoking nonexistent user permission:

$ curl -X POST -d '{"operations": ["EXECUTE"], "login": "UnexistantLogin", "resource": "/"}'
headers={'content-type': 'application/json'} https://server/pulp/api/v2/permissions/actions/revoke_from_user/
--cacert myca.crt -u admin:admin

{"http_request_method": "POST", "exception": null, "error_message": "Invalid properties: ['login']",
"property_names": ["login"], "_href": "/pulp/api/v2/permissions/actions/revoke_from_user/", "http_status": 400,
"error": {"code": "PLP0015", "data": {"property_names": ["login"], "properties": "['login']"},
"description": "Invalid properties: ['login']", "sub_errors": []}, "traceback": null}

granting permissions to nonexistent role:

$ curl -X POST -d '{"operations": ["EXECUTE"], "role_id": "UnexistantRole", "resource": "/"}'
headers={'content-type': 'application/json'} https://server/pulp/api/v2/permissions/actions/grant_to_role/
--cacert myca.crt -u admin:admin

{"http_request_method": "POST", "exception": null, "error_message": "Invalid properties: ['role_id']",
"property_names": ["role_id"], "_href": "/pulp/api/v2/permissions/actions/grant_to_role/", "http_status": 400,
"error": {"code": "PLP0015", "data": {"property_names": ["role_id"], "properties": "['role_id']"},
"description": "Invalid properties: ['role_id']", "sub_errors": []}, "traceback": null}

and revoking permissions from nonexistent role:

$ curl -X POST -d '{"operations": ["EXECUTE"] "role_id": "UnexistantRole", "resource": "/"}'
headers={'content-type': 'application/json'} https://server/pulp/api/v2/permissions/actions/revoke_from_role/
--cacert myca.crt -u admin:admin

{"http_request_method": "POST", "exception": null, "error_message": "Invalid properties: ['role_id']",
"property_names": ["role_id"], "_href": "/pulp/api/v2/permissions/actions/revoke_from_role/", "http_status": 400,
"error": {"code": "PLP0015", "data": {"property_names": ["role_id"], "properties": "['role_id']"},
"description": "Invalid properties: ['role_id']", "sub_errors": []}, "traceback": null}

Also available in: Atom PDF