From 8fae87e2df199a4d88efa9f5cf154fb01bfc1f2c Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Thu, 28 Jul 2022 15:16:40 -0400 Subject: [PATCH] zephyr: Check PERSONAL_ZMIRROR_SERVER before updating cache. Signed-off-by: Zixuan James Li --- zerver/tests/test_zephyr.py | 8 +++++++- zerver/views/zephyr.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/zerver/tests/test_zephyr.py b/zerver/tests/test_zephyr.py index c2655b0193..f4d04ca3ea 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 376429b9e5..a71178f504 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)