From 30c190a1204780a318d905d6c1b2d1dde59f5cb7 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Wed, 24 Nov 2021 12:53:38 +0530 Subject: [PATCH] test: Check json_fetch_raw_message raises error. This commit adds a check to verify that json_fetch_raw_message raises error when enable_spectator_access is False. --- zerver/tests/test_message_edit.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 9376db8072..9ea9f295ef 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -351,6 +351,15 @@ class EditMessageTest(EditMessageTestCase): result, "Not logged in: API authentication or user session required", 401 ) + do_set_realm_property( + user_profile.realm, "enable_spectator_access", False, acting_user=None + ) + result = self.client_get("/json/messages/" + str(web_public_stream_msg_id)) + self.assert_json_error( + result, "Not logged in: API authentication or user session required", 401 + ) + do_set_realm_property(user_profile.realm, "enable_spectator_access", True, acting_user=None) + # Verify success with web-public stream and default SELF_HOSTED plan type. result = self.client_get("/json/messages/" + str(web_public_stream_msg_id)) self.assert_json_success(result)