From 0d9ec68556bf23e970e42f058e2acfb0aeb3ec7b Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 25 Sep 2023 12:17:38 +0200 Subject: [PATCH] cilogon: test with new name, old name confirmed to work --- oauthenticator/tests/test_cilogon.py | 43 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/oauthenticator/tests/test_cilogon.py b/oauthenticator/tests/test_cilogon.py index 2d69a777..94c59bae 100644 --- a/oauthenticator/tests/test_cilogon.py +++ b/oauthenticator/tests/test_cilogon.py @@ -115,7 +115,7 @@ async def test_cilogon( print(f"Running test variation id {test_variation_id}") c = Config() c.CILogonOAuthenticator = Config(class_config) - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { "https://some-idp.com/login/oauth/authorize": { "username_derivation": { "username_claim": "name", @@ -449,7 +449,7 @@ async def test_cilogon_idps( c = Config() c.CILogonOAuthenticator = Config(class_config) test_idp = "https://some-idp.com/login/oauth/authorize" - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { test_idp: idp_config, } authenticator = CILogonOAuthenticator(config=c) @@ -533,12 +533,13 @@ async def test_cilogon_idps( { "idps": { "https://github.com/login/oauth/authorize": { - "username_derivation": {"username_claim": "email"} + 'allowed_domains': [], + "username_derivation": {"username_claim": "email"}, } } }, logging.WARNING, - "CILogonOAuthenticator.allowed_idps is deprecated in CILogonOAuthenticator 16.1.0, use CILogonOAuthenticator.idps instead", + "CILogonOAuthenticator.allowed_idps is deprecated in CILogonOAuthenticator 17.4.0, use CILogonOAuthenticator.idps instead", ), ], ) @@ -579,16 +580,16 @@ async def test_config_idps_wrong_type(caplog): Test alllowed_idps is a dict """ c = Config() - c.CILogonOAuthenticator.allowed_idps = ['pink'] + c.CILogonOAuthenticator.idps = ['pink'] with raises(TraitError): CILogonOAuthenticator(config=c) async def test_config_idps_required_username_derivation(caplog): - # Test username_derivation is a required field of allowed_idps + # Test username_derivation is a required field of idps c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://github.com/login/oauth/authorize': {}, } @@ -598,11 +599,11 @@ async def test_config_idps_required_username_derivation(caplog): async def test_config_idps_invalid_entity_id(caplog): """ - Test allowed_idps keys cannot be domains, but only valid CILogon entity ids, + Test idps keys cannot be domains, but only valid CILogon entity ids, i.e. only fully formed URLs """ c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'uni.edu': { 'username_derivation': { 'username_claim': 'email', @@ -627,7 +628,7 @@ async def test_config_idps_invalid_entity_id(caplog): async def test_config_idps_invalid_type(caplog): c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://github.com/login/oauth/authorize': 'should-be-a-dict' } with raises(ValidationError, match="'should-be-a-dict' is not of type 'object'"): @@ -636,7 +637,7 @@ async def test_config_idps_invalid_type(caplog): async def test_config_idps_unrecognized_options(caplog): c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://github.com/login/oauth/authorize': { 'username_derivation': {'a': 1, 'b': 2} } @@ -647,7 +648,7 @@ async def test_config_idps_unrecognized_options(caplog): async def test_config_idps_domain_required(caplog): c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://github.com/login/oauth/authorize': { 'username_derivation': { 'username_claim': 'email', @@ -661,7 +662,7 @@ async def test_config_idps_domain_required(caplog): async def test_config_idps_prefix_required(caplog): c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://github.com/login/oauth/authorize': { 'username_derivation': { 'username_claim': 'email', @@ -678,7 +679,7 @@ async def test_config_scopes_validation(): Test that required scopes are appended if not configured. """ c = Config() - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://some-idp.com/login/oauth/authorize': { 'username_derivation': { 'username_claim': 'email', @@ -694,14 +695,14 @@ async def test_config_scopes_validation(): assert authenticator.scope == expected_scopes -async def test_allowed_idps_username_derivation_actions(cilogon_client): +async def test_idps_username_derivation_actions(cilogon_client): """ - Tests all `allowed_idps[].username_derivation.action` config choices: + Tests all `idps[].username_derivation.action` config choices: `strip_idp_domain`, `prefix`, and no action specified. """ c = Config() c.CILogonOAuthenticator.allow_all = True - c.CILogonOAuthenticator.allowed_idps = { + c.CILogonOAuthenticator.idps = { 'https://strip-idp-domain.example.com/login/oauth/authorize': { 'default': True, 'username_derivation': { @@ -773,7 +774,7 @@ async def test_allowed_idps_username_derivation_actions(cilogon_client): @mark.parametrize( - "test_variation_id,allowed_idps,expected_return_value", + "test_variation_id,idps,expected_return_value", [ ( "default-specified", @@ -807,7 +808,5 @@ async def test_allowed_idps_username_derivation_actions(cilogon_client): ), ], ) -async def test__get_selected_idp_param( - test_variation_id, allowed_idps, expected_return_value -): - assert _get_select_idp_param(allowed_idps) == expected_return_value +async def test__get_selected_idp_param(test_variation_id, idps, expected_return_value): + assert _get_select_idp_param(idps) == expected_return_value