mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
Change names for clarity sake.
Rename test. What we do when the validation_code fails to send is still to be decided.
This commit is contained in:
@@ -33,10 +33,10 @@ def send_sms(service_id, notification_id, encrypted_notification):
|
||||
|
||||
|
||||
@notify_celery.task(name='send-sms-code')
|
||||
def send_sms_code(encrypted_notification):
|
||||
notification = encryption.decrypt(encrypted_notification)
|
||||
def send_sms_code(encrypted_verification):
|
||||
verification_message = encryption.decrypt(encrypted_verification)
|
||||
|
||||
try:
|
||||
firetext_client.send_sms(notification['to'], notification['secret_code'])
|
||||
firetext_client.send_sms(verification_message['to'], verification_message['secret_code'])
|
||||
except FiretextClientException as e:
|
||||
current_app.logger.debug(e)
|
||||
|
||||
@@ -137,16 +137,16 @@ def send_user_code(user_id):
|
||||
create_user_code(user, secret_code, verify_code.get('code_type'))
|
||||
if verify_code.get('code_type') == 'sms':
|
||||
mobile = user.mobile_number if verify_code.get('to', None) is None else verify_code.get('to')
|
||||
notification = {'to': mobile, 'secret_code': secret_code}
|
||||
send_sms_code.apply_async([encryption.encrypt(notification)], queue='sms_code')
|
||||
verification_message = {'to': mobile, 'secret_code': secret_code}
|
||||
send_sms_code.apply_async([encryption.encrypt(verification_message)], queue='sms_code')
|
||||
elif verify_code.get('code_type') == 'email':
|
||||
email = user.email_address if verify_code.get('to', None) is None else verify_code.get('to')
|
||||
notification = {
|
||||
verification_message = {
|
||||
'to_address': email,
|
||||
'from_address': current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS'],
|
||||
'subject': 'Verification code',
|
||||
'body': secret_code}
|
||||
add_notification_to_queue(api_user['client'], 'admin', 'email', notification)
|
||||
add_notification_to_queue(api_user['client'], 'admin', 'email', verification_message)
|
||||
else:
|
||||
abort(500)
|
||||
return jsonify({}), 204
|
||||
|
||||
@@ -90,7 +90,7 @@ def test_should_send_sms_code(mocker):
|
||||
firetext_client.send_sms.assert_called_once_with(notification['to'], notification['secret_code'])
|
||||
|
||||
|
||||
def test_should_log_firetext_client_exception(mocker):
|
||||
def test_should_throw_firetext_client_exception(mocker):
|
||||
notification = {'to': '+441234123123',
|
||||
'secret_code': '12345'}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user