From e7803635b9fa9e1c446704b162a4770a7a1d4b30 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 15 Apr 2021 14:30:11 +0200 Subject: [PATCH] auth_saml: handle underscores in idp slug (#52981) --- src/authentic2_auth_saml/authenticators.py | 2 +- tests/test_auth_saml.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/authentic2_auth_saml/authenticators.py b/src/authentic2_auth_saml/authenticators.py index 70015bff6..072bd384f 100644 --- a/src/authentic2_auth_saml/authenticators.py +++ b/src/authentic2_auth_saml/authenticators.py @@ -40,7 +40,7 @@ class SAMLAuthenticator(BaseAuthenticator): yield (idp.get('SLUG') or str(idx), idp) def autorun(self, request, block_id): - auth_id, instance_slug = block_id.split('_') + auth_id, instance_slug = block_id.split('_', 1) assert auth_id == self.id for slug, instance in self.instances(request): diff --git a/tests/test_auth_saml.py b/tests/test_auth_saml.py index 77df37408..5d4bf49d2 100644 --- a/tests/test_auth_saml.py +++ b/tests/test_auth_saml.py @@ -249,6 +249,10 @@ def test_login_autorun(db, app, settings): response = app.get('/login/', status=302) assert '/accounts/saml/login/?entityID=' in response['Location'] + settings.MELLON_IDENTITY_PROVIDERS[0]['SLUG'] = 'slug_with_underscore' + response = app.get('/login/', status=302) + assert '/accounts/saml/login/?entityID=' in response['Location'] + def test_save_account_on_delete_user(db): user = User.objects.create()