Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
py3: Fix authenticate api test
  • Loading branch information
mvdbeek committed Aug 2, 2018
1 parent a88ce7c commit dc9e5c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/galaxy/webapps/galaxy/api/authenticate.py
Expand Up @@ -17,6 +17,10 @@

from galaxy import exceptions
from galaxy.managers import api_keys
from galaxy.util import (
smart_str,
unicodify
)
from galaxy.web import _future_expose_api_anonymous_and_sessionless as expose_api_anonymous_and_sessionless
from galaxy.web.base.controller import BaseAPIController

Expand Down Expand Up @@ -81,17 +85,17 @@ def _decode_baseauth(self, encoded_str):
# directly.
if len(split) == 1:
try:
email, password = b64decode(split[0]).split(':')
except Exception:
raise exceptions.ActionInputError()
email, password = unicodify(b64decode(smart_str(split[0]))).split(':')
except Exception as e:
raise exceptions.ActionInputError(str(e))

# If there are only two elements, check the first and ensure it says
# 'basic' so that we know we're about to decode the right thing. If not,
# bail out.
elif len(split) == 2:
if split[0].strip().lower() == 'basic':
try:
email, password = b64decode(split[1]).split(':')
email, password = unicodify(b64decode(smart_str(split[1]))).split(':')
except Exception:
raise exceptions.ActionInputError()
else:
Expand Down
2 changes: 1 addition & 1 deletion test/api/test_authenticate.py
Expand Up @@ -14,7 +14,7 @@ def test_auth(self):
self._setup_user(TEST_USER_EMAIL, TEST_USER_PASSWORD)
baseauth_url = self._api_url("authenticate/baseauth", use_key=False)
unencoded_credentials = "%s:%s" % (TEST_USER_EMAIL, TEST_USER_PASSWORD)
authorization = base64.b64encode(unencoded_credentials)
authorization = base64.b64encode(bytearray(unencoded_credentials, encoding="utf-8"))
headers = {
"Authorization": authorization,
}
Expand Down

0 comments on commit dc9e5c5

Please sign in to comment.