mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Bump utils and sanitise header values
Updated notifications-utils. This brings in - the renamed character sanitization classes - the change to allow unicode in letter addresses (this lets us delete a test that is no longer relevant) Also replaced non-ascii characters in headers. This fixes a bug where non-ascii characters in a CSV filename were causing errors since the filename is also used in the header.
This commit is contained in:
@@ -16,3 +16,20 @@ def test_owasp_useful_headers_set(client, mocker):
|
||||
"img-src 'self' *.google-analytics.com *.notifications.service.gov.uk static-logos.test.com data:;"
|
||||
"frame-src www.youtube.com;"
|
||||
)
|
||||
|
||||
|
||||
def test_headers_non_ascii_characters_are_replaced(client, mocker):
|
||||
mocker.patch('app.get_cdn_domain', return_value='static-logos۾.test.com')
|
||||
|
||||
response = client.get('/')
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.headers['Content-Security-Policy'] == (
|
||||
"default-src 'self' 'unsafe-inline';"
|
||||
"script-src 'self' *.google-analytics.com 'unsafe-inline' 'unsafe-eval' data:;"
|
||||
"connect-src 'self' *.google-analytics.com;"
|
||||
"object-src 'self';"
|
||||
"font-src 'self' data:;"
|
||||
"img-src 'self' *.google-analytics.com *.notifications.service.gov.uk static-logos??.test.com data:;"
|
||||
"frame-src www.youtube.com;"
|
||||
)
|
||||
|
||||
@@ -2382,55 +2382,6 @@ def test_check_messages_shows_over_max_row_error(
|
||||
)
|
||||
|
||||
|
||||
def test_non_ascii_characters_in_letter_recipients_file_shows_error(
|
||||
logged_in_client,
|
||||
api_user_active,
|
||||
mock_login,
|
||||
mock_get_users_by_service,
|
||||
mock_get_live_service,
|
||||
mock_has_permissions,
|
||||
mock_get_service_letter_template,
|
||||
mock_get_service_statistics,
|
||||
mock_get_job_doesnt_exist,
|
||||
fake_uuid,
|
||||
mocker
|
||||
):
|
||||
from tests.conftest import mock_s3_download
|
||||
mock_s3_download(
|
||||
mocker,
|
||||
content=u"""
|
||||
address line 1,address line 2,address line 3,address line 4,address line 5,address line 6,postcode
|
||||
Петя,345 Example Street,,,,,AA1 6BB
|
||||
"""
|
||||
)
|
||||
|
||||
with logged_in_client.session_transaction() as session:
|
||||
session['file_uploads'] = {
|
||||
fake_uuid: {
|
||||
'template_id': fake_uuid,
|
||||
}
|
||||
}
|
||||
|
||||
response = logged_in_client.get(url_for(
|
||||
'main.check_messages',
|
||||
service_id=fake_uuid,
|
||||
template_id=fake_uuid,
|
||||
upload_id=fake_uuid,
|
||||
original_file_name='unicode.csv'
|
||||
))
|
||||
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert ' '.join(
|
||||
page.find('div', class_='banner-dangerous').text.split()
|
||||
) == (
|
||||
'There is a problem with unicode.csv '
|
||||
'You need to fix 1 address '
|
||||
'Skip to file contents'
|
||||
)
|
||||
assert page.find('span', class_='table-field-error-label').text == u'Can’t include П, е, т or я'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('existing_session_items', [
|
||||
{},
|
||||
{'recipient': '07700900001'},
|
||||
|
||||
Reference in New Issue
Block a user