Merge pull request #1254 from rbu/repozewho1-remember-kwargs
Hand RepozeWho1AuthenticationPolicy.remember kwargs to repoze.who (master) #1249
| | |
| | | return effective_principals |
| | | |
| | | def remember(self, request, principal, **kw): |
| | | """ Store the ``principal`` as ``repoze.who.userid``.""" |
| | | """ Store the ``principal`` as ``repoze.who.userid``. |
| | | |
| | | The identity to authenticated to :mod:`repoze.who` |
| | | will contain the given principal as ``userid``, and |
| | | provide all keyword arguments as additional identity |
| | | keys. Useful keys could be ``max_age`` or ``userdata``. |
| | | """ |
| | | identifier = self._get_identifier(request) |
| | | if identifier is None: |
| | | return [] |
| | | environ = request.environ |
| | | identity = {'repoze.who.userid':principal} |
| | | identity = kw |
| | | identity['repoze.who.userid'] = principal |
| | | return identifier.remember(environ, identity) |
| | | |
| | | def forget(self, request): |
| | |
| | | self.assertEqual(result[0], request.environ) |
| | | self.assertEqual(result[1], {'repoze.who.userid':'fred'}) |
| | | |
| | | def test_remember_kwargs(self): |
| | | authtkt = DummyWhoPlugin() |
| | | request = DummyRequest( |
| | | {'repoze.who.plugins':{'auth_tkt':authtkt}}) |
| | | policy = self._makeOne() |
| | | result = policy.remember(request, 'fred', max_age=23) |
| | | self.assertEqual(result[1], {'repoze.who.userid':'fred', 'max_age': 23}) |
| | | |
| | | def test_forget_no_plugins(self): |
| | | request = DummyRequest({}) |
| | | policy = self._makeOne() |