[Zope3-checkins] CVS: Zope3/src/zope/app/browser/exception/tests - test_unauthorized.py:1.2
Jim Fulton
jim@zope.com
Thu, 6 Mar 2003 17:41:39 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/exception/tests
In directory cvs.zope.org:/tmp/cvs-serv15128/tests
Modified Files:
test_unauthorized.py
Log Message:
- Removed the traceback from the output.
User errors should not include tracebacks.
The programmer can get tracebacks in the error logging service.
- Moved the issue warning call to the top of the template.
This is important so we make sure we don't miss the ability
to authenticate due to template rendering errors.
- Added logic to set the error status to 403 (Forbidden) in the case
when we don't challenge the user.
=== Zope3/src/zope/app/browser/exception/tests/test_unauthorized.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/exception/tests/test_unauthorized.py:1.1 Wed Feb 5 06:34:55 2003
+++ Zope3/src/zope/app/browser/exception/tests/test_unauthorized.py Thu Mar 6 17:41:38 2003
@@ -18,7 +18,7 @@
"""
from unittest import TestCase, TestSuite, main, makeSuite
-from zope.publisher.base import TestRequest
+from zope.publisher.browser import TestRequest
from zope.proxy.context import ContextWrapper
from zope.app.interfaces.security import IAuthenticationService, IPrincipal
@@ -52,16 +52,13 @@
request.user = 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)
- self.assertEqual(' '.join(u.traceback.split()),
- '<p>Traceback (innermost last): '
- '<ul> '
- '<li> Module zope.app.browser.exception.tests.test_unauthorized, '
- 'line 47, in test</li> '
- '</ul>Exception '
- '</p>'
- )
def test_suite():
return makeSuite(Test)