Skip to content

Commit 636bad6

Browse files
committed
Production PBKDF rounds back to 2M, test 1k; fix empty_form (python2)
1 parent 45d40dc commit 636bad6

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

roundup/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ def str2value(self, value):
10861086
"get the error 'Error: field larger than field limit' during\n"
10871087
"import."),
10881088
(IntegerNumberGeqZeroOption, 'password_pbkdf2_default_rounds',
1089-
'10000',
1089+
'2000000',
10901090
"Sets the default number of rounds used when encoding passwords\n"
10911091
"using the PBKDF2 scheme. Set this to a higher value on faster\n"
10921092
"systems which want more security.\n"

roundup/password.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,24 @@ def encodePassword(plaintext, scheme, other=None, config=None):
193193
salt = h64encode(raw_salt)
194194
if config:
195195
rounds = config.PASSWORD_PBKDF2_DEFAULT_ROUNDS
196+
197+
# if we are testing
198+
if ("pytest" in sys.modules and
199+
"PYTEST_CURRENT_TEST" in os.environ):
200+
if ("PYTEST_USE_CONFIG" in os.environ):
201+
rounds = config.PASSWORD_PBKDF2_DEFAULT_ROUNDS
202+
else:
203+
# Use 1000 rounds unless the test signals it
204+
# wants the config numberby setting
205+
# PYTEST_USE_CONFIG Using the production 2M
206+
# round values makes testing increase from 12
207+
# minutes to 1 hour in CI.
208+
rounds = 1000
196209
else:
197210
if ("pytest" in sys.modules and
198211
"PYTEST_CURRENT_TEST" in os.environ):
199212
# Set rounds to 1000 if no config is passed and
200-
# we are running within a pytest test. Using
201-
# actual 2M production values makes testing
202-
# increase from 12 minutes to 1 hour in CI.
213+
# we are running within a pytest test.
203214
rounds = 1000
204215
else:
205216
import logging

test/rest_common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ def setUp(self):
245245
self.dummy_client.db = self.db
246246

247247
self.empty_form = cgi.FieldStorage()
248+
# under python2 invoking:
249+
# python2 -m pytest --durations=20
250+
# loads the form with:
251+
# FieldStorage(None, None, [MiniFieldStorage('--durations', '2')])
252+
# Invoking it as: python2 -m pytest -v --durations=20
253+
# results in an empty list. In any case, force it to be empty.
254+
self.empty_form.list = []
248255
self.terse_form = cgi.FieldStorage()
249256
self.terse_form.list = [
250257
cgi.MiniFieldStorage('@verbose', '0'),

0 commit comments

Comments
 (0)