comparison test/test_security.py @ 7167:f6b24a8524cd

Modify code to reduce runtime when testing The prior change to set default number of PBKDF2 rounds to 2000000 (2M) raised runtime in CI from 12 minutes to an hour. This commit checks to see if we are invoked from a pytest test using: if ("pytest" in sys.modules and "PYTEST_CURRENT_TEST" in os.environ): when no config object is present. I assume that the number of times we have a full config object is less than with a missing config object. See if this brings CI runtimes back down. It reduces runtimes on my local box, but.... Code adapted from https://stackoverflow.com/questions/25188119/test-if-code-is-executed-from-within-a-py-test-session/44595269#
author John Rouillard <rouilj@ieee.org>
date Sat, 25 Feb 2023 14:50:34 -0500
parents 970cd6d2b8ea
children 8b2287d850c8
comparison
equal deleted inserted replaced
7166:1549c7e74ef8 7167:f6b24a8524cd
430 430
431 self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS = 2000000 431 self.db.config.PASSWORD_PBKDF2_DEFAULT_ROUNDS = 2000000
432 432
433 self.assertEqual(p.needs_migration(config=self.db.config), True) 433 self.assertEqual(p.needs_migration(config=self.db.config), True)
434 434
435 def test_encodePasswordNoConfig(self):
436 # should run cleanly as we are in a test.
437 #
438 p = roundup.password.encodePassword('sekrit', 'PBKDF2')
439
440 del(os.environ["PYTEST_CURRENT_TEST"])
441 self.assertNotIn("PYTEST_CURRENT_TEST", os.environ)
442
443 with self.assertRaises(roundup.password.ConfigNotSet) as ctx:
444 roundup.password.encodePassword('sekrit', 'PBKDF2')
445
435 # vim: set filetype=python sts=4 sw=4 et si : 446 # vim: set filetype=python sts=4 sw=4 et si :

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