From 04966e40519bdfbbb68bebecef77c78a486d3784 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 19 Jan 2017 16:51:53 +0000 Subject: [PATCH] Test that template content passed to API is dirty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t want sanitized content going into the database, because sometimes we need the content unsanitised. The path from admin to the API is where the template goes on it’s way to the database. So let’s make sure we’re not sanitizing it at this stage. --- tests/app/main/views/test_templates.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index 4ca915753..1f1d0a5a9 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -128,7 +128,7 @@ def test_should_redirect_when_saving_a_template(app_, mocker.patch('app.user_api_client.get_users_for_service', return_value=[active_user_with_permissions]) template_id = fake_uuid name = "new name" - content = "template content" + content = "template content with & entity" data = { 'id': template_id, 'name': name, @@ -165,7 +165,7 @@ def test_should_edit_content_when_process_type_is_priority_not_platform_admin( data = { 'id': template_id, 'name': "new name", - 'template_content': "change the content", + 'template_content': "new template content with & entity", 'template_type': 'sms', 'service': service['id'], 'process_type': 'priority' @@ -178,7 +178,14 @@ def test_should_edit_content_when_process_type_is_priority_not_platform_admin( assert response.location == url_for( '.view_template', service_id=service['id'], template_id=template_id, _external=True) mock_update_service_template.assert_called_with( - template_id, "new name", 'sms', "change the content", service['id'], None, 'priority') + template_id, + "new name", + 'sms', + "new template content with & entity", + service['id'], + None, + 'priority' + ) def test_should_403_when_edit_template_with_process_type_of_priority_for_non_platform_admin( @@ -197,7 +204,7 @@ def test_should_403_when_edit_template_with_process_type_of_priority_for_non_pla data = { 'id': template_id, 'name': "new name", - 'template_content': "template content", + 'template_content': "template content with & entity", 'template_type': 'sms', 'service': service['id'], 'process_type': 'priority' @@ -226,7 +233,7 @@ def test_should_403_when_create_template_with_process_type_of_priority_for_non_p data = { 'id': template_id, 'name': "new name", - 'template_content': "template content", + 'template_content': "template content with & entity", 'template_type': 'sms', 'service': service['id'], 'process_type': 'priority' @@ -362,7 +369,7 @@ def test_should_redirect_when_saving_a_template_email(app_, service_id = fake_uuid template_id = fake_uuid name = "new name" - content = "template content ((thing)) ((date))" + content = "template content with & entity ((thing)) ((date))" subject = "subject" data = { 'id': template_id,