mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-26 20:41:53 -05:00
remove check_rate_limiting
This commit is contained in:
@@ -18,7 +18,6 @@ from app.notifications.process_notifications import (
|
||||
from app.notifications.validators import (
|
||||
check_if_service_can_send_files_by_email,
|
||||
check_is_message_too_long,
|
||||
check_rate_limiting,
|
||||
check_service_email_reply_to_id,
|
||||
check_service_has_permission,
|
||||
check_service_sms_sender_id,
|
||||
@@ -54,8 +53,6 @@ def post_notification(notification_type):
|
||||
|
||||
check_service_has_permission(notification_type, authenticated_service.permissions)
|
||||
|
||||
check_rate_limiting(authenticated_service, api_user)
|
||||
|
||||
template, template_with_content = validate_template(
|
||||
form["template_id"],
|
||||
form.get("personalisation", {}),
|
||||
|
||||
@@ -14,7 +14,7 @@ from app.dao.api_key_dao import save_model_api_key
|
||||
from app.dao.services_dao import dao_update_service
|
||||
from app.dao.templates_dao import dao_get_all_templates_for_service, dao_update_template
|
||||
from app.enums import KeyType, NotificationType, TemplateType
|
||||
from app.errors import InvalidRequest, RateLimitError
|
||||
from app.errors import InvalidRequest
|
||||
from app.models import ApiKey, Notification, NotificationHistory, Template
|
||||
from app.service.send_notification import send_one_off_notification
|
||||
from notifications_utils import SMS_CHAR_COUNT_LIMIT
|
||||
@@ -1124,51 +1124,6 @@ def test_create_template_raises_invalid_request_when_content_too_large(
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"notification_type, send_to",
|
||||
[
|
||||
(NotificationType.SMS, "2028675309"),
|
||||
(
|
||||
NotificationType.EMAIL,
|
||||
"sample@email.com",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_returns_a_429_limit_exceeded_if_rate_limit_exceeded(
|
||||
client, sample_service, mocker, notification_type, send_to
|
||||
):
|
||||
sample = create_template(sample_service, template_type=notification_type)
|
||||
persist_mock = mocker.patch("app.notifications.rest.persist_notification")
|
||||
deliver_mock = mocker.patch("app.notifications.rest.send_notification_to_queue")
|
||||
|
||||
mocker.patch(
|
||||
"app.notifications.rest.check_rate_limiting",
|
||||
side_effect=RateLimitError("LIMIT", "INTERVAL", "TYPE"),
|
||||
)
|
||||
|
||||
data = {"to": send_to, "template": str(sample.id)}
|
||||
|
||||
auth_header = create_service_authorization_header(service_id=sample.service_id)
|
||||
|
||||
response = client.post(
|
||||
path=f"/notifications/{notification_type}",
|
||||
data=json.dumps(data),
|
||||
headers=[("Content-Type", "application/json"), auth_header],
|
||||
)
|
||||
|
||||
message = json.loads(response.data)["message"]
|
||||
result = json.loads(response.data)["result"]
|
||||
assert response.status_code == 429
|
||||
assert result == "error"
|
||||
assert message == (
|
||||
"Exceeded rate limit for key type TYPE of LIMIT "
|
||||
"requests per INTERVAL seconds"
|
||||
)
|
||||
|
||||
assert not persist_mock.called
|
||||
assert not deliver_mock.called
|
||||
|
||||
|
||||
def test_should_allow_store_original_number_on_sms_notification(
|
||||
client, sample_template, mocker
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user