Mercurial > p > roundup > code
comparison roundup/test/memorydb.py @ 7211:506c86823abb
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....
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 04 Mar 2023 00:17:26 -0500 |
| parents | b1130680d4ed |
| children | 617d85ce4ac3 |
comparison
equal
deleted
inserted
replaced
| 7210:7147a4c833e9 | 7211:506c86823abb |
|---|---|
| 60 exec(compile(fd.read(), schema, 'exec'), vars) | 60 exec(compile(fd.read(), schema, 'exec'), vars) |
| 61 fd.close() | 61 fd.close() |
| 62 | 62 |
| 63 initial_data = os.path.join(prefix, 'initial_data.py') | 63 initial_data = os.path.join(prefix, 'initial_data.py') |
| 64 vars = dict(db=db, admin_email='admin@test.com', | 64 vars = dict(db=db, admin_email='admin@test.com', |
| 65 adminpw=password.Password('sekrit')) | 65 adminpw=password.Password('sekrit', config=db.config)) |
| 66 fd = open(initial_data) | 66 fd = open(initial_data) |
| 67 exec(compile(fd.read(), initial_data, 'exec'), vars) | 67 exec(compile(fd.read(), initial_data, 'exec'), vars) |
| 68 fd.close() | 68 fd.close() |
| 69 | 69 |
| 70 # load standard detectors | 70 # load standard detectors |
| 108 recipients=Multilink("user", do_journal='no') | 108 recipients=Multilink("user", do_journal='no') |
| 109 ) | 109 ) |
| 110 ''' | 110 ''' |
| 111 if create: | 111 if create: |
| 112 db.user.create(username="fred", roles='User', | 112 db.user.create(username="fred", roles='User', |
| 113 password=password.Password('sekrit'), | 113 password=password.Password('sekrit', |
| 114 config=db.config), | |
| 114 address='fred@example.com') | 115 address='fred@example.com') |
| 115 | 116 |
| 116 db.security.addPermissionToRole('User', 'Email Access') | 117 db.security.addPermissionToRole('User', 'Email Access') |
| 117 ''' | 118 ''' |
| 118 db.security.addPermission(name='Register', klass='user') | 119 db.security.addPermission(name='Register', klass='user') |
