Error out if OIDC_CLIENT_SECRETS is not set in server config

This commit is contained in:
Matt Jia
2017-02-21 11:03:25 +10:00
parent be65a0ff81
commit 143effcd15
2 changed files with 6 additions and 2 deletions

View File

@@ -44,8 +44,7 @@ def _load_secrets():
return
if not "OIDC_CLIENT_SECRETS" in app.config:
log.warn("To support authorization, OIDC_CLIENT_SECRETS has to be set.")
return
raise Unauthorized("OIDC_CLIENT_SECRETS must be set in server config.")
secrets = _json_loads(open(app.config['OIDC_CLIENT_SECRETS'],
'r').read())

View File

@@ -67,3 +67,8 @@ class TestAuthModule(unittest.TestCase):
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)
@raises(module_build_service.errors.Unauthorized)
def test_misconfiguring_oidc_client_secrets_should_be_failed(self):
request = mock.MagicMock()
module_build_service.auth.get_user(request)