Projet

Général

Profil

0002-show-change-password-link-after-user-unlink-fixes-32.patch

Benjamin Dauvergne, 16 mai 2019 18:13

Télécharger (2,19 ko)

Voir les différences:

Subject: [PATCH 2/2] show change password link after user unlink (fixes
 #32953)

 src/authentic2_auth_fc/__init__.py |  7 ++++---
 tests/test_auth_fc.py              | 13 +++++++++++++
 2 files changed, 17 insertions(+), 3 deletions(-)
src/authentic2_auth_fc/__init__.py
90 90
        return None
91 91

  
92 92
    def a2_hook_user_can_change_password(self, user, request, **kwargs):
93
        for authentication_event in get_authentication_events(request=request):
94
            if authentication_event['how'] == 'france-connect':
95
                return False
93
        if 'fc_id_token' in request.session:
94
            for authentication_event in get_authentication_events(request=request):
95
                if authentication_event['how'] == 'france-connect':
96
                    return False
96 97
        return True
97 98

  
98 99

  
tests/test_auth_fc.py
575 575
    assert path(response['Location']) == '/accounts/'
576 576
    response = response.follow()
577 577
    assert len(response.pyquery('[href*="password/change"]')) == 0
578

  
579
    # Unlink
580
    response = response.click('Delete link')
581
    response.form.set('new_password1', 'ikKL1234')
582
    response.form.set('new_password2', 'ikKL1234')
583
    response = response.form.submit(name='unlink')
584
    continue_url = response.pyquery('a#a2-continue').attr['href']
585
    state = urlparse.parse_qs(urlparse.urlparse(continue_url).query)['state'][0]
586
    assert app.session['fc_states'][state]['next'] == '/accounts/'
587
    response = app.get(reverse('fc-logout') + '?state=' + state)
588
    assert path(response['Location']) == '/accounts/'
589
    response = response.follow()
590
    assert len(response.pyquery('[href*="password/change"]')) > 0
578
-