From 7e63184ab44b279002b96e23b2c499ff803d6026 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 12 Oct 2017 16:25:21 -0400 Subject: [PATCH 1/3] Add missing ping method --- data/users/oidc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/users/oidc.py b/data/users/oidc.py index 5837a9e11..30314f19f 100644 --- a/data/users/oidc.py +++ b/data/users/oidc.py @@ -81,3 +81,7 @@ class OIDCInternalAuth(object): def service_metadata(self): return {} + + def ping(self): + """ Always assumed to be working. If the DB is broken, other checks will handle it. """ + return (True, None) From c1ce84822d7a6ab3774d0b469a7bb4790f4d8782 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 12 Oct 2017 16:25:31 -0400 Subject: [PATCH 2/3] Fix tuple for health check --- data/model/health.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/model/health.py b/data/model/health.py index ca796a48b..80c0cf01d 100644 --- a/data/model/health.py +++ b/data/model/health.py @@ -12,10 +12,10 @@ def check_health(app_config): try: validate_database_url(app_config['DB_URI'], {}, connect_timeout=3) except Exception as ex: - return (False, 'Could not connect to the database: %s', ex.message) + return (False, 'Could not connect to the database: %s' % ex.message) # We will connect to the db, check that it contains some team role kinds try: return (bool(list(TeamRole.select().limit(1))), 'Could not connect to the database') except Exception as ex: - return (False, 'Could not connect to the database: %s', ex.message) + return (False, 'Could not connect to the database: %s' % ex.message) From c2a56ae8287fb32a69b3196a6c31d643d44dfaa9 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 12 Oct 2017 16:49:06 -0400 Subject: [PATCH 3/3] Add a test for ping in OIDC auth --- data/users/test/test_users.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/data/users/test/test_users.py b/data/users/test/test_users.py index d3e5eb09d..408ae4bab 100644 --- a/data/users/test/test_users.py +++ b/data/users/test/test_users.py @@ -1,9 +1,11 @@ import pytest +from contextlib import contextmanager from mock import patch from data.database import model from data.users.federated import DISABLED_MESSAGE +from data.users.oidc import OIDCInternalAuth from test.test_ldap import mock_ldap from test.test_keystone_auth import fake_keystone from test.test_external_jwt_authn import fake_jwt @@ -36,12 +38,18 @@ def test_auth_createuser(auth_system_builder, user1, user2, config, app): assert new_user is None assert err == DISABLED_MESSAGE +@contextmanager +def fake_oidc(app_config): + yield OIDCInternalAuth(app_config, 'someoidc', False) @pytest.mark.parametrize('auth_system_builder,auth_kwargs', [ (mock_ldap, {}), (fake_keystone, {'version': 3}), (fake_keystone, {'version': 2}), (fake_jwt, {}), + (fake_oidc, {'app_config': { + 'SOMEOIDC_LOGIN_CONFIG': {}, + }}), ]) def test_ping(auth_system_builder, auth_kwargs, app): with auth_system_builder(**auth_kwargs) as auth: