From 634f35a9723ca6b2fcf7aa30691e63e2aa1aea49 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 13 Mar 2024 11:19:54 -0700 Subject: [PATCH] 9856 fix graphiql test --- netbox/netbox/graphql/views.py | 8 +------- netbox/netbox/tests/test_graphql.py | 3 --- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/netbox/netbox/graphql/views.py b/netbox/netbox/graphql/views.py index b61157403..23827c9c4 100644 --- a/netbox/netbox/graphql/views.py +++ b/netbox/netbox/graphql/views.py @@ -36,12 +36,6 @@ class NetBoxGraphQLView(GraphQLView): # Enforce LOGIN_REQUIRED if settings.LOGIN_REQUIRED and not request.user.is_authenticated: - - # If this is a human user, send a redirect to the login page - # bug - todo? - # if self.request_wants_html(request): - # return redirect_to_login(reverse('graphql')) - - return HttpResponseForbidden("No credentials provided.") + return redirect_to_login(reverse('graphql')) return super().dispatch(request, *args, **kwargs) diff --git a/netbox/netbox/tests/test_graphql.py b/netbox/netbox/tests/test_graphql.py index a3f4df782..2cf9ee87b 100644 --- a/netbox/netbox/tests/test_graphql.py +++ b/netbox/netbox/tests/test_graphql.py @@ -15,8 +15,6 @@ class GraphQLTestCase(TestCase): response = self.client.get(url) self.assertHttpStatus(response, 404) - ''' - BUG TODO - Re-enable @override_settings(LOGIN_REQUIRED=True) def test_graphiql_interface(self): """ @@ -36,4 +34,3 @@ class GraphQLTestCase(TestCase): response = self.client.get(url, **header) with disable_warnings('django.request'): self.assertHttpStatus(response, 302) # Redirect to login page - '''