summary refs log tree commit diff
path: root/tests/handlers/test_typing.py
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-12-11 18:11:43 +0000
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-12-11 18:11:43 +0000
commit5ebc994f841508beb48f06d22073e08845c5f593 (patch)
tree453aea70ac99691e4c4cd9ab71b9e100bad109f9 /tests/handlers/test_typing.py
parentAdd a sprinkling of logger.debug() into typing notification handler (diff)
downloadsynapse-5ebc994f841508beb48f06d22073e08845c5f593.tar.xz
Actually auth-check to ensure people can only send typing notifications for rooms they're actually in
Diffstat (limited to 'tests/handlers/test_typing.py')
-rw-r--r--tests/handlers/test_typing.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index b858f96323..bc19db8dfa 100644
--- a/tests/handlers/test_typing.py
+++ b/tests/handlers/test_typing.py
@@ -22,6 +22,7 @@ import json
 
 from ..utils import MockHttpResource, MockClock, DeferredMockCallable, MockKey
 
+from synapse.api.errors import AuthError
 from synapse.server import HomeServer
 from synapse.handlers.typing import TypingNotificationHandler
 
@@ -68,7 +69,10 @@ class TypingNotificationsTestCase(unittest.TestCase):
         mock_notifier = Mock(spec=["on_new_user_event"])
         self.on_new_user_event = mock_notifier.on_new_user_event
 
+        self.auth = Mock(spec=[])
+
         hs = HomeServer("test",
+                auth=self.auth,
                 clock=self.clock,
                 db_pool=None,
                 datastore=Mock(spec=[
@@ -142,6 +146,12 @@ class TypingNotificationsTestCase(unittest.TestCase):
         self.room_member_handler.fetch_room_distributions_into = (
                 fetch_room_distributions_into)
 
+        def check_joined_room(room_id, user_id):
+            if user_id not in [u.to_string() for u in self.room_members]:
+                raise AuthError(401, "User is not in the room")
+
+        self.auth.check_joined_room = check_joined_room
+
         # Some local users to test with
         self.u_apple = hs.parse_userid("@apple:test")
         self.u_banana = hs.parse_userid("@banana:test")