mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Don’t 500 when searching with bad email address
In the future we might want to validate email addresses before attempting to search by them. But for a first pass we can just return no results when a user types in something that isn’t an email address or phone number. It definitely better than returning a 500.
This commit is contained in:
@@ -1772,6 +1772,20 @@ def test_dao_get_notifications_by_to_field_search_is_not_case_sensitive(sample_t
|
||||
assert notification.id in notification_ids
|
||||
|
||||
|
||||
@pytest.mark.parametrize('to', [
|
||||
'not@email', '123'
|
||||
])
|
||||
def test_dao_get_notifications_by_to_field_accepts_invalid_phone_numbers_and_email_addresses(
|
||||
sample_template,
|
||||
to,
|
||||
):
|
||||
notification = create_notification(
|
||||
template=sample_template, to_field='test@example.com', normalised_to='test@example.com'
|
||||
)
|
||||
results = dao_get_notifications_by_to_field(notification.service_id, to)
|
||||
assert len(results) == 0
|
||||
|
||||
|
||||
def test_dao_get_notifications_by_to_field_search_ignores_spaces(sample_template):
|
||||
notification1 = create_notification(
|
||||
template=sample_template, to_field='+447700900855', normalised_to='447700900855'
|
||||
|
||||
Reference in New Issue
Block a user