From 134db206a9dda23129e914c2c73f56673b25e599 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 26 Mar 2021 21:36:31 -0700 Subject: [PATCH] outgoing_webhook: Set an X-Smokescreen-Role on requests. This header is used by the Smokescreen outgoing proxy to provide identification. --- zerver/lib/outgoing_webhook.py | 7 ++++++- zerver/tests/test_outgoing_webhook_system.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.py index 5dfba93488..7fa471166e 100644 --- a/zerver/lib/outgoing_webhook.py +++ b/zerver/lib/outgoing_webhook.py @@ -31,7 +31,12 @@ class OutgoingWebhookServiceInterface(metaclass=abc.ABCMeta): self.user_profile: UserProfile = user_profile self.service_name: str = service_name self.session: Session = Session() - self.session.headers.update({"User-Agent": "ZulipOutgoingWebhook/" + ZULIP_VERSION}) + self.session.headers.update( + { + "X-Smokescreen-Role": "webhook", + "User-Agent": "ZulipOutgoingWebhook/" + ZULIP_VERSION, + } + ) @abc.abstractmethod def make_request(self, base_url: str, event: Dict[str, Any]) -> Optional[Response]: diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py index 5d0224e224..148c0f5365 100644 --- a/zerver/tests/test_outgoing_webhook_system.py +++ b/zerver/tests/test_outgoing_webhook_system.py @@ -167,6 +167,7 @@ The webhook got a response with status code *400*.""", headers = { "Content-Type": "application/json", "User-Agent": user_agent, + "X-Smokescreen-Role": "webhook", } self.assertLessEqual(headers.items(), prepared_request.headers.items())