Skip to content

Commit

Permalink
Include username in unauthorized message response
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Jan 26, 2023
1 parent 51a76da commit 75ca274
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion resultsdb/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ def verify_authorization(user, testcase, permissions, ldap_host, ldap_searches):
if not any_groups_found:
raise Unauthorized(f"Failed to find user {user} in LDAP")

raise Unauthorized(f"You are not authorized to submit a result for the test case {testcase}")
raise Unauthorized(
f"User {user} is not authorized to submit a result for the test case {testcase}"
)
4 changes: 3 additions & 1 deletion testing/test_api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ def test_api_v3_permission_denied(client, permissions):
data = brew_build_request_data()
r = client.post("/api/v3/results/brew-builds", json=data)
assert r.status_code == 401, r.text
assert "You are not authorized to submit a result for the test case testcase1" in r.text
assert (
"User testuser1 is not authorized to submit a result for the test case testcase1" in r.text
)


def test_api_v3_permission_matches_username(client, permissions):
Expand Down

0 comments on commit 75ca274

Please sign in to comment.