Skip to content

Commit 7784eb9

Browse files
committed
Add config argument to more password.Password invocations.
The work done to allow password_pbkdf2_default_rounds to be overridden for testing requires that calls to password.Password include a config argument. This was needed because using the real value more than quadrupled testing runtime. However there are still a few places where config was not being set when Password was called. I think this fixes all of the ones that are called from a function that have access to a db.config object. The remaining ones all call Password(encrypted=x). This results in Password.unpack() being called. If x is not a propertly formatted password string ("{scheme}...", it calls encodePassword. It then should end up raising the ConfigNotSet exception. This is probably what we want as it means the shape of "x" is not correct. I don't understand why Password.unpack() attempts to encrypt the value of encrypted if it doesn't match the right form. According to codecov, this encryption branch is being used, so somewhere x is of the wrong form. Hmmm....
1 parent d9b6c92 commit 7784eb9

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

roundup/backends/back_anydbm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def unserialise(self, classname, node):
503503
elif isinstance(prop, hyperdb.Interval) and v is not None:
504504
d[k] = date.Interval(v)
505505
elif isinstance(prop, hyperdb.Password) and v is not None:
506-
d[k] = password.Password(encrypted=v)
506+
d[k] = password.Password(encrypted=v, config=self.config)
507507
else:
508508
d[k] = v
509509
return d
@@ -2147,7 +2147,8 @@ def import_list(self, propnames, proplist):
21472147
elif isinstance(prop, hyperdb.Interval):
21482148
value = date.Interval(value)
21492149
elif isinstance(prop, hyperdb.Password):
2150-
value = password.Password(encrypted=value)
2150+
value = password.Password(encrypted=value,
2151+
config=self.db.config)
21512152
d[propname] = value
21522153

21532154
# get a new id if necessary

roundup/backends/back_mysql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def add_new_columns_v2(self):
328328
elif isinstance(prop, hyperdb.Interval) and v is not None:
329329
v = date.Interval(v)
330330
elif isinstance(prop, hyperdb.Password) and v is not None:
331-
v = password.Password(encrypted=v)
331+
v = password.Password(encrypted=v, config=self.config)
332332
elif isinstance(prop, hyperdb.Integer) and v is not None:
333333
v = int(v)
334334
elif (isinstance(prop, hyperdb.Boolean) or

roundup/backends/rdbms_common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,8 @@ def import_list(self, propnames, proplist):
32553255
elif isinstance(prop, hyperdb.Interval):
32563256
value = date.Interval(value)
32573257
elif isinstance(prop, hyperdb.Password):
3258-
value = password.Password(encrypted=value)
3258+
value = password.Password(encrypted=value,
3259+
config=self.db.config)
32593260
elif isinstance(prop, String):
32603261
value = us2s(value)
32613262
if not isinstance(value, str):

roundup/roundupdb.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ def confirm_registration(self, otk):
114114
elif isinstance(proptype, hyperdb.Interval):
115115
props[propname] = date.Interval(value)
116116
elif isinstance(proptype, hyperdb.Password):
117-
props[propname] = password.Password(encrypted=value)
117+
props[propname] = password.Password(encrypted=value,
118+
config=self.config)
118119

119120
# tag new user creation with 'admin'
120121
self.journaltag = 'admin'

roundup/test/memorydb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def create(journaltag, create=True, debug=False, prefix=default_prefix):
6262

6363
initial_data = os.path.join(prefix, 'initial_data.py')
6464
vars = dict(db=db, admin_email='[email protected]',
65-
adminpw=password.Password('sekrit'))
65+
adminpw=password.Password('sekrit', config=db.config))
6666
fd = open(initial_data)
6767
exec(compile(fd.read(), initial_data, 'exec'), vars)
6868
fd.close()
@@ -110,7 +110,8 @@ def create(journaltag, create=True, debug=False, prefix=default_prefix):
110110
'''
111111
if create:
112112
db.user.create(username="fred", roles='User',
113-
password=password.Password('sekrit'),
113+
password=password.Password('sekrit',
114+
config=db.config),
114115
address='[email protected]')
115116

116117
db.security.addPermissionToRole('User', 'Email Access')

0 commit comments

Comments
 (0)