pulp/pulp — pull request #454 by jdob (2013-04-23 17:37:45+00:00)
Title: 916729 - More detailed error messages for auth failures

https://bugzilla.redhat.com/show_bug.cgi?id=916729

The first step was for the server to provide more information than simply 401. In doing so, I found the response bodies in these cases weren't JSON, so I had to fix that first. The auth_utils file in pulp.common has constants for the error codes describing the auth failure reasons and some utility methods for generating/reading the JSON response body. That was tied into the decorator code to replace the plain strings.

Once that was in place, the client-side exception handling was updated to key off of the error code to produce more detailed error messages.

Examples:
```
# The currently logged in user can't delete (use case from the BZ)
$ pulp-admin rpm repo delete --repo-id jdob-repo
Insufficient Permissions

The user does not have the appropriate permissions to execute this command.

# No user named jdobx
$ pulp-admin login -u jdobx -p jdob
Invalid Username or Password

# Not even logged in
$ pulp-admin rpm repo list
Authentication Failed

Use the login command to authenticate with the server and download a session
certificate for use in future calls to this script. If credentials were
specified, please double check the username and password and attempt the request
again.
```