mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-24 10:35:46 +03:00
Remove redundant HomeserverTestCase.render
This commit is contained in:
parent
be8fa65d0b
commit
acfe3b3065
44 changed files with 0 additions and 629 deletions
|
@ -51,7 +51,6 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/federation/unstable/rooms/%s/complexity" % (room_1,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
complexity = channel.json_body["v1"]
|
||||
self.assertTrue(complexity > 0, complexity)
|
||||
|
@ -64,7 +63,6 @@ class RoomComplexityTests(unittest.FederatingHomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/federation/unstable/rooms/%s/complexity" % (room_1,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
complexity = channel.json_body["v1"]
|
||||
self.assertEqual(complexity, 1.23)
|
||||
|
|
|
@ -51,7 +51,6 @@ class FederationServerTests(unittest.FederatingHomeserverTestCase):
|
|||
"/_matrix/federation/v1/get_missing_events/%s" % (room_1,),
|
||||
query_content,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, channel.result)
|
||||
self.assertEqual(channel.json_body["errcode"], "M_NOT_JSON")
|
||||
|
||||
|
@ -99,7 +98,6 @@ class StateQueryTests(unittest.FederatingHomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/federation/v1/state/%s" % (room_1,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
self.assertEqual(
|
||||
|
@ -132,7 +130,6 @@ class StateQueryTests(unittest.FederatingHomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/federation/v1/state/%s" % (room_1,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, channel.result)
|
||||
self.assertEqual(channel.json_body["errcode"], "M_FORBIDDEN")
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ class RoomDirectoryFederationTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/federation/v1/publicRooms"
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code)
|
||||
|
||||
@override_config({"allow_public_rooms_over_federation": True})
|
||||
|
@ -48,5 +47,4 @@ class RoomDirectoryFederationTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/federation/v1/publicRooms"
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
|
|
@ -412,7 +412,6 @@ class TestCreateAliasACL(unittest.HomeserverTestCase):
|
|||
b"directory/room/%23test%3Atest",
|
||||
('{"room_id":"%s"}' % (room_id,)).encode("ascii"),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, channel.result)
|
||||
|
||||
def test_allowed(self):
|
||||
|
@ -423,7 +422,6 @@ class TestCreateAliasACL(unittest.HomeserverTestCase):
|
|||
b"directory/room/%23unofficial_test%3Atest",
|
||||
('{"room_id":"%s"}' % (room_id,)).encode("ascii"),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
|
||||
|
@ -438,7 +436,6 @@ class TestRoomListSearchDisabled(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", b"directory/list/room/%s" % (room_id.encode("ascii"),), b"{}"
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
self.room_list_handler = hs.get_room_list_handler()
|
||||
|
@ -452,7 +449,6 @@ class TestRoomListSearchDisabled(unittest.HomeserverTestCase):
|
|||
|
||||
# Room list is enabled so we should get some results
|
||||
request, channel = self.make_request("GET", b"publicRooms")
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertTrue(len(channel.json_body["chunk"]) > 0)
|
||||
|
||||
|
@ -461,7 +457,6 @@ class TestRoomListSearchDisabled(unittest.HomeserverTestCase):
|
|||
|
||||
# Room list disabled so we should get no results
|
||||
request, channel = self.make_request("GET", b"publicRooms")
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertTrue(len(channel.json_body["chunk"]) == 0)
|
||||
|
||||
|
@ -470,5 +465,4 @@ class TestRoomListSearchDisabled(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", b"directory/list/room/%s" % (room_id.encode("ascii"),), b"{}"
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, channel.result)
|
||||
|
|
|
@ -209,5 +209,4 @@ class ServerAclValidationTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", path, content={}, access_token=self.access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(int(channel.result["code"]), 403)
|
||||
|
|
|
@ -228,7 +228,6 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
|
|||
),
|
||||
federation_auth_origin=b"farm",
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
self.on_new_event.assert_has_calls([call("typing_key", 1, rooms=[ROOM_ID])])
|
||||
|
|
|
@ -537,7 +537,6 @@ class TestUserDirSearchDisabled(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", b"user_directory/search", b'{"search_term":"user2"}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertTrue(len(channel.json_body["results"]) > 0)
|
||||
|
||||
|
@ -546,6 +545,5 @@ class TestUserDirSearchDisabled(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", b"user_directory/search", b'{"search_term":"user2"}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertTrue(len(channel.json_body["results"]) == 0)
|
||||
|
|
|
@ -43,7 +43,6 @@ class VersionTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
def test_version_string(self):
|
||||
request, channel = self.make_request("GET", self.url, shorthand=False)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -76,7 +75,6 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||
content={"localpart": "test"},
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
group_id = channel.json_body["group_id"]
|
||||
|
@ -89,14 +87,12 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url.encode("ascii"), access_token=self.admin_user_tok, content={}
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
url = "/groups/%s/self/accept_invite" % (group_id,)
|
||||
request, channel = self.make_request(
|
||||
"PUT", url.encode("ascii"), access_token=self.other_user_token, content={}
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Check other user knows they're in the group
|
||||
|
@ -112,7 +108,6 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||
content={"localpart": "test"},
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Check group returns 404
|
||||
|
@ -132,7 +127,6 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||
"GET", url.encode("ascii"), access_token=self.admin_user_tok
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
expect_code, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -144,7 +138,6 @@ class DeleteGroupTestCase(unittest.HomeserverTestCase):
|
|||
"GET", "/joined_groups".encode("ascii"), access_token=access_token
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
return channel.json_body["groups"]
|
||||
|
@ -251,7 +244,6 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url.encode("ascii"), access_token=non_admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Expect a forbidden error
|
||||
self.assertEqual(
|
||||
|
@ -265,7 +257,6 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url.encode("ascii"), access_token=non_admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Expect a forbidden error
|
||||
self.assertEqual(
|
||||
|
@ -309,7 +300,6 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase):
|
|||
urllib.parse.quote(media_id),
|
||||
)
|
||||
request, channel = self.make_request("POST", url, access_token=admin_user_tok,)
|
||||
self.render(request)
|
||||
self.pump(1.0)
|
||||
self.assertEqual(200, int(channel.code), msg=channel.result["body"])
|
||||
|
||||
|
@ -362,7 +352,6 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase):
|
|||
room_id
|
||||
)
|
||||
request, channel = self.make_request("POST", url, access_token=admin_user_tok,)
|
||||
self.render(request)
|
||||
self.pump(1.0)
|
||||
self.assertEqual(200, int(channel.code), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -409,7 +398,6 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url.encode("ascii"), access_token=admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.pump(1.0)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -452,7 +440,6 @@ class QuarantineMediaTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url.encode("ascii"), access_token=admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.pump(1.0)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
|
|
@ -51,19 +51,16 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
Try to get a device of an user without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
request, channel = self.make_request("PUT", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
||||
request, channel = self.make_request("DELETE", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -75,7 +72,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -83,7 +79,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", self.url, access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -91,7 +86,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", self.url, access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -108,7 +102,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -116,7 +109,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -124,7 +116,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -141,7 +132,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -149,7 +139,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -157,7 +146,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -173,7 +161,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -181,14 +168,12 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Delete unknown device returns status 200
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
@ -218,7 +203,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.TOO_LARGE, channel.json_body["errcode"])
|
||||
|
@ -227,7 +211,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("new display", channel.json_body["display_name"])
|
||||
|
@ -247,7 +230,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
|
@ -255,7 +237,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("new display", channel.json_body["display_name"])
|
||||
|
@ -272,7 +253,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
|
@ -280,7 +260,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("new displayname", channel.json_body["display_name"])
|
||||
|
@ -292,7 +271,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(self.other_user, channel.json_body["user_id"])
|
||||
|
@ -316,7 +294,6 @@ class DeviceRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
|
@ -347,7 +324,6 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
Try to list devices of an user without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -361,7 +337,6 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -374,7 +349,6 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -388,7 +362,6 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -403,7 +376,6 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
@ -422,7 +394,6 @@ class DevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(number_devices, channel.json_body["total"])
|
||||
|
@ -461,7 +432,6 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
Try to delete devices of an user without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("POST", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -475,7 +445,6 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", self.url, access_token=other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -488,7 +457,6 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -502,7 +470,6 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -518,7 +485,6 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Delete unknown devices returns status 200
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
@ -550,7 +516,6 @@ class DeleteDevicesRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
Try to get an event report without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -88,7 +87,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.other_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -101,7 +99,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -117,7 +114,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -133,7 +129,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -149,7 +144,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=5&limit=10", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -167,7 +161,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?room_id=%s" % self.room_id1,
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 10)
|
||||
|
@ -188,7 +181,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?user_id=%s" % self.other_user,
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 10)
|
||||
|
@ -209,7 +201,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?user_id=%s&room_id=%s" % (self.other_user, self.room_id1),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 5)
|
||||
|
@ -230,7 +221,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?dir=b", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -247,7 +237,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?dir=f", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -268,7 +257,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?dir=bar", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -282,7 +270,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=-5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -295,7 +282,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=-5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -310,7 +296,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=20", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -322,7 +307,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=21", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -334,7 +318,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=19", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -347,7 +330,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=19", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -366,7 +348,6 @@ class EventReportsTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"score": -100, "reason": "this makes me sad"}),
|
||||
access_token=user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
def _check_fields(self, content):
|
||||
|
@ -419,7 +400,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
Try to get event report without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -432,7 +412,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.other_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -445,7 +424,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self._check_fields(channel.json_body)
|
||||
|
@ -461,7 +439,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
"/_synapse/admin/v1/event_reports/-123",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -476,7 +453,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
"/_synapse/admin/v1/event_reports/abcdef",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -491,7 +467,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
"/_synapse/admin/v1/event_reports/",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -510,7 +485,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
"/_synapse/admin/v1/event_reports/123",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -528,7 +502,6 @@ class EventReportDetailTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"score": -100, "reason": "this makes me sad"}),
|
||||
access_token=user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
def _check_fields(self, content):
|
||||
|
|
|
@ -51,7 +51,6 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
|||
url = "/_synapse/admin/v1/media/%s/%s" % (self.server_name, "12345")
|
||||
|
||||
request, channel = self.make_request("DELETE", url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -68,7 +67,6 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -82,7 +80,6 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -96,7 +93,6 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only delete local media", channel.json_body["error"])
|
||||
|
@ -153,7 +149,6 @@ class DeleteMediaByIDTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
|
@ -211,7 +206,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
"""
|
||||
|
||||
request, channel = self.make_request("POST", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -226,7 +220,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", self.url, access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -240,7 +233,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url + "?before_ts=1234", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only delete local media", channel.json_body["error"])
|
||||
|
@ -252,7 +244,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
@ -267,7 +258,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", self.url + "?before_ts=-1234", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -281,7 +271,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=1234&size_gt=-1234",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -295,7 +284,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=1234&keep_profiles=not_bool",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.UNKNOWN, channel.json_body["errcode"])
|
||||
|
@ -326,7 +314,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
self.assertEqual(
|
||||
|
@ -351,7 +338,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
||||
|
@ -364,7 +350,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
self.assertEqual(
|
||||
|
@ -388,7 +373,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms) + "&size_gt=67",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
||||
|
@ -400,7 +384,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms) + "&size_gt=66",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
self.assertEqual(
|
||||
|
@ -425,7 +408,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
content=json.dumps({"avatar_url": "mxc://%s" % (server_and_media_id,)}),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
now_ms = self.clock.time_msec()
|
||||
|
@ -434,7 +416,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms) + "&keep_profiles=true",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
||||
|
@ -446,7 +427,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms) + "&keep_profiles=false",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
self.assertEqual(
|
||||
|
@ -472,7 +452,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
content=json.dumps({"url": "mxc://%s" % (server_and_media_id,)}),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
now_ms = self.clock.time_msec()
|
||||
|
@ -481,7 +460,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms) + "&keep_profiles=true",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
||||
|
@ -493,7 +471,6 @@ class DeleteMediaByDateSizeTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?before_ts=" + str(now_ms) + "&keep_profiles=false",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
self.assertEqual(
|
||||
|
|
|
@ -85,7 +85,6 @@ class ShutdownRoomTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"new_room_user_id": self.admin_user}),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
|
@ -110,7 +109,6 @@ class ShutdownRoomTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"history_visibility": "world_readable"}),
|
||||
access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Test that the admin can still send shutdown
|
||||
|
@ -121,7 +119,6 @@ class ShutdownRoomTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"new_room_user_id": self.admin_user}),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
|
@ -136,7 +133,6 @@ class ShutdownRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
expect_code, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -145,7 +141,6 @@ class ShutdownRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
expect_code, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -192,7 +187,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", self.url, json.dumps({}), access_token=self.other_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -206,7 +200,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url, json.dumps({}), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -220,7 +213,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url, json.dumps({}), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -239,7 +231,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertIn("new_room_id", channel.json_body)
|
||||
|
@ -259,7 +250,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -278,7 +268,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
@ -295,7 +284,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.BAD_JSON, channel.json_body["errcode"])
|
||||
|
@ -322,7 +310,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(None, channel.json_body["new_room_id"])
|
||||
|
@ -356,7 +343,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(None, channel.json_body["new_room_id"])
|
||||
|
@ -391,7 +377,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(None, channel.json_body["new_room_id"])
|
||||
|
@ -439,7 +424,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"new_room_user_id": self.admin_user}),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(self.other_user, channel.json_body["kicked_users"][0])
|
||||
|
@ -470,7 +454,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"history_visibility": "world_readable"}),
|
||||
access_token=self.other_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Test that room is not purged
|
||||
|
@ -488,7 +471,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps({"new_room_user_id": self.admin_user}),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(self.other_user, channel.json_body["kicked_users"][0])
|
||||
|
@ -551,7 +533,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
expect_code, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -560,7 +541,6 @@ class DeleteRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
expect_code, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -595,7 +575,6 @@ class PurgeRoomTestCase(unittest.HomeserverTestCase):
|
|||
{"room_id": room_id},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
|
@ -647,7 +626,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Check request completed successfully
|
||||
self.assertEqual(200, int(channel.code), msg=channel.json_body)
|
||||
|
@ -729,7 +707,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
200, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -770,7 +747,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
def test_correct_room_attributes(self):
|
||||
|
@ -794,7 +770,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
{"room_id": room_id},
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Set this new alias as the canonical alias for this room
|
||||
|
@ -822,7 +797,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Check that rooms were returned
|
||||
|
@ -867,7 +841,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
{"room_id": room_id},
|
||||
access_token=admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(
|
||||
200, int(channel.result["code"]), msg=channel.result["body"]
|
||||
)
|
||||
|
@ -905,7 +878,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
# Check that rooms were returned
|
||||
|
@ -1042,7 +1014,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(expected_http_code, channel.code, msg=channel.json_body)
|
||||
|
||||
if expected_http_code != 200:
|
||||
|
@ -1104,7 +1075,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
self.assertIn("room_id", channel.json_body)
|
||||
|
@ -1152,7 +1122,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
self.assertCountEqual(
|
||||
|
@ -1164,7 +1133,6 @@ class RoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
|
||||
self.assertCountEqual(
|
||||
|
@ -1208,7 +1176,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -1225,7 +1192,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_PARAM, channel.json_body["errcode"])
|
||||
|
@ -1242,7 +1208,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -1259,7 +1224,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -1280,7 +1244,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("No known servers", channel.json_body["error"])
|
||||
|
@ -1298,7 +1261,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -1318,7 +1280,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(self.public_room_id, channel.json_body["room_id"])
|
||||
|
@ -1328,7 +1289,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/joined_rooms", access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(self.public_room_id, channel.json_body["joined_rooms"][0])
|
||||
|
||||
|
@ -1349,7 +1309,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -1377,7 +1336,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/joined_rooms", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(private_room_id, channel.json_body["joined_rooms"][0])
|
||||
|
||||
|
@ -1392,7 +1350,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(private_room_id, channel.json_body["room_id"])
|
||||
|
||||
|
@ -1401,7 +1358,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/joined_rooms", access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(private_room_id, channel.json_body["joined_rooms"][0])
|
||||
|
||||
|
@ -1422,7 +1378,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
content=body.encode(encoding="utf_8"),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(private_room_id, channel.json_body["room_id"])
|
||||
|
@ -1432,7 +1387,6 @@ class JoinAliasRoomTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/joined_rooms", access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(private_room_id, channel.json_body["joined_rooms"][0])
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
Try to list users without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -59,7 +58,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, json.dumps({}), access_token=self.other_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -72,7 +70,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?order_by=bar", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -81,7 +78,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=-5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -90,7 +86,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=-5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -99,7 +94,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from_ts=-1234", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -108,7 +102,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?until_ts=-1234", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -119,7 +112,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?from_ts=10&until_ts=5",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -128,7 +120,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?search_term=", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -137,7 +128,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?dir=bar", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -151,7 +141,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 10)
|
||||
|
@ -168,7 +157,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -185,7 +173,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=5&limit=10", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
@ -206,7 +193,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=20", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_users)
|
||||
|
@ -218,7 +204,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=21", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_users)
|
||||
|
@ -230,7 +215,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=19", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_users)
|
||||
|
@ -242,7 +226,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=19", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_users)
|
||||
|
@ -258,7 +241,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
@ -337,7 +319,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["users"][0]["media_count"], 3)
|
||||
|
||||
|
@ -346,7 +327,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from_ts=%s" % (ts1,), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 0)
|
||||
|
||||
|
@ -362,7 +342,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?from_ts=%s&until_ts=%s" % (ts1, ts2),
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["users"][0]["media_count"], 3)
|
||||
|
||||
|
@ -370,7 +349,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?until_ts=%s" % (ts2,), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["users"][0]["media_count"], 6)
|
||||
|
||||
|
@ -381,7 +359,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 20)
|
||||
|
||||
|
@ -391,7 +368,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?search_term=foo_user_1",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 11)
|
||||
|
||||
|
@ -401,7 +377,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
self.url + "?search_term=bar_user_10",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["users"][0]["displayname"], "bar_user_10")
|
||||
self.assertEqual(channel.json_body["total"], 1)
|
||||
|
@ -410,7 +385,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?search_term=foobar", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], 0)
|
||||
|
||||
|
@ -476,7 +450,6 @@ class UserMediaStatisticsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url.encode("ascii"), access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(channel.json_body["total"], len(expected_user_list))
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
self.hs.config.registration_shared_secret = None
|
||||
|
||||
request, channel = self.make_request("POST", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(
|
||||
|
@ -89,7 +88,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
self.hs.get_secrets = Mock(return_value=secrets)
|
||||
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.json_body, {"nonce": "abcd"})
|
||||
|
||||
|
@ -99,7 +97,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
only last for SALT_TIMEOUT (60s).
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
# 59 seconds
|
||||
|
@ -107,7 +104,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
body = json.dumps({"nonce": nonce})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("username must be specified", channel.json_body["error"])
|
||||
|
@ -116,7 +112,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
self.reactor.advance(2)
|
||||
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("unrecognised nonce", channel.json_body["error"])
|
||||
|
@ -126,7 +121,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
Only the provided nonce can be used, as it's checked in the MAC.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -143,7 +137,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("HMAC incorrect", channel.json_body["error"])
|
||||
|
@ -154,7 +147,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
user is registered.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -174,7 +166,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["user_id"])
|
||||
|
@ -184,7 +175,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
A valid unrecognised nonce.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -201,14 +191,12 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["user_id"])
|
||||
|
||||
# Now, try and reuse it
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("unrecognised nonce", channel.json_body["error"])
|
||||
|
@ -222,7 +210,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
def nonce():
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
return channel.json_body["nonce"]
|
||||
|
||||
#
|
||||
|
@ -232,7 +219,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must be present
|
||||
body = json.dumps({})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("nonce must be specified", channel.json_body["error"])
|
||||
|
@ -244,7 +230,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must be present
|
||||
body = json.dumps({"nonce": nonce()})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("username must be specified", channel.json_body["error"])
|
||||
|
@ -252,7 +237,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must be a string
|
||||
body = json.dumps({"nonce": nonce(), "username": 1234})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid username", channel.json_body["error"])
|
||||
|
@ -260,7 +244,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must not have null bytes
|
||||
body = json.dumps({"nonce": nonce(), "username": "abcd\u0000"})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid username", channel.json_body["error"])
|
||||
|
@ -268,7 +251,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must not have null bytes
|
||||
body = json.dumps({"nonce": nonce(), "username": "a" * 1000})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid username", channel.json_body["error"])
|
||||
|
@ -280,7 +262,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must be present
|
||||
body = json.dumps({"nonce": nonce(), "username": "a"})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("password must be specified", channel.json_body["error"])
|
||||
|
@ -288,7 +269,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must be a string
|
||||
body = json.dumps({"nonce": nonce(), "username": "a", "password": 1234})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid password", channel.json_body["error"])
|
||||
|
@ -296,7 +276,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Must not have null bytes
|
||||
body = json.dumps({"nonce": nonce(), "username": "a", "password": "abcd\u0000"})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid password", channel.json_body["error"])
|
||||
|
@ -304,7 +283,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
# Super long
|
||||
body = json.dumps({"nonce": nonce(), "username": "a", "password": "A" * 1000})
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid password", channel.json_body["error"])
|
||||
|
@ -323,7 +301,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Invalid user type", channel.json_body["error"])
|
||||
|
@ -335,7 +312,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# set no displayname
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -346,19 +322,16 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
{"nonce": nonce, "username": "bob1", "password": "abc123", "mac": want_mac}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob1:test", channel.json_body["user_id"])
|
||||
|
||||
request, channel = self.make_request("GET", "/profile/@bob1:test/displayname")
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("bob1", channel.json_body["displayname"])
|
||||
|
||||
# displayname is None
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -375,19 +348,16 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob2:test", channel.json_body["user_id"])
|
||||
|
||||
request, channel = self.make_request("GET", "/profile/@bob2:test/displayname")
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("bob2", channel.json_body["displayname"])
|
||||
|
||||
# displayname is empty
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -404,18 +374,15 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob3:test", channel.json_body["user_id"])
|
||||
|
||||
request, channel = self.make_request("GET", "/profile/@bob3:test/displayname")
|
||||
self.render(request)
|
||||
self.assertEqual(404, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# set displayname
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -432,13 +399,11 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob4:test", channel.json_body["user_id"])
|
||||
|
||||
request, channel = self.make_request("GET", "/profile/@bob4:test/displayname")
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("Bob's Name", channel.json_body["displayname"])
|
||||
|
||||
|
@ -465,7 +430,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Register new user with admin API
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
want_mac = hmac.new(key=b"shared", digestmod=hashlib.sha1)
|
||||
|
@ -485,7 +449,6 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request("POST", self.url, body.encode("utf8"))
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["user_id"])
|
||||
|
@ -511,7 +474,6 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
|||
Try to list users without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("M_MISSING_TOKEN", channel.json_body["errcode"])
|
||||
|
@ -526,7 +488,6 @@ class UsersListTestCase(unittest.HomeserverTestCase):
|
|||
b"{}",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(3, len(channel.json_body["users"]))
|
||||
|
@ -562,7 +523,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("You are not a server admin", channel.json_body["error"])
|
||||
|
@ -570,7 +530,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, access_token=self.other_user_token, content=b"{}",
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("You are not a server admin", channel.json_body["error"])
|
||||
|
@ -585,7 +544,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
"/_synapse/admin/v2/users/@unknown_person:test",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("M_NOT_FOUND", channel.json_body["errcode"])
|
||||
|
@ -613,7 +571,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -626,7 +583,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -659,7 +615,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -672,7 +627,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -700,7 +654,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/sync", access_token=self.admin_user_tok
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
if channel.code != 200:
|
||||
raise HttpResponseException(
|
||||
|
@ -729,7 +682,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -769,7 +721,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Admin user is not blocked by mau anymore
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
@ -807,7 +758,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -852,7 +802,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -879,7 +828,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
|
@ -897,7 +845,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -907,7 +854,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_other_user, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -929,7 +875,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -940,7 +885,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_other_user, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -961,7 +905,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -972,7 +915,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_other_user, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -990,7 +932,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=json.dumps({"deactivated": True}).encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self._is_erased("@user:test", False)
|
||||
d = self.store.mark_user_erased("@user:test")
|
||||
|
@ -1004,7 +945,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=json.dumps({"deactivated": False}).encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Reactivate the user.
|
||||
|
@ -1016,14 +956,12 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
encoding="utf_8"
|
||||
),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Get user
|
||||
request, channel = self.make_request(
|
||||
"GET", self.url_other_user, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -1044,7 +982,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -1054,7 +991,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_other_user, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@user:test", channel.json_body["name"])
|
||||
|
@ -1076,7 +1012,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(201, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -1086,7 +1021,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -1102,7 +1036,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.admin_user_tok,
|
||||
content=body.encode(encoding="utf_8"),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
|
@ -1110,7 +1043,6 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("@bob:test", channel.json_body["name"])
|
||||
|
@ -1153,7 +1085,6 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase):
|
|||
Try to list rooms of an user without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -1167,7 +1098,6 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -1180,7 +1110,6 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -1194,7 +1123,6 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -1208,7 +1136,6 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
@ -1228,7 +1155,6 @@ class UserMembershipRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(number_rooms, channel.json_body["total"])
|
||||
|
@ -1258,7 +1184,6 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
Try to list pushers of an user without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -1272,7 +1197,6 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -1285,7 +1209,6 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -1299,7 +1222,6 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -1313,7 +1235,6 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
@ -1343,7 +1264,6 @@ class PushersRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(1, channel.json_body["total"])
|
||||
|
@ -1383,7 +1303,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
Try to list media of an user without authentication.
|
||||
"""
|
||||
request, channel = self.make_request("GET", self.url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(401, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
|
||||
|
@ -1397,7 +1316,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=other_user_token,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(403, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -1410,7 +1328,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(404, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
@ -1424,7 +1341,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, channel.code, msg=channel.json_body)
|
||||
self.assertEqual("Can only lookup local users", channel.json_body["error"])
|
||||
|
@ -1441,7 +1357,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1461,7 +1376,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1481,7 +1395,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=5&limit=10", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1497,7 +1410,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=-5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -1510,7 +1422,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=-5", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"])
|
||||
|
@ -1529,7 +1440,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=20", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1541,7 +1451,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=21", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1553,7 +1462,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?limit=19", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1566,7 +1474,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url + "?from=19", access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(channel.json_body["total"], number_media)
|
||||
|
@ -1582,7 +1489,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(0, channel.json_body["total"])
|
||||
|
@ -1600,7 +1506,6 @@ class UserMediaRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url, access_token=self.admin_user_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(number_media, channel.json_body["total"])
|
||||
|
|
|
@ -94,7 +94,6 @@ class EphemeralMessageTestCase(unittest.HomeserverTestCase):
|
|||
url = "/_matrix/client/r0/rooms/%s/event/%s" % (room_id, event_id)
|
||||
|
||||
request, channel = self.make_request("GET", url)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ class IdentityTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", "/createRoom", b"{}", access_token=tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
room_id = channel.json_body["room_id"]
|
||||
|
||||
|
@ -60,5 +59,4 @@ class IdentityTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", request_url, request_data, access_token=tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
|
|
@ -72,7 +72,6 @@ class RedactionsTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", path, content={}, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(int(channel.result["code"]), expect_code)
|
||||
return channel.json_body
|
||||
|
||||
|
@ -80,7 +79,6 @@ class RedactionsTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "sync", access_token=self.mod_access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.result["code"], b"200")
|
||||
room_sync = channel.json_body["rooms"]["join"][room_id]
|
||||
return room_sync["timeline"]["events"]
|
||||
|
|
|
@ -326,7 +326,6 @@ class RetentionNoDefaultPolicyTestCase(unittest.HomeserverTestCase):
|
|||
url = "/_matrix/client/r0/rooms/%s/event/%s" % (room_id, event_id)
|
||||
|
||||
request, channel = self.make_request("GET", url, access_token=self.token)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
|
|
|
@ -95,7 +95,6 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
{"id_server": "test", "medium": "email", "address": "test@test.test"},
|
||||
access_token=self.banned_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
# This should have raised an error earlier, but double check this wasn't called.
|
||||
|
@ -110,7 +109,6 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
{"visibility": "public", "invite": [self.other_user_id]},
|
||||
access_token=self.banned_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
room_id = channel.json_body["room_id"]
|
||||
|
||||
|
@ -166,7 +164,6 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
{"new_version": "6"},
|
||||
access_token=self.banned_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
# A new room_id should be returned.
|
||||
self.assertIn("replacement_room", channel.json_body)
|
||||
|
@ -192,7 +189,6 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
{"typing": True, "timeout": 30000},
|
||||
access_token=self.banned_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
# There should be no typing events.
|
||||
|
@ -208,7 +204,6 @@ class RoomTestCase(_ShadowBannedBase):
|
|||
{"typing": True, "timeout": 30000},
|
||||
access_token=self.other_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
# These appear in the room.
|
||||
|
@ -255,7 +250,6 @@ class ProfileTestCase(_ShadowBannedBase):
|
|||
{"displayname": new_display_name},
|
||||
access_token=self.banned_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertEqual(channel.json_body, {})
|
||||
|
||||
|
@ -263,7 +257,6 @@ class ProfileTestCase(_ShadowBannedBase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/profile/%s/displayname" % (self.banned_user_id,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
self.assertEqual(channel.json_body["displayname"], new_display_name)
|
||||
|
||||
|
@ -296,7 +289,6 @@ class ProfileTestCase(_ShadowBannedBase):
|
|||
{"membership": "join", "displayname": new_display_name},
|
||||
access_token=self.banned_access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertIn("event_id", channel.json_body)
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
{},
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
callback.assert_called_once()
|
||||
|
@ -111,7 +110,6 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
{},
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
||||
def test_cannot_modify_event(self):
|
||||
|
@ -131,7 +129,6 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
{"x": "x"},
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.result["code"], b"500", channel.result)
|
||||
|
||||
def test_modify_event(self):
|
||||
|
@ -151,7 +148,6 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
{"x": "x"},
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.result["code"], b"200", channel.result)
|
||||
event_id = channel.json_body["event_id"]
|
||||
|
||||
|
@ -161,7 +157,6 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/rooms/%s/event/%s" % (self.room_id, event_id),
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.result["code"], b"200", channel.result)
|
||||
ev = channel.json_body
|
||||
self.assertEqual(ev["content"]["x"], "y")
|
||||
|
|
|
@ -94,7 +94,6 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url, request_data, access_token=self.user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
|
||||
def test_room_creation(self):
|
||||
|
@ -108,7 +107,6 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", url, request_data, access_token=self.user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
def set_alias_via_state_event(self, expected_code, alias_length=5):
|
||||
|
@ -123,7 +121,6 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, request_data, access_token=self.user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
def set_alias_via_directory(self, expected_code, alias_length=5):
|
||||
|
@ -134,7 +131,6 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, request_data, access_token=self.user_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
def random_alias(self, length):
|
||||
|
|
|
@ -66,14 +66,12 @@ class EventStreamPermissionsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/events?access_token=%s" % ("invalid" + self.token,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, msg=channel.result)
|
||||
|
||||
# valid token, expect content
|
||||
request, channel = self.make_request(
|
||||
"GET", "/events?access_token=%s&timeout=0" % (self.token,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, msg=channel.result)
|
||||
self.assertTrue("chunk" in channel.json_body)
|
||||
self.assertTrue("start" in channel.json_body)
|
||||
|
@ -92,7 +90,6 @@ class EventStreamPermissionsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/events?access_token=%s&timeout=0" % (self.token,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, msg=channel.result)
|
||||
|
||||
# We may get a presence event for ourselves down
|
||||
|
@ -155,5 +152,4 @@ class GetEventsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/events/" + event_id, access_token=self.token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, msg=channel.result)
|
||||
|
|
|
@ -64,7 +64,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "monkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
if i == 5:
|
||||
self.assertEquals(channel.result["code"], b"429", channel.result)
|
||||
|
@ -84,7 +83,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "monkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
|
@ -111,7 +109,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "monkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
if i == 5:
|
||||
self.assertEquals(channel.result["code"], b"429", channel.result)
|
||||
|
@ -131,7 +128,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "monkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
|
@ -158,7 +154,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "notamonkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
if i == 5:
|
||||
self.assertEquals(channel.result["code"], b"429", channel.result)
|
||||
|
@ -178,7 +173,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "notamonkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
||||
|
@ -188,7 +182,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# we shouldn't be able to make requests without an access token
|
||||
request, channel = self.make_request(b"GET", TEST_URL)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
self.assertEquals(channel.json_body["errcode"], "M_MISSING_TOKEN")
|
||||
|
||||
|
@ -199,7 +192,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"password": "monkey",
|
||||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.code, 200, channel.result)
|
||||
access_token = channel.json_body["access_token"]
|
||||
|
@ -209,7 +201,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, channel.result)
|
||||
|
||||
# time passes
|
||||
|
@ -219,7 +210,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, channel.result)
|
||||
self.assertEquals(channel.json_body["errcode"], "M_UNKNOWN_TOKEN")
|
||||
self.assertEquals(channel.json_body["soft_logout"], True)
|
||||
|
@ -236,7 +226,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, channel.result)
|
||||
self.assertEquals(channel.json_body["errcode"], "M_UNKNOWN_TOKEN")
|
||||
self.assertEquals(channel.json_body["soft_logout"], True)
|
||||
|
@ -247,7 +236,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, channel.result)
|
||||
self.assertEquals(channel.json_body["errcode"], "M_UNKNOWN_TOKEN")
|
||||
self.assertEquals(channel.json_body["soft_logout"], False)
|
||||
|
@ -257,7 +245,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"DELETE", "devices/" + device_id, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, channel.result)
|
||||
# check it's a UI-Auth fail
|
||||
self.assertEqual(
|
||||
|
@ -281,7 +268,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
access_token=access_token,
|
||||
content={"auth": auth},
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, channel.result)
|
||||
|
||||
@override_config({"session_lifetime": "24h"})
|
||||
|
@ -295,7 +281,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, channel.result)
|
||||
|
||||
# time passes
|
||||
|
@ -305,7 +290,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, channel.result)
|
||||
self.assertEquals(channel.json_body["errcode"], "M_UNKNOWN_TOKEN")
|
||||
self.assertEquals(channel.json_body["soft_logout"], True)
|
||||
|
@ -314,7 +298,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", "/logout", access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
@override_config({"session_lifetime": "24h"})
|
||||
|
@ -328,7 +311,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, channel.result)
|
||||
|
||||
# time passes
|
||||
|
@ -338,7 +320,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"GET", TEST_URL, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 401, channel.result)
|
||||
self.assertEquals(channel.json_body["errcode"], "M_UNKNOWN_TOKEN")
|
||||
self.assertEquals(channel.json_body["soft_logout"], True)
|
||||
|
@ -347,7 +328,6 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", "/logout/all", access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
|
||||
|
@ -423,7 +403,6 @@ class CASTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Get Synapse to call the fake CAS and serve the template.
|
||||
request, channel = self.make_request("GET", cas_ticket_url)
|
||||
self.render(request)
|
||||
|
||||
# Test that the response is HTML.
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
@ -468,7 +447,6 @@ class CASTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Get Synapse to call the fake CAS and serve the template.
|
||||
request, channel = self.make_request("GET", cas_ticket_url)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 302)
|
||||
location_headers = channel.headers.getRawHeaders("Location")
|
||||
|
@ -495,7 +473,6 @@ class CASTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Get Synapse to call the fake CAS and serve the template.
|
||||
request, channel = self.make_request("GET", cas_ticket_url)
|
||||
self.render(request)
|
||||
|
||||
# Because the user is deactivated they are served an error template.
|
||||
self.assertEqual(channel.code, 403)
|
||||
|
@ -526,7 +503,6 @@ class JWTTestCase(unittest.HomeserverTestCase):
|
|||
{"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)}
|
||||
)
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
return channel
|
||||
|
||||
def test_login_jwt_valid_registered(self):
|
||||
|
@ -659,7 +635,6 @@ class JWTTestCase(unittest.HomeserverTestCase):
|
|||
def test_login_no_token(self):
|
||||
params = json.dumps({"type": "org.matrix.login.jwt"})
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.result["code"], b"403", channel.result)
|
||||
self.assertEqual(channel.json_body["errcode"], "M_FORBIDDEN")
|
||||
self.assertEqual(channel.json_body["error"], "Token field for JWT is missing")
|
||||
|
@ -733,7 +708,6 @@ class JWTPubKeyTestCase(unittest.HomeserverTestCase):
|
|||
{"type": "org.matrix.login.jwt", "token": self.jwt_encode(*args)}
|
||||
)
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
self.render(request)
|
||||
return channel
|
||||
|
||||
def test_login_jwt_valid(self):
|
||||
|
@ -766,7 +740,6 @@ class AppserviceLoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/register?access_token=%s" % (self.service.token,),
|
||||
{"username": username},
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
def make_homeserver(self, reactor, clock):
|
||||
self.hs = self.setup_test_homeserver()
|
||||
|
@ -815,7 +788,6 @@ class AppserviceLoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
b"POST", LOGIN_URL, params, access_token=self.service.token
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
def test_login_appservice_user_bot(self):
|
||||
|
@ -831,7 +803,6 @@ class AppserviceLoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
b"POST", LOGIN_URL, params, access_token=self.service.token
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
def test_login_appservice_wrong_user(self):
|
||||
|
@ -847,7 +818,6 @@ class AppserviceLoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
b"POST", LOGIN_URL, params, access_token=self.service.token
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
||||
def test_login_appservice_wrong_as(self):
|
||||
|
@ -863,7 +833,6 @@ class AppserviceLoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
b"POST", LOGIN_URL, params, access_token=self.another_service.token
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
||||
def test_login_appservice_no_token(self):
|
||||
|
@ -878,5 +847,4 @@ class AppserviceLoginRestServletTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
request, channel = self.make_request(b"POST", LOGIN_URL, params)
|
||||
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
|
|
|
@ -53,7 +53,6 @@ class PresenceTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/presence/%s/status" % (self.user_id,), body
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(self.hs.presence_handler.set_state.call_count, 1)
|
||||
|
@ -69,7 +68,6 @@ class PresenceTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/presence/%s/status" % (self.user_id,), body
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(self.hs.presence_handler.set_state.call_count, 0)
|
||||
|
|
|
@ -195,7 +195,6 @@ class ProfileTestCase(unittest.HomeserverTestCase):
|
|||
content=json.dumps({"displayname": "test"}),
|
||||
access_token=self.owner_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
res = self.get_displayname()
|
||||
|
@ -209,7 +208,6 @@ class ProfileTestCase(unittest.HomeserverTestCase):
|
|||
content=json.dumps({"displayname": "test" * 100}),
|
||||
access_token=self.owner_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
|
||||
res = self.get_displayname()
|
||||
|
@ -219,7 +217,6 @@ class ProfileTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/profile/%s/displayname" % (self.owner,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
return channel.json_body["displayname"]
|
||||
|
||||
|
@ -284,7 +281,6 @@ class ProfilesRestrictedTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.profile_url + url_suffix, access_token=access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
def ensure_requester_left_room(self):
|
||||
|
@ -327,7 +323,6 @@ class OwnProfileUnrestrictedTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/profile/" + self.requester, access_token=self.requester_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
request, channel = self.make_request(
|
||||
|
@ -335,7 +330,6 @@ class OwnProfileUnrestrictedTestCase(unittest.HomeserverTestCase):
|
|||
"/profile/" + self.requester + "/displayname",
|
||||
access_token=self.requester_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
request, channel = self.make_request(
|
||||
|
@ -343,5 +337,4 @@ class OwnProfileUnrestrictedTestCase(unittest.HomeserverTestCase):
|
|||
"/profile/" + self.requester + "/avatar_url",
|
||||
access_token=self.requester_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
|
|
@ -48,14 +48,12 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# GET enabled for that new rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(channel.json_body["enabled"], True)
|
||||
|
||||
|
@ -79,7 +77,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# disable the rule
|
||||
|
@ -89,14 +86,12 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"enabled": False},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# check rule disabled
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(channel.json_body["enabled"], False)
|
||||
|
||||
|
@ -104,21 +99,18 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", "/pushrules/global/override/best.friend", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# PUT a new rule
|
||||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# GET enabled for that new rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(channel.json_body["enabled"], True)
|
||||
|
||||
|
@ -141,7 +133,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# disable the rule
|
||||
|
@ -151,14 +142,12 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"enabled": False},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# check rule disabled
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(channel.json_body["enabled"], False)
|
||||
|
||||
|
@ -169,14 +158,12 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"enabled": True},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# check rule enabled
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(channel.json_body["enabled"], True)
|
||||
|
||||
|
@ -198,7 +185,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -206,28 +192,24 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# GET enabled for that new rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# DELETE the rule
|
||||
request, channel = self.make_request(
|
||||
"DELETE", "/pushrules/global/override/best.friend", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# check 404 for deleted rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -242,7 +224,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/.m.muahahaha/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -260,7 +241,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"enabled": True},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -278,7 +258,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"enabled": True},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -300,14 +279,12 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# GET actions for that new rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/actions", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(
|
||||
channel.json_body["actions"], ["notify", {"set_tweak": "highlight"}]
|
||||
|
@ -331,7 +308,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# change the rule actions
|
||||
|
@ -341,14 +317,12 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"actions": ["dont_notify"]},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# GET actions for that new rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/actions", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertEqual(channel.json_body["actions"], ["dont_notify"])
|
||||
|
||||
|
@ -370,7 +344,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -378,21 +351,18 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/pushrules/global/override/best.friend", body, access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# DELETE the rule
|
||||
request, channel = self.make_request(
|
||||
"DELETE", "/pushrules/global/override/best.friend", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# check 404 for deleted rule
|
||||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/best.friend/enabled", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -407,7 +377,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/pushrules/global/override/.m.muahahaha/actions", access_token=token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -425,7 +394,6 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"actions": ["dont_notify"]},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
||||
|
@ -443,6 +411,5 @@ class PushRuleAttributesTestCase(HomeserverTestCase):
|
|||
{"actions": ["dont_notify"]},
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 404)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
|
|
@ -86,7 +86,6 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", self.created_rmid_msg_path, b'{"msgtype":"m.text","body":"test msg"}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
# set topic for public room
|
||||
|
@ -95,7 +94,6 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
("rooms/%s/state/m.room.topic" % self.created_public_rmid).encode("ascii"),
|
||||
b'{"topic":"Public Room Topic"}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
# auth as user_id now
|
||||
|
@ -118,12 +116,10 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
"/rooms/%s/send/m.room.message/mid2" % (self.uncreated_rmid,),
|
||||
msg_content,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# send message in created room not joined (no state), expect 403
|
||||
request, channel = self.make_request("PUT", send_msg_path(), msg_content)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# send message in created room and invited, expect 403
|
||||
|
@ -131,19 +127,16 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
room=self.created_rmid, src=self.rmcreator_id, targ=self.user_id
|
||||
)
|
||||
request, channel = self.make_request("PUT", send_msg_path(), msg_content)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# send message in created room and joined, expect 200
|
||||
self.helper.join(room=self.created_rmid, user=self.user_id)
|
||||
request, channel = self.make_request("PUT", send_msg_path(), msg_content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
# send message in created room and left, expect 403
|
||||
self.helper.leave(room=self.created_rmid, user=self.user_id)
|
||||
request, channel = self.make_request("PUT", send_msg_path(), msg_content)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_topic_perms(self):
|
||||
|
@ -154,20 +147,16 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", "/rooms/%s/state/m.room.topic" % self.uncreated_rmid, topic_content
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
request, channel = self.make_request(
|
||||
"GET", "/rooms/%s/state/m.room.topic" % self.uncreated_rmid
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# set/get topic in created PRIVATE room not joined, expect 403
|
||||
request, channel = self.make_request("PUT", topic_path, topic_content)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
request, channel = self.make_request("GET", topic_path)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# set topic in created PRIVATE room and invited, expect 403
|
||||
|
@ -175,12 +164,10 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
room=self.created_rmid, src=self.rmcreator_id, targ=self.user_id
|
||||
)
|
||||
request, channel = self.make_request("PUT", topic_path, topic_content)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# get topic in created PRIVATE room and invited, expect 403
|
||||
request, channel = self.make_request("GET", topic_path)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# set/get topic in created PRIVATE room and joined, expect 200
|
||||
|
@ -189,29 +176,24 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
# Only room ops can set topic by default
|
||||
self.helper.auth_user_id = self.rmcreator_id
|
||||
request, channel = self.make_request("PUT", topic_path, topic_content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
self.helper.auth_user_id = self.user_id
|
||||
|
||||
request, channel = self.make_request("GET", topic_path)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
self.assert_dict(json.loads(topic_content.decode("utf8")), channel.json_body)
|
||||
|
||||
# set/get topic in created PRIVATE room and left, expect 403
|
||||
self.helper.leave(room=self.created_rmid, user=self.user_id)
|
||||
request, channel = self.make_request("PUT", topic_path, topic_content)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
request, channel = self.make_request("GET", topic_path)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
# get topic in PUBLIC room, not joined, expect 403
|
||||
request, channel = self.make_request(
|
||||
"GET", "/rooms/%s/state/m.room.topic" % self.created_public_rmid
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
# set topic in PUBLIC room, not joined, expect 403
|
||||
|
@ -220,14 +202,12 @@ class RoomPermissionsTestCase(RoomBase):
|
|||
"/rooms/%s/state/m.room.topic" % self.created_public_rmid,
|
||||
topic_content,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
def _test_get_membership(self, room=None, members=[], expect_code=None):
|
||||
for member in members:
|
||||
path = "/rooms/%s/state/m.room.member/%s" % (room, member)
|
||||
request, channel = self.make_request("GET", path)
|
||||
self.render(request)
|
||||
self.assertEquals(expect_code, channel.code)
|
||||
|
||||
def test_membership_basic_room_perms(self):
|
||||
|
@ -400,18 +380,15 @@ class RoomsMemberListTestCase(RoomBase):
|
|||
def test_get_member_list(self):
|
||||
room_id = self.helper.create_room_as(self.user_id)
|
||||
request, channel = self.make_request("GET", "/rooms/%s/members" % room_id)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_get_member_list_no_room(self):
|
||||
request, channel = self.make_request("GET", "/rooms/roomdoesnotexist/members")
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_get_member_list_no_permission(self):
|
||||
room_id = self.helper.create_room_as("@some_other_guy:red")
|
||||
request, channel = self.make_request("GET", "/rooms/%s/members" % room_id)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_get_member_list_mixed_memberships(self):
|
||||
|
@ -421,19 +398,16 @@ class RoomsMemberListTestCase(RoomBase):
|
|||
self.helper.invite(room=room_id, src=room_creator, targ=self.user_id)
|
||||
# can't see list if you're just invited.
|
||||
request, channel = self.make_request("GET", room_path)
|
||||
self.render(request)
|
||||
self.assertEquals(403, channel.code, msg=channel.result["body"])
|
||||
|
||||
self.helper.join(room=room_id, user=self.user_id)
|
||||
# can see list now joined
|
||||
request, channel = self.make_request("GET", room_path)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
self.helper.leave(room=room_id, user=self.user_id)
|
||||
# can see old list once left
|
||||
request, channel = self.make_request("GET", room_path)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
|
||||
|
@ -446,7 +420,6 @@ class RoomsCreateTestCase(RoomBase):
|
|||
# POST with no config keys, expect new room id
|
||||
request, channel = self.make_request("POST", "/createRoom", "{}")
|
||||
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
self.assertTrue("room_id" in channel.json_body)
|
||||
|
||||
|
@ -455,7 +428,6 @@ class RoomsCreateTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/createRoom", b'{"visibility":"private"}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
self.assertTrue("room_id" in channel.json_body)
|
||||
|
||||
|
@ -464,7 +436,6 @@ class RoomsCreateTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/createRoom", b'{"custom":"stuff"}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
self.assertTrue("room_id" in channel.json_body)
|
||||
|
||||
|
@ -473,18 +444,15 @@ class RoomsCreateTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/createRoom", b'{"visibility":"private","custom":"things"}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
self.assertTrue("room_id" in channel.json_body)
|
||||
|
||||
def test_post_room_invalid_content(self):
|
||||
# POST with invalid content / paths, expect 400
|
||||
request, channel = self.make_request("POST", "/createRoom", b'{"visibili')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code)
|
||||
|
||||
request, channel = self.make_request("POST", "/createRoom", b'["hello"]')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code)
|
||||
|
||||
def test_post_room_invitees_invalid_mxid(self):
|
||||
|
@ -493,7 +461,6 @@ class RoomsCreateTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/createRoom", b'{"invite":["@alice:example.com "]}'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code)
|
||||
|
||||
|
||||
|
@ -510,52 +477,42 @@ class RoomTopicTestCase(RoomBase):
|
|||
def test_invalid_puts(self):
|
||||
# missing keys or invalid json
|
||||
request, channel = self.make_request("PUT", self.path, "{}")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", self.path, '{"_name":"bo"}')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", self.path, '{"nao')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request(
|
||||
"PUT", self.path, '[{"_name":"bo"},{"_name":"jill"}]'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", self.path, "text only")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", self.path, "")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
# valid key, wrong type
|
||||
content = '{"topic":["Topic name"]}'
|
||||
request, channel = self.make_request("PUT", self.path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_rooms_topic(self):
|
||||
# nothing should be there
|
||||
request, channel = self.make_request("GET", self.path)
|
||||
self.render(request)
|
||||
self.assertEquals(404, channel.code, msg=channel.result["body"])
|
||||
|
||||
# valid put
|
||||
content = '{"topic":"Topic name"}'
|
||||
request, channel = self.make_request("PUT", self.path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
# valid get
|
||||
request, channel = self.make_request("GET", self.path)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
self.assert_dict(json.loads(content), channel.json_body)
|
||||
|
||||
|
@ -563,12 +520,10 @@ class RoomTopicTestCase(RoomBase):
|
|||
# valid put with extra keys
|
||||
content = '{"topic":"Seasons","subtopic":"Summer"}'
|
||||
request, channel = self.make_request("PUT", self.path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
# valid get
|
||||
request, channel = self.make_request("GET", self.path)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
self.assert_dict(json.loads(content), channel.json_body)
|
||||
|
||||
|
@ -585,29 +540,23 @@ class RoomMemberStateTestCase(RoomBase):
|
|||
path = "/rooms/%s/state/m.room.member/%s" % (self.room_id, self.user_id)
|
||||
# missing keys or invalid json
|
||||
request, channel = self.make_request("PUT", path, "{}")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, '{"_name":"bo"}')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, '{"nao')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request(
|
||||
"PUT", path, b'[{"_name":"bo"},{"_name":"jill"}]'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, "text only")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, "")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
# valid keys, wrong types
|
||||
|
@ -617,7 +566,6 @@ class RoomMemberStateTestCase(RoomBase):
|
|||
Membership.LEAVE,
|
||||
)
|
||||
request, channel = self.make_request("PUT", path, content.encode("ascii"))
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_rooms_members_self(self):
|
||||
|
@ -629,11 +577,9 @@ class RoomMemberStateTestCase(RoomBase):
|
|||
# valid join message (NOOP since we made the room)
|
||||
content = '{"membership":"%s"}' % Membership.JOIN
|
||||
request, channel = self.make_request("PUT", path, content.encode("ascii"))
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("GET", path, None)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
expected_response = {"membership": Membership.JOIN}
|
||||
|
@ -649,11 +595,9 @@ class RoomMemberStateTestCase(RoomBase):
|
|||
# valid invite message
|
||||
content = '{"membership":"%s"}' % Membership.INVITE
|
||||
request, channel = self.make_request("PUT", path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("GET", path, None)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
self.assertEquals(json.loads(content), channel.json_body)
|
||||
|
||||
|
@ -670,11 +614,9 @@ class RoomMemberStateTestCase(RoomBase):
|
|||
"Join us!",
|
||||
)
|
||||
request, channel = self.make_request("PUT", path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("GET", path, None)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
self.assertEquals(json.loads(content), channel.json_body)
|
||||
|
||||
|
@ -725,7 +667,6 @@ class RoomJoinRatelimitTestCase(RoomBase):
|
|||
# Update the display name for the user.
|
||||
path = "/_matrix/client/r0/profile/%s/displayname" % self.user_id
|
||||
request, channel = self.make_request("PUT", path, {"displayname": "John Doe"})
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200, channel.json_body)
|
||||
|
||||
# Check that all the rooms have been sent a profile update into.
|
||||
|
@ -736,7 +677,6 @@ class RoomJoinRatelimitTestCase(RoomBase):
|
|||
)
|
||||
|
||||
request, channel = self.make_request("GET", path)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200)
|
||||
|
||||
self.assertIn("displayname", channel.json_body)
|
||||
|
@ -761,7 +701,6 @@ class RoomJoinRatelimitTestCase(RoomBase):
|
|||
# if all of these requests ended up joining the user to a room.
|
||||
for i in range(4):
|
||||
request, channel = self.make_request("POST", path % room_id, {})
|
||||
self.render(request)
|
||||
self.assertEquals(channel.code, 200)
|
||||
|
||||
|
||||
|
@ -777,29 +716,23 @@ class RoomMessagesTestCase(RoomBase):
|
|||
path = "/rooms/%s/send/m.room.message/mid1" % (urlparse.quote(self.room_id))
|
||||
# missing keys or invalid json
|
||||
request, channel = self.make_request("PUT", path, b"{}")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, b'{"_name":"bo"}')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, b'{"nao')
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request(
|
||||
"PUT", path, b'[{"_name":"bo"},{"_name":"jill"}]'
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, b"text only")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
request, channel = self.make_request("PUT", path, b"")
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
def test_rooms_messages_sent(self):
|
||||
|
@ -807,20 +740,17 @@ class RoomMessagesTestCase(RoomBase):
|
|||
|
||||
content = b'{"body":"test","msgtype":{"type":"a"}}'
|
||||
request, channel = self.make_request("PUT", path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, msg=channel.result["body"])
|
||||
|
||||
# custom message types
|
||||
content = b'{"body":"test","msgtype":"test.custom.text"}'
|
||||
request, channel = self.make_request("PUT", path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
# m.text message type
|
||||
path = "/rooms/%s/send/m.room.message/mid2" % (urlparse.quote(self.room_id))
|
||||
content = b'{"body":"test2","msgtype":"m.text"}'
|
||||
request, channel = self.make_request("PUT", path, content)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, msg=channel.result["body"])
|
||||
|
||||
|
||||
|
@ -837,7 +767,6 @@ class RoomInitialSyncTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/rooms/%s/initialSync" % self.room_id
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
self.assertEquals(self.room_id, channel.json_body["room_id"])
|
||||
|
@ -881,7 +810,6 @@ class RoomMessageListTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/rooms/%s/messages?access_token=x&from=%s" % (self.room_id, token)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
self.assertTrue("start" in channel.json_body)
|
||||
self.assertEquals(token, channel.json_body["start"])
|
||||
|
@ -893,7 +821,6 @@ class RoomMessageListTestCase(RoomBase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/rooms/%s/messages?access_token=x&from=%s" % (self.room_id, token)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
self.assertTrue("start" in channel.json_body)
|
||||
self.assertEquals(token, channel.json_body["start"])
|
||||
|
@ -933,7 +860,6 @@ class RoomMessageListTestCase(RoomBase):
|
|||
json.dumps({"types": [EventTypes.Message]}),
|
||||
),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.json_body)
|
||||
|
||||
chunk = channel.json_body["chunk"]
|
||||
|
@ -962,7 +888,6 @@ class RoomMessageListTestCase(RoomBase):
|
|||
json.dumps({"types": [EventTypes.Message]}),
|
||||
),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.json_body)
|
||||
|
||||
chunk = channel.json_body["chunk"]
|
||||
|
@ -980,7 +905,6 @@ class RoomMessageListTestCase(RoomBase):
|
|||
json.dumps({"types": [EventTypes.Message]}),
|
||||
),
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.json_body)
|
||||
|
||||
chunk = channel.json_body["chunk"]
|
||||
|
@ -1040,7 +964,6 @@ class RoomSearchTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
},
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Check we get the results we expect -- one search result, of the sent
|
||||
# messages
|
||||
|
@ -1074,7 +997,6 @@ class RoomSearchTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
},
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Check we get the results we expect -- one search result, of the sent
|
||||
# messages
|
||||
|
@ -1111,7 +1033,6 @@ class PublicRoomsRestrictedTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
def test_restricted_no_auth(self):
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 401, channel.result)
|
||||
|
||||
def test_restricted_auth(self):
|
||||
|
@ -1119,7 +1040,6 @@ class PublicRoomsRestrictedTestCase(unittest.HomeserverTestCase):
|
|||
tok = self.login("user", "pass")
|
||||
|
||||
request, channel = self.make_request("GET", self.url, access_token=tok)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
|
||||
|
@ -1153,7 +1073,6 @@ class PerRoomProfilesForbiddenTestCase(unittest.HomeserverTestCase):
|
|||
request_data,
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self.room_id = self.helper.create_room_as(self.user_id, tok=self.tok)
|
||||
|
@ -1168,7 +1087,6 @@ class PerRoomProfilesForbiddenTestCase(unittest.HomeserverTestCase):
|
|||
request_data,
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
event_id = channel.json_body["event_id"]
|
||||
|
||||
|
@ -1177,7 +1095,6 @@ class PerRoomProfilesForbiddenTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/rooms/%s/event/%s" % (self.room_id, event_id),
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
res_displayname = channel.json_body["content"]["displayname"]
|
||||
|
@ -1212,7 +1129,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason},
|
||||
access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1227,7 +1143,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason},
|
||||
access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1242,7 +1157,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason, "user_id": self.second_user_id},
|
||||
access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1257,7 +1171,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason, "user_id": self.second_user_id},
|
||||
access_token=self.creator_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1270,7 +1183,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason, "user_id": self.second_user_id},
|
||||
access_token=self.creator_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1283,7 +1195,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason, "user_id": self.second_user_id},
|
||||
access_token=self.creator_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1303,7 +1214,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
content={"reason": reason},
|
||||
access_token=self.second_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
self._check_for_reason(reason)
|
||||
|
@ -1316,7 +1226,6 @@ class RoomMembershipReasonTestCase(unittest.HomeserverTestCase):
|
|||
),
|
||||
access_token=self.creator_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
event_content = channel.json_body
|
||||
|
@ -1365,7 +1274,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room_id, event_id, json.dumps(self.FILTER_LABELS)),
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
events_before = channel.json_body["events_before"]
|
||||
|
@ -1396,7 +1304,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room_id, event_id, json.dumps(self.FILTER_NOT_LABELS)),
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
events_before = channel.json_body["events_before"]
|
||||
|
@ -1432,7 +1339,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room_id, event_id, json.dumps(self.FILTER_LABELS_NOT_LABELS)),
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
events_before = channel.json_body["events_before"]
|
||||
|
@ -1460,7 +1366,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/messages?access_token=%s&from=%s&filter=%s"
|
||||
% (self.room_id, self.tok, token, json.dumps(self.FILTER_LABELS)),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
events = channel.json_body["chunk"]
|
||||
|
||||
|
@ -1478,7 +1383,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/messages?access_token=%s&from=%s&filter=%s"
|
||||
% (self.room_id, self.tok, token, json.dumps(self.FILTER_NOT_LABELS)),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
events = channel.json_body["chunk"]
|
||||
|
||||
|
@ -1507,7 +1411,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps(self.FILTER_LABELS_NOT_LABELS),
|
||||
),
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
events = channel.json_body["chunk"]
|
||||
|
||||
|
@ -1532,7 +1435,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/search?access_token=%s" % self.tok, request_data
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
results = channel.json_body["search_categories"]["room_events"]["results"]
|
||||
|
||||
|
@ -1568,7 +1470,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/search?access_token=%s" % self.tok, request_data
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
results = channel.json_body["search_categories"]["room_events"]["results"]
|
||||
|
||||
|
@ -1616,7 +1517,6 @@ class LabelsTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/search?access_token=%s" % self.tok, request_data
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
results = channel.json_body["search_categories"]["room_events"]["results"]
|
||||
|
||||
|
@ -1741,7 +1641,6 @@ class ContextTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room_id, event_id),
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
events_before = channel.json_body["events_before"]
|
||||
|
@ -1806,7 +1705,6 @@ class ContextTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room_id, event_id),
|
||||
access_token=invited_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
events_before = channel.json_body["events_before"]
|
||||
|
@ -1897,7 +1795,6 @@ class RoomAliasListTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room_id,),
|
||||
access_token=access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
res = channel.json_body
|
||||
self.assertIsInstance(res, dict)
|
||||
|
@ -1916,7 +1813,6 @@ class RoomAliasListTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, request_data, access_token=self.room_owner_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
|
||||
|
@ -1947,7 +1843,6 @@ class RoomCanonicalAliasTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"PUT", url, request_data, access_token=self.room_owner_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
|
||||
def _get_canonical_alias(self, expected_code: int = 200) -> JsonDict:
|
||||
|
@ -1957,7 +1852,6 @@ class RoomCanonicalAliasTestCase(unittest.HomeserverTestCase):
|
|||
"rooms/%s/state/m.room.canonical_alias" % (self.room_id,),
|
||||
access_token=self.room_owner_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
res = channel.json_body
|
||||
self.assertIsInstance(res, dict)
|
||||
|
@ -1971,7 +1865,6 @@ class RoomCanonicalAliasTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps(content),
|
||||
access_token=self.room_owner_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, expected_code, channel.result)
|
||||
res = channel.json_body
|
||||
self.assertIsInstance(res, dict)
|
||||
|
|
|
@ -99,7 +99,6 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/typing/%s" % (self.room_id, self.user_id),
|
||||
b'{"typing": true, "timeout": 30000}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||
|
@ -123,7 +122,6 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/typing/%s" % (self.room_id, self.user_id),
|
||||
b'{"typing": false}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
def test_typing_timeout(self):
|
||||
|
@ -132,7 +130,6 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/typing/%s" % (self.room_id, self.user_id),
|
||||
b'{"typing": true, "timeout": 30000}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
self.assertEquals(self.event_source.get_current_key(), 1)
|
||||
|
@ -146,7 +143,6 @@ class RoomTypingTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/typing/%s" % (self.room_id, self.user_id),
|
||||
b'{"typing": true, "timeout": 30000}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
self.assertEquals(self.event_source.get_current_key(), 3)
|
||||
|
|
|
@ -246,7 +246,6 @@ class PasswordResetTestCase(unittest.HomeserverTestCase):
|
|||
b"account/password/email/requestToken",
|
||||
{"client_secret": client_secret, "email": email, "send_attempt": 1},
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
return channel.json_body["sid"]
|
||||
|
@ -325,7 +324,6 @@ class PasswordResetTestCase(unittest.HomeserverTestCase):
|
|||
},
|
||||
},
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(expected_code, channel.code, channel.result)
|
||||
|
||||
|
||||
|
@ -355,7 +353,6 @@ class DeactivateTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Check that this access token has been invalidated.
|
||||
request, channel = self.make_request("GET", "account/whoami")
|
||||
self.render(request)
|
||||
self.assertEqual(request.code, 401)
|
||||
|
||||
def test_pending_invites(self):
|
||||
|
@ -413,7 +410,6 @@ class DeactivateTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "account/deactivate", request_data, access_token=tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(request.code, 200)
|
||||
|
||||
|
||||
|
@ -548,7 +544,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
},
|
||||
access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
||||
|
@ -556,7 +551,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_3pid, access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertFalse(channel.json_body["threepids"])
|
||||
|
@ -581,14 +575,12 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
{"medium": "email", "address": self.email},
|
||||
access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Get user
|
||||
request, channel = self.make_request(
|
||||
"GET", self.url_3pid, access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertFalse(channel.json_body["threepids"])
|
||||
|
@ -615,7 +607,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
{"medium": "email", "address": self.email},
|
||||
access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.FORBIDDEN, channel.json_body["errcode"])
|
||||
|
@ -624,7 +615,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_3pid, access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
|
@ -653,7 +643,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
},
|
||||
access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.THREEPID_AUTH_FAILED, channel.json_body["errcode"])
|
||||
|
||||
|
@ -661,7 +650,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_3pid, access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertFalse(channel.json_body["threepids"])
|
||||
|
@ -688,7 +676,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
},
|
||||
access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(Codes.THREEPID_AUTH_FAILED, channel.json_body["errcode"])
|
||||
|
||||
|
@ -696,7 +683,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url_3pid, access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertFalse(channel.json_body["threepids"])
|
||||
|
@ -801,7 +787,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", b"account/3pid/email/requestToken", body,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(expect_code, channel.code, channel.result)
|
||||
|
||||
return channel.json_body.get("sid")
|
||||
|
@ -814,7 +799,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
b"account/3pid/email/requestToken",
|
||||
{"client_secret": client_secret, "email": email, "send_attempt": 1},
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(400, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual(expected_errcode, channel.json_body["errcode"])
|
||||
self.assertEqual(expected_error, channel.json_body["error"])
|
||||
|
@ -824,7 +808,6 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
path = link.replace("https://example.com", "")
|
||||
|
||||
request, channel = self.make_request("GET", path, shorthand=False)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
def _get_link_from_email(self):
|
||||
|
@ -873,14 +856,12 @@ class ThreepidEmailRestTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.user_id_tok,
|
||||
)
|
||||
|
||||
self.render(request)
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
|
||||
# Get user
|
||||
request, channel = self.make_request(
|
||||
"GET", self.url_3pid, access_token=self.user_id_tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"])
|
||||
self.assertEqual("email", channel.json_body["threepids"][0]["medium"])
|
||||
|
|
|
@ -72,7 +72,6 @@ class FallbackAuthTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "register", body
|
||||
) # type: SynapseRequest, FakeChannel
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(request.code, expected_response)
|
||||
return channel
|
||||
|
@ -87,7 +86,6 @@ class FallbackAuthTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "auth/m.login.recaptcha/fallback/web?session=" + session
|
||||
) # type: SynapseRequest, FakeChannel
|
||||
self.render(request)
|
||||
self.assertEqual(request.code, 200)
|
||||
|
||||
request, channel = self.make_request(
|
||||
|
@ -96,7 +94,6 @@ class FallbackAuthTests(unittest.HomeserverTestCase):
|
|||
+ post_session
|
||||
+ "&g-recaptcha-response=a",
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(request.code, expected_post_response)
|
||||
|
||||
# The recaptcha handler is called with the response given
|
||||
|
@ -177,7 +174,6 @@ class UIAuthTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "devices", access_token=self.user_tok,
|
||||
) # type: SynapseRequest, FakeChannel
|
||||
self.render(request)
|
||||
|
||||
# Get the ID of the device.
|
||||
self.assertEqual(request.code, 200)
|
||||
|
@ -190,7 +186,6 @@ class UIAuthTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"DELETE", "devices/" + device, body, access_token=self.user_tok
|
||||
) # type: SynapseRequest, FakeChannel
|
||||
self.render(request)
|
||||
|
||||
# Ensure the response is sane.
|
||||
self.assertEqual(request.code, expected_response)
|
||||
|
@ -204,7 +199,6 @@ class UIAuthTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "delete_devices", body, access_token=self.user_tok,
|
||||
) # type: SynapseRequest, FakeChannel
|
||||
self.render(request)
|
||||
|
||||
# Ensure the response is sane.
|
||||
self.assertEqual(request.code, expected_response)
|
||||
|
|
|
@ -37,7 +37,6 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
def test_check_auth_required(self):
|
||||
request, channel = self.make_request("GET", self.url)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 401)
|
||||
|
||||
|
@ -46,7 +45,6 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
access_token = self.login("user", "pass")
|
||||
|
||||
request, channel = self.make_request("GET", self.url, access_token=access_token)
|
||||
self.render(request)
|
||||
capabilities = channel.json_body["capabilities"]
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
@ -65,7 +63,6 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
access_token = self.login(user, password)
|
||||
|
||||
request, channel = self.make_request("GET", self.url, access_token=access_token)
|
||||
self.render(request)
|
||||
capabilities = channel.json_body["capabilities"]
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
@ -74,7 +71,6 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
|||
self.assertTrue(capabilities["m.change_password"]["enabled"])
|
||||
self.get_success(self.store.user_set_password_hash(user, None))
|
||||
request, channel = self.make_request("GET", self.url, access_token=access_token)
|
||||
self.render(request)
|
||||
capabilities = channel.json_body["capabilities"]
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
|
|
@ -41,7 +41,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/user/%s/filter" % (self.user_id),
|
||||
self.EXAMPLE_FILTER_JSON,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.result["code"], b"200")
|
||||
self.assertEqual(channel.json_body, {"filter_id": "0"})
|
||||
|
@ -55,7 +54,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/user/%s/filter" % ("@watermelon:test"),
|
||||
self.EXAMPLE_FILTER_JSON,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.result["code"], b"403")
|
||||
self.assertEquals(channel.json_body["errcode"], Codes.FORBIDDEN)
|
||||
|
@ -68,7 +66,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/user/%s/filter" % (self.user_id),
|
||||
self.EXAMPLE_FILTER_JSON,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.hs.is_mine = _is_mine
|
||||
self.assertEqual(channel.result["code"], b"403")
|
||||
|
@ -85,7 +82,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/user/%s/filter/%s" % (self.user_id, filter_id)
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.result["code"], b"200")
|
||||
self.assertEquals(channel.json_body, self.EXAMPLE_FILTER)
|
||||
|
@ -94,7 +90,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/user/%s/filter/12382148321" % (self.user_id)
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.result["code"], b"404")
|
||||
self.assertEquals(channel.json_body["errcode"], Codes.NOT_FOUND)
|
||||
|
@ -105,7 +100,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/user/%s/filter/foobar" % (self.user_id)
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.result["code"], b"400")
|
||||
|
||||
|
@ -114,6 +108,5 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/user/%s/filter/" % (self.user_id)
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.result["code"], b"400")
|
||||
|
|
|
@ -73,7 +73,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/password_policy"
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
self.assertEqual(
|
||||
|
@ -91,7 +90,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
def test_password_too_short(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": "shorty"})
|
||||
request, channel = self.make_request("POST", self.register_url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
self.assertEqual(
|
||||
|
@ -101,7 +99,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
def test_password_no_digit(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": "longerpassword"})
|
||||
request, channel = self.make_request("POST", self.register_url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
self.assertEqual(
|
||||
|
@ -111,7 +108,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
def test_password_no_symbol(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": "l0ngerpassword"})
|
||||
request, channel = self.make_request("POST", self.register_url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
self.assertEqual(
|
||||
|
@ -121,7 +117,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
def test_password_no_uppercase(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": "l0ngerpassword!"})
|
||||
request, channel = self.make_request("POST", self.register_url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
self.assertEqual(
|
||||
|
@ -131,7 +126,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
def test_password_no_lowercase(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": "L0NGERPASSWORD!"})
|
||||
request, channel = self.make_request("POST", self.register_url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
self.assertEqual(
|
||||
|
@ -141,7 +135,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
def test_password_compliant(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": "L0ngerpassword!"})
|
||||
request, channel = self.make_request("POST", self.register_url, request_data)
|
||||
self.render(request)
|
||||
|
||||
# Getting a 401 here means the password has passed validation and the server has
|
||||
# responded with a list of registration flows.
|
||||
|
@ -173,7 +166,6 @@ class PasswordPolicyTestCase(unittest.HomeserverTestCase):
|
|||
request_data,
|
||||
access_token=tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 400, channel.result)
|
||||
self.assertEqual(channel.json_body["errcode"], Codes.PASSWORD_NO_DIGIT)
|
||||
|
|
|
@ -64,7 +64,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", self.url + b"?access_token=i_am_an_app_service", request_data
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
det_data = {"user_id": user_id, "home_server": self.hs.hostname}
|
||||
|
@ -76,14 +75,12 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", self.url + b"?access_token=i_am_an_app_service", request_data
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
|
||||
def test_POST_bad_password(self):
|
||||
request_data = json.dumps({"username": "kermit", "password": 666})
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"400", channel.result)
|
||||
self.assertEquals(channel.json_body["error"], "Invalid password")
|
||||
|
@ -91,7 +88,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
def test_POST_bad_username(self):
|
||||
request_data = json.dumps({"username": 777, "password": "monkey"})
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"400", channel.result)
|
||||
self.assertEquals(channel.json_body["error"], "Invalid username")
|
||||
|
@ -107,7 +103,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
request_data = json.dumps(params)
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
det_data = {
|
||||
"user_id": user_id,
|
||||
|
@ -123,7 +118,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
self.auth_result = (None, {"username": "kermit", "password": "monkey"}, None)
|
||||
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
self.assertEquals(channel.json_body["error"], "Registration has been disabled")
|
||||
|
@ -133,7 +127,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
self.hs.config.allow_guest_access = True
|
||||
|
||||
request, channel = self.make_request(b"POST", self.url + b"?kind=guest", b"{}")
|
||||
self.render(request)
|
||||
|
||||
det_data = {"home_server": self.hs.hostname, "device_id": "guest_device"}
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
@ -143,7 +136,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
self.hs.config.allow_guest_access = False
|
||||
|
||||
request, channel = self.make_request(b"POST", self.url + b"?kind=guest", b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
self.assertEquals(channel.json_body["error"], "Guest access is disabled")
|
||||
|
@ -153,7 +145,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
for i in range(0, 6):
|
||||
url = self.url + b"?kind=guest"
|
||||
request, channel = self.make_request(b"POST", url, b"{}")
|
||||
self.render(request)
|
||||
|
||||
if i == 5:
|
||||
self.assertEquals(channel.result["code"], b"429", channel.result)
|
||||
|
@ -164,7 +155,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
self.reactor.advance(retry_after_ms / 1000.0 + 1.0)
|
||||
|
||||
request, channel = self.make_request(b"POST", self.url + b"?kind=guest", b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
|
@ -179,7 +169,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
request_data = json.dumps(params)
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
if i == 5:
|
||||
self.assertEquals(channel.result["code"], b"429", channel.result)
|
||||
|
@ -190,13 +179,11 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
self.reactor.advance(retry_after_ms / 1000.0 + 1.0)
|
||||
|
||||
request, channel = self.make_request(b"POST", self.url + b"?kind=guest", b"{}")
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
def test_advertised_flows(self):
|
||||
request, channel = self.make_request(b"POST", self.url, b"{}")
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
flows = channel.json_body["flows"]
|
||||
|
||||
|
@ -220,7 +207,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
)
|
||||
def test_advertised_flows_captcha_and_terms_and_3pids(self):
|
||||
request, channel = self.make_request(b"POST", self.url, b"{}")
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
flows = channel.json_body["flows"]
|
||||
|
||||
|
@ -253,7 +239,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
)
|
||||
def test_advertised_flows_no_msisdn_email_required(self):
|
||||
request, channel = self.make_request(b"POST", self.url, b"{}")
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
flows = channel.json_body["flows"]
|
||||
|
||||
|
@ -298,7 +283,6 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
|||
b"register/email/requestToken",
|
||||
{"client_secret": "foobar", "email": email, "send_attempt": 1},
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.result)
|
||||
|
||||
self.assertIsNotNone(channel.json_body.get("sid"))
|
||||
|
@ -334,14 +318,12 @@ class AccountValidityTestCase(unittest.HomeserverTestCase):
|
|||
# The specific endpoint doesn't matter, all we need is an authenticated
|
||||
# endpoint.
|
||||
request, channel = self.make_request(b"GET", "/sync", access_token=tok)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
self.reactor.advance(datetime.timedelta(weeks=1).total_seconds())
|
||||
|
||||
request, channel = self.make_request(b"GET", "/sync", access_token=tok)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
self.assertEquals(
|
||||
|
@ -366,13 +348,11 @@ class AccountValidityTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", url, request_data, access_token=admin_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
# The specific endpoint doesn't matter, all we need is an authenticated
|
||||
# endpoint.
|
||||
request, channel = self.make_request(b"GET", "/sync", access_token=tok)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
def test_manual_expire(self):
|
||||
|
@ -392,13 +372,11 @@ class AccountValidityTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", url, request_data, access_token=admin_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
# The specific endpoint doesn't matter, all we need is an authenticated
|
||||
# endpoint.
|
||||
request, channel = self.make_request(b"GET", "/sync", access_token=tok)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
self.assertEquals(
|
||||
channel.json_body["errcode"], Codes.EXPIRED_ACCOUNT, channel.result
|
||||
|
@ -421,12 +399,10 @@ class AccountValidityTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
b"POST", url, request_data, access_token=admin_tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
# Try to log the user out
|
||||
request, channel = self.make_request(b"POST", "/logout", access_token=tok)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
# Log the user in again (allowed for expired accounts)
|
||||
|
@ -434,7 +410,6 @@ class AccountValidityTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
# Try to log out all of the user's sessions
|
||||
request, channel = self.make_request(b"POST", "/logout/all", access_token=tok)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
|
||||
|
@ -509,7 +484,6 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
renewal_token = self.get_success(self.store.get_renewal_token_for_user(user_id))
|
||||
url = "/_matrix/client/unstable/account_validity/renew?token=%s" % renewal_token
|
||||
request, channel = self.make_request(b"GET", url)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
# Check that we're getting HTML back.
|
||||
|
@ -530,7 +504,6 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
# succeed.
|
||||
self.reactor.advance(datetime.timedelta(days=3).total_seconds())
|
||||
request, channel = self.make_request(b"GET", "/sync", access_token=tok)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
def test_renewal_invalid_token(self):
|
||||
|
@ -538,7 +511,6 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
# expected, i.e. that it responds with 404 Not Found and the correct HTML.
|
||||
url = "/_matrix/client/unstable/account_validity/renew?token=123"
|
||||
request, channel = self.make_request(b"GET", url)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"404", channel.result)
|
||||
|
||||
# Check that we're getting HTML back.
|
||||
|
@ -564,7 +536,6 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/unstable/account_validity/send_mail",
|
||||
access_token=tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
self.assertEqual(len(self.email_attempts), 1)
|
||||
|
@ -587,7 +558,6 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "account/deactivate", request_data, access_token=tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(request.code, 200)
|
||||
|
||||
self.reactor.advance(datetime.timedelta(days=8).total_seconds())
|
||||
|
@ -641,7 +611,6 @@ class AccountValidityRenewalByEmailTestCase(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/unstable/account_validity/send_mail",
|
||||
access_token=tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(channel.result["code"], b"200", channel.result)
|
||||
|
||||
self.assertEqual(len(self.email_attempts), 1)
|
||||
|
|
|
@ -65,7 +65,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/event/%s" % (self.room, event_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assert_dict(
|
||||
|
@ -114,7 +113,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, self.parent_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
# We expect to get back a single pagination result, which is the full
|
||||
|
@ -160,7 +158,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, self.parent_id, from_token),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
found_event_ids.extend(e["event_id"] for e in channel.json_body["chunk"])
|
||||
|
@ -219,7 +216,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, self.parent_id, from_token),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEqual(len(channel.json_body["chunk"]), 1, channel.json_body)
|
||||
|
@ -296,7 +292,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEqual(len(channel.json_body["chunk"]), 1, channel.json_body)
|
||||
|
@ -336,7 +331,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, self.parent_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEquals(
|
||||
|
@ -369,7 +363,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.user_token,
|
||||
content={},
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
request, channel = self.make_request(
|
||||
|
@ -378,7 +371,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, self.parent_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEquals(
|
||||
|
@ -396,7 +388,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, self.parent_id, RelationTypes.REPLACE),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(400, channel.code, channel.json_body)
|
||||
|
||||
def test_aggregation_get_event(self):
|
||||
|
@ -428,7 +419,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/event/%s" % (self.room, self.parent_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEquals(
|
||||
|
@ -465,7 +455,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/event/%s" % (self.room, self.parent_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEquals(channel.json_body["content"], new_body)
|
||||
|
@ -523,7 +512,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
"/rooms/%s/event/%s" % (self.room, self.parent_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertEquals(channel.json_body["content"], new_body)
|
||||
|
@ -567,7 +555,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, original_event_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertIn("chunk", channel.json_body)
|
||||
|
@ -581,7 +568,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.user_token,
|
||||
content="{}",
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
# Try to check for remaining m.replace relations
|
||||
|
@ -591,7 +577,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, original_event_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
# Check that no relations are returned
|
||||
|
@ -624,7 +609,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
access_token=self.user_token,
|
||||
content="{}",
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
# Check that aggregations returns zero
|
||||
|
@ -634,7 +618,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
% (self.room, original_event_id),
|
||||
access_token=self.user_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code, channel.json_body)
|
||||
|
||||
self.assertIn("chunk", channel.json_body)
|
||||
|
@ -680,7 +663,6 @@ class RelationsTestCase(unittest.HomeserverTestCase):
|
|||
json.dumps(content).encode("utf-8"),
|
||||
access_token=access_token,
|
||||
)
|
||||
self.render(request)
|
||||
return channel
|
||||
|
||||
def _create_user(self, localpart):
|
||||
|
|
|
@ -47,7 +47,6 @@ class UserSharedRoomsTest(unittest.HomeserverTestCase):
|
|||
% other_user,
|
||||
access_token=token,
|
||||
)
|
||||
self.render(request)
|
||||
return request, channel
|
||||
|
||||
def test_shared_room_list_public(self):
|
||||
|
|
|
@ -36,7 +36,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
def test_sync_argless(self):
|
||||
request, channel = self.make_request("GET", "/sync")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertTrue(
|
||||
|
@ -57,7 +56,6 @@ class FilterTestCase(unittest.HomeserverTestCase):
|
|||
self.hs.config.use_presence = False
|
||||
|
||||
request, channel = self.make_request("GET", "/sync")
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertTrue(
|
||||
|
@ -199,7 +197,6 @@ class SyncFilterTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/sync?filter=%s" % sync_filter, access_token=tok
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
return channel.json_body["rooms"]["join"][room_id]["timeline"]["events"]
|
||||
|
@ -253,13 +250,11 @@ class SyncTypingTests(unittest.HomeserverTestCase):
|
|||
typing_url % (room, other_user_id, other_access_token),
|
||||
b'{"typing": true, "timeout": 30000}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
request, channel = self.make_request(
|
||||
"GET", "/sync?access_token=%s" % (access_token,)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
next_batch = channel.json_body["next_batch"]
|
||||
|
||||
|
@ -269,7 +264,6 @@ class SyncTypingTests(unittest.HomeserverTestCase):
|
|||
typing_url % (room, other_user_id, other_access_token),
|
||||
b'{"typing": false}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
# Start typing.
|
||||
|
@ -278,14 +272,12 @@ class SyncTypingTests(unittest.HomeserverTestCase):
|
|||
typing_url % (room, other_user_id, other_access_token),
|
||||
b'{"typing": true, "timeout": 30000}',
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
|
||||
# Should return immediately
|
||||
request, channel = self.make_request(
|
||||
"GET", sync_url % (access_token, next_batch)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
next_batch = channel.json_body["next_batch"]
|
||||
|
||||
|
@ -300,7 +292,6 @@ class SyncTypingTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", sync_url % (access_token, next_batch)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
next_batch = channel.json_body["next_batch"]
|
||||
|
||||
|
@ -311,7 +302,6 @@ class SyncTypingTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", sync_url % (access_token, next_batch)
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEquals(200, channel.code)
|
||||
next_batch = channel.json_body["next_batch"]
|
||||
|
||||
|
@ -399,7 +389,6 @@ class UnreadMessagesTestCase(unittest.HomeserverTestCase):
|
|||
body,
|
||||
access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.json_body)
|
||||
|
||||
# Check that the unread counter is back to 0.
|
||||
|
@ -464,7 +453,6 @@ class UnreadMessagesTestCase(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", self.url % self.next_batch, access_token=self.tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(channel.code, 200, channel.json_body)
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ class HealthCheckTests(unittest.HomeserverTestCase):
|
|||
|
||||
def test_health(self):
|
||||
request, channel = self.make_request("GET", "/health", shorthand=False)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(request.code, 200)
|
||||
self.assertEqual(channel.result["body"], b"OK")
|
||||
|
|
|
@ -31,7 +31,6 @@ class WellKnownTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/.well-known/matrix/client", shorthand=False
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(request.code, 200)
|
||||
self.assertEqual(
|
||||
|
@ -48,6 +47,5 @@ class WellKnownTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/.well-known/matrix/client", shorthand=False
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
self.assertEqual(request.code, 404)
|
||||
|
|
|
@ -73,7 +73,6 @@ class ConsentNoticesTests(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/sync", access_token=self.access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# Get the Room ID to join
|
||||
|
@ -85,14 +84,12 @@ class ConsentNoticesTests(unittest.HomeserverTestCase):
|
|||
"/_matrix/client/r0/rooms/" + room_id + "/join",
|
||||
access_token=self.access_token,
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# Sync again, to get the message in the room
|
||||
request, channel = self.make_request(
|
||||
"GET", "/_matrix/client/r0/sync", access_token=self.access_token
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200)
|
||||
|
||||
# Get the message
|
||||
|
|
|
@ -306,7 +306,6 @@ class TestResourceLimitsServerNoticesWithRealRooms(unittest.HomeserverTestCase):
|
|||
tok = self.login("user", "password")
|
||||
|
||||
request, channel = self.make_request("GET", "/sync?timeout=0", access_token=tok)
|
||||
self.render(request)
|
||||
|
||||
invites = channel.json_body["rooms"]["invite"]
|
||||
self.assertEqual(len(invites), 0, invites)
|
||||
|
@ -320,7 +319,6 @@ class TestResourceLimitsServerNoticesWithRealRooms(unittest.HomeserverTestCase):
|
|||
# Sync again to retrieve the events in the room, so we can check whether this
|
||||
# room has a notice in it.
|
||||
request, channel = self.make_request("GET", "/sync?timeout=0", access_token=tok)
|
||||
self.render(request)
|
||||
|
||||
# Scan the events in the room to search for a message from the server notices
|
||||
# user.
|
||||
|
@ -358,7 +356,6 @@ class TestResourceLimitsServerNoticesWithRealRooms(unittest.HomeserverTestCase):
|
|||
request, channel = self.make_request(
|
||||
"GET", "/sync?timeout=0", access_token=tok,
|
||||
)
|
||||
self.render(request)
|
||||
|
||||
# Also retrieves the list of invites for this user. We don't care about that
|
||||
# one except if we're processing the last user, which should have received an
|
||||
|
|
|
@ -202,7 +202,6 @@ class TestMauLimit(unittest.HomeserverTestCase):
|
|||
)
|
||||
|
||||
request, channel = self.make_request("POST", "/register", request_data)
|
||||
self.render(request)
|
||||
|
||||
if channel.code != 200:
|
||||
raise HttpResponseException(
|
||||
|
@ -215,7 +214,6 @@ class TestMauLimit(unittest.HomeserverTestCase):
|
|||
|
||||
def do_sync_for_user(self, token):
|
||||
request, channel = self.make_request("GET", "/sync", access_token=token)
|
||||
self.render(request)
|
||||
|
||||
if channel.code != 200:
|
||||
raise HttpResponseException(
|
||||
|
|
|
@ -54,7 +54,6 @@ class TermsTestCase(unittest.HomeserverTestCase):
|
|||
# Do a UI auth request
|
||||
request_data = json.dumps({"username": "kermit", "password": "monkey"})
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
self.assertEquals(channel.result["code"], b"401", channel.result)
|
||||
|
||||
|
@ -98,7 +97,6 @@ class TermsTestCase(unittest.HomeserverTestCase):
|
|||
self.registration_handler.check_username = Mock(return_value=True)
|
||||
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
# We don't bother checking that the response is correct - we'll leave that to
|
||||
# other tests. We just want to make sure we're on the right path.
|
||||
|
@ -116,7 +114,6 @@ class TermsTestCase(unittest.HomeserverTestCase):
|
|||
}
|
||||
)
|
||||
request, channel = self.make_request(b"POST", self.url, request_data)
|
||||
self.render(request)
|
||||
|
||||
# We're interested in getting a response that looks like a successful
|
||||
# registration, not so much that the details are exactly what we want.
|
||||
|
|
|
@ -440,16 +440,6 @@ class HomeserverTestCase(TestCase):
|
|||
await_result,
|
||||
)
|
||||
|
||||
def render(self, request):
|
||||
"""
|
||||
Render a request against the resources registered by the test class's
|
||||
servlets.
|
||||
|
||||
Args:
|
||||
request (synapse.http.site.SynapseRequest): The request to render.
|
||||
"""
|
||||
pass
|
||||
|
||||
def setup_test_homeserver(self, *args, **kwargs):
|
||||
"""
|
||||
Set up the test homeserver, meant to be called by the overridable
|
||||
|
@ -565,7 +555,6 @@ class HomeserverTestCase(TestCase):
|
|||
|
||||
# Create the user
|
||||
request, channel = self.make_request("GET", "/_matrix/client/r0/admin/register")
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, msg=channel.result)
|
||||
nonce = channel.json_body["nonce"]
|
||||
|
||||
|
@ -593,7 +582,6 @@ class HomeserverTestCase(TestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/_matrix/client/r0/admin/register", body.encode("utf8")
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.json_body)
|
||||
|
||||
user_id = channel.json_body["user_id"]
|
||||
|
@ -612,7 +600,6 @@ class HomeserverTestCase(TestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/_matrix/client/r0/login", json.dumps(body).encode("utf8")
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 200, channel.result)
|
||||
|
||||
access_token = channel.json_body["access_token"]
|
||||
|
@ -681,7 +668,6 @@ class HomeserverTestCase(TestCase):
|
|||
request, channel = self.make_request(
|
||||
"POST", "/_matrix/client/r0/login", json.dumps(body).encode("utf8")
|
||||
)
|
||||
self.render(request)
|
||||
self.assertEqual(channel.code, 403, channel.result)
|
||||
|
||||
def inject_room_member(self, room: str, user: str, membership: Membership) -> None:
|
||||
|
|
Loading…
Reference in a new issue