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.

zephyr: Check PERSONAL_ZMIRROR_SERVER before updating cache.

Zixuan James Li8fae87e2df19
diff --git a/zerver/tests/test_zephyr.py b/zerver/tests/test_zephyr.py
index c2655b01939..f4d04ca3ead 100644
--- a/zerver/tests/test_zephyr.py
+++ b/zerver/tests/test_zephyr.py
@@ -52,12 +52,18 @@ class ZephyrTest(ZulipTestCase):
with ccache_mock(return_value=b"1234"), ssh_mock(
side_effect=subprocess.CalledProcessError(1, [])
- ), self.assertLogs(level="ERROR") as log:
+ ), mirror_mock(), self.assertLogs(level="ERROR") as log:
result = post("zephyr", cred=cred)
self.assert_json_error(result, "We were unable to set up mirroring for you")
self.assertIn("Error updating the user's ccache", log.output[0])
+ with ccache_mock(return_value=b"1234"), self.assertLogs(level="ERROR") as log:
+ result = post("zephyr", cred=cred)
+
+ self.assert_json_error(result, "We were unable to set up mirroring for you")
+ self.assertIn("PERSONAL_ZMIRROR_SERVER is not properly configured", log.output[0])
+
with ccache_mock(return_value=b"1234"), mirror_mock(), ssh_mock() as ssh:
result = post("zephyr", cred=cred)
diff --git a/zerver/views/zephyr.py b/zerver/views/zephyr.py
index 376429b9e50..a71178f5044 100644
--- a/zerver/views/zephyr.py
+++ b/zerver/views/zephyr.py
@@ -59,6 +59,10 @@ def webathena_kerberos_login(
except Exception:
raise JsonableError(_("Invalid Kerberos cache"))
+ if settings.PERSONAL_ZMIRROR_SERVER is None:
+ logging.error("PERSONAL_ZMIRROR_SERVER is not properly configured", stack_info=True)
+ raise JsonableError(_("We were unable to set up mirroring for you"))
+
# TODO: Send these data via (say) RabbitMQ
try:
api_key = get_api_key(user_profile)