Audit permissions when adding a user to a service

This is useful information to store for the event, which would be
lost if someone subsequently changed them.

Rather than updating lots of mock assertions, I've replaced them
with a single test / assert at a lower level, which is consistent
with auditing being a non-critical function.
This commit is contained in:
Ben Thorner
2021-07-15 12:13:42 +01:00
parent 171f911237
commit 9fafc092f7
6 changed files with 24 additions and 23 deletions

View File

@@ -334,8 +334,6 @@ def test_register_from_email_auth_invite(
fake_uuid,
mocker,
):
mock_audit_event = mocker.patch('app.models.user.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:
@@ -373,10 +371,6 @@ 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_id'] == sample_invite['id']