| | |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; secure; HttpOnly' % val)) |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'secure; ' |
| | | 'HttpOnly' % val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=localhost; secure; HttpOnly' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=localhost; ' |
| | | 'secure; HttpOnly' |
| | | % val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=.localhost; secure; HttpOnly' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost; ' |
| | | 'secure; HttpOnly' |
| | | % val)) |
| | | |
| | | def test_remember_creds_different(self): |
| | |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/' % new_val)) |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/' % new_val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=localhost' |
| | | % new_val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=.localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost' |
| | | % new_val)) |
| | | |
| | | def test_remember_creds_different_strips_port(self): |
| | | plugin = self._makeOne('secret') |
| | | old_val = self._makeTicket(userid='userid') |
| | | environ = self._makeEnviron({'HTTP_COOKIE':'auth_tkt=%s' % old_val, |
| | | 'HTTP_HOST': 'localhost:8080', |
| | | }) |
| | | new_val = self._makeTicket(userid='other', userdata='userdata') |
| | | result = plugin.remember(environ, {'repoze.who.userid':'other', |
| | | 'userdata':'userdata'}) |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/' % new_val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=localhost' |
| | | % new_val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost' |
| | | % new_val)) |
| | | |
| | | def test_remember_creds_different_include_ip(self): |
| | |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/' % new_val)) |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/' % new_val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=localhost' |
| | | % new_val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=.localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost' |
| | | % new_val)) |
| | | |
| | | def test_remember_creds_different_bad_old_cookie(self): |
| | |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/' % new_val)) |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/' % new_val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=localhost' |
| | | % new_val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=.localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost' |
| | | % new_val)) |
| | | |
| | | def test_remember_creds_different_with_tokens(self): |
| | |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/' % new_val)) |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/' % new_val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; Domain=localhost' |
| | | % new_val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=.localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost' |
| | | % new_val)) |
| | | |
| | | def test_remember_creds_different_with_tuple_tokens(self): |
| | |
| | | self.assertEqual(len(result), 3) |
| | | self.assertEqual(result[0], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/' % new_val)) |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/' % new_val)) |
| | | self.assertEqual(result[1], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=localhost' |
| | | % new_val)) |
| | | self.assertEqual(result[2], |
| | | ('Set-Cookie', |
| | | 'auth_tkt="%s"; Path=/; Domain=.localhost' |
| | | 'auth_tkt="%s"; ' |
| | | 'Path=/; ' |
| | | 'Domain=.localhost' |
| | | % new_val)) |
| | | |
| | | 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): |
| | | plugin = self._makeOne('secret') |
| | |
| | | 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') |
| | |
| | | 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 |
| | |
| | | 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') |