From 5ca05f327eadd39b4bbb869574ab84cd40cf4243 Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Mon, 19 Apr 2021 11:03:35 +0200 Subject: [PATCH] auth_fc: restore button on registration page (#53241) --- src/authentic2_auth_fc/authenticators.py | 3 +++ tests/auth_fc/test_auth_fc.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/authentic2_auth_fc/authenticators.py b/src/authentic2_auth_fc/authenticators.py index b28ade7bf..c88bfca29 100644 --- a/src/authentic2_auth_fc/authenticators.py +++ b/src/authentic2_auth_fc/authenticators.py @@ -79,3 +79,6 @@ class FcAuthenticator(BaseAuthenticator): } ) return render_to_string('authentic2_auth_fc/linking.html', context, request=request) + + def registration(self, request, *args, **kwargs): + return self.login(request, *args, **kwargs) diff --git a/tests/auth_fc/test_auth_fc.py b/tests/auth_fc/test_auth_fc.py index 624a0706f..88607cff5 100644 --- a/tests/auth_fc/test_auth_fc.py +++ b/tests/auth_fc/test_auth_fc.py @@ -535,3 +535,18 @@ def test_authorization_error(app, franceconnect): messages = response.pyquery('.messages').text() assert error in messages assert error_description not in messages + + +def test_registration_page(settings, app, franceconnect, hooks): + assert User.objects.count() == 0 + response = app.get('/accounts/register/?service=portail&next=/idp/') + response = franceconnect.login_with_fc_fixed_params(app) + + # a new user has been created + assert User.objects.count() == 1 + + # we must be connected + assert app.session['_auth_user_id'] + + # hook must have been called + assert hooks.calls['event'][0]['kwargs']['name'] == 'fc-create'