mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Send text message that are to an international number from a number rather than "Notify"
Update `send_user_2fa_code` to send from number when recipient is international Update `update_user_attribute` to send from number when recipient is international
This commit is contained in:
@@ -4,7 +4,7 @@ import mock
|
||||
from uuid import UUID
|
||||
from datetime import datetime
|
||||
|
||||
from flask import url_for
|
||||
from flask import url_for, current_app
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.models import (
|
||||
@@ -310,6 +310,28 @@ def test_post_user_attribute_with_updated_by(
|
||||
mock_persist_notification.assert_not_called()
|
||||
|
||||
|
||||
def test_post_user_attribute_with_updated_by_sends_notification_to_international_from_number(
|
||||
client, mocker, sample_user, team_member_mobile_edit_template
|
||||
):
|
||||
updater = create_user(name="Service Manago")
|
||||
update_dict = {
|
||||
'mobile_number': '601117224412',
|
||||
'updated_by': str(updater.id)
|
||||
}
|
||||
auth_header = create_authorization_header()
|
||||
headers = [('Content-Type', 'application/json'), auth_header]
|
||||
mocker.patch('app.user.rest.send_notification_to_queue')
|
||||
resp = client.post(
|
||||
url_for('user.update_user_attribute', user_id=sample_user.id),
|
||||
data=json.dumps(update_dict),
|
||||
headers=headers)
|
||||
|
||||
assert resp.status_code == 200, resp.get_data(as_text=True)
|
||||
|
||||
notification = Notification.query.first()
|
||||
assert notification.reply_to_text == current_app.config['NOTIFY_NUMBER_SMS_SENDER']
|
||||
|
||||
|
||||
def test_archive_user(mocker, client, sample_user):
|
||||
archive_mock = mocker.patch('app.user.rest.dao_archive_user')
|
||||
|
||||
|
||||
@@ -477,3 +477,21 @@ def test_user_verify_email_code_fails_if_code_already_used(admin_request, sample
|
||||
assert verify_code.code_used
|
||||
assert sample_user.logged_in_at is None
|
||||
assert sample_user.current_session_id is None
|
||||
|
||||
|
||||
def test_send_user_2fa_code_sends_from_number_for_international_numbers(
|
||||
client, sample_user, mocker, sms_code_template
|
||||
):
|
||||
sample_user.mobile_number = "601117224412"
|
||||
auth_header = create_authorization_header()
|
||||
mocker.patch('app.user.rest.create_secret_code', return_value='11111')
|
||||
mocker.patch('app.user.rest.send_notification_to_queue')
|
||||
|
||||
resp = client.post(
|
||||
url_for('user.send_user_2fa_code', code_type='sms', user_id=sample_user.id),
|
||||
data=json.dumps({}),
|
||||
headers=[('Content-Type', 'application/json'), auth_header])
|
||||
assert resp.status_code == 204
|
||||
|
||||
notification = Notification.query.first()
|
||||
assert notification.reply_to_text == current_app.config['NOTIFY_NUMBER_SMS_SENDER']
|
||||
|
||||
Reference in New Issue
Block a user