diff options
author | Erik Johnston <erik@matrix.org> | 2018-08-23 18:33:04 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-08-23 19:17:19 +0100 |
commit | f2cbbda956a5abd3163665ad87d2fc9500a265d2 (patch) | |
tree | 4d0746dab86ea8d4a0ba50f177ff60b78eaab17f /tests/server.py | |
parent | Implement trail users (diff) | |
download | synapse-f2cbbda956a5abd3163665ad87d2fc9500a265d2.tar.xz |
Unit tests
Diffstat (limited to 'tests/server.py')
-rw-r--r-- | tests/server.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/server.py b/tests/server.py index c63b2c3100..7dbdb7f8ea 100644 --- a/tests/server.py +++ b/tests/server.py @@ -5,7 +5,7 @@ from six import text_type import attr -from twisted.internet import threads +from twisted.internet import address, threads from twisted.internet.defer import Deferred from twisted.python.failure import Failure from twisted.test.proto_helpers import MemoryReactorClock @@ -63,7 +63,9 @@ class FakeChannel(object): self.result["done"] = True def getPeer(self): - return None + # We give an address so that getClientIP returns a non null entry, + # causing us to record the MAU + return address.IPv4Address(b"TCP", "127.0.0.1", 3423) def getHost(self): return None @@ -91,7 +93,7 @@ class FakeSite: return FakeLogger() -def make_request(method, path, content=b""): +def make_request(method, path, content=b"", access_token=None): """ Make a web request using the given method and path, feed it the content, and return the Request and the Channel underneath. @@ -116,6 +118,11 @@ def make_request(method, path, content=b""): req = SynapseRequest(site, channel) req.process = lambda: b"" req.content = BytesIO(content) + + if access_token: + req.requestHeaders.addRawHeader(b"Authorization", b"Bearer " + access_token) + + req.requestHeaders.addRawHeader(b"X-Forwarded-For", b"127.0.0.1") req.requestReceived(method, path, b"1.1") return req, channel |