Skip to content

Commit

Permalink
Merge pull request #424 from canonical/cli_authorization_messages
Browse files Browse the repository at this point in the history
Add better messages for 401 and 403 errors from job submissions
  • Loading branch information
val500 authored Dec 12, 2024
2 parents d0ac206 + 26453a3 commit b1b7323
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cli/testflinger_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,23 @@ def submit_job_data(self, data: dict, headers: dict = None):
"Received 404 error from server. Are you "
"sure this is a testflinger server?"
)
if exc.status == 401:
sys.exit(
"Received 401 error from server. You are "
"attempting to use a feature that requires "
"client authorisation without using client "
"credentials. See https://testflinger.readthedocs"
".io/en/latest/how-to/authentication/ for more details"
)
if exc.status == 403:
sys.exit(
"Received 403 error from server with reason "
f"{exc.msg}"
"The specified client credentials do "
"not have sufficient permissions for the resource(s) "
"you are trying to access."
)

# This shouldn't happen, so let's get more information
sys.exit(
"Unexpected error status from testflinger "
Expand Down

0 comments on commit b1b7323

Please sign in to comment.