mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
tests: Test forging timestamps for mirrored messages.
This commit is contained in:
@@ -84,7 +84,7 @@ from zerver.models import (
|
|||||||
|
|
||||||
|
|
||||||
from zerver.lib.upload import create_attachment
|
from zerver.lib.upload import create_attachment
|
||||||
from zerver.lib.timestamp import convert_to_UTC
|
from zerver.lib.timestamp import convert_to_UTC, datetime_to_timestamp
|
||||||
from zerver.lib.timezone import get_timezone
|
from zerver.lib.timezone import get_timezone
|
||||||
|
|
||||||
from zerver.views.messages import create_mirrored_message_users
|
from zerver.views.messages import create_mirrored_message_users
|
||||||
@@ -1639,8 +1639,14 @@ class MessagePOSTTest(ZulipTestCase):
|
|||||||
user.save()
|
user.save()
|
||||||
user = get_user(email, get_realm('zulip'))
|
user = get_user(email, get_realm('zulip'))
|
||||||
self.subscribe(user, "IRCland")
|
self.subscribe(user, "IRCland")
|
||||||
|
|
||||||
|
# Simulate a mirrored message with a slightly old timestamp.
|
||||||
|
fake_pub_date = timezone_now() - datetime.timedelta(minutes=37)
|
||||||
|
fake_pub_time = datetime_to_timestamp(fake_pub_date)
|
||||||
|
|
||||||
result = self.api_post(email, "/api/v1/messages", {"type": "stream",
|
result = self.api_post(email, "/api/v1/messages", {"type": "stream",
|
||||||
"forged": "true",
|
"forged": "true",
|
||||||
|
"time": fake_pub_time,
|
||||||
"sender": "irc-user@irc.zulip.com",
|
"sender": "irc-user@irc.zulip.com",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "irc_mirror",
|
"client": "irc_mirror",
|
||||||
@@ -1648,6 +1654,9 @@ class MessagePOSTTest(ZulipTestCase):
|
|||||||
"to": "IRCLand"})
|
"to": "IRCLand"})
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
|
||||||
|
msg = self.get_last_message()
|
||||||
|
self.assertEqual(int(datetime_to_timestamp(msg.pub_date)), int(fake_pub_time))
|
||||||
|
|
||||||
def test_unsubscribed_api_super_user(self) -> None:
|
def test_unsubscribed_api_super_user(self) -> None:
|
||||||
sender = self.example_user('cordelia')
|
sender = self.example_user('cordelia')
|
||||||
stream_name = 'private_stream'
|
stream_name = 'private_stream'
|
||||||
|
|||||||
Reference in New Issue
Block a user