Add audit event for inviting users to a service

This commit is contained in:
Katie Smith
2021-03-05 12:19:36 +00:00
parent fed40326da
commit 7ae4017d50
7 changed files with 76 additions and 3 deletions

View File

@@ -365,7 +365,12 @@ def test_register_from_email_auth_invite(
mock_add_user_to_service,
mock_get_service,
invite_email_address,
service_one,
fake_uuid,
mocker,
):
mock_audit_event = mocker.patch('app.event_handlers.create_add_user_to_service_event')
sample_invite['auth_type'] = 'email_auth'
sample_invite['email_address'] = invite_email_address
with client.session_transaction() as session:
@@ -401,6 +406,10 @@ def test_register_from_email_auth_invite(
assert current_user.is_authenticated
assert mock_add_user_to_service.called
mock_audit_event.assert_called_once_with(invited_by_id=service_one['users'][0],
service_id=sample_invite['service'],
user_id=fake_uuid)
with client.session_transaction() as session:
# invited user details are still there so they can get added to the service
assert session['invited_user'] == sample_invite