From 1268c8e205486bb2647f9016a3cf1f926ca1d328 Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Fri, 23 Sep 2016 08:22:26 -0400 Subject: [PATCH] update authentication class in postprocess and add unit test --- awx/main/tests/unit/test_settings.py | 11 +++++++++++ awx/settings/postprocess.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 awx/main/tests/unit/test_settings.py diff --git a/awx/main/tests/unit/test_settings.py b/awx/main/tests/unit/test_settings.py new file mode 100644 index 0000000000..2018771c63 --- /dev/null +++ b/awx/main/tests/unit/test_settings.py @@ -0,0 +1,11 @@ +from split_settings.tools import include + +def test_postprocess_auth_basic_enabled(): + locals().update({'__file__': __file__}) + + include('../../../settings/defaults.py', scope=locals()) + assert 'awx.api.authentication.LoggedBasicAuthentication' in locals()['REST_FRAMEWORK']['DEFAULT_AUTHENTICATION_CLASSES'] + + locals().update({'AUTH_BASIC_ENABLED': False}) + include('../../../settings/postprocess.py', scope=locals()) + assert 'awx.api.authentication.LoggedBasicAuthentication' not in locals()['REST_FRAMEWORK']['DEFAULT_AUTHENTICATION_CLASSES'] diff --git a/awx/settings/postprocess.py b/awx/settings/postprocess.py index 544758e04f..fd54fd5050 100644 --- a/awx/settings/postprocess.py +++ b/awx/settings/postprocess.py @@ -31,4 +31,4 @@ if not all([SOCIAL_AUTH_SAML_SP_ENTITY_ID, SOCIAL_AUTH_SAML_SP_PUBLIC_CERT, AUTHENTICATION_BACKENDS = [x for x in AUTHENTICATION_BACKENDS if x != 'awx.sso.backends.SAMLAuth'] if not AUTH_BASIC_ENABLED: - REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = [x for x in REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] if x != 'rest_framework.authentication.BasicAuthentication'] + REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = [x for x in REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] if x != 'awx.api.authentication.LoggedBasicAuthentication']