summary refs log tree commit diff
path: root/tests/rest
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-19 14:48:19 +0100
committerErik Johnston <erik@matrix.org>2014-08-19 14:48:19 +0100
commit347242a5c408d4ceb1880f6b90c8e9c658226dde (patch)
tree12a25b72d8f13a48f99441c249c3c531c79fff66 /tests/rest
parentFix bug where we sometimes set min_token to None. (diff)
parentProofing (diff)
downloadsynapse-347242a5c408d4ceb1880f6b90c8e9c658226dde.tar.xz
Merge branch 'master' of github.com:matrix-org/synapse into sql_refactor
Conflicts:
	tests/rest/test_presence.py
	tests/rest/test_rooms.py
	tests/utils.py
Diffstat (limited to 'tests/rest')
-rw-r--r--tests/rest/test_events.py16
-rw-r--r--tests/rest/test_presence.py166
-rw-r--r--tests/rest/test_profile.py20
-rw-r--r--tests/rest/test_rooms.py196
-rw-r--r--tests/rest/utils.py14
5 files changed, 232 insertions, 180 deletions
diff --git a/tests/rest/test_events.py b/tests/rest/test_events.py
index e1b3cb4ddf..1ab92395f2 100644
--- a/tests/rest/test_events.py
+++ b/tests/rest/test_events.py
@@ -29,7 +29,7 @@ from synapse.server import HomeServer
 import json
 import logging
 
-from ..utils import MockHttpServer, MemoryDataStore
+from ..utils import MockHttpResource, MemoryDataStore
 from .utils import RestTestCase
 
 from mock import Mock
@@ -116,7 +116,7 @@ class EventStreamPermissionsTestCase(RestTestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
 
         state_handler = Mock(spec=["handle_new_event"])
         state_handler.handle_new_event.return_value = True
@@ -142,9 +142,9 @@ class EventStreamPermissionsTestCase(RestTestCase):
         hs.get_clock().time_msec.return_value = 1000000
 
         hs.datastore = MemoryDataStore()
-        synapse.rest.register.register_servlets(hs, self.mock_server)
-        synapse.rest.events.register_servlets(hs, self.mock_server)
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.register.register_servlets(hs, self.mock_resource)
+        synapse.rest.events.register_servlets(hs, self.mock_resource)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
         # register an account
         self.user_id = "sid1"
@@ -164,12 +164,12 @@ class EventStreamPermissionsTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_stream_basic_permissions(self):
         # invalid token, expect 403
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/events?access_token=%s" % ("invalid" + self.token))
         self.assertEquals(403, code, msg=str(response))
 
         # valid token, expect content
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/events?access_token=%s&timeout=0" % (self.token))
         self.assertEquals(200, code, msg=str(response))
         self.assertTrue("chunk" in response)
@@ -186,7 +186,7 @@ class EventStreamPermissionsTestCase(RestTestCase):
         # invited to room (expect no content for room)
         yield self.invite(room_id, src=self.other_user, targ=self.user_id,
                           tok=self.other_token)
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/events?access_token=%s&timeout=0" % (self.token))
         self.assertEquals(200, code, msg=str(response))
 
diff --git a/tests/rest/test_presence.py b/tests/rest/test_presence.py
index 99287823e4..80b5972b4b 100644
--- a/tests/rest/test_presence.py
+++ b/tests/rest/test_presence.py
@@ -21,9 +21,10 @@ from twisted.internet import defer
 from mock import Mock
 import logging
 
-from ..utils import MockHttpServer
+from ..utils import MockHttpResource
 
 from synapse.api.constants import PresenceState
+from synapse.handlers.presence import PresenceHandler
 from synapse.server import HomeServer
 
 
@@ -39,29 +40,49 @@ myid = "@apple:test"
 PATH_PREFIX = "/matrix/client/api/v1"
 
 
+class JustPresenceHandlers(object):
+    def __init__(self, hs):
+        self.presence_handler = PresenceHandler(hs)
+
+
 class PresenceStateTestCase(unittest.TestCase):
 
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
-        self.mock_handler = Mock(spec=[
-            "get_state",
-            "set_state",
-        ])
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
 
         hs = HomeServer("test",
             db_pool=None,
+            datastore=Mock(spec=[
+                "get_presence_state",
+                "set_presence_state",
+            ]),
             http_client=None,
             datastore=None,
-            resource_for_client=self.mock_server,
-            resource_for_federation=self.mock_server,
+            resource_for_client=self.mock_resource,
+            resource_for_federation=self.mock_resource,
         )
+        hs.handlers = JustPresenceHandlers(hs)
+
+        self.datastore = hs.get_datastore()
+
+        def get_presence_list(*a, **kw):
+            return defer.succeed([])
+        self.datastore.get_presence_list = get_presence_list
 
         def _get_user_by_token(token=None):
             return hs.parse_userid(myid)
 
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        hs.get_handlers().presence_handler = self.mock_handler
+        room_member_handler = hs.handlers.room_member_handler = Mock(
+            spec=[
+                "get_rooms_for_user",
+            ]
+        )
+
+        def get_rooms_for_user(user):
+            return defer.succeed([])
+        room_member_handler.get_rooms_for_user = get_rooms_for_user
 
         hs.register_servlets()
 
@@ -69,58 +90,75 @@ class PresenceStateTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def test_get_my_status(self):
-        mocked_get = self.mock_handler.get_state
+        mocked_get = self.datastore.get_presence_state
         mocked_get.return_value = defer.succeed(
-                {"state": ONLINE, "status_msg": "Available"})
+            {"state": ONLINE, "status_msg": "Available"}
+        )
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/presence/%s/status" % (myid), None)
 
         self.assertEquals(200, code)
         self.assertEquals({"state": ONLINE, "status_msg": "Available"},
                 response)
-        mocked_get.assert_called_with(target_user=self.u_apple,
-                auth_user=self.u_apple)
+        mocked_get.assert_called_with("apple")
 
     @defer.inlineCallbacks
     def test_set_my_status(self):
-        mocked_set = self.mock_handler.set_state
-        mocked_set.return_value = defer.succeed(())
+        mocked_set = self.datastore.set_presence_state
+        mocked_set.return_value = defer.succeed({"state": OFFLINE})
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                 "/presence/%s/status" % (myid),
                 '{"state": "unavailable", "status_msg": "Away"}')
 
         self.assertEquals(200, code)
-        mocked_set.assert_called_with(target_user=self.u_apple,
-                auth_user=self.u_apple,
-                state={"state": UNAVAILABLE, "status_msg": "Away"})
+        mocked_set.assert_called_with("apple",
+                {"state": UNAVAILABLE, "status_msg": "Away"})
 
 
 class PresenceListTestCase(unittest.TestCase):
 
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
-        self.mock_handler = Mock(spec=[
-            "get_presence_list",
-            "send_invite",
-            "drop",
-        ])
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
 
         hs = HomeServer("test",
             db_pool=None,
+            datastore=Mock(spec=[
+                "has_presence_state",
+                "get_presence_state",
+                "allow_presence_visible",
+                "is_presence_visible",
+                "add_presence_list_pending",
+                "set_presence_list_accepted",
+                "del_presence_list",
+                "get_presence_list",
+            ]),
             http_client=None,
             datastore=None,
-            resource_for_client=self.mock_server,
-            resource_for_federation=self.mock_server
+            resource_for_client=self.mock_resource,
+            resource_for_federation=self.mock_resource
         )
+        hs.handlers = JustPresenceHandlers(hs)
+
+        self.datastore = hs.get_datastore()
+
+        def has_presence_state(user_localpart):
+            return defer.succeed(
+                user_localpart in ("apple", "banana",)
+            )
+        self.datastore.has_presence_state = has_presence_state
 
         def _get_user_by_token(token=None):
             return hs.parse_userid(myid)
 
-        hs.get_auth().get_user_by_token = _get_user_by_token
+        room_member_handler = hs.handlers.room_member_handler = Mock(
+            spec=[
+                "get_rooms_for_user",
+            ]
+        )
 
-        hs.get_handlers().presence_handler = self.mock_handler
+        hs.get_auth().get_user_by_token = _get_user_by_token
 
         hs.register_servlets()
 
@@ -129,52 +167,66 @@ class PresenceListTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def test_get_my_list(self):
-        self.mock_handler.get_presence_list.return_value = defer.succeed(
-                [{"observed_user": self.u_banana}]
+        self.datastore.get_presence_list.return_value = defer.succeed(
+            [{"observed_user_id": "@banana:test"}],
         )
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/presence_list/%s" % (myid), None)
 
         self.assertEquals(200, code)
-        self.assertEquals([{"user_id": "@banana:test"}], response)
+        self.assertEquals(
+            [{"user_id": "@banana:test", "state": OFFLINE}], response
+        )
+
+        self.datastore.get_presence_list.assert_called_with(
+            "apple", accepted=True
+        )
 
     @defer.inlineCallbacks
     def test_invite(self):
-        self.mock_handler.send_invite.return_value = defer.succeed(())
+        self.datastore.add_presence_list_pending.return_value = (
+            defer.succeed(())
+        )
+        self.datastore.is_presence_visible.return_value = defer.succeed(
+            True
+        )
 
-        (code, response) = yield self.mock_server.trigger("POST",
-                "/presence_list/%s" % (myid),
-                """{
-                    "invite": ["@banana:test"]
-                }""")
+        (code, response) = yield self.mock_resource.trigger("POST",
+            "/presence_list/%s" % (myid),
+            """{"invite": ["@banana:test"]}"""
+        )
 
         self.assertEquals(200, code)
 
-        self.mock_handler.send_invite.assert_called_with(
-                observer_user=self.u_apple, observed_user=self.u_banana)
+        self.datastore.add_presence_list_pending.assert_called_with(
+            "apple", "@banana:test"
+        )
+        self.datastore.set_presence_list_accepted.assert_called_with(
+            "apple", "@banana:test"
+        )
 
     @defer.inlineCallbacks
     def test_drop(self):
-        self.mock_handler.drop.return_value = defer.succeed(())
+        self.datastore.del_presence_list.return_value = (
+            defer.succeed(())
+        )
 
-        (code, response) = yield self.mock_server.trigger("POST",
-                "/presence_list/%s" % (myid),
-                """{
-                    "drop": ["@banana:test"]
-                }""")
+        (code, response) = yield self.mock_resource.trigger("POST",
+            "/presence_list/%s" % (myid),
+            """{"drop": ["@banana:test"]}"""
+        )
 
         self.assertEquals(200, code)
 
-        self.mock_handler.drop.assert_called_with(
-                observer_user=self.u_apple, observed_user=self.u_banana)
+        self.datastore.del_presence_list.assert_called_with(
+            "apple", "@banana:test"
+        )
 
 
 class PresenceEventStreamTestCase(unittest.TestCase):
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
-
-        # TODO: mocked data store
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
 
         # HIDEOUS HACKERY
         # TODO(paul): This should be injected in via the HomeServer DI system
@@ -187,8 +239,8 @@ class PresenceEventStreamTestCase(unittest.TestCase):
         hs = HomeServer("test",
             db_pool=None,
             http_client=None,
-            resource_for_client=self.mock_server,
-            resource_for_federation=self.mock_server,
+            resource_for_client=self.mock_resource,
+            resource_for_federation=self.mock_resource,
             datastore=Mock(spec=[
                 "set_presence_state",
                 "get_presence_list",
@@ -228,7 +280,7 @@ class PresenceEventStreamTestCase(unittest.TestCase):
         self.mock_datastore.get_presence_list.return_value = defer.succeed(
                 [])
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/events?timeout=0", None)
 
         self.assertEquals(200, code)
@@ -254,7 +306,7 @@ class PresenceEventStreamTestCase(unittest.TestCase):
         yield self.presence.set_state(self.u_banana, self.u_banana,
                 state={"state": ONLINE})
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/events?from=1&timeout=0", None)
 
         self.assertEquals(200, code)
diff --git a/tests/rest/test_profile.py b/tests/rest/test_profile.py
index ee47daf4c2..9bd8dc9783 100644
--- a/tests/rest/test_profile.py
+++ b/tests/rest/test_profile.py
@@ -20,7 +20,7 @@ from twisted.internet import defer
 
 from mock import Mock
 
-from ..utils import MockHttpServer
+from ..utils import MockHttpResource
 
 from synapse.api.errors import SynapseError, AuthError
 from synapse.server import HomeServer
@@ -32,7 +32,7 @@ class ProfileTestCase(unittest.TestCase):
     """ Tests profile management. """
 
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
         self.mock_handler = Mock(spec=[
             "get_displayname",
             "set_displayname",
@@ -43,7 +43,7 @@ class ProfileTestCase(unittest.TestCase):
         hs = HomeServer("test",
             db_pool=None,
             http_client=None,
-            resource_for_client=self.mock_server,
+            resource_for_client=self.mock_resource,
             federation=Mock(),
             replication_layer=Mock(),
             datastore=None,
@@ -63,7 +63,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_get = self.mock_handler.get_displayname
         mocked_get.return_value = defer.succeed("Frank")
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/profile/%s/displayname" % (myid), None)
 
         self.assertEquals(200, code)
@@ -75,7 +75,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_set = self.mock_handler.set_displayname
         mocked_set.return_value = defer.succeed(())
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                 "/profile/%s/displayname" % (myid),
                 '{"displayname": "Frank Jr."}')
 
@@ -89,7 +89,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_set = self.mock_handler.set_displayname
         mocked_set.side_effect = AuthError(400, "message")
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                 "/profile/%s/displayname" % ("@4567:test"), '"Frank Jr."')
 
         self.assertTrue(400 <= code < 499,
@@ -100,7 +100,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_get = self.mock_handler.get_displayname
         mocked_get.return_value = defer.succeed("Bob")
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/profile/%s/displayname" % ("@opaque:elsewhere"), None)
 
         self.assertEquals(200, code)
@@ -111,7 +111,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_set = self.mock_handler.set_displayname
         mocked_set.side_effect = SynapseError(400, "message")
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                 "/profile/%s/displayname" % ("@opaque:elsewhere"), None)
 
         self.assertTrue(400 <= code <= 499,
@@ -122,7 +122,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_get = self.mock_handler.get_avatar_url
         mocked_get.return_value = defer.succeed("http://my.server/me.png")
 
-        (code, response) = yield self.mock_server.trigger("GET",
+        (code, response) = yield self.mock_resource.trigger("GET",
                 "/profile/%s/avatar_url" % (myid), None)
 
         self.assertEquals(200, code)
@@ -134,7 +134,7 @@ class ProfileTestCase(unittest.TestCase):
         mocked_set = self.mock_handler.set_avatar_url
         mocked_set.return_value = defer.succeed(())
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                 "/profile/%s/avatar_url" % (myid),
                 '{"avatar_url": "http://my.server/pic.gif"}')
 
diff --git a/tests/rest/test_rooms.py b/tests/rest/test_rooms.py
index 3ac2bbdd0f..e873181044 100644
--- a/tests/rest/test_rooms.py
+++ b/tests/rest/test_rooms.py
@@ -27,7 +27,7 @@ from synapse.server import HomeServer
 import json
 import urllib
 
-from ..utils import MockHttpServer, MemoryDataStore
+from ..utils import MockHttpResource, MemoryDataStore
 from .utils import RestTestCase
 
 from mock import Mock
@@ -42,7 +42,7 @@ class RoomPermissionsTestCase(RestTestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
 
         state_handler = Mock(spec=["handle_new_event"])
         state_handler.handle_new_event.return_value = True
@@ -67,7 +67,7 @@ class RoomPermissionsTestCase(RestTestCase):
 
         self.auth_user_id = self.rmcreator_id
 
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
         self.auth = hs.get_auth()
 
@@ -85,14 +85,14 @@ class RoomPermissionsTestCase(RestTestCase):
         # send a message in one of the rooms
         self.created_rmid_msg_path = ("/rooms/%s/messages/%s/midaaa1" %
                                 (self.created_rmid, self.rmcreator_id))
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT",
                            self.created_rmid_msg_path,
                            '{"msgtype":"m.text","body":"test msg"}')
         self.assertEquals(200, code, msg=str(response))
 
         # set topic for public room
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT",
                            "/rooms/%s/topic" % self.created_public_rmid,
                            '{"topic":"Public Room Topic"}')
@@ -107,31 +107,31 @@ class RoomPermissionsTestCase(RestTestCase):
 #    @defer.inlineCallbacks
 #    def test_get_message(self):
 #        # get message in uncreated room, expect 403
-#        (code, response) = yield self.mock_server.trigger_get(
+#        (code, response) = yield self.mock_resource.trigger_get(
 #                           "/rooms/noroom/messages/someid/m1")
 #        self.assertEquals(403, code, msg=str(response))
 #
 #        # get message in created room not joined (no state), expect 403
-#        (code, response) = yield self.mock_server.trigger_get(
+#        (code, response) = yield self.mock_resource.trigger_get(
 #                           self.created_rmid_msg_path)
 #        self.assertEquals(403, code, msg=str(response))
 #
 #        # get message in created room and invited, expect 403
 #        yield self.invite(room=self.created_rmid, src=self.rmcreator_id,
 #                          targ=self.user_id)
-#        (code, response) = yield self.mock_server.trigger_get(
+#        (code, response) = yield self.mock_resource.trigger_get(
 #                           self.created_rmid_msg_path)
 #        self.assertEquals(403, code, msg=str(response))
 #
 #        # get message in created room and joined, expect 200
 #        yield self.join(room=self.created_rmid, user=self.user_id)
-#        (code, response) = yield self.mock_server.trigger_get(
+#        (code, response) = yield self.mock_resource.trigger_get(
 #                           self.created_rmid_msg_path)
 #        self.assertEquals(200, code, msg=str(response))
 #
 #        # get message in created room and left, expect 403
 #        yield self.leave(room=self.created_rmid, user=self.user_id)
-#        (code, response) = yield self.mock_server.trigger_get(
+#        (code, response) = yield self.mock_resource.trigger_get(
 #                           self.created_rmid_msg_path)
 #        self.assertEquals(403, code, msg=str(response))
 
@@ -142,33 +142,33 @@ class RoomPermissionsTestCase(RestTestCase):
                         (self.created_rmid, self.user_id))
 
         # send message in uncreated room, expect 403
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT",
                            "/rooms/%s/messages/%s/mid1" %
                            (self.uncreated_rmid, self.user_id), msg_content)
         self.assertEquals(403, code, msg=str(response))
 
         # send message in created room not joined (no state), expect 403
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", send_msg_path, msg_content)
         self.assertEquals(403, code, msg=str(response))
 
         # send message in created room and invited, expect 403
         yield self.invite(room=self.created_rmid, src=self.rmcreator_id,
                           targ=self.user_id)
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", send_msg_path, msg_content)
         self.assertEquals(403, code, msg=str(response))
 
         # send message in created room and joined, expect 200
         yield self.join(room=self.created_rmid, user=self.user_id)
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", send_msg_path, msg_content)
         self.assertEquals(200, code, msg=str(response))
 
         # send message in created room and left, expect 403
         yield self.leave(room=self.created_rmid, user=self.user_id)
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", send_msg_path, msg_content)
         self.assertEquals(403, code, msg=str(response))
 
@@ -178,56 +178,56 @@ class RoomPermissionsTestCase(RestTestCase):
         topic_path = "/rooms/%s/topic" % self.created_rmid
 
         # set/get topic in uncreated room, expect 403
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", "/rooms/%s/topic" % self.uncreated_rmid,
                            topic_content)
         self.assertEquals(403, code, msg=str(response))
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/rooms/%s/topic" % self.uncreated_rmid)
         self.assertEquals(403, code, msg=str(response))
 
         # set/get topic in created PRIVATE room not joined, expect 403
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", topic_path, topic_content)
         self.assertEquals(403, code, msg=str(response))
-        (code, response) = yield self.mock_server.trigger_get(topic_path)
+        (code, response) = yield self.mock_resource.trigger_get(topic_path)
         self.assertEquals(403, code, msg=str(response))
 
         # set topic in created PRIVATE room and invited, expect 403
         yield self.invite(room=self.created_rmid, src=self.rmcreator_id,
                           targ=self.user_id)
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", topic_path, topic_content)
         self.assertEquals(403, code, msg=str(response))
 
         # get topic in created PRIVATE room and invited, expect 200 (or 404)
-        (code, response) = yield self.mock_server.trigger_get(topic_path)
+        (code, response) = yield self.mock_resource.trigger_get(topic_path)
         self.assertEquals(404, code, msg=str(response))
 
         # set/get topic in created PRIVATE room and joined, expect 200
         yield self.join(room=self.created_rmid, user=self.user_id)
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", topic_path, topic_content)
         self.assertEquals(200, code, msg=str(response))
-        (code, response) = yield self.mock_server.trigger_get(topic_path)
+        (code, response) = yield self.mock_resource.trigger_get(topic_path)
         self.assertEquals(200, code, msg=str(response))
         self.assert_dict(json.loads(topic_content), response)
 
         # set/get topic in created PRIVATE room and left, expect 403
         yield self.leave(room=self.created_rmid, user=self.user_id)
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT", topic_path, topic_content)
         self.assertEquals(403, code, msg=str(response))
-        (code, response) = yield self.mock_server.trigger_get(topic_path)
+        (code, response) = yield self.mock_resource.trigger_get(topic_path)
         self.assertEquals(403, code, msg=str(response))
 
         # get topic in PUBLIC room, not joined, expect 200 (or 404)
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/rooms/%s/topic" % self.created_public_rmid)
         self.assertEquals(200, code, msg=str(response))
 
         # set topic in PUBLIC room, not joined, expect 403
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
                            "PUT",
                            "/rooms/%s/topic" % self.created_public_rmid,
                            topic_content)
@@ -237,7 +237,7 @@ class RoomPermissionsTestCase(RestTestCase):
     def _test_get_membership(self, room=None, members=[], expect_code=None):
         path = "/rooms/%s/members/%s/state"
         for member in members:
-            (code, response) = yield self.mock_server.trigger_get(
+            (code, response) = yield self.mock_resource.trigger_get(
                                path %
                                (room, member))
             self.assertEquals(expect_code, code)
@@ -391,7 +391,7 @@ class RoomsMemberListTestCase(RestTestCase):
     user_id = "@sid1:red"
 
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
 
         state_handler = Mock(spec=["handle_new_event"])
         state_handler.handle_new_event.return_value = True
@@ -416,7 +416,7 @@ class RoomsMemberListTestCase(RestTestCase):
             return hs.parse_userid(self.auth_user_id)
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
     def tearDown(self):
         pass
@@ -425,13 +425,13 @@ class RoomsMemberListTestCase(RestTestCase):
     def test_get_member_list(self):
         room_id = "!aa:test"
         yield self.create_room_as(room_id, self.user_id)
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/rooms/%s/members/list" % room_id)
         self.assertEquals(200, code, msg=str(response))
 
     @defer.inlineCallbacks
     def test_get_member_list_no_room(self):
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/rooms/roomdoesnotexist/members/list")
         self.assertEquals(403, code, msg=str(response))
 
@@ -439,7 +439,7 @@ class RoomsMemberListTestCase(RestTestCase):
     def test_get_member_list_no_permission(self):
         room_id = "!bb:test"
         yield self.create_room_as(room_id, "@some_other_guy:red")
-        (code, response) = yield self.mock_server.trigger_get(
+        (code, response) = yield self.mock_resource.trigger_get(
                            "/rooms/%s/members/list" % room_id)
         self.assertEquals(403, code, msg=str(response))
 
@@ -452,17 +452,17 @@ class RoomsMemberListTestCase(RestTestCase):
         yield self.invite(room=room_id, src=room_creator,
                           targ=self.user_id)
         # can't see list if you're just invited.
-        (code, response) = yield self.mock_server.trigger_get(room_path)
+        (code, response) = yield self.mock_resource.trigger_get(room_path)
         self.assertEquals(403, code, msg=str(response))
 
         yield self.join(room=room_id, user=self.user_id)
         # can see list now joined
-        (code, response) = yield self.mock_server.trigger_get(room_path)
+        (code, response) = yield self.mock_resource.trigger_get(room_path)
         self.assertEquals(200, code, msg=str(response))
 
         yield self.leave(room=room_id, user=self.user_id)
         # can no longer see list, you've left.
-        (code, response) = yield self.mock_server.trigger_get(room_path)
+        (code, response) = yield self.mock_resource.trigger_get(room_path)
         self.assertEquals(403, code, msg=str(response))
 
 
@@ -471,7 +471,7 @@ class RoomsCreateTestCase(RestTestCase):
     user_id = "@sid1:red"
 
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
         self.auth_user_id = self.user_id
 
         state_handler = Mock(spec=["handle_new_event"])
@@ -495,7 +495,7 @@ class RoomsCreateTestCase(RestTestCase):
             return hs.parse_userid(self.auth_user_id)
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
     def tearDown(self):
         pass
@@ -503,7 +503,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_post_room_no_keys(self):
         # POST with no config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger("POST", "/rooms",
+        (code, response) = yield self.mock_resource.trigger("POST", "/rooms",
                                                           "{}")
         self.assertEquals(200, code, response)
         self.assertTrue("room_id" in response)
@@ -511,7 +511,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_post_room_visibility_key(self):
         # POST with visibility config key, expect new room id
-        (code, response) = yield self.mock_server.trigger("POST", "/rooms",
+        (code, response) = yield self.mock_resource.trigger("POST", "/rooms",
                                                 '{"visibility":"private"}')
         self.assertEquals(200, code)
         self.assertTrue("room_id" in response)
@@ -519,7 +519,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_post_room_custom_key(self):
         # POST with custom config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger("POST", "/rooms",
+        (code, response) = yield self.mock_resource.trigger("POST", "/rooms",
                                                 '{"custom":"stuff"}')
         self.assertEquals(200, code)
         self.assertTrue("room_id" in response)
@@ -527,7 +527,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_post_room_known_and_unknown_keys(self):
         # POST with custom + known config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger("POST", "/rooms",
+        (code, response) = yield self.mock_resource.trigger("POST", "/rooms",
                                  '{"visibility":"private","custom":"things"}')
         self.assertEquals(200, code)
         self.assertTrue("room_id" in response)
@@ -535,18 +535,18 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_post_room_invalid_content(self):
         # POST with invalid content / paths, expect 400
-        (code, response) = yield self.mock_server.trigger("POST", "/rooms",
+        (code, response) = yield self.mock_resource.trigger("POST", "/rooms",
                                                           '{"visibili')
         self.assertEquals(400, code)
 
-        (code, response) = yield self.mock_server.trigger("POST", "/rooms",
+        (code, response) = yield self.mock_resource.trigger("POST", "/rooms",
                                                           '["hello"]')
         self.assertEquals(400, code)
 
     @defer.inlineCallbacks
     def test_put_room_no_keys(self):
         # PUT with no config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/%21aa%3Atest", "{}"
         )
         self.assertEquals(200, code)
@@ -555,7 +555,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_put_room_visibility_key(self):
         # PUT with known config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/%21bb%3Atest", '{"visibility":"private"}'
         )
         self.assertEquals(200, code)
@@ -564,7 +564,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_put_room_custom_key(self):
         # PUT with custom config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/%21cc%3Atest", '{"custom":"stuff"}'
         )
         self.assertEquals(200, code)
@@ -573,7 +573,7 @@ class RoomsCreateTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_put_room_known_and_unknown_keys(self):
         # PUT with custom + known config keys, expect new room id
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/%21dd%3Atest",
             '{"visibility":"private","custom":"things"}'
         )
@@ -584,12 +584,12 @@ class RoomsCreateTestCase(RestTestCase):
     def test_put_room_invalid_content(self):
         # PUT with invalid content / room names, expect 400
 
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/ee", '{"sdf"'
         )
         self.assertEquals(400, code)
 
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/ee", '["hello"]'
         )
         self.assertEquals(400, code)
@@ -599,7 +599,7 @@ class RoomsCreateTestCase(RestTestCase):
         yield self.create_room_as("!aa:test", self.user_id)
 
         # PUT with conflicting room ID, expect 409
-        (code, response) = yield self.mock_server.trigger(
+        (code, response) = yield self.mock_resource.trigger(
             "PUT", "/rooms/%21aa%3Atest", "{}"
         )
         self.assertEquals(409, code)
@@ -611,7 +611,7 @@ class RoomTopicTestCase(RestTestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
         self.auth_user_id = self.user_id
         self.room_id = "!rid1:test"
         self.path = "/rooms/%s/topic" % self.room_id
@@ -637,7 +637,7 @@ class RoomTopicTestCase(RestTestCase):
             return hs.parse_userid(self.auth_user_id)
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
         # create the room
         yield self.create_room_as(self.room_id, self.user_id)
@@ -648,50 +648,50 @@ class RoomTopicTestCase(RestTestCase):
     @defer.inlineCallbacks
     def test_invalid_puts(self):
         # missing keys or invalid json
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, '{}')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, '{"_name":"bob"}')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, '{"nao')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, '[{"_name":"bob"},{"_name":"jill"}]')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, 'text only')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, '')
         self.assertEquals(400, code, msg=str(response))
 
         # valid key, wrong type
         content = '{"topic":["Topic name"]}'
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, content)
         self.assertEquals(400, code, msg=str(response))
 
     @defer.inlineCallbacks
     def test_rooms_topic(self):
         # nothing should be there
-        (code, response) = yield self.mock_server.trigger_get(self.path)
+        (code, response) = yield self.mock_resource.trigger_get(self.path)
         self.assertEquals(404, code, msg=str(response))
 
         # valid put
         content = '{"topic":"Topic name"}'
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, content)
         self.assertEquals(200, code, msg=str(response))
 
         # valid get
-        (code, response) = yield self.mock_server.trigger_get(self.path)
+        (code, response) = yield self.mock_resource.trigger_get(self.path)
         self.assertEquals(200, code, msg=str(response))
         self.assert_dict(json.loads(content), response)
 
@@ -699,12 +699,12 @@ class RoomTopicTestCase(RestTestCase):
     def test_rooms_topic_with_extra_keys(self):
         # valid put with extra keys
         content = '{"topic":"Seasons","subtopic":"Summer"}'
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            self.path, content)
         self.assertEquals(200, code, msg=str(response))
 
         # valid get
-        (code, response) = yield self.mock_server.trigger_get(self.path)
+        (code, response) = yield self.mock_resource.trigger_get(self.path)
         self.assertEquals(200, code, msg=str(response))
         self.assert_dict(json.loads(content), response)
 
@@ -715,7 +715,7 @@ class RoomMemberStateTestCase(RestTestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
         self.auth_user_id = self.user_id
         self.room_id = "!rid1:test"
 
@@ -740,7 +740,7 @@ class RoomMemberStateTestCase(RestTestCase):
             return hs.parse_userid(self.auth_user_id)
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
         yield self.create_room_as(self.room_id, self.user_id)
 
@@ -751,34 +751,34 @@ class RoomMemberStateTestCase(RestTestCase):
     def test_invalid_puts(self):
         path = "/rooms/%s/members/%s/state" % (self.room_id, self.user_id)
         # missing keys or invalid json
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '{}')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '{"_name":"bob"}')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '{"nao')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '[{"_name":"bob"},{"_name":"jill"}]')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, 'text only')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '')
         self.assertEquals(400, code, msg=str(response))
 
         # valid keys, wrong types
         content = ('{"membership":["%s","%s","%s"]}' %
                   (Membership.INVITE, Membership.JOIN, Membership.LEAVE))
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(400, code, msg=str(response))
 
     @defer.inlineCallbacks
@@ -789,10 +789,10 @@ class RoomMemberStateTestCase(RestTestCase):
 
         # valid join message (NOOP since we made the room)
         content = '{"membership":"%s"}' % Membership.JOIN
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("GET", path, None)
+        (code, response) = yield self.mock_resource.trigger("GET", path, None)
         self.assertEquals(200, code, msg=str(response))
         self.assertEquals(json.loads(content), response)
 
@@ -805,10 +805,10 @@ class RoomMemberStateTestCase(RestTestCase):
 
         # valid invite message
         content = '{"membership":"%s"}' % Membership.INVITE
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("GET", path, None)
+        (code, response) = yield self.mock_resource.trigger("GET", path, None)
         self.assertEquals(200, code, msg=str(response))
         self.assertEquals(json.loads(content), response)
 
@@ -822,10 +822,10 @@ class RoomMemberStateTestCase(RestTestCase):
         # valid invite message with custom key
         content = ('{"membership":"%s","invite_text":"%s"}' %
                     (Membership.INVITE, "Join us!"))
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("GET", path, None)
+        (code, response) = yield self.mock_resource.trigger("GET", path, None)
         self.assertEquals(200, code, msg=str(response))
         self.assertEquals(json.loads(content), response)
 
@@ -836,7 +836,7 @@ class RoomMessagesTestCase(RestTestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        self.mock_server = MockHttpServer(prefix=PATH_PREFIX)
+        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
         self.auth_user_id = self.user_id
         self.room_id = "!rid1:test"
 
@@ -861,7 +861,7 @@ class RoomMessagesTestCase(RestTestCase):
             return hs.parse_userid(self.auth_user_id)
         hs.get_auth().get_user_by_token = _get_user_by_token
 
-        synapse.rest.room.register_servlets(hs, self.mock_server)
+        synapse.rest.room.register_servlets(hs, self.mock_resource)
 
         yield self.create_room_as(self.room_id, self.user_id)
 
@@ -874,27 +874,27 @@ class RoomMessagesTestCase(RestTestCase):
             urllib.quote(self.room_id), self.user_id
         )
         # missing keys or invalid json
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '{}')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '{"_name":"bob"}')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '{"nao')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '[{"_name":"bob"},{"_name":"jill"}]')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, 'text only')
         self.assertEquals(400, code, msg=str(response))
 
-        (code, response) = yield self.mock_server.trigger("PUT",
+        (code, response) = yield self.mock_resource.trigger("PUT",
                            path, '')
         self.assertEquals(400, code, msg=str(response))
 
@@ -905,34 +905,34 @@ class RoomMessagesTestCase(RestTestCase):
         )
 
         content = '{"body":"test","msgtype":{"type":"a"}}'
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(400, code, msg=str(response))
 
         # custom message types
         content = '{"body":"test","msgtype":"test.custom.text"}'
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
 
-        # (code, response) = yield self.mock_server.trigger("GET", path, None)
-        # self.assertEquals(200, code, msg=str(response))
-        # self.assert_dict(json.loads(content), response)
+#        (code, response) = yield self.mock_resource.trigger("GET", path, None)
+#        self.assertEquals(200, code, msg=str(response))
+#        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
         )
         content = '{"body":"test2","msgtype":"m.text"}'
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
 
-        # (code, response) = yield self.mock_server.trigger("GET", path, None)
-        # self.assertEquals(200, code, msg=str(response))
-        # self.assert_dict(json.loads(content), response)
+#        (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_server.trigger("PUT", path, content)
+        (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 a543f049c4..8ed228b218 100644
--- a/tests/rest/utils.py
+++ b/tests/rest/utils.py
@@ -27,12 +27,12 @@ class RestTestCase(unittest.TestCase):
     """Contains extra helper functions to quickly and clearly perform a given
     REST action, which isn't the focus of the test.
 
-    This subclass assumes there are mock_server and auth_user_id attributes.
+    This subclass assumes there are mock_resource and auth_user_id attributes.
     """
 
     def __init__(self, *args, **kwargs):
         super(RestTestCase, self).__init__(*args, **kwargs)
-        self.mock_server = None
+        self.mock_resource = None
         self.auth_user_id = None
 
     def mock_get_user_by_token(self, token=None):
@@ -48,7 +48,7 @@ class RestTestCase(unittest.TestCase):
             content = '{"visibility":"private"}'
         if tok:
             path = path + "?access_token=%s" % tok
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(200, code, msg=str(response))
         self.auth_user_id = temp_id
 
@@ -81,11 +81,11 @@ class RestTestCase(unittest.TestCase):
             path = path + "?access_token=%s" % tok
 
         if membership == Membership.LEAVE:
-            (code, response) = yield self.mock_server.trigger("DELETE", path,
+            (code, response) = yield self.mock_resource.trigger("DELETE", path,
                                     None)
             self.assertEquals(expect_code, code, msg=str(response))
         else:
-            (code, response) = yield self.mock_server.trigger("PUT", path,
+            (code, response) = yield self.mock_resource.trigger("PUT", path,
                                     '{"membership":"%s"}' % membership)
             self.assertEquals(expect_code, code, msg=str(response))
 
@@ -93,7 +93,7 @@ class RestTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def register(self, user_id):
-        (code, response) = yield self.mock_server.trigger("POST", "/register",
+        (code, response) = yield self.mock_resource.trigger("POST", "/register",
                                 '{"user_id":"%s"}' % user_id)
         self.assertEquals(200, code)
         defer.returnValue(response)
@@ -111,7 +111,7 @@ class RestTestCase(unittest.TestCase):
         if tok:
             path = path + "?access_token=%s" % tok
 
-        (code, response) = yield self.mock_server.trigger("PUT", path, content)
+        (code, response) = yield self.mock_resource.trigger("PUT", path, content)
         self.assertEquals(expect_code, code, msg=str(response))
 
     def assert_dict(self, required, actual):