summaryrefslogtreecommitdiff
path: root/passlib/tests/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* bugfix: passlib.tests.utils: backend inspection code was mistakenly reading ↵Eli Collins2016-06-101-1/+2
| | | | .set_backend() return value.
* passlib.utils.handlers / HasRounds: the 'rounds' keyword is now treatedEli Collins2016-06-101-4/+21
| | | | | | | | | | | as a fallback for 'default_rounds', 'min_rounds', and 'max_rounds'. this makes it easier to specify a django-style policy of "deprecate all hashes which have a differing rounds value". * removed special handling from 'rounds' from CryptContext parser * tweaked affected CryptContext serialization tests * added test for new behavior
* bugfix: plaintext, htdigest, unix_disabled hashes: added missing .using() ↵Eli Collins2016-06-101-0/+9
| | | | | | | | | | | implementation these all derived directly from PasswordHash, and lacked a working .using(). * added UT to check for a working .using() method * factored out GenericHandler's .using() into another base class which these three hashes could inherit from.
* deprecating the 'vary_rounds' option -- *very* little security benefit,Eli Collins2016-06-101-0/+1
| | | | | | | and not worth the amount of code it requires to support it. * stripped out vary_rounds from all internal presets * added deprecation warning if it's ever used
* passlib.utils.handlers: HasSalt.using() implemented to support customizingEli Collins2016-06-101-0/+45
| | | | default salt size, added UTs.
* passlib.tests.test_totp: use proper timing tool for runtime measurement,Eli Collins2016-06-101-0/+18
| | | | prevents some spurious test failures when under erratic system load
* passlib.utils.handlers: some fixes to HasManyIdent.using(), added more UTsEli Collins2016-06-101-2/+5
|
* passlib.utils.handlers: some fixes to HasRounds.using(), added more UTsEli Collins2016-06-101-42/+190
| | | | | | | | | * HasRounds: now parses vary_rounds="0.x" format correctly * PrefixWrapper: now exposes "vary_rounds" attr * handler tests: split HasRounds.using() into multiple tests, one for each property (max_rounds, min_rounds, etc) * context tests: added checks that custom handler is being configured correctly, since actual behavior is now being checked by handler tests.
* .encrypt() method renamed to .hash(), other api cleanupsEli Collins2016-06-101-64/+104
| | | | | | | | | | | | | | | | .encrypt() ---------- hash.encrypt() & context.encrypt() have been renamed to .hash(). this should take care of the long-standing issue 21 (the poor naming of .encrypt). per docs, legacy aliases will remain in place until passlib 2.0. .genhash() / .genconfig() ------------------------- taking advantage of this reorganization to also deprecate .genconfig() and .genhash() -- they're not really useful in a modern system, nor as needed for historical support as initially thought: .genconfig() will be retired completely in passlib 2.0; .genhash() is rolled into the new .hash() method along with .encrypt().
* passlib.tests / HandlerTest: when generating random rounds,Eli Collins2016-02-101-4/+4
| | | | don't use 0, even if "allowed" by hash, causes spurious failures.
* Merge with stableEli Collins2016-02-091-0/+50
|\
| * fix: handler test suite: avoid even rounds for bsdi_cryptEli Collins2016-02-081-1/+4
| |
| * PasswordHash ifc: added temporarily helper .parse_rounds(),Eli Collins2016-02-081-0/+47
| | | | | | | | which abstracts out job of parsing rounds value from hash.
| * bugfix: tests.utils: added list wrapper, since tuple().index doesn't exist ↵Eli Collins2015-07-281-1/+3
| | | | | | | | | | | | under py25 (fixes issue 58)
* | updated fuzzy test timeout factor greatlyEli Collins2015-07-261-1/+1
| |
* | tweaked threaded fuzz test logging & timeoutEli Collins2015-07-261-9/+16
| |
* | misc test bugfixesEli Collins2015-07-261-39/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test_handlers: fix py3 u() compat issue * test_totp: clean norm_hash_name() caches so warnings repeat per-test, added/fixed some warnings checks. * HandlerCase: HasRounds.using() test: hack so bsdi_crypt can pass (the 'odd rounds only' was playing havoc w/ the test's expectations) * HandlerCase: effective_rounds() / effective_ident() helpers now unwrap PrefixWrappers first; wrappers aren't callable like classes. * HandlerCase: HasRounds.using() test: don't check min_rounds-1 if min_rounds is 0. * HandlerCase: multithreaded fuzz test -- detect & log errors if stalled thread, rather than main thread stalling forever. reduced thread count down to 10. * reset_warning_filter() context manager -- simplified __exit__() cleanup code
* | minor bugfixesEli Collins2015-07-251-5/+8
| | | | | | | | | | | | | | | | | | | | * tests: assertWarningList() wasn't running under some python versions * tests: create_backend_case() had typo from recent refactor * tests: multi-threading fuzz testing now TEST_MODE=full only * tests: fixed effective_ident() helper
* | HasRounds.using() improved, added UTs.Eli Collins2015-07-251-0/+163
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * added UTs for basic min/max/default options. still needs vary_rounds & alias tests * clarified error/warning condtions for some cases, handled implicit min/max policy settings. * All HasRounds.using() options now accept values as strings, to help CryptContext. * Replaced some dup code in _norm_rounds w/ a call to _clip_to_valid_rounds * departing from previous CryptContext behavior, passing an explicit rounds value to encrypt() will now override the policy limits (w/ a warning)
* | HasManyIdents.using() -- fleshed out, added UTsEli Collins2015-07-251-3/+51
| |
* | passlib.tests -- clean ups of os_crypt & general backend handlingEli Collins2015-07-231-189/+209
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * moved utils.patchAttr() function to TestCase.patchAttr(), redid a bunch of manual monkeypatches to use .patchAttr() method. * temporary_backend() hack replaced by subcls.using(), so temporary backend use will be threadsafe (needed for concurrent tests). * HandlerCase.create_backend_cases() replaced with HandlerCase.create_backend_case(), all calls split out to make individual calls for each backend. Easier to read in diffs going forward when backends added/removed. * moved os_crypt specific code w/in create_backend_case() to OsCryptMixin, which just subclasses the method it needs to modify. allowed removing find_crypt_replacement() method entirely; decision to skip backend now directly uses OsCryptMixin's own logic. * fuzz_verifier_crypt() cleanups - moved to OsCryptMixin; removing .using_patched_crypt ref from HandlerCase - has_crypt_support() helper rolled into method, was only caller. - os_supports_ident() refactored into crypt_supports_variant(). fuzz_verified_crypt() is (now) the only caller. * bcrypt's crypt_supports_variant() now uses actual test of crypt() rather than hardcoded list of supported values. * fuzz verifier now handlers hashes throwing SkipTest. * utils.has_crypt_support() rolled into
* | Merge from stableEli Collins2015-07-221-16/+57
|\ \ | |/
| * testing fix: test_70_known() now deals w/ os_crypt backend not beingEli Collins2015-07-211-10/+30
| | | | | | | | | | able to handle non-utf8 passwords. only coming up now because bcrypt's os_crypt fallback can now fail for such inputs.
| * bunch of bcrypt updates, centered around the bsd wraparound bug.Eli Collins2015-07-211-6/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bcrypt ------ * added support & UT for $2b$ hash format. not making it the default yet, for backward compat. * large refactor of how bcrypt backends are loaded: instead of per-backend workarounds within each _calc_checksum_<backend>() function: now using runtime detection of specific capabilities & workarounds, that runs whenever set_backend() is called, combined with consolidated workaround code within _calc_checksum(), controlled by the flags set by set_backend(). this detection now looks for: - the 8bit bug: throws a PasslibSecurityError - the wraparound bug: issues warning, sets flag enabling a workaround. - support for 2/2y/2b: if backend lacks support for particular variants, sets flag enabling workaround to add support. * os_crypt backend now just issues error if it can't handle a password encoding; rather than trying fallbacks first -- edge case anyways, and likely to not have any fallbacks when it does happen. simplifies backend code. * added UTs to make sure wraparound-vulnerable passwords are hashed correctly (as a 72char string, not a 1-3 char string that's repeated). * internal blowfish code's ident parsing clarified. other ----- * added exc.PasslibSecurityError for fatal runtime errors. * test framework: os_crypt backends no longer expected to use *any* backend as fallback, just ones with lower priority than os_crypt. * test framework: crypt_stub() wrapper now subclasses the handler, so it can use an independant backend, instead of changing global backend for duration of call (made parallel testing hard) docs ---- * added entry to bcrypt page, writing down wraparound bug details, and how passlib is handling it. * all versions of pybcrypt & bcryptor seem to be vulnerable to wraparound bug. starting process of deprecating these backends: marked bcrypt backend as 'preferred' throughout the documentation.
| * style cleanups (transplant of rc94c6072a652 in default)Eli Collins2013-12-271-76/+74
| |
* | renamed compat helper 'base_string_types' -> 'unicode_or_bytes_types' for ↵Eli Collins2015-01-231-2/+1
| | | | | | | | clarity.
* | more post-py25/31 cleanupsEli Collins2015-01-231-1/+1
| | | | | | | | | | | | | | | | * removed exc_err() compat helper, can now use "Exception as err" * next_method_attr replaced by nextgetter(), which seems a little cleaner * removed py30/31 alias for SafeConfigParser * put some PY26 features behind PY26 compat flag * removed PY25 from setup classifiers
* | fix in test harness: _use_mock_crypt() reworked so it doesn't disable ↵Eli Collins2015-01-101-5/+18
| | | | | | | | | | | | _load_backend() entirely, was causing problems with new _load_backend() framework.
* | removed a LOT of compatibility shims -- dropped python 2.5, 3.0, and 3.1 ↵Eli Collins2015-01-101-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | support; as well as PyPy 1.x and Jython 2.5. shims removed ------------- * b() shim replaced with b'' (py25) * 'bytes' alias no longer needed (py25) * callable() shim no longer needed (py30,31) * PY_MIN_32 flag replaced with PY3 flag (py30,31) * removed 'abc' module stub used by passlib.ifc (py25) * removed chain_from_iterable() backport (py25) * tests: removed catch_warnings() backport, replaced refs with real warnings.catch_warnings() (py25) * tests: removed unittest2 backports (py25, py30, py31) -- now throw hard error if unittest2 not present under py26 (the only release remaining which lacks the unittest2 features) * removed SUPPORTS_DIR_METHOD conditional (py25, pypy 1.x) * some other minor workarounds other ----- * added check in passlib.compat which now throws error telling user version isn't supported (to prevent spurious errors later)
* | comment & doc updates, removed some extraneous try/except clauses from ↵Eli Collins2013-12-281-1/+1
| | | | | | | | des_crypt code
* | UT fixes:Eli Collins2013-12-281-1/+1
| | | | | | | | | | | | | | * simplified get_handler_case() a little * has_active_backend() now returns a less confusing default string ("builtin" was ambiguous since it's a common backend name) * probabilistic getrandstr() test fails 1/600 times, upped to 1/430,000 :)
* | Merge from stableEli Collins2013-12-271-2/+25
|\ \ | |/
| * added passlib.hash.bcrypt_sha256Eli Collins2013-12-261-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * not too much trouble, and definitely needed. after considering options, decided to use sha256 + base64. * added note re: bcrypt password truncation * HasBackend mixin -- changed to use _calc_checksum_backend() as the attribute it patches, instead of _calc_checksum(). makes it easier to consolidate code common to all backends (e.g. bcrypt) * test_60_secret_size: changed hardcoded exception list to a class flag * added registry test to make sure all hashes are being tested (with a few known exceptions) * clarified names inside builtin bcrypt backend * updated changelog
| * django compatibility part 2Eli Collins2013-12-221-1/+2
| | | | | | | | | | | | | | | | * added implementation of django 1.6's bcrypt_sha256 hasher, and UTs * added django16 premade context to passlib.apps, made it default django_context * test_ext_django now makes use of django16_context * passlib.ext.django.utils.get_preset_config() now uses django16_context * tox 'django' and 'django-py3' now test bcrypt integration
| * django compatibility updates (should fix issue 50)Eli Collins2013-12-201-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | passlib.ext.django & it's tests have gotten out of sync with django, leading to a number of UT failures, as reported in issue 50. tests now pass on django 1.2 through 1.6 passlib.ext.django ------------------ mimic changes in django's hasher logic: * handle unsalted_sha1 hasher (django 1.4.6+) * check_password(): empty hashes return False, rather throw error (django 1.5+ * allow empty passwords (django 1.6+) * generate unusuable password suffixes (django 1.6+) passlib.hash ------------ * django_des_crypt: added "use_duplicate_salt" class attr, allowing tests to enable django 1.4+ style hashes which omit 1st salt. * django_disabled: added support for django 1.6+ random suffixes passlib.tests ------------- * test_ext_django: lots of changes to verify django 1.5/1.6 behavior * test_handlers_django: split django tests out of test_handlers to make it easiers to run django-related tests. * added workaround for encoding glitch in salted_md5 / salted_sha1 hashers (django 1.5+)
* | concurrency testingEli Collins2013-04-101-0/+59
| | | | | | | | | | | | | | * added multi-thread fuzz testing to shared PasswordHash test suite * added code to detect pybcrypt <0.3, issue warning, and implement thread-lock to workaround it's fatal concurrency issue. * TODO: audit rest of passlib for threading issues (shouldn't be any major ones)
* | minor fixes to some test codeEli Collins2013-04-091-9/+8
| |
* | style cleanupsEli Collins2013-04-091-76/+74
| |
* | fix two minor bugs in unittests (closes issue 46)Eli Collins2013-04-061-3/+0
|/
* rearranged/refactored HandlerCase fuzz testing functions somewhatEli Collins2012-08-021-78/+91
|
* project-wide whitespace & comment cleanup (it's been a couple of years)Eli Collins2012-08-011-126/+126
|
* replaced HAS_INTEGER_MTIME flag with more reliable workaroundEli Collins2012-06-271-1/+9
|
* reworked platform_crypt_support test to be more granular, updated to account ↵Eli Collins2012-06-271-14/+21
| | | | for FreeBSD 8.3+ supporting SHA512-Crypt
* misc testing fixesEli Collins2012-05-011-18/+30
| | | | | | | | | | | * bcrypt fuzz fix: detect $2$ hashes w/ passwords like 'abc' 'abcabc' and regenerate, since $2$ would hash them the same. one in a million chance, but I hit it. * django_bcrypt: skip multi-ident testing entirely, only one prefix is used. * get_fuzz_settings() now handles passwords too, so handlers can alter them * get_fuzz_ident() now checks os_supports_ident() directly, so bcrypt test doesn't have to * test_14_salt_chars now cleans up salt, so bcrypt test doesn't have to * glitch in fuzz skip code * add tox.ini to sdist
* bunch bugfixes to the unittestsEli Collins2012-05-011-14/+27
| | | | | | | | | * timer issues under windows * id() issues under jython * mtime issues under jython & darwin * corrected expectations of test_ext_django's patch checker * added darwin flags to platform_os_crypt info * fixed regression in os_crypt backend test mocking
* unittest cleanups, better coverage, etcEli Collins2012-04-301-563/+394
| | | | | | | | | | | | | | | * split ut2 backports into separate module to keep them distinct from customizations * added backport of skip() / skipIf(), simplified a bunch of code * "PASSLIB_TESTS" env var renamed to "PASSLIB_TEST_MODE", has one of three values (quick,default,full) * assertWarningList() can now be used as context manager * added TestCase.mktemp(), and some capability tests via TestCase.require_xxx() * HandlerCase - subclasses can now modify do_xxx() settings and context using unified interface. - defaults to lower number of rounds for all hashes, to speed up UTs - create_backend_case() is now classmethod that yields multiple backends - added test to ensure os_crypt hashes forbid NULL chars - EncodingHandlerMixin for common tests of 'encoding' keyword
* added some missing tests; fixed a bunch of bugsEli Collins2012-04-281-2/+7
|
* added support for the new Django 1.4 hash formatsEli Collins2012-04-271-7/+26
| | | | | | - updated salt handling of the existing django hashes, in a way which should be backwards compatible w/ django 1.0 - UTs now test Django hasher output against passlib handlers (reverse was already being done) - refactor of fuzz testing to reuse some of the methods.
* setup warning filters early in TestCase to work around HandlerCase warning ↵Eli Collins2012-04-171-0/+3
| | | | issue w/ os_crypt proxying builtin bcrypt
* changed bcrypt's os_crypt backend to try alternatives before bailing.Eli Collins2012-04-171-4/+1
|