diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-06-25 07:07:55 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-06-25 07:07:55 +0000 |
| commit | 3bef31e78563997ecaec0bf6bf1715ce66f5605b (patch) | |
| tree | d06c219460f741aea3abf4faa798a0c025df6057 /repoze/bfg/tests/test_authentication.py | |
| parent | 27d23ae34362f20ff1504bc80b941b18d472b9e3 (diff) | |
| download | pyramid-3bef31e78563997ecaec0bf6bf1715ce66f5605b.tar.gz pyramid-3bef31e78563997ecaec0bf6bf1715ce66f5605b.tar.bz2 pyramid-3bef31e78563997ecaec0bf6bf1715ce66f5605b.zip | |
- Add optional ``max_age`` keyword value to the ``remember`` method of
``repoze.bfg.authentication.AuthTktAuthenticationPolicy``; if this
value is passed to ``remember``, the generated cookie will have a
corresponding Max-Age value.
Diffstat (limited to 'repoze/bfg/tests/test_authentication.py')
| -rw-r--r-- | repoze/bfg/tests/test_authentication.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_authentication.py b/repoze/bfg/tests/test_authentication.py index 2032f53c3..12ecb6b16 100644 --- a/repoze/bfg/tests/test_authentication.py +++ b/repoze/bfg/tests/test_authentication.py @@ -248,6 +248,13 @@ class TestAutkTktAuthenticationPolicy(unittest.TestCase): policy = self._makeOne(None, None) result = policy.remember(request, 'fred') self.assertEqual(result, []) + + def test_remember_with_extra_kargs(self): + request = DummyRequest({}) + policy = self._makeOne(None, None) + result = policy.remember(request, 'fred', a=1, b=2) + self.assertEqual(policy.cookie.kw, {'a':1, 'b':2}) + self.assertEqual(result, []) def test_forget(self): request = DummyRequest({}) @@ -491,6 +498,36 @@ class TestAuthTktCookieHelper(unittest.TestCase): ('Set-Cookie', 'auth_tkt="%s"; Path=/' % new_val)) + def test_remember_max_age(self): + plugin = self._makeOne('secret') + environ = {'HTTP_HOST':'example.com'} + tkt = self._makeTicket(userid='chris', userdata='') + request = self._makeRequest(environ) + result = plugin.remember(request, 'chris', max_age='500') + + name,value = result.pop(0) + self.assertEqual('Set-Cookie', name) + self.failUnless( + value.startswith('auth_tkt="%s"; Path=/; Max-Age=500' % tkt), + value) + self.failUnless('; Expires=' in value) + + name,value = result.pop(0) + self.assertEqual('Set-Cookie', name) + self.failUnless( + value.startswith( + 'auth_tkt="%s"; Path=/; Domain=example.com; Max-Age=500' + % tkt), value) + self.failUnless('; Expires=' in value) + + name,value = result.pop(0) + self.assertEqual('Set-Cookie', name) + self.failUnless( + value.startswith( + 'auth_tkt="%s"; Path=/; Domain=.example.com; Max-Age=500' % tkt), + value) + self.failUnless('; Expires=' in value) + def test_forget(self): plugin = self._makeOne('secret') request = self._makeRequest() @@ -546,6 +583,7 @@ class DummyCookieHelper: return self.result def remember(self, *arg, **kw): + self.kw = kw return [] def forget(self, *arg): |
