summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-10-11 07:42:51 -0400
committerChris McDonough <chrism@plope.com>2011-10-11 07:42:51 -0400
commitbc4d359ea25ddc5ec8b0b82144115fb704c81669 (patch)
tree79e9b28c419f385b312e3858514d43e9ca381804
parentc5724cb393b3de6facfe8a587a53a4dafeeb74c6 (diff)
parentaeb144cf296c2e682cc78ff7afa4fc52baf3ca99 (diff)
downloadpyramid-bc4d359ea25ddc5ec8b0b82144115fb704c81669.tar.gz
pyramid-bc4d359ea25ddc5ec8b0b82144115fb704c81669.tar.bz2
pyramid-bc4d359ea25ddc5ec8b0b82144115fb704c81669.zip
Merge branch 'jinty-master'
-rw-r--r--pyramid/authentication.py5
-rw-r--r--pyramid/tests/test_authentication.py6
2 files changed, 8 insertions, 3 deletions
diff --git a/pyramid/authentication.py b/pyramid/authentication.py
index 245a9692f..d17117055 100644
--- a/pyramid/authentication.py
+++ b/pyramid/authentication.py
@@ -726,7 +726,8 @@ class AuthTktCookieHelper(object):
encoding, encoder = encoding_data
userid = encoder(userid)
user_data = 'userid_type:%s' % encoding
-
+
+ new_tokens = []
for token in tokens:
if isinstance(token, text_type):
try:
@@ -735,6 +736,8 @@ class AuthTktCookieHelper(object):
raise ValueError("Invalid token %r" % (token,))
if not (isinstance(token, str) and VALID_TOKEN.match(token)):
raise ValueError("Invalid token %r" % (token,))
+ new_tokens.append(token)
+ tokens = tuple(new_tokens)
if hasattr(request, '_authtkt_reissued'):
request._authtkt_reissue_revoked = True
diff --git a/pyramid/tests/test_authentication.py b/pyramid/tests/test_authentication.py
index 6bf14e76c..c7ae407ce 100644
--- a/pyramid/tests/test_authentication.py
+++ b/pyramid/tests/test_authentication.py
@@ -703,7 +703,7 @@ class TestAuthTktCookieHelper(unittest.TestCase):
request.callbacks[0](None, response)
self.assertEqual(len(response.headerlist), 3)
self.assertEqual(response.headerlist[0][0], 'Set-Cookie')
- self.assertTrue("'tokens': []" in response.headerlist[0][1])
+ self.assertTrue("'tokens': ()" in response.headerlist[0][1])
def test_remember(self):
helper = self._makeOne('secret')
@@ -912,7 +912,9 @@ class TestAuthTktCookieHelper(unittest.TestCase):
helper = self._makeOne('secret')
request = self._makeRequest()
la = text_(b'foo', 'utf-8')
- helper.remember(request, 'other', tokens=(la,))
+ result = helper.remember(request, 'other', tokens=(la,))
+ # tokens must be str type on both Python 2 and 3
+ self.assertTrue("'tokens': ('foo',)" in result[0][1])
def test_remember_nonascii_token(self):
helper = self._makeOne('secret')