diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-08-12 14:15:41 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-08-12 14:15:41 +0000 |
| commit | 351d5da69b994c2e390f8d33e66ce5836b0bf348 (patch) | |
| tree | 3505bde3aaab890e6dfe65451ae6c50fcd474e46 /tests/modeltests/test_client/models.py | |
| parent | 1ca6e9b9e24240033349c93b05902c79c0a25bbb (diff) | |
Fixed #4617 -- Added `raise_exception` option to `permission_required` decorator to be able to raise a PermissionDenied exception instead of redirecting to the login page.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16607 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/test_client/models.py')
| -rw-r--r-- | tests/modeltests/test_client/models.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py index 16bdd2d29a..e7bb004ff4 100644 --- a/tests/modeltests/test_client/models.py +++ b/tests/modeltests/test_client/models.py @@ -370,6 +370,21 @@ class ClientTest(TestCase): # TODO: Log in with right permissions and request the page again + def test_view_with_permissions_exception(self): + "Request a page that is protected with @permission_required but raises a exception" + + # Get the page without logging in. Should result in 403. + response = self.client.get('/test_client/permission_protected_view_exception/') + self.assertEquals(response.status_code, 403) + + # Log in + login = self.client.login(username='testclient', password='password') + self.assertTrue(login, 'Could not log in') + + # Log in with wrong permissions. Should result in 403. + response = self.client.get('/test_client/permission_protected_view_exception/') + self.assertEquals(response.status_code, 403) + def test_view_with_method_permissions(self): "Request a page that is protected with a @permission_required method" |
