Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integrations: Use directory name to get HTTP headers from fixtures.

Niloth P6a1d231689e0
diff --git a/tools/screenshots/generate-integration-docs-screenshot b/tools/screenshots/generate-integration-docs-screenshot
index c80b1f01408..ce5b4cab605 100755
--- a/tools/screenshots/generate-integration-docs-screenshot
+++ b/tools/screenshots/generate-integration-docs-screenshot
@@ -122,8 +122,8 @@ def get_fixture_info(fixture_path: str) -> tuple[Any, bool, bool, str]:
return data, json_fixture, multipart_fixture, fixture_name
-def get_requests_headers(integration_name: str, fixture_name: str) -> dict[str, Any]:
- headers = get_fixture_http_headers(integration_name, fixture_name)
+def get_requests_headers(integration_dir_name: str, fixture_name: str) -> dict[str, Any]:
+ headers = get_fixture_http_headers(integration_dir_name, fixture_name)
def fix_name(header: str) -> str:
return header.removeprefix("HTTP_").replace("_", "-")
@@ -153,7 +153,7 @@ def send_bot_payload_message(
Message.objects.filter(realm_id=bot.realm_id, sender=bot).delete()
data, json_fixture, multipart_fixture, fixture_name = get_fixture_info(fixture_path)
- headers = get_requests_headers(integration.name, fixture_name)
+ headers = get_requests_headers(integration.dir_name, fixture_name)
if config.custom_headers:
headers.update(config.custom_headers)
if config.use_basic_auth:
diff --git a/zerver/lib/webhooks/common.py b/zerver/lib/webhooks/common.py
index 0fd59c4a18b..5282d13129f 100644
--- a/zerver/lib/webhooks/common.py
+++ b/zerver/lib/webhooks/common.py
@@ -214,13 +214,13 @@ def validate_extract_webhook_http_header(
return extracted_header
-def get_fixture_http_headers(integration_name: str, fixture_name: str) -> dict["str", "str"]:
+def get_fixture_http_headers(integration_dir_name: str, fixture_name: str) -> dict["str", "str"]:
"""For integrations that require custom HTTP headers for some (or all)
of their test fixtures, this method will call a specially named
function from the target integration module to determine what set
of HTTP headers goes with the given test fixture.
"""
- view_module_name = f"zerver.webhooks.{integration_name}.view"
+ view_module_name = f"zerver.webhooks.{integration_dir_name}.view"
try:
# TODO: We may want to migrate to a more explicit registration
# strategy for this behavior rather than a try/except import.