mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Merge pull request #1562 from alphagov/fix-phone-validator-bug
Add validation to check that sms recipient is not None
This commit is contained in:
@@ -98,6 +98,9 @@ def check_service_can_schedule_notification(permissions, scheduled_for):
|
|||||||
|
|
||||||
|
|
||||||
def validate_and_format_recipient(send_to, key_type, service, notification_type):
|
def validate_and_format_recipient(send_to, key_type, service, notification_type):
|
||||||
|
if send_to is None:
|
||||||
|
raise BadRequestError(message="Recipient can't be empty")
|
||||||
|
|
||||||
service_can_send_to_recipient(send_to, key_type, service)
|
service_can_send_to_recipient(send_to, key_type, service)
|
||||||
|
|
||||||
if notification_type == SMS_TYPE:
|
if notification_type == SMS_TYPE:
|
||||||
|
|||||||
@@ -347,6 +347,13 @@ def test_allows_api_calls_with_international_numbers_if_service_does_allow_int_s
|
|||||||
assert result == '201212341234'
|
assert result == '201212341234'
|
||||||
|
|
||||||
|
|
||||||
|
def test_rejects_api_calls_with_no_recipient():
|
||||||
|
with pytest.raises(BadRequestError) as e:
|
||||||
|
validate_and_format_recipient(None, 'key_type', 'service', 'SMS_TYPE')
|
||||||
|
assert e.value.status_code == 400
|
||||||
|
assert e.value.message == "Recipient can't be empty"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('notification_type', ['sms', 'email', 'letter'])
|
@pytest.mark.parametrize('notification_type', ['sms', 'email', 'letter'])
|
||||||
def test_check_service_email_reply_to_id_where_reply_to_id_is_none(notification_type):
|
def test_check_service_email_reply_to_id_where_reply_to_id_is_none(notification_type):
|
||||||
assert check_service_email_reply_to_id(None, None, notification_type) is None
|
assert check_service_email_reply_to_id(None, None, notification_type) is None
|
||||||
|
|||||||
Reference in New Issue
Block a user