def test_verifyable_hash(self): password = '******' hash = pwhash.Hash(password=password) hashed = str(hash) hash2 = pwhash.Hash() hash2.set_hash(hashed) assert hash2.verify(password)
def test_bad_hash(self): hash = pwhash.Hash() self.assertRaises(pwhash.InvalidHashStringError, hash.set_hash, 'badc0ffee')
def test_verify_md5_hash(self): hash = pwhash.Hash() hash.set_hash('{md5}e7MaFMQE$wbzoUnM9Jju9ob9bY29+hA==') self.assert_(hash.verify('foobar')) self.assertFalse(hash.verify('blueparrot'))
def test_verify_sha1_hash(self): hash = pwhash.Hash() hash.set_hash('{sha1}e7MaFMQE$cCqMIINS5t85J0MIgNwMprXBfLA=') self.assert_(hash.verify('foobar')) self.assertFalse(hash.verify('blueparrot'))
def test_pbkdf25_hash(self): hash = pwhash.Hash('pbkdf2', 'e7MaFMQE', 'foobar') self.assertEquals( '{pbkdf2}e7MaFMQE$7j7bgQb8xED7mEY+8g1QM2zs/ispKZVeNEv/nMCYPX0=', str(hash))
def test_md5_hash(self): hash = pwhash.Hash('md5', 'e7MaFMQE', 'foobar') self.assertEquals('{md5}e7MaFMQE$wbzoUnM9Jju9ob9bY29+hA==', str(hash))
def test_sha1_hash(self): hash = pwhash.Hash('sha1', 'e7MaFMQE', 'foobar') self.assertEquals('{sha1}e7MaFMQE$cCqMIINS5t85J0MIgNwMprXBfLA=', str(hash))
def test_bad_hash(self): hash = pwhash.Hash() with pytest.raises(pwhash.InvalidHashStringError): hash.set_hash('badc0ffee')
def test_unknown_hash(self): with pytest.raises(pwhash.UnknownHashMethodError): pwhash.Hash('montyhash', 'e7MaFMQE', 'foobar')
def test_md5_hash(self): hash = pwhash.Hash('md5', 'e7MaFMQE', 'foobar') assert '{md5}e7MaFMQE$wbzoUnM9Jju9ob9bY29+hA==' == str(hash)
def test_sha1_hash(self): hash = pwhash.Hash('sha1', 'e7MaFMQE', 'foobar') assert '{sha1}e7MaFMQE$cCqMIINS5t85J0MIgNwMprXBfLA=' == str(hash)