mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -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')
|
@notify_celery.task(name='send-sms-code')
|
||||||
def send_sms_code(encrypted_notification):
|
def send_sms_code(encrypted_verification):
|
||||||
notification = encryption.decrypt(encrypted_notification)
|
verification_message = encryption.decrypt(encrypted_verification)
|
||||||
|
|
||||||
try:
|
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:
|
except FiretextClientException as e:
|
||||||
current_app.logger.debug(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'))
|
create_user_code(user, secret_code, verify_code.get('code_type'))
|
||||||
if verify_code.get('code_type') == 'sms':
|
if verify_code.get('code_type') == 'sms':
|
||||||
mobile = user.mobile_number if verify_code.get('to', None) is None else verify_code.get('to')
|
mobile = user.mobile_number if verify_code.get('to', None) is None else verify_code.get('to')
|
||||||
notification = {'to': mobile, 'secret_code': secret_code}
|
verification_message = {'to': mobile, 'secret_code': secret_code}
|
||||||
send_sms_code.apply_async([encryption.encrypt(notification)], queue='sms_code')
|
send_sms_code.apply_async([encryption.encrypt(verification_message)], queue='sms_code')
|
||||||
elif verify_code.get('code_type') == 'email':
|
elif verify_code.get('code_type') == 'email':
|
||||||
email = user.email_address if verify_code.get('to', None) is None else verify_code.get('to')
|
email = user.email_address if verify_code.get('to', None) is None else verify_code.get('to')
|
||||||
notification = {
|
verification_message = {
|
||||||
'to_address': email,
|
'to_address': email,
|
||||||
'from_address': current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS'],
|
'from_address': current_app.config['VERIFY_CODE_FROM_EMAIL_ADDRESS'],
|
||||||
'subject': 'Verification code',
|
'subject': 'Verification code',
|
||||||
'body': secret_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:
|
else:
|
||||||
abort(500)
|
abort(500)
|
||||||
return jsonify({}), 204
|
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'])
|
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',
|
notification = {'to': '+441234123123',
|
||||||
'secret_code': '12345'}
|
'secret_code': '12345'}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user