From 2c40209e30ce92920eafc88e7f7fe68124f4e870 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Thu, 7 Aug 2014 16:49:14 -0400 Subject: [PATCH] Remove auth checks for /api/ and /api/v1/ to fix auth errors in UI after logging into munin. --- awx/api/views.py | 2 ++ awx/main/tests/users.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/awx/api/views.py b/awx/api/views.py index 891c360721..82247d428e 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -64,6 +64,7 @@ def api_exception_handler(exc): class ApiRootView(APIView): + authentication_classes = [] permission_classes = (AllowAny,) view_name = 'REST API' @@ -82,6 +83,7 @@ class ApiRootView(APIView): class ApiV1RootView(APIView): + authentication_classes = [] permission_classes = (AllowAny,) view_name = 'Version 1' diff --git a/awx/main/tests/users.py b/awx/main/tests/users.py index a70a126f41..50226925f3 100644 --- a/awx/main/tests/users.py +++ b/awx/main/tests/users.py @@ -53,12 +53,22 @@ class UsersTest(BaseTest): def test_auth_token_login(self): auth_token_url = reverse('api:auth_token_view') user_me_url = reverse('api:user_me_list') + api_url = reverse('api:api_root_view') + api_v1_url = reverse('api:api_v1_root_view') # Always returns a 405 for any GET request, regardless of credentials. self.get(auth_token_url, expect=405, auth=None) self.get(auth_token_url, expect=405, auth=self.get_invalid_credentials()) self.get(auth_token_url, expect=405, auth=self.get_normal_credentials()) - + + # /api/ and /api/v1 should work and ignore any credenials passed. + self.get(api_url, expect=200, auth=None) + self.get(api_url, expect=200, auth=self.get_invalid_credentials()) + self.get(api_url, expect=200, auth=self.get_normal_credentials()) + self.get(api_v1_url, expect=200, auth=None) + self.get(api_v1_url, expect=200, auth=self.get_invalid_credentials()) + self.get(api_v1_url, expect=200, auth=self.get_normal_credentials()) + # Posting without username/password fields or invalid username/password # returns a 400 error. data = {}