From 8626f974cf4cf47bdb37ca2c833ec32ceb23935c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kadl=C4=8D=C3=ADk?= Date: Mon, 27 Mar 2017 11:39:16 +0200 Subject: [PATCH] Set anonymous owner when NO_AUTH --- module_build_service/auth.py | 2 +- tests/test_auth.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/module_build_service/auth.py b/module_build_service/auth.py index 43691e2c..8bfb9eba 100644 --- a/module_build_service/auth.py +++ b/module_build_service/auth.py @@ -85,7 +85,7 @@ def get_user(request): if app.config['NO_AUTH']: log.debug("Authorization is disabled.") - return + return "anonymous", {"packager"} _load_secrets() diff --git a/tests/test_auth.py b/tests/test_auth.py index 2c562cba..fa430b7c 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -104,7 +104,9 @@ class TestAuthModule(unittest.TestCase): def test_disable_authentication(self): with patch.dict('module_build_service.app.config', {'NO_AUTH': True}, clear=True): request = mock.MagicMock() - eq_(module_build_service.auth.get_user(request), None) + username, groups = module_build_service.auth.get_user(request) + eq_(username, "anonymous") + eq_(groups, {"packager"}) @patch('module_build_service.auth.client_secrets', None) def test_misconfiguring_oidc_client_secrets_should_be_failed(self):