From 5a93bfe1f03bf225bcf3b14089faefa3b5715499 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 26 Aug 2014 17:21:48 +0100 Subject: Removed MessageRestServlet, use RoomSendEventRestServlet instead. Updated cmdclient, tests and webclient. All appears to work. --- tests/rest/test_events.py | 2 +- tests/rest/test_rooms.py | 35 ++++++++++++----------------------- tests/rest/utils.py | 8 ++++---- 3 files changed, 17 insertions(+), 28 deletions(-) (limited to 'tests/rest') diff --git a/tests/rest/test_events.py b/tests/rest/test_events.py index 4025e14581..7bc05dc2b6 100644 --- a/tests/rest/test_events.py +++ b/tests/rest/test_events.py @@ -181,7 +181,7 @@ class EventStreamPermissionsTestCase(RestTestCase): room_id = "!rid1:test" yield self.create_room_as(room_id, self.other_user, tok=self.other_token) - yield self.send(room_id, self.other_user, tok=self.other_token) + yield self.send(room_id, tok=self.other_token) # invited to room (expect no content for room) yield self.invite(room_id, src=self.other_user, targ=self.user_id, diff --git a/tests/rest/test_rooms.py b/tests/rest/test_rooms.py index 8514d6ba21..f18c506a7d 100644 --- a/tests/rest/test_rooms.py +++ b/tests/rest/test_rooms.py @@ -83,8 +83,8 @@ class RoomPermissionsTestCase(RestTestCase): is_public=True) # send a message in one of the rooms - self.created_rmid_msg_path = ("/rooms/%s/messages/%s/midaaa1" % - (self.created_rmid, self.rmcreator_id)) + self.created_rmid_msg_path = ("/rooms/%s/send/m.room.message/a1" % + (self.created_rmid)) (code, response) = yield self.mock_resource.trigger( "PUT", self.created_rmid_msg_path, @@ -138,14 +138,14 @@ class RoomPermissionsTestCase(RestTestCase): @defer.inlineCallbacks def test_send_message(self): msg_content = '{"msgtype":"m.text","body":"hello"}' - send_msg_path = ("/rooms/%s/messages/%s/mid1" % - (self.created_rmid, self.user_id)) + send_msg_path = ("/rooms/%s/send/m.room.message/mid1" % + (self.created_rmid)) # send message in uncreated room, expect 403 (code, response) = yield self.mock_resource.trigger( "PUT", - "/rooms/%s/messages/%s/mid1" % - (self.uncreated_rmid, self.user_id), msg_content) + "/rooms/%s/send/m.room.message/mid2" % + (self.uncreated_rmid), msg_content) self.assertEquals(403, code, msg=str(response)) # send message in created room not joined (no state), expect 403 @@ -875,9 +875,8 @@ class RoomMessagesTestCase(RestTestCase): @defer.inlineCallbacks def test_invalid_puts(self): - path = "/rooms/%s/messages/%s/mid1" % ( - urllib.quote(self.room_id), self.user_id - ) + path = "/rooms/%s/send/m.room.message/mid1" % ( + urllib.quote(self.room_id)) # missing keys or invalid json (code, response) = yield self.mock_resource.trigger("PUT", path, '{}') @@ -905,9 +904,8 @@ class RoomMessagesTestCase(RestTestCase): @defer.inlineCallbacks def test_rooms_messages_sent(self): - path = "/rooms/%s/messages/%s/mid1" % ( - urllib.quote(self.room_id), self.user_id - ) + path = "/rooms/%s/send/m.room.message/mid1" % ( + urllib.quote(self.room_id)) content = '{"body":"test","msgtype":{"type":"a"}}' (code, response) = yield self.mock_resource.trigger("PUT", path, content) @@ -923,9 +921,8 @@ class RoomMessagesTestCase(RestTestCase): # self.assert_dict(json.loads(content), response) # m.text message type - path = "/rooms/%s/messages/%s/mid2" % ( - urllib.quote(self.room_id), self.user_id - ) + path = "/rooms/%s/send/m.room.message/mid2" % ( + urllib.quote(self.room_id)) content = '{"body":"test2","msgtype":"m.text"}' (code, response) = yield self.mock_resource.trigger("PUT", path, content) self.assertEquals(200, code, msg=str(response)) @@ -933,11 +930,3 @@ class RoomMessagesTestCase(RestTestCase): # (code, response) = yield self.mock_resource.trigger("GET", path, None) # self.assertEquals(200, code, msg=str(response)) # self.assert_dict(json.loads(content), response) - - # trying to send message in different user path - path = "/rooms/%s/messages/%s/mid2" % ( - urllib.quote(self.room_id), "invalid" + self.user_id - ) - content = '{"body":"test2","msgtype":"m.text"}' - (code, response) = yield self.mock_resource.trigger("PUT", path, content) - self.assertEquals(403, code, msg=str(response)) diff --git a/tests/rest/utils.py b/tests/rest/utils.py index bc8bff0f1a..590d12f155 100644 --- a/tests/rest/utils.py +++ b/tests/rest/utils.py @@ -99,14 +99,14 @@ class RestTestCase(unittest.TestCase): defer.returnValue(response) @defer.inlineCallbacks - def send(self, room_id, sender_id, body=None, msg_id=None, tok=None, + def send(self, room_id, body=None, txn_id=None, tok=None, expect_code=200): - if msg_id is None: - msg_id = "m%s" % (str(time.time())) + if txn_id is None: + txn_id = "m%s" % (str(time.time())) if body is None: body = "body_text_here" - path = "/rooms/%s/messages/%s/%s" % (room_id, sender_id, msg_id) + path = "/rooms/%s/send/m.room.message/%s" % (room_id, txn_id) content = '{"msgtype":"m.text","body":"%s"}' % body if tok: path = path + "?access_token=%s" % tok -- cgit 1.4.1