mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
webhooks: Add a system for storing http headers for integrations.
Using this system, we can now associate any fixture of any integration with a particular set of HTTP headers. A helper method called determine_http_headers was introduced, and the test suite was upgraded to use determine_http_headers. Comments and documentation significantly edited by tabbott.
This commit is contained in:
committed by
Tim Abbott
parent
1817f657ee
commit
7c145c3f68
@@ -23,6 +23,7 @@ from zerver.lib.initial_password import initial_password
|
||||
from zerver.lib.utils import is_remote_server
|
||||
from zerver.lib.users import get_api_key
|
||||
from zerver.lib.sessions import get_session_dict_user
|
||||
from zerver.lib.webhooks.common import get_fixture_http_headers, parse_headers_dict
|
||||
|
||||
from zerver.lib.actions import (
|
||||
check_send_message, create_stream_if_needed, bulk_add_subscriptions,
|
||||
@@ -751,6 +752,9 @@ class WebhookTestCase(ZulipTestCase):
|
||||
payload = self.get_body(fixture_name)
|
||||
if content_type is not None:
|
||||
kwargs['content_type'] = content_type
|
||||
headers = get_fixture_http_headers(self.FIXTURE_DIR_NAME, fixture_name)
|
||||
headers = parse_headers_dict(headers)
|
||||
kwargs.update(headers)
|
||||
msg = self.send_json_payload(self.test_user, self.url, payload,
|
||||
self.STREAM_NAME, **kwargs)
|
||||
self.do_test_topic(msg, expected_topic)
|
||||
@@ -764,7 +768,9 @@ class WebhookTestCase(ZulipTestCase):
|
||||
payload = self.get_body(fixture_name)
|
||||
if content_type is not None:
|
||||
kwargs['content_type'] = content_type
|
||||
|
||||
headers = get_fixture_http_headers(self.FIXTURE_DIR_NAME, fixture_name)
|
||||
headers = parse_headers_dict(headers)
|
||||
kwargs.update(headers)
|
||||
sender = kwargs.get('sender', self.test_user)
|
||||
msg = self.send_json_payload(sender, self.url, payload,
|
||||
stream_name=None, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user