def test_80_faulty_crypt(self):
"test with faulty crypt()"
hash = self.get_sample_hash()[1]
exc_types = (AssertionError,)
setter = self._use_mock_crypt()
def test(value):
# set safe_crypt() to return specified value, and
# make sure assertion error is raised by handler.
setter(value)
self.assertRaises(exc_types, self.do_genhash, "stub", hash)
self.assertRaises(exc_types, self.do_encrypt, "stub")
self.assertRaises(exc_types, self.do_verify, "stub", hash)
test('$x' + hash[2:]) # detect wrong prefix
test(hash[:-1]) # detect too short
test(hash + 'x') # detect too long
评论列表
文章目录