summary refs log tree commit diff
path: root/tests/utils.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2015-08-26 15:59:32 +0100
committerDaniel Wagner-Hall <daniel@matrix.org>2015-08-26 15:59:32 +0100
commit3063383547529a542b48f416d64fd98eaf6a2f60 (patch)
tree600f0a0659d454bac71acb22623406efebef8c3a /tests/utils.py
parentMerge pull request #254 from matrix-org/markjh/tox_setuptools (diff)
downloadsynapse-3063383547529a542b48f416d64fd98eaf6a2f60.tar.xz
Swap out bcrypt for md5 in tests
This reduces our ~8 second sequential test time down to ~7 seconds
Diffstat (limited to '')
-rw-r--r--tests/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py
index 3766a994f2..dd19a16fc7 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -27,6 +27,7 @@ from twisted.enterprise.adbapi import ConnectionPool
 
 from collections import namedtuple
 from mock import patch, Mock
+import hashlib
 import urllib
 import urlparse
 
@@ -67,6 +68,18 @@ def setup_test_homeserver(name="test", datastore=None, config=None, **kargs):
             **kargs
         )
 
+    # bcrypt is far too slow to be doing in unit tests
+    def swap_out_hash_for_testing(old_build_handlers):
+        def build_handlers():
+            handlers = old_build_handlers()
+            auth_handler = handlers.auth_handler
+            auth_handler.hash = lambda p: hashlib.md5(p).hexdigest()
+            auth_handler.validate_hash = lambda p, h: hashlib.md5(p).hexdigest() == h
+            return handlers
+        return build_handlers
+
+    hs.build_handlers = swap_out_hash_for_testing(hs.build_handlers)
+
     defer.returnValue(hs)