mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
statuspage: Raise AnomalousWebhookPayloadError on other events.
Their documentation only describes these two event types.
This commit is contained in:
committed by
Tim Abbott
parent
bda6a4b7e4
commit
c4085d1b8a
@@ -43,3 +43,13 @@ class StatuspageHookTests(WebhookTestCase):
|
|||||||
expected_message,
|
expected_message,
|
||||||
content_type="application/x-www-form-urlencoded",
|
content_type="application/x-www-form-urlencoded",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_statuspage_anomalous_payload(self) -> None:
|
||||||
|
result = self.client_post(
|
||||||
|
self.url,
|
||||||
|
{},
|
||||||
|
content_type="application/json",
|
||||||
|
)
|
||||||
|
self.assert_json_error(
|
||||||
|
result, "Unable to parse request: Did Statuspage generate this event?", 400
|
||||||
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
|
||||||
from zerver.decorator import webhook_view
|
from zerver.decorator import webhook_view
|
||||||
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
|
from zerver.lib.exceptions import AnomalousWebhookPayloadError
|
||||||
from zerver.lib.response import json_success
|
from zerver.lib.response import json_success
|
||||||
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
|
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
|
||||||
from zerver.lib.validator import WildValue, check_string
|
from zerver.lib.validator import WildValue, check_string
|
||||||
@@ -69,7 +69,7 @@ def api_statuspage_webhook(
|
|||||||
topic = get_component_topic(payload)
|
topic = get_component_topic(payload)
|
||||||
body = get_components_update_body(payload)
|
body = get_components_update_body(payload)
|
||||||
else:
|
else:
|
||||||
raise UnsupportedWebhookEventTypeError("unknown-event")
|
raise AnomalousWebhookPayloadError
|
||||||
|
|
||||||
check_send_webhook_message(request, user_profile, topic, body, event)
|
check_send_webhook_message(request, user_profile, topic, body, event)
|
||||||
return json_success(request)
|
return json_success(request)
|
||||||
|
|||||||
Reference in New Issue
Block a user