def test_webhook_http_header_header_does_not_exist(self) -> None: webhook_bot = get_user('*****@*****.**', get_realm('zulip')) webhook_bot.last_reminder = None notification_bot = self.notification_bot() request = HostRequestMock() request.user = webhook_bot request.path = 'some/random/path' exception_msg = "Missing the HTTP event header 'X_CUSTOM_HEADER'" with self.assertRaisesRegex(MissingHTTPEventHeader, exception_msg): validate_extract_webhook_http_header(request, 'X_CUSTOM_HEADER', 'test_webhook') msg = self.get_last_message() expected_message = MISSING_EVENT_HEADER_MESSAGE.format( bot_name=webhook_bot.full_name, request_path=request.path, header_name='X_CUSTOM_HEADER', integration_name='test_webhook', support_email=FromAddress.SUPPORT).rstrip() self.assertEqual(msg.sender.email, notification_bot.email) self.assertEqual(msg.content, expected_message)
def test_webhook_http_header_header_does_not_exist(self) -> None: webhook_bot = get_user('*****@*****.**', get_realm('zulip')) webhook_bot.last_reminder = None notification_bot = self.notification_bot() request = HostRequestMock() request.user = webhook_bot request.path = 'some/random/path' exception_msg = "Missing the HTTP event header 'X_CUSTOM_HEADER'" with self.assertRaisesRegex(MissingHTTPEventHeader, exception_msg): validate_extract_webhook_http_header(request, 'X_CUSTOM_HEADER', 'test_webhook') msg = self.get_last_message() expected_message = MISSING_EVENT_HEADER_MESSAGE.format( bot_name=webhook_bot.full_name, request_path=request.path, header_name='X_CUSTOM_HEADER', integration_name='test_webhook', support_email=FromAddress.SUPPORT ).rstrip() self.assertEqual(msg.sender.email, notification_bot.email) self.assertEqual(msg.content, expected_message)
def test_webhook_http_header_header_does_not_exist(self) -> None: realm = get_realm("zulip") webhook_bot = get_user("*****@*****.**", realm) webhook_bot.last_reminder = None notification_bot = self.notification_bot(realm) request = HostRequestMock() request.user = webhook_bot request.path = "some/random/path" exception_msg = "Missing the HTTP event header 'X-Custom-Header'" with self.assertRaisesRegex(MissingHTTPEventHeader, exception_msg): validate_extract_webhook_http_header(request, "X-Custom-Header", "test_webhook") msg = self.get_last_message() expected_message = MISSING_EVENT_HEADER_MESSAGE.format( bot_name=webhook_bot.full_name, request_path=request.path, header_name="X-Custom-Header", integration_name="test_webhook", support_email=FromAddress.SUPPORT, ).rstrip() self.assertEqual(msg.sender.id, notification_bot.id) self.assertEqual(msg.content, expected_message)