mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-31 18:40:07 +03:00
Merge 4ca09514da
into 7f77340b33
This commit is contained in:
commit
0d355feba5
|
@ -173,7 +173,7 @@ class APIView(View):
|
|||
If request is not permitted, determine what kind of exception to raise.
|
||||
"""
|
||||
if request.authenticators and not request.successful_authenticator:
|
||||
raise exceptions.NotAuthenticated()
|
||||
raise exceptions.NotAuthenticated(detail=message)
|
||||
raise exceptions.PermissionDenied(detail=message)
|
||||
|
||||
def throttled(self, request, wait):
|
||||
|
|
|
@ -522,3 +522,10 @@ class CustomPermissionsTests(TestCase):
|
|||
detail = response.data.get('detail')
|
||||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
|
||||
self.assertEqual(detail, self.custom_message)
|
||||
|
||||
def test_permission_denied_for_object_with_custom_detail_by_anonymous_user(self):
|
||||
anonymous_request = factory.get('/1', format='json')
|
||||
response = denied_object_view_with_detail(anonymous_request, pk=1)
|
||||
detail = response.data.get('detail')
|
||||
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
|
||||
self.assertEqual(detail, self.custom_message)
|
||||
|
|
Loading…
Reference in New Issue
Block a user