zephyr: Check PERSONAL_ZMIRROR_SERVER before updating cache.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-07-28 15:16:40 -04:00 committed by Tim Abbott
parent d7746c9e6c
commit 8fae87e2df
2 changed files with 11 additions and 1 deletions

View File

@ -52,12 +52,18 @@ class ZephyrTest(ZulipTestCase):
with ccache_mock(return_value=b"1234"), ssh_mock( with ccache_mock(return_value=b"1234"), ssh_mock(
side_effect=subprocess.CalledProcessError(1, []) side_effect=subprocess.CalledProcessError(1, [])
), self.assertLogs(level="ERROR") as log: ), mirror_mock(), self.assertLogs(level="ERROR") as log:
result = post("zephyr", cred=cred) result = post("zephyr", cred=cred)
self.assert_json_error(result, "We were unable to set up mirroring for you") 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]) 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: with ccache_mock(return_value=b"1234"), mirror_mock(), ssh_mock() as ssh:
result = post("zephyr", cred=cred) result = post("zephyr", cred=cred)

View File

@ -59,6 +59,10 @@ def webathena_kerberos_login(
except Exception: except Exception:
raise JsonableError(_("Invalid Kerberos cache")) 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 # TODO: Send these data via (say) RabbitMQ
try: try:
api_key = get_api_key(user_profile) api_key = get_api_key(user_profile)