mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 21:04:50 -04:00
Swap out bcrypt for md5 in tests
This reduces our ~8 second sequential test time down to ~7 seconds
This commit is contained in:
parent
4c56928263
commit
3063383547
3 changed files with 39 additions and 3 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue