settings: Rework how push notifications service is configured.

Instead of the PUSH_NOTIFICATIONS_BOUNCER_URL and
SUBMIT_USAGE_STATISTICS settings, we want servers to configure
individual ZULIP_SERVICE_* settings, while maintaining backward
compatibility with the old settings. Thus, if all the new
ZULIP_SERVICE_* are at their default False value, but the legacy
settings are activated, they need to be translated in computed_settings
to the modern way.
This commit is contained in:
Mateusz Mandera
2024-07-16 22:52:01 +02:00
committed by Tim Abbott
parent 722842a0aa
commit 4a93149435
22 changed files with 374 additions and 140 deletions

View File

@@ -2566,8 +2566,8 @@ class BouncerTestCase(ZulipTestCase):
# we can safely pick the first value.
data = {k: v[0] for k, v in params.items()}
assert request.url is not None # allow mypy to infer url is present.
assert settings.PUSH_NOTIFICATION_BOUNCER_URL is not None
local_url = request.url.replace(settings.PUSH_NOTIFICATION_BOUNCER_URL, "")
assert settings.ZULIP_SERVICES_URL is not None
local_url = request.url.replace(settings.ZULIP_SERVICES_URL, "")
if request.method == "POST":
result = self.uuid_post(self.server_uuid, local_url, data, subdomain="", **kwargs)
elif request.method == "GET":
@@ -2575,9 +2575,9 @@ class BouncerTestCase(ZulipTestCase):
return (result.status_code, result.headers, result.content)
def add_mock_response(self) -> None:
# Match any endpoint with the PUSH_NOTIFICATION_BOUNCER_URL.
assert settings.PUSH_NOTIFICATION_BOUNCER_URL is not None
COMPILED_URL = re.compile(settings.PUSH_NOTIFICATION_BOUNCER_URL + r".*")
# Match any endpoint with the ZULIP_SERVICES_URL.
assert settings.ZULIP_SERVICES_URL is not None
COMPILED_URL = re.compile(settings.ZULIP_SERVICES_URL + r".*")
responses.add_callback(responses.POST, COMPILED_URL, callback=self.request_callback)
responses.add_callback(responses.GET, COMPILED_URL, callback=self.request_callback)