Skip to content

Commit 33a2d0c

Browse files
committed
Test pbkdf2_unpack error conditions
1 parent ef59495 commit 33a2d0c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_security.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,27 @@ def test_password(self):
422422
roundup.password.test_missing_crypt()
423423
roundup.password.crypt = orig_crypt
424424

425+
def test_pbkdf2_unpack(self):
426+
pbkdf2_unpack = roundup.password.pbkdf2_unpack
427+
428+
with self.assertRaises(roundup.password.PasswordValueError) as ctx:
429+
pbkdf2_unpack("fred$password")
430+
431+
self.assertEqual(ctx.exception.args[0],
432+
'invalid PBKDF2 hash (wrong number of separators)')
433+
434+
with self.assertRaises(roundup.password.PasswordValueError) as ctx:
435+
pbkdf2_unpack("0200000$salt$password")
436+
437+
self.assertEqual(ctx.exception.args[0],
438+
'invalid PBKDF2 hash (zero-padded rounds)')
439+
440+
with self.assertRaises(roundup.password.PasswordValueError) as ctx:
441+
pbkdf2_unpack("fred$salt$password")
442+
443+
self.assertEqual(ctx.exception.args[0],
444+
'invalid PBKDF2 hash (invalid rounds)')
445+
425446
def test_pbkdf2_migrate_rounds(self):
426447
'''Check that migration happens when number of rounds in
427448
config is larger than number of rounds in current password.

0 commit comments

Comments
 (0)