auth_saml: handle underscores in idp slug (#52981)

This commit is contained in:
Valentin Deniaud 2021-04-15 14:30:11 +02:00
parent b429cfd794
commit e7803635b9
2 changed files with 5 additions and 1 deletions

View File

@ -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):

View File

@ -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()