[Zope3-checkins] CVS: Zope3/src/zope/app/browser/exception/tests - test_unauthorized.py:1.8
Albertas Agejevas
alga@codeworks.lt
Fri, 18 Jul 2003 10:00:54 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/exception/tests
In directory cvs.zope.org:/tmp/cvs-serv28998/zope/app/browser/exception/tests
Modified Files:
test_unauthorized.py
Log Message:
Fixed breakage of the unauthorized view with the pluggable auth
service.
=== Zope3/src/zope/app/browser/exception/tests/test_unauthorized.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/exception/tests/test_unauthorized.py:1.7 Mon Jun 9 12:39:12 2003
+++ Zope3/src/zope/app/browser/exception/tests/test_unauthorized.py Fri Jul 18 10:00:20 2003
@@ -39,6 +39,9 @@
self.principal_id = principal_id
self.request = request
+class DummyPrincipalSource:
+ pass
+
class Test(TestCase):
def test(self):
@@ -51,6 +54,28 @@
request = TestRequest('/')
authservice = DummyAuthService()
request.setUser(ContextWrapper(DummyPrincipal(23), authservice))
+ u = Unauthorized(exception, request)
+ u.issueChallenge()
+
+ # Make sure the response status was set
+ self.assertEqual(request.response.getStatus(), 403)
+
+ # Make sure the auth service was called
+ self.failUnless(authservice.request is request)
+ self.assertEqual(authservice.principal_id, 23)
+
+ def testPluggableAuthService(self):
+ from zope.app.browser.exception.unauthorized import Unauthorized
+ exception = Exception()
+ try:
+ raise exception
+ except:
+ pass
+ request = TestRequest('/')
+ authservice = DummyAuthService()
+ psrc = DummyPrincipalSource()
+ psrc = ContextWrapper(psrc, authservice)
+ request.setUser(ContextWrapper(DummyPrincipal(23), psrc))
u = Unauthorized(exception, request)
u.issueChallenge()