message_send: Fix old guests being treated as full members.

For streams in which only full members are allowed to post,
we block guest users from posting there.

Guests users were blocked from posting to admin only streams
already. So now, guest users can only post to
STREAM_POST_POLICY_EVERYONE streams.

This is not a new feature but a bugfix which should have
happened when implementing full member stream policy / guest users.
This commit is contained in:
Aman Agrawal
2020-10-09 00:00:11 +05:30
committed by GitHub
parent 6fe82620df
commit 8b419c93e4
4 changed files with 53 additions and 2 deletions

View File

@@ -194,6 +194,10 @@ class MessagePOSTTest(ZulipTestCase):
'Test topic', 'Test message by notification bot')
self.assertEqual(self.get_last_message().content, 'Test message by notification bot')
guest_profile = self.example_user("polonius")
# Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams
self._send_and_verify_message(guest_profile, stream_name, "Only organization administrators can send to this stream.")
def test_sending_message_as_stream_post_policy_restrict_new_members(self) -> None:
"""
Sending messages to streams which new members cannot create and post to.
@@ -258,6 +262,10 @@ class MessagePOSTTest(ZulipTestCase):
'Test topic', 'Test message by notification bot')
self.assertEqual(self.get_last_message().content, 'Test message by notification bot')
guest_profile = self.example_user("polonius")
# Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams
self._send_and_verify_message(guest_profile, stream_name, "Guests cannot send to this stream.")
def test_api_message_with_default_to(self) -> None:
"""
Sending messages without a to field should be sent to the default