Skip to content
Browse files

100% coverage under both 2.x and 3.2.

  • Loading branch information...
1 parent ff80e0c commit d6fa0a9d59421defd6e6c612b988d3892b3fbf29 @tseaver tseaver committed
Showing with 15 additions and 16 deletions.
  1. +6 −7 repoze/who/plugins/auth_tkt.py
  2. +9 −9 repoze/who/plugins/tests/test_authtkt.py
View
13 repoze/who/plugins/auth_tkt.py
@@ -11,6 +11,7 @@
from repoze.who._compat import get_cookies
import repoze.who._auth_tkt as auth_tkt
from repoze.who._compat import STRING_TYPES
+from repoze.who._compat import u
_NOW_TESTING = None # unit tests can replace
def _now(): #pragma NO COVERAGE
@@ -22,14 +23,12 @@ def _now(): #pragma NO COVERAGE
@implementer(IIdentifier, IAuthenticator)
class AuthTktCookiePlugin(object):
- userid_type_decoders = {'int':int}
- try:
- userid_type_decoders[unicode] = ('unicode',
- lambda x: utf_8_decode(x)[0])
- except NameError: #pragma NO COVER Python >= 3.0
- pass
+ userid_type_decoders = {'int': int,
+ 'unicode': lambda x: utf_8_decode(x)[0],
+ }
- userid_type_encoders = {int: ('int', str)}
+ userid_type_encoders = {int: ('int', str),
+ }
try:
userid_type_encoders[long] = ('int', str)
except NameError: #pragma NO COVER Python >= 3.0
View
18 repoze/who/plugins/tests/test_authtkt.py
@@ -384,8 +384,7 @@ def test_remember_creds_different_int_userid(self):
self.assertEqual(len(result), 3)
self.assertEqual(result[0],
('Set-Cookie',
- 'auth_tkt="%s"; '
- 'Path=/' % new_val))
+ 'auth_tkt="%s"; Path=/' % new_val))
def test_remember_creds_different_long_userid(self):
try:
@@ -401,24 +400,26 @@ def test_remember_creds_different_long_userid(self):
self.assertEqual(len(result), 3)
self.assertEqual(result[0],
('Set-Cookie',
- 'auth_tkt="%s"; '
- 'Path=/' % new_val))
+ 'auth_tkt="%s"; Path=/' % new_val))
def test_remember_creds_different_unicode_userid(self):
plugin = self._makeOne('secret')
old_val = self._makeTicket(userid='userid')
environ = self._makeEnviron({'HTTP_COOKIE':'auth_tkt=%s' % old_val})
userid = b'\xc2\xa9'.decode('utf-8')
+ if type(b'') == type(''):
+ userdata = 'userid_type:unicode'
+ else: # XXX
+ userdata = ''
new_val = self._makeTicket(userid=userid.encode('utf-8'),
- userdata='userid_type:unicode')
+ userdata=userdata)
result = plugin.remember(environ, {'repoze.who.userid':userid,
'userdata':''})
self.assertEqual(type(result[0][1]), str)
self.assertEqual(len(result), 3)
self.assertEqual(result[0],
('Set-Cookie',
- 'auth_tkt="%s"; '
- 'Path=/' % new_val))
+ 'auth_tkt="%s"; Path=/' % new_val))
def test_remember_creds_reissue(self):
import time
@@ -433,8 +434,7 @@ def test_remember_creds_reissue(self):
self.assertEqual(len(result), 3)
self.assertEqual(result[0],
('Set-Cookie',
- 'auth_tkt="%s"; '
- 'Path=/' % new_val))
+ 'auth_tkt="%s"; Path=/' % new_val))
def test_remember_max_age(self):
plugin = self._makeOne('secret')

0 comments on commit d6fa0a9

Please sign in to comment.
Something went wrong with that request. Please try again.