summary refs log tree commit diff
path: root/tests/utils.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-10-17 21:02:16 +0100
committerErik Johnston <erik@matrix.org>2014-10-17 21:02:16 +0100
commit449739e6a364759a86f73417626af49d6a794e3d (patch)
tree04b2f39c91ec6098ffe3b380442787ac3ce2908f /tests/utils.py
parentMerge branch 'release-v0.3.4' of github.com:matrix-org/synapse (diff)
parentCheck that we have auth headers and fail nicely (diff)
downloadsynapse-449739e6a364759a86f73417626af49d6a794e3d.tar.xz
Merge branch 'release-v0.4.0' of github.com:matrix-org/synapse
Diffstat (limited to 'tests/utils.py')
-rw-r--r--tests/utils.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/utils.py b/tests/utils.py
index bb8e9964dd..60fd6085ac 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -76,6 +76,13 @@ class MockHttpResource(HttpServer):
         mock_content.configure_mock(**config)
         mock_request.content = mock_content
 
+        mock_request.method = http_method
+        mock_request.uri = path
+
+        mock_request.requestHeaders.getRawHeaders.return_value=[
+            "X-Matrix origin=test,key=,sig="
+        ]
+
         # return the right path if the event requires it
         mock_request.path = path
 
@@ -108,6 +115,21 @@ class MockHttpResource(HttpServer):
         self.callbacks.append((method, path_pattern, callback))
 
 
+class MockKey(object):
+    alg = "mock_alg"
+    version = "mock_version"
+
+    @property
+    def verify_key(self):
+        return self
+
+    def sign(self, message):
+        return b"\x9a\x87$"
+
+    def verify(self, message, sig):
+        assert sig == b"\x9a\x87$"
+
+
 class MockClock(object):
     now = 1000
 
@@ -167,7 +189,11 @@ class MemoryDataStore(object):
 
     def get_user_by_token(self, token):
         try:
-            return self.tokens_to_users[token]
+            return {
+                "name": self.tokens_to_users[token],
+                "admin": 0,
+                "device_id": None,
+            }
         except:
             raise StoreError(400, "User does not exist.")
 
@@ -264,6 +290,9 @@ class MemoryDataStore(object):
     def get_ops_levels(self, room_id):
         return defer.succeed((5, 5, 5))
 
+    def insert_client_ip(self, user, device_id, access_token, ip, user_agent):
+        return defer.succeed(None)
+
 
 def _format_call(args, kwargs):
     return ", ".join(