Skip to content

Commit

Permalink
cilogon: test with new name, old name confirmed to work
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Sep 25, 2023
1 parent 3ca1da8 commit 02b2f67
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions oauthenticator/tests/test_cilogon.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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",
Expand Down Expand Up @@ -377,7 +377,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)
Expand Down Expand Up @@ -504,16 +504,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': {},
}

Expand All @@ -523,11 +523,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',
Expand All @@ -552,7 +552,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'"):
Expand All @@ -561,7 +561,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}
}
Expand All @@ -572,7 +572,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',
Expand All @@ -586,7 +586,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',
Expand All @@ -603,7 +603,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',
Expand All @@ -619,14 +619,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': {
'username_derivation': {
'username_claim': 'email',
Expand Down

0 comments on commit 02b2f67

Please sign in to comment.