• 
      

    Fix some validation issues and error display on Bitbucket.

    Review Request #6359 — Created Sept. 23, 2014 and submitted — Latest diff uploaded

    Information

    Review Board
    release-2.0.x
    a8bf629...

    Reviewers

    It was common for people to put invalid repository names or usernames
    into the Bitbucket repository config form. When this happened, we'd
    either end up storing bad account information, fail with a cryptic
    error, or crash.

    Some of the most common problems here have been fixed.

    We now check the the validity of the username and password prior to
    storage. We fetch the user session API, using the credentials provided
    by the user. The credential data is only stored if this succeeds.

    If any API request results in an HTTP 401, we raise an
    AuthorizationError. All other errors result in a HostingServiceError
    (previously, we'd raise an Exception, which wouldn't always be caught
    correctly). If the data from the server was a valid error payload, we
    now parse that and display the error message.

    Repositories are now validated properly as well. A repository name that
    looks like a path (has a '/') or contains '.git' will immediately result
    in an error instructing the user to provide just the name. If a name
    meets the criteria, but is not found, a suitable error will also be
    shown instead of a JSON payload.

    Tested each failure condition manually.

    Tested successful authentication and repository access.

    Unit tests pass.