Send upload_id to Template Preview for logging

This means we can include the anonymous ID for the file in the log
we have about Type3 fonts [1]. Currently, we have no way of tracing
manually uploaded files with this potential defect.

[1]: https://github.com/alphagov/notifications-template-preview/pull/557
This commit is contained in:
Ben Thorner
2021-07-01 12:09:47 +01:00
parent bcc494f0ec
commit 1f33924ceb
4 changed files with 20 additions and 8 deletions

View File

@@ -83,6 +83,7 @@ def test_post_upload_letter_redirects_for_valid_file(
mock_sanitise.assert_called_once_with(
ANY,
allow_international_letters=expected_allow_international,
upload_id=ANY,
)
assert 'The Queen' in page.find('div', class_='js-stick-at-bottom-when-scrolling').text

View File

@@ -164,18 +164,27 @@ def test_from_example_template_makes_request(mocker):
)
@pytest.mark.parametrize('allow_international_letters, expected_url', (
(False, 'http://localhost:9999/precompiled/sanitise?allow_international_letters=false'),
(True, 'http://localhost:9999/precompiled/sanitise?allow_international_letters=true'),
))
@pytest.mark.parametrize('allow_international_letters, query_param_value', [
[False, "false"],
[True, "true"]
])
def test_sanitise_letter_calls_template_preview_sanitise_endoint_with_file(
mocker,
allow_international_letters,
expected_url,
query_param_value,
fake_uuid,
):
request_mock = mocker.patch('app.template_previews.requests.post')
sanitise_letter('pdf_data', allow_international_letters=allow_international_letters)
sanitise_letter(
'pdf_data',
upload_id=fake_uuid,
allow_international_letters=allow_international_letters
)
expected_url = f'http://localhost:9999/precompiled/sanitise' \
f'?allow_international_letters={query_param_value}' \
f'&upload_id={fake_uuid}'
request_mock.assert_called_once_with(
expected_url,