diff options
| -rw-r--r-- | src/pyramid/security.py | 2 | ||||
| -rw-r--r-- | tests/test_security.py | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/pyramid/security.py b/src/pyramid/security.py index e28ce0f1c..a55320ce6 100644 --- a/src/pyramid/security.py +++ b/src/pyramid/security.py @@ -355,7 +355,7 @@ class AuthenticationAPIMixin(object): if authn is not None: return authn.authenticated_userid(self) elif security is not None: - return security.identify(self) + return str(security.identify(self)) else: return None diff --git a/tests/test_security.py b/tests/test_security.py index b66632baa..97aec42c6 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -357,8 +357,9 @@ class TestAuthenticatedUserId(unittest.TestCase): def test_with_security_policy(self): request = _makeRequest() - _registerSecurityPolicy(request.registry, 'yo') - self.assertEqual(request.authenticated_userid, 'yo') + # Ensure the identity is stringified. + _registerSecurityPolicy(request.registry, 123) + self.assertEqual(request.authenticated_userid, '123') def test_with_authentication_policy_no_reg_on_request(self): from pyramid.threadlocal import get_current_registry |
