mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
Merge branch 'master' into rate-limit-api-calls
Conflicts: requirements.txt tests/app/notifications/rest/test_send_notification.py tests/app/notifications/test_validators.py tests/app/v2/notifications/test_post_notifications.py
This commit is contained in:
@@ -8,7 +8,10 @@ from app.notifications.validators import (
|
||||
check_template_is_active,
|
||||
service_can_send_to_recipient,
|
||||
check_sms_content_char_count,
|
||||
check_service_over_api_rate_limit)
|
||||
check_service_over_api_rate_limit,
|
||||
validate_and_format_recipient
|
||||
)
|
||||
|
||||
from app.v2.errors import (
|
||||
BadRequestError,
|
||||
TooManyRequestsError,
|
||||
@@ -337,3 +340,19 @@ def test_should_not_rate_limit_if_limiting_is_disabled(
|
||||
|
||||
check_service_over_api_rate_limit(service, api_key)
|
||||
assert not app.redis_store.exceeded_rate_limit.called
|
||||
|
||||
|
||||
@pytest.mark.parametrize('key_type', ['test', 'normal'])
|
||||
def test_rejects_api_calls_with_international_numbers_if_service_does_not_allow_int_sms(sample_service, key_type):
|
||||
with pytest.raises(BadRequestError) as e:
|
||||
validate_and_format_recipient('20-12-1234-1234', key_type, sample_service, 'sms')
|
||||
assert e.value.status_code == 400
|
||||
assert e.value.message == 'Cannot send to international mobile numbers'
|
||||
assert e.value.fields == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('key_type', ['test', 'normal'])
|
||||
def test_allows_api_calls_with_international_numbers_if_service_does_allow_int_sms(sample_service, key_type):
|
||||
sample_service.can_send_international_sms = True
|
||||
result = validate_and_format_recipient('20-12-1234-1234', key_type, sample_service, 'sms')
|
||||
assert result == '201212341234'
|
||||
|
||||
Reference in New Issue
Block a user