comparison 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
comparison
equal deleted inserted replaced
7220:4d83f9f751ff 7221:cbeac604d9d5
420 roundup.password.crypt = None 420 roundup.password.crypt = None
421 with self.assertRaises(roundup.password.PasswordValueError) as ctx: 421 with self.assertRaises(roundup.password.PasswordValueError) as ctx:
422 roundup.password.test_missing_crypt() 422 roundup.password.test_missing_crypt()
423 roundup.password.crypt = orig_crypt 423 roundup.password.crypt = orig_crypt
424 424
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
425 def test_pbkdf2_migrate_rounds(self): 446 def test_pbkdf2_migrate_rounds(self):
426 '''Check that migration happens when number of rounds in 447 '''Check that migration happens when number of rounds in
427 config is larger than number of rounds in current password. 448 config is larger than number of rounds in current password.
428 ''' 449 '''
429 450

Roundup Issue Tracker: http://roundup-tracker.org/