Projet

Général

Profil

0002-manager-search-events-by-authentication-method-57932.patch

Valentin Deniaud, 27 octobre 2021 15:50

Télécharger (2,18 ko)

Voir les différences:

Subject: [PATCH 2/2] manager: search events by authentication method (#57932)

 src/authentic2/manager/journal_views.py |  9 +++++++++
 tests/test_manager_journal.py           | 11 ++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
src/authentic2/manager/journal_views.py
94 94
            ),
95 95
        )
96 96

  
97
    def search_by_how(self, lexem):
98
        yield Q(data__how__startswith=lexem)
99

  
100
    @classmethod
101
    def search_by_how_documentation(cls):
102
        return _(
103
            'You can use <tt>how:france-connect</tt> to find all events related to FranceConnect. Other possible values are "saml", "oidc" and "password".'
104
        )
105

  
97 106

  
98 107
EVENT_TYPE_CHOICES = (
99 108
    ('', _('All')),
tests/test_manager_journal.py
1065 1065
        text_content(response.pyquery('tbody tr td.journal-list--message-column')[0]).strip()
1066 1066
        == 'creation of user "Johnny doe"'
1067 1067
    )
1068
    assert text_content(response.pyquery('tbody tr td.journal-list--session-column')[0]).strip() == 'API'
1068

  
1069
    response.form.set('search', 'how:france-connect')
1070
    response = response.form.submit()
1071
    table_content = [text_content(p) for p in response.pyquery('tbody td.journal-list--message-column')]
1072
    assert table_content == ['registration using FranceConnect']
1073

  
1074
    response.form.set('search', 'how:saml')
1075
    response = response.form.submit()
1076
    table_content = [text_content(p) for p in response.pyquery('tbody td.journal-list--message-column')]
1077
    assert table_content == ['login using SAML']
1069 1078

  
1070 1079
    response.form.set('search', '')
1071 1080
    response.form['event_type'].select(text='Profile changes')
1072
-