outgoing_webhook: Set an X-Smokescreen-Role on requests.

This header is used by the Smokescreen outgoing proxy to provide
identification.
This commit is contained in:
Alex Vandiver 2021-03-26 21:36:31 -07:00 committed by Tim Abbott
parent bd37dc0b83
commit 134db206a9
2 changed files with 7 additions and 1 deletions

View File

@ -31,7 +31,12 @@ class OutgoingWebhookServiceInterface(metaclass=abc.ABCMeta):
self.user_profile: UserProfile = user_profile self.user_profile: UserProfile = user_profile
self.service_name: str = service_name self.service_name: str = service_name
self.session: Session = Session() 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 @abc.abstractmethod
def make_request(self, base_url: str, event: Dict[str, Any]) -> Optional[Response]: def make_request(self, base_url: str, event: Dict[str, Any]) -> Optional[Response]:

View File

@ -167,6 +167,7 @@ The webhook got a response with status code *400*.""",
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": user_agent, "User-Agent": user_agent,
"X-Smokescreen-Role": "webhook",
} }
self.assertLessEqual(headers.items(), prepared_request.headers.items()) self.assertLessEqual(headers.items(), prepared_request.headers.items())