Add an audit event when a service's broadcast permissions change

This adds an audit event to the `events` table when the broadcast
permissions for a service (the service mode, channel or provider
restriction) changes.
This commit is contained in:
Katie Smith
2021-03-04 12:09:28 +00:00
parent 187a38a0e9
commit 0561937c13
4 changed files with 65 additions and 1 deletions

View File

@@ -5557,8 +5557,10 @@ def test_post_service_set_broadcast_account_type_posts_data_to_api_and_redirects
service_mode,
broadcast_channel,
allowed_broadcast_provider,
fake_uuid,
):
set_service_broadcast_settings_mock = mocker.patch('app.service_api_client.set_service_broadcast_settings')
mock_event_handler = mocker.patch('app.main.views.service_settings.create_broadcast_account_type_change_event')
response = platform_admin_client.post(
url_for(
@@ -5577,11 +5579,22 @@ def test_post_service_set_broadcast_account_type_posts_data_to_api_and_redirects
broadcast_channel=broadcast_channel,
provider_restriction=allowed_broadcast_provider,
)
mock_event_handler.assert_called_once_with(
service_id=SERVICE_ONE_ID,
changed_by_id=fake_uuid,
service_mode=service_mode,
broadcast_channel=broadcast_channel,
provider_restriction=allowed_broadcast_provider,
)
def test_post_service_set_broadcast_account_type_shows_errors_if_no_radio_selected(
platform_admin_client
platform_admin_client,
mocker,
):
set_service_broadcast_settings_mock = mocker.patch('app.service_api_client.set_service_broadcast_settings')
mock_event_handler = mocker.patch('app.main.views.service_settings.create_broadcast_account_type_change_event')
response = platform_admin_client.post(
url_for(
'main.service_set_broadcast_account_type',
@@ -5591,3 +5604,5 @@ def test_post_service_set_broadcast_account_type_shows_errors_if_no_radio_select
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert "This field is required" in page.find("span", {"class": "govuk-error-message"}).text
assert not set_service_broadcast_settings_mock.called
assert not mock_event_handler.called