From 2ea368e80f16311f50b31563abb70571b95fff86 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 30 Aug 2017 16:53:08 -0400 Subject: [PATCH] Add failing test for #5367 --- tests/test_permissions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 70fb38caa..ed5c7af7a 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -209,6 +209,16 @@ class ModelPermissionsIntegrationTests(TestCase): response = instance_view(request, pk='1') self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) + def test_check_auth_before_queryset_call(self): + class View(RootView): + def get_queryset(_): + self.fail('should not reach due to auth check') + view = View.as_view() + + request = factory.get('/', HTTP_AUTHORIZATION='') + response = view(request) + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + class BasicPermModel(models.Model): text = models.CharField(max_length=100)