mirror of
https://github.com/django/django.git
synced 2025-10-30 09:06:13 +00:00
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
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user