summary refs log tree commit diff
path: root/tests/unittest.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-12-02 15:26:25 +0000
committerRichard van der Hoff <richard@matrix.org>2020-12-02 16:30:01 +0000
commit7ea85302f3ce59cdb38bceb1c2aeea2d690e2dbb (patch)
tree2636a3544e0ced69fcb04996a2eb3c8cbe4b21ef /tests/unittest.py
parentAdd `create_resource_dict` method to HomeserverTestCase (diff)
downloadsynapse-7ea85302f3ce59cdb38bceb1c2aeea2d690e2dbb.tar.xz
fix up various test cases
A few test cases were relying on being able to mount non-client servlets on the
test resource. it's better to give them their own Resources.
Diffstat (limited to 'tests/unittest.py')
-rw-r--r--tests/unittest.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/unittest.py b/tests/unittest.py
index 425b39b1d1..102b0a1f34 100644
--- a/tests/unittest.py
+++ b/tests/unittest.py
@@ -705,13 +705,29 @@ class FederatingHomeserverTestCase(HomeserverTestCase):
     A federating homeserver that authenticates incoming requests as `other.example.com`.
     """
 
-    def prepare(self, reactor, clock, homeserver):
+    def create_resource_dict(self) -> Dict[str, Resource]:
+        d = super().create_resource_dict()
+        d["/_matrix/federation"] = TestTransportLayerServer(self.hs)
+        return d
+
+
+class TestTransportLayerServer(JsonResource):
+    """A test implementation of TransportLayerServer
+
+    authenticates incoming requests as `other.example.com`.
+    """
+
+    def __init__(self, hs):
+        super().__init__(hs)
+
         class Authenticator:
             def authenticate_request(self, request, content):
                 return succeed("other.example.com")
 
+        authenticator = Authenticator()
+
         ratelimiter = FederationRateLimiter(
-            clock,
+            hs.get_clock(),
             FederationRateLimitConfig(
                 window_size=1,
                 sleep_limit=1,
@@ -720,11 +736,8 @@ class FederatingHomeserverTestCase(HomeserverTestCase):
                 concurrent_requests=1000,
             ),
         )
-        federation_server.register_servlets(
-            homeserver, self.resource, Authenticator(), ratelimiter
-        )
 
-        return super().prepare(reactor, clock, homeserver)
+        federation_server.register_servlets(hs, self, authenticator, ratelimiter)
 
 
 def override_config(extra_config):