Use encrypt/decrypt methods in place of signing

This commit is contained in:
Ryan Ahearn
2022-12-09 16:33:10 -05:00
parent 1f183b96b9
commit 17ee4c3f2b
15 changed files with 179 additions and 150 deletions

View File

@@ -1,5 +1,6 @@
import json
from datetime import datetime
from unittest.mock import ANY
from freezegun import freeze_time
@@ -14,11 +15,8 @@ from app.celery.research_mode_tasks import (
ses_notification_callback,
ses_soft_bounce_callback,
)
from app.celery.service_callback_tasks import (
create_delivery_status_callback_data,
)
from app.dao.notifications_dao import get_notification_by_id
from app.models import Complaint, Notification
from app.models import Complaint
from tests.app.conftest import create_sample_notification
from tests.app.db import (
create_notification,
@@ -156,7 +154,7 @@ def test_ses_callback_should_update_notification_status(
status='sending',
sent_at=datetime.utcnow()
)
callback_api = create_service_callback_api(
create_service_callback_api(
service=sample_email_template.service,
url="https://original_url.com"
)
@@ -167,9 +165,9 @@ def test_ses_callback_should_update_notification_status(
"callback.ses.elapsed-time", datetime.utcnow(), notification.sent_at
)
statsd_client.incr.assert_any_call("callback.ses.delivered")
updated_notification = Notification.query.get(notification.id)
encrypted_data = create_delivery_status_callback_data(updated_notification, callback_api)
send_mock.assert_called_once_with([str(notification.id), encrypted_data], queue="service-callbacks")
send_mock.assert_called_once_with([str(notification.id), ANY], queue="service-callbacks")
# assert second arg is an encrypted string
assert isinstance(send_mock.call_args.args[0][1], str)
def test_ses_callback_should_not_update_notification_status_if_already_delivered(sample_email_template, mocker):
@@ -331,7 +329,7 @@ def test_ses_callback_should_send_on_complaint_to_user_callback_api(sample_email
response = ses_complaint_callback()
assert process_ses_results(response)
assert send_mock.call_count == 1
assert encryption.verify_signature(send_mock.call_args[0][0][0]) == {
assert encryption.decrypt(send_mock.call_args[0][0][0]) == {
'complaint_date': '2018-06-05T13:59:58.000000Z',
'complaint_id': str(Complaint.query.one().id),
'notification_id': str(notification.id),

View File

@@ -465,7 +465,7 @@ def test_check_for_missing_rows_in_completed_jobs_ignores_old_and_new_jobs(
):
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('multiple_email'), {"sender_id": None}))
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
process_row = mocker.patch('app.celery.scheduled_tasks.process_row')
job = create_job(
@@ -485,7 +485,7 @@ def test_check_for_missing_rows_in_completed_jobs_ignores_old_and_new_jobs(
def test_check_for_missing_rows_in_completed_jobs(mocker, sample_email_template):
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('multiple_email'), {"sender_id": None}))
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
process_row = mocker.patch('app.celery.scheduled_tasks.process_row')
job = create_job(template=sample_email_template,
@@ -506,7 +506,7 @@ def test_check_for_missing_rows_in_completed_jobs_calls_save_email(mocker, sampl
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('multiple_email'), {'sender_id': None}))
save_email_task = mocker.patch('app.celery.tasks.save_email.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value='uuid')
job = create_job(template=sample_email_template,

View File

@@ -191,7 +191,7 @@ def _set_up_data_for_status_update(callback_api, notification):
"template_id": str(notification.template_id),
"template_version": notification.template_version,
}
encrypted_status_update = encryption.sign(data)
encrypted_status_update = encryption.encrypt(data)
return encrypted_status_update
@@ -205,5 +205,5 @@ def _set_up_data_for_complaint(callback_api, complaint, notification):
"service_callback_api_url": callback_api.url,
"service_callback_api_bearer_token": callback_api.bearer_token,
}
obscured_status_update = encryption.sign(data)
obscured_status_update = encryption.encrypt(data)
return obscured_status_update

View File

@@ -109,7 +109,7 @@ def test_should_process_sms_job(sample_job, mocker):
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('sms'), {'sender_id': None}))
mocker.patch('app.celery.tasks.save_sms.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
process_job(sample_job.id)
@@ -117,11 +117,11 @@ def test_should_process_sms_job(sample_job, mocker):
service_id=str(sample_job.service.id),
job_id=str(sample_job.id)
)
assert encryption.sign.call_args[0][0]['to'] == '+441234123123'
assert encryption.sign.call_args[0][0]['template'] == str(sample_job.template.id)
assert encryption.sign.call_args[0][0]['template_version'] == sample_job.template.version
assert encryption.sign.call_args[0][0]['personalisation'] == {'phonenumber': '+441234123123'}
assert encryption.sign.call_args[0][0]['row_number'] == 0
assert encryption.encrypt.call_args[0][0]['to'] == '+441234123123'
assert encryption.encrypt.call_args[0][0]['template'] == str(sample_job.template.id)
assert encryption.encrypt.call_args[0][0]['template_version'] == sample_job.template.version
assert encryption.encrypt.call_args[0][0]['personalisation'] == {'phonenumber': '+441234123123'}
assert encryption.encrypt.call_args[0][0]['row_number'] == 0
tasks.save_sms.apply_async.assert_called_once_with(
(str(sample_job.service_id),
"uuid",
@@ -137,7 +137,7 @@ def test_should_process_sms_job_with_sender_id(sample_job, mocker, fake_uuid):
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('sms'), {'sender_id': fake_uuid}))
mocker.patch('app.celery.tasks.save_sms.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
process_job(sample_job.id, sender_id=fake_uuid)
@@ -211,7 +211,7 @@ def test_should_process_job_if_send_limits_are_not_exceeded(
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('multiple_email'), {"sender_id": None}))
mocker.patch('app.celery.tasks.save_email.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
mocker.patch('app.celery.tasks.check_service_over_daily_message_limit', return_value=0)
process_job(job.id)
@@ -255,7 +255,7 @@ def test_should_process_email_job(email_job_with_placeholders, mocker):
"""
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3', return_value=(email_csv, {"sender_id": None}))
mocker.patch('app.celery.tasks.save_email.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
process_job(email_job_with_placeholders.id)
@@ -264,10 +264,10 @@ def test_should_process_email_job(email_job_with_placeholders, mocker):
service_id=str(email_job_with_placeholders.service.id),
job_id=str(email_job_with_placeholders.id)
)
assert encryption.sign.call_args[0][0]['to'] == 'test@test.com'
assert encryption.sign.call_args[0][0]['template'] == str(email_job_with_placeholders.template.id)
assert encryption.sign.call_args[0][0]['template_version'] == email_job_with_placeholders.template.version
assert encryption.sign.call_args[0][0]['personalisation'] == {'emailaddress': 'test@test.com', 'name': 'foo'}
assert encryption.encrypt.call_args[0][0]['to'] == 'test@test.com'
assert encryption.encrypt.call_args[0][0]['template'] == str(email_job_with_placeholders.template.id)
assert encryption.encrypt.call_args[0][0]['template_version'] == email_job_with_placeholders.template.version
assert encryption.encrypt.call_args[0][0]['personalisation'] == {'emailaddress': 'test@test.com', 'name': 'foo'}
tasks.save_email.apply_async.assert_called_once_with(
(
str(email_job_with_placeholders.service_id),
@@ -287,7 +287,7 @@ def test_should_process_email_job_with_sender_id(email_job_with_placeholders, mo
"""
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3', return_value=(email_csv, {"sender_id": fake_uuid}))
mocker.patch('app.celery.tasks.save_email.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
process_job(email_job_with_placeholders.id, sender_id=fake_uuid)
@@ -341,7 +341,7 @@ def test_should_process_all_sms_job(sample_job_with_placeholdered_template,
mocker.patch('app.celery.tasks.s3.get_job_and_metadata_from_s3',
return_value=(load_example_csv('multiple_sms'), {"sender_id": None}))
mocker.patch('app.celery.tasks.save_sms.apply_async')
mocker.patch('app.encryption.sign', return_value="something_encrypted")
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
process_job(sample_job_with_placeholdered_template.id)
@@ -350,11 +350,11 @@ def test_should_process_all_sms_job(sample_job_with_placeholdered_template,
service_id=str(sample_job_with_placeholdered_template.service.id),
job_id=str(sample_job_with_placeholdered_template.id)
)
assert encryption.sign.call_args[0][0]['to'] == '+441234123120'
assert encryption.sign.call_args[0][0]['template'] == str(sample_job_with_placeholdered_template.template.id)
assert encryption.sign.call_args[0][0][
assert encryption.encrypt.call_args[0][0]['to'] == '+441234123120'
assert encryption.encrypt.call_args[0][0]['template'] == str(sample_job_with_placeholdered_template.template.id)
assert encryption.encrypt.call_args[0][0][
'template_version'] == sample_job_with_placeholdered_template.template.version # noqa
assert encryption.sign.call_args[0][0]['personalisation'] == {'phonenumber': '+441234123120', 'name': 'chris'}
assert encryption.encrypt.call_args[0][0]['personalisation'] == {'phonenumber': '+441234123120', 'name': 'chris'}
assert tasks.save_sms.apply_async.call_count == 10
job = jobs_dao.dao_get_job_by_id(sample_job_with_placeholdered_template.id)
assert job.job_status == 'finished'
@@ -374,7 +374,7 @@ def test_should_process_all_sms_job(sample_job_with_placeholdered_template,
def test_process_row_sends_letter_task(template_type, research_mode, expected_function, expected_queue, mocker):
mocker.patch('app.celery.tasks.create_uuid', return_value='noti_uuid')
task_mock = mocker.patch('app.celery.tasks.{}.apply_async'.format(expected_function))
encrypt_mock = mocker.patch('app.celery.tasks.encryption.sign')
encrypt_mock = mocker.patch('app.celery.tasks.encryption.encrypt')
template = Mock(id='template_id', template_type=template_type)
job = Mock(id='job_id', template_version='temp_vers')
service = Mock(id='service_id', research_mode=research_mode)
@@ -417,7 +417,7 @@ def test_process_row_sends_letter_task(template_type, research_mode, expected_fu
def test_process_row_when_sender_id_is_provided(mocker, fake_uuid):
mocker.patch('app.celery.tasks.create_uuid', return_value='noti_uuid')
task_mock = mocker.patch('app.celery.tasks.save_sms.apply_async')
encrypt_mock = mocker.patch('app.celery.tasks.encryption.sign')
encrypt_mock = mocker.patch('app.celery.tasks.encryption.encrypt')
template = Mock(id='template_id', template_type=SMS_TYPE)
job = Mock(id='job_id', template_version='temp_vers')
service = Mock(id='service_id', research_mode=False)
@@ -460,7 +460,7 @@ def test_should_send_template_to_correct_sms_task_and_persist(sample_template_wi
save_sms(
sample_template_with_placeholders.service_id,
uuid.uuid4(),
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -473,7 +473,6 @@ def test_should_send_template_to_correct_sms_task_and_persist(sample_template_wi
assert not persisted_notification.sent_by
assert not persisted_notification.job_id
assert persisted_notification.personalisation == {'name': 'Jo'}
assert persisted_notification._personalisation == encryption.sign({"name": "Jo"})
assert persisted_notification.notification_type == 'sms'
mocked_deliver_sms.assert_called_once_with(
[str(persisted_notification.id)],
@@ -495,7 +494,7 @@ def test_should_put_save_sms_task_in_research_mode_queue_if_research_mode_servic
save_sms(
template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
provider_tasks.deliver_sms.apply_async.assert_called_once_with(
@@ -514,7 +513,7 @@ def test_should_save_sms_if_restricted_service_and_valid_number(notify_db_sessio
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
notification_id = uuid.uuid4()
encrypt_notification = encryption.sign(notification)
encrypt_notification = encryption.encrypt(notification)
save_sms(
service.id,
notification_id,
@@ -550,7 +549,7 @@ def test_save_email_should_save_default_email_reply_to_text_on_notification(noti
save_email(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -568,7 +567,7 @@ def test_save_sms_should_save_default_smm_sender_notification_reply_to_text_on(n
save_sms(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -587,7 +586,7 @@ def test_should_not_save_sms_if_restricted_service_and_invalid_number(notify_db_
save_sms(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
assert provider_tasks.deliver_sms.apply_async.called is False
assert Notification.query.count() == 0
@@ -603,7 +602,7 @@ def test_should_not_save_email_if_restricted_service_and_invalid_email_address(n
save_email(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
assert Notification.query.count() == 0
@@ -625,7 +624,7 @@ def test_should_put_save_email_task_in_research_mode_queue_if_research_mode_serv
save_email(
template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -648,7 +647,7 @@ def test_should_save_sms_template_to_and_persist_with_job_id(sample_job, mocker)
save_sms(
sample_job.service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
assert persisted_notification.to == '+447234123123'
@@ -685,7 +684,7 @@ def test_should_not_save_sms_if_team_key_and_recipient_not_in_team(notify_db_ses
save_sms(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
assert provider_tasks.deliver_sms.apply_async.called is False
assert Notification.query.count() == 0
@@ -708,7 +707,7 @@ def test_should_use_email_template_and_persist(sample_email_template_with_placeh
save_email(
sample_email_template_with_placeholders.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -721,7 +720,6 @@ def test_should_use_email_template_and_persist(sample_email_template_with_placeh
assert not persisted_notification.sent_by
assert persisted_notification.job_row_number == 1
assert persisted_notification.personalisation == {'name': 'Jo'}
assert persisted_notification._personalisation == encryption.sign({"name": "Jo"})
assert persisted_notification.api_key_id is None
assert persisted_notification.key_type == KEY_TYPE_NORMAL
assert persisted_notification.notification_type == 'email'
@@ -747,7 +745,7 @@ def test_save_email_should_use_template_version_from_job_not_latest(sample_email
save_email(
sample_email_template.service_id,
uuid.uuid4(),
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -773,7 +771,7 @@ def test_should_use_email_template_subject_placeholders(sample_email_template_wi
save_email(
sample_email_template_with_placeholders.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
assert persisted_notification.to == 'my_email@my_email.com'
@@ -802,7 +800,7 @@ def test_save_email_uses_the_reply_to_text_when_provided(sample_email_template,
save_email(
sample_email_template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
sender_id=other_email_reply_to.id,
)
persisted_notification = Notification.query.one()
@@ -821,7 +819,7 @@ def test_save_email_uses_the_default_reply_to_text_if_sender_id_is_none(sample_e
save_email(
sample_email_template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
sender_id=None,
)
persisted_notification = Notification.query.one()
@@ -839,7 +837,7 @@ def test_should_use_email_template_and_persist_without_personalisation(sample_em
save_email(
sample_email_template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
assert persisted_notification.to == 'my_email@my_email.com'
@@ -870,7 +868,7 @@ def test_save_sms_should_go_to_retry_queue_if_database_errors(sample_template, m
save_sms(
sample_template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
assert provider_tasks.deliver_sms.apply_async.called is False
tasks.save_sms.retry.assert_called_with(exc=expected_exception, queue="retry-tasks")
@@ -893,7 +891,7 @@ def test_save_email_should_go_to_retry_queue_if_database_errors(sample_email_tem
save_email(
sample_email_template.service_id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
assert not provider_tasks.deliver_email.apply_async.called
tasks.save_email.retry.assert_called_with(exc=expected_exception, queue="retry-tasks")
@@ -911,7 +909,7 @@ def test_save_email_does_not_send_duplicate_and_does_not_put_in_retry_queue(samp
save_email(
sample_notification.service_id,
notification_id,
encryption.sign(json),
encryption.encrypt(json),
)
assert Notification.query.count() == 1
assert not deliver_email.called
@@ -928,7 +926,7 @@ def test_save_sms_does_not_send_duplicate_and_does_not_put_in_retry_queue(sample
save_sms(
sample_notification.service_id,
notification_id,
encryption.sign(json),
encryption.encrypt(json),
)
assert Notification.query.count() == 1
assert not deliver_sms.called
@@ -998,7 +996,7 @@ def test_save_letter_saves_letter_to_database(
save_letter(
job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification_db = Notification.query.one()
@@ -1042,7 +1040,7 @@ def test_save_letter_saves_letter_to_database_with_correct_postage(
save_letter(
letter_job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification_db = Notification.query.one()
@@ -1075,7 +1073,7 @@ def test_save_letter_saves_letter_to_database_with_correct_client_reference(
save_letter(
letter_job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification_db = Notification.query.one()
@@ -1100,7 +1098,7 @@ def test_save_letter_saves_letter_to_database_with_formatted_postcode(mocker, no
save_letter(
letter_job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification_db = Notification.query.one()
@@ -1139,7 +1137,7 @@ def test_save_letter_saves_letter_to_database_right_reply_to(mocker, notify_db_s
save_letter(
job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification_db = Notification.query.one()
@@ -1201,7 +1199,7 @@ def test_save_letter_uses_template_reply_to_text(mocker, notify_db_session):
save_letter(
job.service_id,
uuid.uuid4(),
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification_db = Notification.query.one()
@@ -1219,7 +1217,7 @@ def test_save_sms_uses_sms_sender_reply_to_text(mocker, notify_db_session):
save_sms(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
)
persisted_notification = Notification.query.one()
@@ -1238,7 +1236,7 @@ def test_save_sms_uses_non_default_sms_sender_reply_to_text_if_provided(mocker,
save_sms(
service.id,
notification_id,
encryption.sign(notification),
encryption.encrypt(notification),
sender_id=new_sender.id,
)
@@ -1276,7 +1274,7 @@ def test_save_letter_sets_delivered_letters_as_pdf_permission_in_research_mode_i
save_letter(
sample_letter_job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
notification = Notification.query.filter(Notification.id == notification_id).one()
@@ -1314,7 +1312,7 @@ def test_save_letter_calls_create_fake_response_for_letters_in_research_mode_on_
save_letter(
sample_letter_job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
mock_create_fake_letter_response_file.assert_called_once_with(
@@ -1345,7 +1343,7 @@ def test_save_letter_calls_get_pdf_for_templated_letter_task_not_in_research(
save_letter(
sample_letter_job.service_id,
notification_id,
encryption.sign(notification_json),
encryption.encrypt(notification_json),
)
assert mock_create_letters_pdf.called
@@ -1843,7 +1841,7 @@ def test_save_api_email_or_sms(mocker, sample_service, notification_type):
data.update({"to": "+447700900855"})
expected_queue = QueueNames.SEND_SMS
encrypted = encryption.sign(
encrypted = encryption.encrypt(
data
)
@@ -1890,7 +1888,7 @@ def test_save_api_email_dont_retry_if_notification_already_exists(sample_service
data.update({"to": "+447700900855"})
expected_queue = QueueNames.SEND_SMS
encrypted = encryption.sign(
encrypted = encryption.encrypt(
data
)
assert len(Notification.query.all()) == 0
@@ -1953,7 +1951,7 @@ def test_save_tasks_use_cached_service_and_template(
task_function(
service.id,
uuid.uuid4(),
encryption.sign(notification),
encryption.encrypt(notification),
)
# We talk to the database once for the service and once for the
@@ -1995,7 +1993,7 @@ def test_save_api_tasks_use_cache(
api_key = create_api_key(service=template.service)
def create_encrypted_notification():
return encryption.sign({
return encryption.encrypt({
"to": recipient,
"id": str(uuid.uuid4()),
"template_id": str(template.id),

View File

@@ -40,7 +40,7 @@ def test_save_service_callback_api(sample_service):
assert versioned.service_id == sample_service.id
assert versioned.updated_by_id == sample_service.users[0].id
assert versioned.url == "https://some_service/callback_endpoint"
assert encryption.verify_signature(versioned._bearer_token) == "some_unique_string"
assert encryption.decrypt(versioned._bearer_token) == "some_unique_string"
assert versioned.updated_at is None
assert versioned.version == 1
@@ -140,7 +140,7 @@ def test_update_service_callback_api(sample_service):
assert x.id is not None
assert x.service_id == sample_service.id
assert x.updated_by_id == sample_service.users[0].id
assert encryption.verify_signature(x._bearer_token) == "some_unique_string"
assert encryption.decrypt(x._bearer_token) == "some_unique_string"
def test_get_service_callback_api(sample_service):

View File

@@ -40,7 +40,7 @@ def test_save_service_inbound_api(sample_service):
assert versioned.service_id == sample_service.id
assert versioned.updated_by_id == sample_service.users[0].id
assert versioned.url == "https://some_service/inbound_messages"
assert encryption.verify_signature(versioned._bearer_token) == "some_unique_string"
assert encryption.decrypt(versioned._bearer_token) == "some_unique_string"
assert versioned.updated_at is None
assert versioned.version == 1
@@ -97,7 +97,7 @@ def test_update_service_inbound_api(sample_service):
assert x.id is not None
assert x.service_id == sample_service.id
assert x.updated_by_id == sample_service.users[0].id
assert encryption.verify_signature(x._bearer_token) == "some_unique_string"
assert encryption.decrypt(x._bearer_token) == "some_unique_string"
def test_get_service_inbound_api(sample_service):

View File

@@ -154,9 +154,9 @@ def test_notification_personalisation_getter_returns_empty_dict_from_None():
assert noti.personalisation == {}
def test_notification_personalisation_getter_always_returns_empty_dict():
def test_notification_personalisation_getter_always_returns_empty_dict(notify_api):
noti = Notification()
noti._personalisation = encryption.sign({})
noti._personalisation = encryption.encrypt({})
assert noti.personalisation == {}
@@ -164,11 +164,11 @@ def test_notification_personalisation_getter_always_returns_empty_dict():
None,
{}
])
def test_notification_personalisation_setter_always_sets_empty_dict(input_value):
def test_notification_personalisation_setter_always_sets_empty_dict(notify_api, input_value):
noti = Notification()
noti.personalisation = input_value
assert noti._personalisation == encryption.sign({})
assert noti.personalisation == {}
def test_notification_subject_is_none_for_sms(sample_service):