Skip to content

Commit

Permalink
zephyr: Check PERSONAL_ZMIRROR_SERVER before updating cache.
Browse files Browse the repository at this point in the history
Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 authored and timabbott committed Aug 13, 2022
1 parent d7746c9 commit 8fae87e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion zerver/tests/test_zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,18 @@ def mirror_mock() -> Any:

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)

Expand Down
4 changes: 4 additions & 0 deletions zerver/views/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8fae87e

Please sign in to comment.