Fix bug in repoze.who.api where the remember() or forget() methods could
return a None if the identifier plugin returned a None. According to the
interfaces in repoze.who.interfaces the API methods cannot return None while
the plugin methods can.
I'm not entirely sure this fix is right. I'm assuming that the interface
documentation is more correct than the code in this case.
| | |
| | | After 2.0a3 (unreleased) |
| | | ------------------------ |
| | | |
| | | - Fix bug in repoze.who.api where the remember() or forget() methods could |
| | | return a None if the identifier plugin returned a None. According to the |
| | | interfaces in repoze.who.interfaces the API methods cannot return None while |
| | | the plugin methods can. |
| | | |
| | | - Fix auth_tkt plugin to not hand over tokens as strings to paste. See |
| | | http://lists.repoze.org/pipermail/repoze-dev/2010-November/003680.html |
| | | |
| | |
| | | identity = self.environ.get('repoze.who.identity', {}) |
| | | identifier = identity.get('identifier') |
| | | if identifier: |
| | | headers = identifier.remember(self.environ, identity) |
| | | if headers: |
| | | got_headers = identifier.remember(self.environ, identity) |
| | | if got_headers: |
| | | headers = got_headers |
| | | logger = self.logger |
| | | logger and logger.info('remembering via headers from %s: %s' |
| | | % (identifier, headers)) |
| | |
| | | identity = self.environ.get('repoze.who.identity', {}) |
| | | identifier = identity.get('identifier') |
| | | if identifier: |
| | | headers = identifier.forget(self.environ, identity) |
| | | if headers: |
| | | got_headers = identifier.forget(self.environ, identity) |
| | | if got_headers: |
| | | headers = got_headers |
| | | logger = self.logger |
| | | logger and logger.info('forgetting via headers from %s: %s' |
| | | % (identifier, headers)) |
| | |
| | | self.assertEqual(identity['repoze.who.userid'], 'chrisid') |
| | | self.assertEqual(headers, REMEMBER_HEADERS) |
| | | |
| | | def test_identifier_plugin_returns_none(self): |
| | | class _Identifier: |
| | | def identify(self, environ): |
| | | return None |
| | | def remember(self, environ, identity): |
| | | return None |
| | | def forget(self, environ, identity): |
| | | return None |
| | | identity = {'identifier': _Identifier()} |
| | | api = self._makeOne() |
| | | headers = api.remember(identity=identity) |
| | | self.assertEqual(tuple(headers), ()) |
| | | headers = api.forget(identity=identity) |
| | | self.assertEqual(tuple(headers), ()) |
| | | |
| | | def test_login_wo_identifier_name_hit(self): |
| | | REMEMBER_HEADERS = [('Foo', 'Bar'), ('Baz', 'Qux')] |
| | | FORGET_HEADERS = [('Spam', 'Blah')] |