def test_password_MD5(): pass_string = crypt_password("secret", "MD5") method, salt, crypt = parse_pass(pass_string) assert method == "{MD5}", "method is %s, not {MD5}" % method assert salt is not None, "salt is None" md5_hash = hashlib.md5(salt) md5_hash.update(u"secret") assert crypt == md5_hash.hexdigest(), "Crypted password did not match"
def test_parse_pass(): password = u"{method}$SALTSALT$PASSWORDPASSWORD" method, salt, crypt = parse_pass(password) assert method == "{method}", "failed to parse method" assert salt == "SALTSALT", "failed to parse salt" assert crypt == "PASSWORDPASSWORD"