auth_fc: add tests on login with minimal user_info (#47566)
This commit is contained in:
parent
e28713c583
commit
4e0be8c7c3
|
@ -352,3 +352,28 @@ def test_manager_user_sidebar(app, superuser, simple_user):
|
|||
|
||||
response = app.get('/manage/users/%s/' % simple_user.id)
|
||||
assert 'FranceConnect' in response
|
||||
|
||||
|
||||
def test_user_info_incomplete(settings, app, franceconnect):
|
||||
settings.A2_FC_CREATE = True
|
||||
franceconnect.user_info = {}
|
||||
franceconnect.login_with_fc_fixed_params(app)
|
||||
|
||||
user = User.objects.get()
|
||||
assert app.session['_auth_user_id'] == str(user.pk)
|
||||
fc_account = models.FcAccount.objects.get(user=user)
|
||||
assert fc_account.sub == franceconnect.sub
|
||||
assert fc_account.get_user_info() == {'sub': franceconnect.sub}
|
||||
|
||||
|
||||
def test_user_info_incomplete_already_linked(settings, app, franceconnect, simple_user):
|
||||
settings.A2_FC_CREATE = True
|
||||
user = User.objects.create()
|
||||
models.FcAccount.objects.create(user=user, sub=franceconnect.sub)
|
||||
franceconnect.user_info = {}
|
||||
franceconnect.callback_params = {'next': '/accounts/'}
|
||||
|
||||
response = login(app, simple_user, path='/accounts/')
|
||||
response = response.click(href='callback')
|
||||
response = franceconnect.handle_authorization(app, response.location, status=302)
|
||||
assert 'FranceConnect account is already' in app.cookies['messages']
|
||||
|
|
Loading…
Reference in New Issue