def wrapper(*a, **ka): args = signature(func).bind_partial(*a, **ka).arguments plaintext = None if 'name' not in args: args['name'] = uuid4().hex if 'hashed' not in args: plaintext = uuid4().hex # We need to run tests faster. # This doesn't get called for authentication tests. with patch.object(auth, 'BCRYPT_ROUNDS', 4): args['hashed'] = auth.hashed(plaintext) rec = func(**args) acid, token = auth._gen_acid(), auth._gen_token() auth.cookies.save(acct=rec, acid=acid, token=token, session=True) return rec.add({'plaintext_pwd': plaintext, 'cookies': {'acid': acid, 'token': token}})
def test_hashing(pwd): hashed = auth.hashed(pwd) assert auth.compare(pwd, hashed) assert hashed != auth.hashed("")