journal: fix get_message for user.login.failure events (#87616)
gitea/authentic/pipeline/head This commit looks good
Details
gitea/authentic/pipeline/head This commit looks good
Details
This commit is contained in:
parent
35e0425386
commit
2d9a56b43e
|
@ -188,7 +188,7 @@ class UserLoginFailure(EventTypeWithService):
|
|||
if authenticator and context != authenticator:
|
||||
msg += _(' on authenticator {authenticator}').format(authenticator=authenticator)
|
||||
if reason:
|
||||
msg.append(_(' (reason: {reason})').format(reason=reason))
|
||||
msg += _(' (reason: {reason})').format(reason=reason)
|
||||
return msg
|
||||
|
||||
|
||||
|
|
|
@ -2802,7 +2802,11 @@ def test_user_journal_login_failure(slapd, settings, client, db, monkeypatch, ex
|
|||
'/login/', {'login-password-submit': '1', 'username': USERNAME, 'password': PASS}, follow=True
|
||||
)
|
||||
user = ldap_backend.LDAPUser.objects.get(username='%s@ldap' % UID)
|
||||
utils.assert_event('user.login.failure', user=user, username=UID, reason=exception[1])
|
||||
event = utils.assert_event('user.login.failure', user=user, username=UID, reason=exception[1])
|
||||
assert (
|
||||
event.message
|
||||
== f'login failure with username "etienne.michu" on authenticator Password (reason: {exception[1]})'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
@ -405,8 +405,11 @@ def assert_event(event_type_name, user=None, session=None, service=None, target_
|
|||
event.data.get(key),
|
||||
value,
|
||||
)
|
||||
return event
|
||||
elif data and count > 1:
|
||||
assert qs.filter(**{'data__' + k: v for k, v in data.items()}).count() == 1
|
||||
qs = qs.filter(**{'data__' + k: v for k, v in data.items()})
|
||||
assert qs.count() == 1
|
||||
return qs.get()
|
||||
|
||||
|
||||
def clear_events():
|
||||
|
|
Loading…
Reference in New Issue