import pytest from util.config.validators import ConfigValidationException from util.config.validators.validate_oidcauth import OIDCAuthValidator from test.fixtures import * @pytest.mark.parametrize('unvalidated_config', [ ({'AUTHENTICATION_TYPE': 'OIDC'}), ({'AUTHENTICATION_TYPE': 'OIDC', 'INTERNAL_OIDC_SERVICE_ID': 'someservice'}), ]) def test_validate_invalid_oidc_auth_config(unvalidated_config, app): validator = OIDCAuthValidator() with pytest.raises(ConfigValidationException): validator.validate(unvalidated_config, None, None) def test_validate_oidc_auth(app): config = { 'AUTHENTICATION_TYPE': 'OIDC', 'INTERNAL_OIDC_SERVICE_ID': 'someservice', 'SOMESERVICE_LOGIN_CONFIG': { 'CLIENT_ID': 'foo', 'CLIENT_SECRET': 'bar', 'OIDC_SERVER': 'http://someserver', }, 'HTTPCLIENT': None, } validator = OIDCAuthValidator() validator.validate(config, None, None)