Opened 10 years ago
Closed 8 years ago
#12192 closed defect (fixed)
[PATCH] test suite failures with trac 1.0.x
Reported by: | Owned by: | Ryan J Ollos | |
---|---|---|---|
Priority: | normal | Component: | AccountManagerPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 1.0 |
Description
Didn't see this with older trac
versions:
$ python setup.py test running test running egg_info writing requirements to TracAccountManager.egg-info/requires.txt writing TracAccountManager.egg-info/PKG-INFO writing top-level names to TracAccountManager.egg-info/top_level.txt writing dependency_links to TracAccountManager.egg-info/dependency_links.txt writing entry points to TracAccountManager.egg-info/entry_points.txt reading manifest file 'TracAccountManager.egg-info/SOURCES.txt' writing manifest file 'TracAccountManager.egg-info/SOURCES.txt' running build_ext test_available_actions (acct_mgr.tests.api.PermissionTestCase) ... ok test_available_actions_config_admin (acct_mgr.tests.api.PermissionTestCase) ... ok test_available_actions_full_perms (acct_mgr.tests.api.PermissionTestCase) ... ok test_available_actions_no_perms (acct_mgr.tests.api.PermissionTestCase) ... ok test_available_actions_user_admin (acct_mgr.tests.api.PermissionTestCase) ... ok test_create_user (acct_mgr.tests.db.HtDigestTestCase) ... ok test_delete_nonexistant_user (acct_mgr.tests.db.HtDigestTestCase) ... ok test_delete_user (acct_mgr.tests.db.HtDigestTestCase) ... ok test_get_users (acct_mgr.tests.db.HtDigestTestCase) ... ok test_has_user (acct_mgr.tests.db.HtDigestTestCase) ... ok test_unicode_username_and_password (acct_mgr.tests.db.HtDigestTestCase) ... ok test_update_password (acct_mgr.tests.db.HtDigestTestCase) ... ok test_create_user (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_delete_nonexistant_user (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_delete_user (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_get_users (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_has_user (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_unicode_username_and_password (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_update_password (acct_mgr.tests.db.HtPasswdTestCase) ... ok test_file (acct_mgr.tests.htfile.HtDigestTestCase) ... ok test_unicode (acct_mgr.tests.htfile.HtDigestTestCase) ... ok test_update_password (acct_mgr.tests.htfile.HtDigestTestCase) ... ok test_userline (acct_mgr.tests.htfile.HtDigestTestCase) ... ok test_add_with_no_trailing_newline (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_create_hash (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_crypt (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_md5 (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_no_trailing_newline (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_sha (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_sha256 (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_sha512 (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_unicode (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_update_password (acct_mgr.tests.htfile.HtPasswdTestCase) ... ok test_bad_check (acct_mgr.tests.register.DummyRegInspectorTestCase) ... ok test_check_error (acct_mgr.tests.register.DummyRegInspectorTestCase) ... ok test_dummy_check (acct_mgr.tests.register.DummyRegInspectorTestCase) ... ok test_check (acct_mgr.tests.register.BasicCheckTestCase) ... ERROR test_check (acct_mgr.tests.register.BotTrapCheckTestCase) ... ok test_verify_conf_changes (acct_mgr.tests.register.EmailCheckTestCase) Registration challenges with EmailVerificationModule enabled. ... ERROR test_verify_mod_disabled (acct_mgr.tests.register.EmailCheckTestCase) Registration challenges with EmailVerificationModule disabled. ... ok test_check (acct_mgr.tests.register.RegExpCheckTestCase) ... ok test_check (acct_mgr.tests.register.UsernamePermCheckTestCase) ... ok test_checks (acct_mgr.tests.register.RegistrationModuleTestCase) ... ok test_mandatory_email_registration (acct_mgr.tests.register.RegistrationModuleTestCase) ... ok test_optional_email_registration (acct_mgr.tests.register.RegistrationModuleTestCase) ... ok test_check (acct_mgr.tests.register.EmailVerificationModuleTestCase) ... ok test_check_email_used (acct_mgr.tests.register.EmailVerificationModuleTestCase) ... ok test_check_no_email (acct_mgr.tests.register.EmailVerificationModuleTestCase) ... ok ====================================================================== ERROR: test_check (acct_mgr.tests.register.BasicCheckTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/TracAccountManager-0.4.4/acct_mgr/tests/register.py", line 131, in test_check self.assertRaises(RegistrationError, check.validate_registration, req) File "/usr/lib64/python2.7/unittest/case.py", line 511, in assertRaises callableObj(*args, **kwargs) File "/builddir/build/BUILD/TracAccountManager-0.4.4/acct_mgr/register.py", line 136, in validate_registration for store_user in acctmgr.get_users(): File "/builddir/build/BUILD/TracAccountManager-0.4.4/acct_mgr/api.py", line 220, in get_users for store in self._password_store: File "/usr/lib/python2.7/site-packages/trac/config.py", line 779, in __get__ option=tag.tt("[%s] %s" % (self.section, self.name)))) ConfigurationError: Cannot find implementation(s) of the <tt>IPasswordStore</tt> interface named <tt>SessionStore</tt>. Please check that the Component is enabled or update the option <tt>[account-manager] password_store</tt> in trac.ini. ====================================================================== ERROR: test_verify_conf_changes (acct_mgr.tests.register.EmailCheckTestCase) Registration challenges with EmailVerificationModule enabled. ---------------------------------------------------------------------- Traceback (most recent call last): File "/builddir/build/BUILD/TracAccountManager-0.4.4/acct_mgr/tests/register.py", line 214, in test_verify_conf_changes field_res = check.render_registration_fields(req, acct) File "/builddir/build/BUILD/TracAccountManager-0.4.4/acct_mgr/register.py", line 233, in render_registration_fields reset_password = AccountModule(self.env).reset_password_enabled File "/builddir/build/BUILD/TracAccountManager-0.4.4/acct_mgr/web_ui.py", line 144, in _reset_password_enabled self.store.hash_method File "/usr/lib/python2.7/site-packages/trac/config.py", line 741, in __get__ option=tag.tt("[%s] %s" % (self.section, self.name)))) ConfigurationError: Cannot find an implementation of the <tt>IPasswordHashMethod</tt> interface named <tt>HtDigestHashMethod</tt>. Please check that the Component is enabled or update the option <tt>[account-manager] hash_method</tt> in trac.ini. ---------------------------------------------------------------------- Ran 48 tests in 0.717s FAILED (errors=2)
I'll attach a patch I've used that resolves this problem for me.
Attachments (1)
Change History (10)
Changed 10 years ago by
Attachment: | TracAccountManager-0.4.4-tests.patch added |
---|
comment:1 Changed 10 years ago by
Replying to paul@…:
Didn't see this with older
trac
versions:
The failures likely started with trac:milestone:1.0.2, due to implementation of trac:#10285.
Thanks for the patch.
comment:3 Changed 9 years ago by
I still see a few test failures on OSX:
test_obfuscate_shared_secret (acct_mgr.opt.tests.radius.RadiusAuthTestCase) ... ok test_update_password (acct_mgr.opt.tests.radius.RadiusAuthTestCase) ... ok ====================================================================== ERROR: test_create_hash (acct_mgr.tests.htfile.HtPasswdTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/tests/htfile.py", line 184, in test_create_hash self.assertTrue(self.store.userline('user', 'password' File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/htfile.py", line 211, in userline return self.prefix(user) + mkhtpasswd(password, self.hash_type) File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/pwhash.py", line 141, in mkhtpasswd return htpasswd(password, salt_) File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/pwhash.py", line 126, in htpasswd available.""")) NotImplementedError: Neither are "sha2" hash algorithms supported by the "crypt" module on this platform nor is "passlib" available. ====================================================================== FAIL: test_sha256 (acct_mgr.tests.htfile.HtPasswdTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/tests/htfile.py", line 130, in test_sha256 'user:$5$saltsaltsaltsalt$' File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/tests/htfile.py", line 52, in _do_password_test self.assertTrue(self.store.check_password('user', 'password')) AssertionError: None is not true ====================================================================== FAIL: test_sha512 (acct_mgr.tests.htfile.HtPasswdTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/tests/htfile.py", line 135, in test_sha512 'user:$6$saltsaltsaltsalt$' File "/Users/rjollos/acct-mgr-eval/accountmanagerplugin-trunk2/acct_mgr/tests/htfile.py", line 52, in _do_password_test self.assertTrue(self.store.check_password('user', 'password')) AssertionError: None is not true ---------------------------------------------------------------------- Ran 78 tests in 2.437s FAILED (failures=2, errors=1)
comment:4 Changed 9 years ago by
After installing passlib
the following errors are seen:
test_update_password (acct_mgr.opt.tests.radius.RadiusAuthTestCase) ... ok ====================================================================== ERROR: test_create_hash (acct_mgr.tests.htfile.HtPasswdTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rjollos/temp/trunk2/acct_mgr/tests/htfile.py", line 184, in test_create_hash self.assertTrue(self.store.userline('user', 'password' File "/Users/rjollos/temp/trunk2/acct_mgr/htfile.py", line 211, in userline return self.prefix(user) + mkhtpasswd(password, self.hash_type) File "/Users/rjollos/temp/trunk2/acct_mgr/pwhash.py", line 146, in mkhtpasswd return htpasswd(password, salt_) File "/Users/rjollos/temp/trunk2/acct_mgr/pwhash.py", line 130, in htpasswd available.""")) NotImplementedError: Neither are "sha2" hash algorithms supported by the "crypt" module on this platform nor is "passlib" available. ====================================================================== FAIL: test_sha256 (acct_mgr.tests.htfile.HtPasswdTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rjollos/temp/trunk2/acct_mgr/tests/htfile.py", line 130, in test_sha256 'user:$5$saltsaltsaltsalt$' File "/Users/rjollos/temp/trunk2/acct_mgr/tests/htfile.py", line 52, in _do_password_test self.assertTrue(self.store.check_password('user', 'password')) AssertionError: None is not true ====================================================================== FAIL: test_sha512 (acct_mgr.tests.htfile.HtPasswdTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/rjollos/temp/trunk2/acct_mgr/tests/htfile.py", line 135, in test_sha512 'user:$6$saltsaltsaltsalt$' File "/Users/rjollos/temp/trunk2/acct_mgr/tests/htfile.py", line 52, in _do_password_test self.assertTrue(self.store.check_password('user', 'password')) AssertionError: None is not true ---------------------------------------------------------------------- Ran 78 tests in 2.513s FAILED (failures=2, errors=1)
comment:5 Changed 9 years ago by
For the case that passlib
is installed, I think the following patch would be backwards-compatible, but I need to do more testing before committing.
-
acct_mgr/pwhash.py
9 9 # 10 10 # Author: Matthew Good <trac@matt-good.net> 11 11 12 import re 13 12 14 from binascii import hexlify 13 15 from os import urandom 14 16 … … 103 105 104 106 105 107 def htpasswd(password, hash): 108 def from_hash(hash): 109 match = re.match(r'\$[5,6]\$(?:rounds=(\d+)\$)?(\w+)', hash) 110 groups = match.groups() 111 rounds = int(groups[0]) if groups[0] is not None else 5000 112 salt = groups[1] 113 return rounds, salt 106 114 if hash.startswith('$apr1$'): 107 115 return md5crypt(password, hash[6:].split('$')[0], '$apr1$') 108 116 elif hash.startswith('{SHA}'): 109 117 return '{SHA}' + sha1(password).digest().encode('base64')[:-1] 110 118 elif passlib_ctxt is not None and hash.startswith('$5$') and \ 111 119 'sha256_crypt' in passlib_ctxt.policy.schemes(): 112 return passlib_ctxt.encrypt(password, scheme="sha256_crypt", 113 rounds=5000, salt=hash[3:].split('$')[0]) 120 rounds, salt = from_hash(hash) 121 return passlib_ctxt.encrypt(password, scheme='sha256_crypt', 122 rounds=rounds, salt=salt) 114 123 elif passlib_ctxt is not None and hash.startswith('$6$') and \ 115 124 'sha512_crypt' in passlib_ctxt.policy.schemes(): 116 return passlib_ctxt.encrypt(password, scheme="sha512_crypt", 117 rounds=5000, salt=hash[3:].split('$')[0]) 125 rounds, salt = from_hash(hash) 126 return passlib_ctxt.encrypt(password, scheme='sha512_crypt', 127 rounds=rounds, salt=salt) 118 128 elif crypt is None: 119 129 # crypt passwords are only supported on Unix-like systems 120 130 raise NotImplementedError(_("The \"crypt\" module is unavailable " -
acct_mgr/tests/htfile.py
127 127 128 128 def test_sha256(self): 129 129 self._do_password_test(self.flavor, 'test_sha256', 130 'user:$5$ saltsaltsaltsalt$'131 ' WsFBeg1qQ90JL3VkUTuM7xVV/5njhLngIVm6ftSnBR2\n')130 'user:$5$rounds=535000$saltsaltsaltsalt$wfx' 131 '3LZ09XA7qrZB.ttuCbBidMXt51Kgu5YQ.YFqzxA7\n') 132 132 133 133 def test_sha512(self): 134 134 self._do_password_test(self.flavor, 'test_sha512', 135 'user:$6$ saltsaltsaltsalt$'136 ' bcXJ8qxwY5sQ4v8MTl.0B1jeZ0z0JlA9jjmbUoCJZ.1'137 ' wYXiLTU.q2ILyrDJLm890lyfuF7sWAeli0yjOyFPkf0\n')135 'user:$6$rounds=535000$saltsaltsaltsalt$' 136 '9ExQK2S3YXW7/FlfUcw2vy7WF.NH5ZF6SIT14DjngOGkc' 137 'x.5mINko67cLRrqFFh1AltOT4uPnET7BsJXuI56H/\n') 138 138 139 139 def test_no_trailing_newline(self): 140 140 self._do_password_test(self.flavor, 'test_no_trailing_newline',
comment:7 Changed 9 years ago by
Owner: | changed from Steffen Hoffmann to Ryan J Ollos |
---|---|
Status: | new → accepted |
comment:9 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
All unit tests are passing for me on OSX. Please reply or open a new ticket if test failures are seen on other platforms.
Patch that fixes test failures