Mercurial > p > roundup > code
diff test/test_security.py @ 7221:cbeac604d9d5
Test pbkdf2_unpack error conditions
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 12 Mar 2023 21:19:51 -0400 |
| parents | 8b2287d850c8 |
| children | b124c38930ed |
line wrap: on
line diff
--- a/test/test_security.py Sun Mar 12 20:28:53 2023 -0400 +++ b/test/test_security.py Sun Mar 12 21:19:51 2023 -0400 @@ -422,6 +422,27 @@ roundup.password.test_missing_crypt() roundup.password.crypt = orig_crypt + def test_pbkdf2_unpack(self): + pbkdf2_unpack = roundup.password.pbkdf2_unpack + + with self.assertRaises(roundup.password.PasswordValueError) as ctx: + pbkdf2_unpack("fred$password") + + self.assertEqual(ctx.exception.args[0], + 'invalid PBKDF2 hash (wrong number of separators)') + + with self.assertRaises(roundup.password.PasswordValueError) as ctx: + pbkdf2_unpack("0200000$salt$password") + + self.assertEqual(ctx.exception.args[0], + 'invalid PBKDF2 hash (zero-padded rounds)') + + with self.assertRaises(roundup.password.PasswordValueError) as ctx: + pbkdf2_unpack("fred$salt$password") + + self.assertEqual(ctx.exception.args[0], + 'invalid PBKDF2 hash (invalid rounds)') + def test_pbkdf2_migrate_rounds(self): '''Check that migration happens when number of rounds in config is larger than number of rounds in current password.
