diff options
author | David Baker <dave@matrix.org> | 2016-06-02 13:35:25 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-06-02 13:35:25 +0100 |
commit | 3a3fb2f6f9d958d62a96391491f794042d1a419c (patch) | |
tree | b0085e37f02db4f019440086a91905057843889b /tests/utils.py | |
parent | Email unsubscribing that may in theory, work (diff) | |
parent | Split out the auth handler (diff) | |
download | synapse-3a3fb2f6f9d958d62a96391491f794042d1a419c.tar.xz |
Merge branch 'dbkr/split_out_auth_handler' into dbkr/email_unsubscribe
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/tests/utils.py b/tests/utils.py index 006abedbc1..e19ae581e0 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -81,16 +81,11 @@ def setup_test_homeserver(name="test", datastore=None, config=None, **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) + # Need to let the HS build an auth handler and then mess with it + # because AuthHandler's constructor requires the HS, so we can't make one + # beforehand and pass it in to the HS's constructor (chicken / egg) + hs.get_auth_handler().hash = lambda p: hashlib.md5(p).hexdigest() + hs.get_auth_handler().validate_hash = lambda p, h: hashlib.md5(p).hexdigest() == h fed = kargs.get("resource_for_federation", None) if fed: |