From 44c39e06ad01701774de389868ee49ae3b02e564 Mon Sep 17 00:00:00 2001 From: David Read Date: Wed, 21 Dec 2016 16:32:15 +0000 Subject: [PATCH] Fix unicode auth exception --- ckan/lib/base.py | 2 +- ckan/tests/lib/test_base.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ckan/lib/base.py b/ckan/lib/base.py index 2b6232cf10a..71551bb0173 100644 --- a/ckan/lib/base.py +++ b/ckan/lib/base.py @@ -366,7 +366,7 @@ def _get_user_for_apikey(self): if not apikey: return None self.log.debug("Received API Key: %s" % apikey) - apikey = unicode(apikey) + apikey = apikey.decode('utf8', 'ignore') query = model.Session.query(model.User) user = query.filter_by(apikey=apikey).first() return user diff --git a/ckan/tests/lib/test_base.py b/ckan/tests/lib/test_base.py index cea90eaed51..a070f4e26f4 100644 --- a/ckan/tests/lib/test_base.py +++ b/ckan/tests/lib/test_base.py @@ -3,6 +3,7 @@ from nose import tools as nose_tools import ckan.tests.helpers as helpers +import ckan.tests.factories as factories class TestRenderSnippet(helpers.FunctionalTestBase): @@ -20,6 +21,38 @@ def test_comment_absent_if_debug_false(self): assert '