Audit api key id when cancelling broadcast via api

This commit is contained in:
Pea Tyczynska
2022-02-09 14:23:00 +00:00
parent 9ce6d2fe92
commit 3dc1907321
5 changed files with 94 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ from app.dao.broadcast_message_dao import (
dao_get_broadcast_message_by_id_and_service_id,
)
from tests import create_service_authorization_header
from tests.app.db import create_api_key
from . import sample_cap_xml_documents
@@ -130,6 +131,7 @@ def test_valid_cancel_broadcast_request_calls_validate_and_update_broadcast_mess
is_approved,
expected_status
):
api_key = create_api_key(service=sample_broadcast_service)
auth_header = create_service_authorization_header(service_id=sample_broadcast_service.id)
# create a broadcast
@@ -158,7 +160,11 @@ def test_valid_cancel_broadcast_request_calls_validate_and_update_broadcast_mess
headers=[('Content-Type', 'application/cap+xml'), auth_header],
)
assert response_for_cancel.status_code == 201
mock_update.assert_called_once_with(broadcast_message, expected_status, updating_user=None)
mock_update.assert_called_once_with(
broadcast_message,
expected_status,
api_key_id=api_key.id
)
def test_cancel_request_does_not_cancel_broadcast_if_reference_does_not_match(