mirror of https://github.com/zulip/zulip.git
message_send: Fix tests to use json encoded 'to'.
OpenApi docs requires the `to` param to be Json encoded, but the tests were using raw strings. This commit fixes the tests. Despite OpenApi docs requiring the `to` param to be Json encoded, the endpoint still accepts the `to` param as a raw string. This is undesireable, but fixing it would render older bots that take advantage of this feature unusable.
This commit is contained in:
parent
eef65d7e30
commit
42a482759d
|
@ -609,7 +609,7 @@ class DeactivatedRealmTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": self.example_email("othello"),
|
"to": orjson.dumps([self.example_email("othello")]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error_contains(result, "Not logged in", status_code=401)
|
self.assert_json_error_contains(result, "Not logged in", status_code=401)
|
||||||
|
@ -626,7 +626,7 @@ class DeactivatedRealmTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": self.example_email("othello"),
|
"to": orjson.dumps([self.example_email("othello")]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error_contains(
|
self.assert_json_error_contains(
|
||||||
|
@ -639,7 +639,7 @@ class DeactivatedRealmTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": self.example_email("othello"),
|
"to": orjson.dumps([self.example_email("othello")]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error_contains(
|
self.assert_json_error_contains(
|
||||||
|
@ -765,7 +765,7 @@ class InactiveUserTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": self.example_email("othello"),
|
"to": orjson.dumps([self.example_email("othello")]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error_contains(result, "Not logged in", status_code=401)
|
self.assert_json_error_contains(result, "Not logged in", status_code=401)
|
||||||
|
@ -780,7 +780,7 @@ class InactiveUserTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": self.example_email("othello"),
|
"to": orjson.dumps([self.example_email("othello")]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error_contains(result, "Account is deactivated", status_code=401)
|
self.assert_json_error_contains(result, "Account is deactivated", status_code=401)
|
||||||
|
@ -791,7 +791,7 @@ class InactiveUserTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": self.example_email("othello"),
|
"to": orjson.dumps([self.example_email("othello")]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error_contains(result, "Account is deactivated", status_code=401)
|
self.assert_json_error_contains(result, "Account is deactivated", status_code=401)
|
||||||
|
|
|
@ -560,7 +560,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "nonexistent_stream",
|
"to": orjson.dumps("nonexistent_stream").decode(),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"topic": "Test topic",
|
"topic": "Test topic",
|
||||||
},
|
},
|
||||||
|
@ -577,7 +577,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": """&<"'><non-existent>""",
|
"to": orjson.dumps("""&<"'><non-existent>""").decode(),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"topic": "Test topic",
|
"topic": "Test topic",
|
||||||
},
|
},
|
||||||
|
@ -760,7 +760,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "direct",
|
"type": "direct",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": "nonexistent",
|
"to": orjson.dumps("nonexistent").decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid email 'nonexistent'")
|
self.assert_json_error(result, "Invalid email 'nonexistent'")
|
||||||
|
@ -874,7 +874,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
{
|
{
|
||||||
"type": "invalid type",
|
"type": "invalid type",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"to": othello.email,
|
"to": orjson.dumps([othello.email]).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid type")
|
self.assert_json_error(result, "Invalid type")
|
||||||
|
@ -887,7 +887,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
othello = self.example_user("othello")
|
othello = self.example_user("othello")
|
||||||
result = self.client_post(
|
result = self.client_post(
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{"type": "direct", "content": " ", "to": othello.email},
|
{"type": "direct", "content": " ", "to": orjson.dumps([othello.email]).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Message must not be empty")
|
self.assert_json_error(result, "Message must not be empty")
|
||||||
|
|
||||||
|
@ -900,7 +900,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"topic": "",
|
"topic": "",
|
||||||
},
|
},
|
||||||
|
@ -914,7 +914,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
result = self.client_post(
|
result = self.client_post(
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{"type": "channel", "to": "Verona", "content": "Test message"},
|
{"type": "channel", "to": orjson.dumps("Verona").decode(), "content": "Test message"},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Missing topic")
|
self.assert_json_error(result, "Missing topic")
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"topic": "Test\n\rTopic",
|
"topic": "Test\n\rTopic",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
},
|
},
|
||||||
|
@ -940,7 +940,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"topic": "Test\ufffeTopic",
|
"topic": "Test\ufffeTopic",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
},
|
},
|
||||||
|
@ -956,7 +956,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "invalid",
|
"type": "invalid",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"topic": "Test topic",
|
"topic": "Test topic",
|
||||||
},
|
},
|
||||||
|
@ -970,7 +970,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
result = self.client_post(
|
result = self.client_post(
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{"type": "direct", "content": "Test content", "to": ""},
|
{"type": "direct", "content": "Test content", "to": orjson.dumps("").decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Message must have recipients")
|
self.assert_json_error(result, "Message must have recipients")
|
||||||
|
|
||||||
|
@ -1025,7 +1025,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"sender": self.mit_email("sipbtest"),
|
"sender": self.mit_email("sipbtest"),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"to": self.mit_email("starnine"),
|
"to": orjson.dumps([self.mit_email("starnine")]).decode(),
|
||||||
},
|
},
|
||||||
subdomain="zephyr",
|
subdomain="zephyr",
|
||||||
)
|
)
|
||||||
|
@ -1043,7 +1043,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"sender": self.mit_email("sipbtest"),
|
"sender": self.mit_email("sipbtest"),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"to": self.mit_email("espuser"),
|
"to": orjson.dumps([self.mit_email("espuser")]).decode(),
|
||||||
},
|
},
|
||||||
subdomain="zephyr",
|
subdomain="zephyr",
|
||||||
)
|
)
|
||||||
|
@ -1090,7 +1090,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
post_data = {
|
post_data = {
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"content": " I like null bytes \x00 in my content",
|
"content": " I like null bytes \x00 in my content",
|
||||||
"topic": "Test topic",
|
"topic": "Test topic",
|
||||||
}
|
}
|
||||||
|
@ -1175,7 +1175,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"/json/messages",
|
"/json/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"topic": "Test topic",
|
"topic": "Test topic",
|
||||||
"forged": "true",
|
"forged": "true",
|
||||||
|
@ -1191,7 +1191,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"type": "direct",
|
"type": "direct",
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"to": self.mit_email("starnine"),
|
"to": orjson.dumps([self.mit_email("starnine")]).decode(),
|
||||||
},
|
},
|
||||||
subdomain="zephyr",
|
subdomain="zephyr",
|
||||||
)
|
)
|
||||||
|
@ -1206,7 +1206,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"sender": self.mit_email("sipbtest"),
|
"sender": self.mit_email("sipbtest"),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"to": self.mit_email("starnine"),
|
"to": orjson.dumps([self.mit_email("starnine")]).decode(),
|
||||||
},
|
},
|
||||||
subdomain="zephyr",
|
subdomain="zephyr",
|
||||||
)
|
)
|
||||||
|
@ -1225,7 +1225,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"sender": self.mit_email("sipbtest"),
|
"sender": self.mit_email("sipbtest"),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"to": self.mit_email("starnine"),
|
"to": orjson.dumps([self.mit_email("starnine")]).decode(),
|
||||||
},
|
},
|
||||||
subdomain="zephyr",
|
subdomain="zephyr",
|
||||||
)
|
)
|
||||||
|
@ -1247,7 +1247,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
"sender": self.mit_email("sipbtest"),
|
"sender": self.mit_email("sipbtest"),
|
||||||
"content": "Test message",
|
"content": "Test message",
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"to": user.email,
|
"to": orjson.dumps([user.email]).decode(),
|
||||||
},
|
},
|
||||||
subdomain="notzephyr",
|
subdomain="notzephyr",
|
||||||
)
|
)
|
||||||
|
@ -2298,7 +2298,7 @@ class StreamMessagesTest(ZulipTestCase):
|
||||||
"/api/v1/messages",
|
"/api/v1/messages",
|
||||||
{
|
{
|
||||||
"type": "channel",
|
"type": "channel",
|
||||||
"to": "Verona",
|
"to": orjson.dumps("Verona").decode(),
|
||||||
"sender": self.mit_email("sipbtest"),
|
"sender": self.mit_email("sipbtest"),
|
||||||
"client": "zephyr_mirror",
|
"client": "zephyr_mirror",
|
||||||
"topic": "announcement",
|
"topic": "announcement",
|
||||||
|
|
Loading…
Reference in New Issue