Fix some validation issues and error display on Bitbucket.
Review Request #6359 — Created Sept. 23, 2014 and submitted
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.
Description | From | Last Updated |
---|---|---|
local variable 'data' is assigned to but never used |
reviewbot | |
local variable 'e' is assigned to but never used |
reviewbot | |
'HostingServiceError' imported but unused |
reviewbot | |
undefined name 'HostingServiceError' |
reviewbot | |
undefined name 'HostingServiceError' |
reviewbot | |
'HostingServiceError' imported but unused |
reviewbot | |
Should these be using gettext or ugettext? |
david | |
This should be six.text_type(message) or ... |
david |
- Change Summary:
-
Fixed unused variables and imports.
- Commit:
-
35a6593ae926e2ae908068a1cd721804fc9d2f97690dadd21b9e6b2a12c561aacdba1d93bd13ad7d
-
Tool: Pyflakes Processed Files: reviewboard/hostingsvcs/tests.py reviewboard/hostingsvcs/bitbucket.py Tool: PEP8 Style Checker Processed Files: reviewboard/hostingsvcs/tests.py reviewboard/hostingsvcs/bitbucket.py
-
-
-
- Change Summary:
-
Previously removed the import from the wrong file. Fixed.
- Commit:
-
690dadd21b9e6b2a12c561aacdba1d93bd13ad7d986ff66be44ce8898254989ccad496cb66252a5a
-
Tool: Pyflakes Processed Files: reviewboard/hostingsvcs/tests.py reviewboard/hostingsvcs/bitbucket.py Tool: PEP8 Style Checker Processed Files: reviewboard/hostingsvcs/tests.py reviewboard/hostingsvcs/bitbucket.py
- Change Summary:
-
Switched to ugettext.
- Commit:
-
986ff66be44ce8898254989ccad496cb66252a5ae562db0d2873706ab8abd94a300239981bd489f2
-
Tool: Pyflakes Processed Files: reviewboard/hostingsvcs/tests.py reviewboard/hostingsvcs/bitbucket.py Tool: PEP8 Style Checker Processed Files: reviewboard/hostingsvcs/tests.py reviewboard/hostingsvcs/bitbucket.py
- Change Summary:
-
Fixed conversion of
message
tosix.text_type
. - Commit:
-
e562db0d2873706ab8abd94a300239981bd489f2a8bf629b022ae80a53cf46d8adac7eecf60eb4b6