mirror of https://github.com/zulip/zulip.git
tests: Tests bots can send to owner's streams.
This commit is contained in:
parent
edd8437c76
commit
82469b89e5
|
@ -1591,6 +1591,34 @@ class MessagePOSTTest(ZulipTestCase):
|
|||
result = self.api_post(sender.email, "/api/v1/messages", payload)
|
||||
self.assert_json_success(result)
|
||||
|
||||
def test_bot_can_send_to_owner_stream(self) -> None:
|
||||
cordelia = self.example_user('cordelia')
|
||||
bot = self.create_test_bot(
|
||||
short_name='whatever',
|
||||
user_profile=cordelia,
|
||||
)
|
||||
|
||||
stream_name = 'private_stream'
|
||||
self.make_stream(stream_name, invite_only=True)
|
||||
|
||||
payload = dict(
|
||||
type="stream",
|
||||
to=stream_name,
|
||||
sender=bot.email,
|
||||
client='test suite',
|
||||
subject='whatever',
|
||||
content='whatever',
|
||||
)
|
||||
|
||||
result = self.api_post(bot.email, "/api/v1/messages", payload)
|
||||
self.assert_json_error_contains(result, 'Not authorized to send')
|
||||
|
||||
# We subscribe the bot owner! (aka cordelia)
|
||||
self.subscribe(bot.bot_owner, stream_name)
|
||||
|
||||
result = self.api_post(bot.email, "/api/v1/messages", payload)
|
||||
self.assert_json_success(result)
|
||||
|
||||
class ScheduledMessageTest(ZulipTestCase):
|
||||
|
||||
def last_scheduled_message(self) -> ScheduledMessage:
|
||||
|
|
Loading…
Reference in New Issue