[Zope-CVS] CVS: Products/PluggableAuthService/tests -
test_PluggableAuthService.py:1.12.2.5
Zachery Bir
zbir at urbanape.com
Thu Oct 14 12:07:49 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService/tests
In directory cvs.zope.org:/tmp/cvs-serv20774
Modified Files:
Tag: pre-1_0_3-zbir-challenge-branch
test_PluggableAuthService.py
Log Message:
Test that challenge() is only called once per request/response
=== Products/PluggableAuthService/tests/test_PluggableAuthService.py 1.12.2.4 => 1.12.2.5 ===
--- Products/PluggableAuthService/tests/test_PluggableAuthService.py:1.12.2.4 Fri Oct 8 11:59:08 2004
+++ Products/PluggableAuthService/tests/test_PluggableAuthService.py Thu Oct 14 12:07:48 2004
@@ -120,6 +120,16 @@
response.reindeer_games = reindeer_games
return True
+class DummyCounterChallenger( DummyChallenger ):
+
+ def __init__(self, id):
+ self.id = id
+ self.count = 0
+
+ def challenge(self, request, response):
+ self.count += 1
+ return True
+
class FauxRequest:
def __init__( self, steps=(), **kw ):
@@ -1697,6 +1707,27 @@
# will play
self.assertEqual(response.reindeer_games, ['dasher', 'dancer'])
+ def test_dont_call_challenge_twice(self):
+ from Products.PluggableAuthService.interfaces.plugins \
+ import IChallengePlugin
+ plugins = self._makePlugins()
+ zcuf = self._makeOne( plugins )
+
+ counter = self._makeChallengePlugin('counter', DummyCounterChallenger)
+ zcuf._setObject( 'counter', counter )
+
+ plugins = zcuf._getOb( 'plugins' )
+ plugins.activatePlugin( IChallengePlugin, 'counter' )
+
+ response = FauxResponse()
+ request = FauxRequest(RESPONSE=response)
+ zcuf.REQUEST = request
+
+ zcuf(self, request)
+
+ self.failUnlessRaises( Unauthorized, response.unauthorized)
+
+ self.assertEqual(counter.count, 1)
if __name__ == "__main__":
unittest.main()
More information about the Zope-CVS
mailing list