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.

tests: Modify invite_to_stream_policy tests to check all cases.

sahil83913e412d5535c
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index 62c4a64dcbb..e2f25bf847d 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -3256,7 +3256,22 @@ class SubscriptionAPITest(ZulipTestCase):
)
self.assert_json_error(result, "Only administrators can modify other users' subscriptions.")
+ do_change_user_role(self.test_user, UserProfile.ROLE_REALM_ADMINISTRATOR)
+ self.common_subscribe_to_streams(
+ self.test_user, ["stream1"], {"principals": orjson.dumps([invitee_user_id]).decode()}
+ )
+
do_set_realm_property(realm, "invite_to_stream_policy", Realm.POLICY_MEMBERS_ONLY)
+ do_change_user_role(self.test_user, UserProfile.ROLE_GUEST)
+ result = self.common_subscribe_to_streams(
+ self.test_user,
+ ["stream2"],
+ {"principals": orjson.dumps([invitee_user_id]).decode()},
+ allow_fail=True,
+ )
+ self.assert_json_error(result, "Not allowed for guest users")
+
+ do_change_user_role(self.test_user, UserProfile.ROLE_MEMBER)
self.common_subscribe_to_streams(
self.test_user,
["stream2"],