Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Commit

Permalink
- Added a test for 403 Forbidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Oct 11, 2010
1 parent fbb06a3 commit 8bf31df
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CHANGES

- Got rid of `zope.app.testing` test dependency by using `zope.app.wsgi`.

- Added a test for ``403 Forbidden``.

1.8.0 (2010-08-20)
------------------
Expand Down
34 changes: 31 additions & 3 deletions src/z3c/layer/pagelet/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ show up otherwise:
>>> unauthorized = Browser()
>>> unauthorized.open(skinURL + '/@@forbidden.html')
Traceback (most recent call last):
...
HTTPError: HTTP Error 401: Unauthorized

>>> print unauthorized.contents
Expand All @@ -199,7 +198,36 @@ show up otherwise:
<br />
<b>You are not authorized.</b>
</div>
<BLANKLINE>
</body>
</html>
<BLANKLINE>

Forbidden
~~~~~~~~~

When an authorized user tries to access a URL where he does not have enough
permissions he gets a ``403 Forbidden``, the displayed page contents are the
same like ``401 Unauthorized``. When an authentication utility is registered
it might display a log-in form:

>>> authorized = Browser()
>>> authorized.addHeader('Authorization', 'Basic tester:tester')
>>> authorized.open(skinURL + '/@@forbidden.html')
Traceback (most recent call last):
HTTPError: HTTP Error 403: Forbidden

>>> print authorized.contents
<!DOCTYPE ...
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>PageletTestLayout</title>
</head>
<body>
<div>
<br />
<br />
<h3>Unauthorized</h3>
<br />
<b>You are not authorized.</b>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions src/z3c/layer/pagelet/tests/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,11 @@

<grantAll principal="zope.manager" />

<principal
id="zope.tester"
title="Tester"
login="tester"
password="tester"
/>

</configure>

0 comments on commit 8bf31df

Please sign in to comment.