mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-17 18:52:30 -05:00
add reply-to-text to user/rest persist notifications
This commit is contained in:
@@ -159,7 +159,6 @@ def get_reply_to_text(notification_type):
|
||||
return authenticated_service.get_default_letter_contact()
|
||||
|
||||
|
||||
|
||||
def get_notification_return_data(notification_id, notification, template):
|
||||
output = {
|
||||
'body': str(template),
|
||||
|
||||
@@ -223,7 +223,8 @@ def create_2fa_code(template_id, user_to_send_to, secret_code, recipient, person
|
||||
personalisation=personalisation,
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=template.service.get_default_sms_sender()
|
||||
)
|
||||
# Assume that we never want to observe the Notify service's research mode
|
||||
# setting for this notification - we still need to be able to log into the
|
||||
@@ -253,7 +254,8 @@ def send_user_confirm_new_email(user_id):
|
||||
},
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=service.get_default_reply_to_email_address()
|
||||
)
|
||||
|
||||
send_notification_to_queue(saved_notification, False, queue=QueueNames.NOTIFY)
|
||||
@@ -279,7 +281,8 @@ def send_new_user_email_verification(user_id):
|
||||
},
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=service.get_default_reply_to_email_address()
|
||||
)
|
||||
|
||||
send_notification_to_queue(saved_notification, False, queue=QueueNames.NOTIFY)
|
||||
@@ -305,7 +308,8 @@ def send_already_registered_email(user_id):
|
||||
},
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=service.get_default_reply_to_email_address()
|
||||
)
|
||||
|
||||
send_notification_to_queue(saved_notification, False, queue=QueueNames.NOTIFY)
|
||||
@@ -367,7 +371,8 @@ def send_user_reset_password():
|
||||
},
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
reply_to_text=service.get_default_reply_to_email_address()
|
||||
)
|
||||
|
||||
send_notification_to_queue(saved_notification, False, queue=QueueNames.NOTIFY)
|
||||
|
||||
@@ -347,6 +347,7 @@ def test_send_user_reset_password_should_send_reset_password_link(client,
|
||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||
data = json.dumps({'email': sample_user.email_address})
|
||||
auth_header = create_authorization_header()
|
||||
notify_service = password_reset_email_template.service
|
||||
resp = client.post(
|
||||
url_for('user.send_user_reset_password'),
|
||||
data=data,
|
||||
@@ -355,6 +356,7 @@ def test_send_user_reset_password_should_send_reset_password_link(client,
|
||||
assert resp.status_code == 204
|
||||
notification = Notification.query.first()
|
||||
mocked.assert_called_once_with([str(notification.id)], queue="notify-internal-tasks")
|
||||
assert notification.reply_to_text == notify_service.get_default_reply_to_email_address()
|
||||
|
||||
|
||||
def test_send_user_reset_password_should_return_400_when_email_is_missing(client, mocker):
|
||||
@@ -408,6 +410,7 @@ def test_send_already_registered_email(client, sample_user, already_registered_t
|
||||
data = json.dumps({'email': sample_user.email_address})
|
||||
auth_header = create_authorization_header()
|
||||
mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async')
|
||||
notify_service = already_registered_template.service
|
||||
|
||||
resp = client.post(
|
||||
url_for('user.send_already_registered_email', user_id=str(sample_user.id)),
|
||||
@@ -417,6 +420,7 @@ def test_send_already_registered_email(client, sample_user, already_registered_t
|
||||
|
||||
notification = Notification.query.first()
|
||||
mocked.assert_called_once_with(([str(notification.id)]), queue="notify-internal-tasks")
|
||||
assert notification.reply_to_text == notify_service.get_default_reply_to_email_address()
|
||||
|
||||
|
||||
def test_send_already_registered_email_returns_400_when_data_is_missing(client, sample_user):
|
||||
@@ -436,6 +440,7 @@ def test_send_user_confirm_new_email_returns_204(client, sample_user, change_ema
|
||||
new_email = 'new_address@dig.gov.uk'
|
||||
data = json.dumps({'email': new_email})
|
||||
auth_header = create_authorization_header()
|
||||
notify_service = change_email_confirmation_template.service
|
||||
|
||||
resp = client.post(url_for('user.send_user_confirm_new_email', user_id=str(sample_user.id)),
|
||||
data=data,
|
||||
@@ -445,6 +450,7 @@ def test_send_user_confirm_new_email_returns_204(client, sample_user, change_ema
|
||||
mocked.assert_called_once_with(
|
||||
([str(notification.id)]),
|
||||
queue="notify-internal-tasks")
|
||||
assert notification.reply_to_text == notify_service.get_default_reply_to_email_address()
|
||||
|
||||
|
||||
def test_send_user_confirm_new_email_returns_400_when_email_missing(client, sample_user, mocker):
|
||||
|
||||
@@ -175,8 +175,8 @@ def test_send_user_sms_code(client,
|
||||
"""
|
||||
Tests POST endpoint /user/<user_id>/sms-code
|
||||
"""
|
||||
if research_mode:
|
||||
notify_service = dao_fetch_service_by_id(current_app.config['NOTIFY_SERVICE_ID'])
|
||||
if research_mode:
|
||||
notify_service.research_mode = True
|
||||
dao_update_service(notify_service)
|
||||
|
||||
@@ -197,6 +197,7 @@ def test_send_user_sms_code(client,
|
||||
assert notification.personalisation == {'verify_code': '11111'}
|
||||
assert notification.to == sample_user.mobile_number
|
||||
assert str(notification.service_id) == current_app.config['NOTIFY_SERVICE_ID']
|
||||
assert notification.reply_to_text == notify_service.get_default_sms_sender()
|
||||
|
||||
app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with(
|
||||
([str(notification.id)]),
|
||||
@@ -274,10 +275,12 @@ def test_send_new_user_email_verification(client,
|
||||
url_for('user.send_new_user_email_verification', user_id=str(sample_user.id)),
|
||||
data=json.dumps({}),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
notify_service = email_verification_template.service
|
||||
assert resp.status_code == 204
|
||||
notification = Notification.query.first()
|
||||
assert VerifyCode.query.count() == 0
|
||||
mocked.assert_called_once_with(([str(notification.id)]), queue="notify-internal-tasks")
|
||||
assert notification.reply_to_text == notify_service.get_default_reply_to_email_address()
|
||||
|
||||
|
||||
def test_send_email_verification_returns_404_for_bad_input_data(client, notify_db_session, mocker):
|
||||
|
||||
Reference in New Issue
Block a user