summaryrefslogtreecommitdiff
path: root/passlib/tests/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* changed bcrypt's os_crypt backend to try alternatives before bailing.Eli Collins2012-04-171-4/+1
|
* reworked fuzz verifier system, so that we can skip $2x$ hashes during bcrypt ↵Eli Collins2012-04-171-19/+43
| | | | crypt() testing
* disabling saslprep() support under Jython - it lacks the stringprep moduleEli Collins2012-04-171-0/+7
|
* a bunch of bugfixes found during unittestingEli Collins2012-04-171-4/+4
| | | | | | | | | | * bsdi_crypt apparently available on openbsd 4.9 * typo fixes * ConfigParser apparently only uses OrderedDict for >= PY27, adjusted CryptContext test accordingly * fixed test that depended on sha256_crypt.default_rounds * handle os_crypt backend w/ no fallback (bcrypt) * let _norm_rounds accept longs
* assorted bugfixes, tweaks, and tests added; based on coverage examinationEli Collins2012-04-121-16/+107
| | | | | | | * test os_crypt backend has functional fallback * test handler methods accept all unicode/bytes combinations for secret & hash * fixed some incorrect error messages & types being caught & raised * other minor cleanups
* ran full UTs, found and fixed a few bugs introduced in last few commits.Eli Collins2012-04-111-3/+3
|
* rearranged some test casesEli Collins2012-04-111-42/+91
|
* clarify behavior for secret=None and hash=NoneEli Collins2012-04-111-24/+41
| | | | | | | | | | | | | | | | | | | | | | | * passing a non-string secret or non-string hash to any CryptContext or handler method will now reliably result in a TypeError. previously, passing hash=None to many handler identify() and verify() methods would return False, while others would raise a TypeError. other handler methods would alternately throw ValueError or TypeError when passed a value that wasn't unicode or bytes. the various CryptContext methods also behaved inconsistently, depending on the behavior of the underlying handler. all of these behaviors are gone, they should all raise the same TypeError. * redid many of the from_string() methods to verify the hash type. * moved secret type & size validation to GenericHandler's encrypt/genhash/verify methods. this cheaply made the secret validation global to all hashes, and lets _calc_digest() implementations trust that the secret is valid. * updated the CryptContext and handler unittests to verify the above behavior is adhered to.
* replaced some common string ops with util funcs (repeat_string, ↵Eli Collins2012-04-101-3/+3
| | | | right_pad_string)
* tightened OS crypt backend testsEli Collins2012-04-101-25/+140
| | | | | | | | | * split os_crypt tests into separate mixin * tests now require os_crypt backends to detect some simple incorrect returns from crypt() - e.g. returning wrong ident prefix, wrong size, etc - added relevant asserts to all os_crypt backends * tests now check if platform crypt detection is functioning correctly via platform_crypt_support dict in tests.
* *all* hashes now throw PasswordSizeError if password is larger than 4096 ↵Eli Collins2012-04-091-0/+13
| | | | chars; to prevent DOS issues.
* misc bugfixesEli Collins2012-03-121-7/+16
| | | | | | | | | | | * removed cisco_type7 config string, conflicted w/ empty password * fixed unicode type issue in cisco_type7, win32.nthash * bsdi_crypt.min_rounds now 1 (0 results in identical hashes) * fixed unicode type issue in UPASS_TABLE tests for plaintext, ldap_plaintext * relocated test vectors from test_win32 to lmhash/nthash * 8bit test for UnsaltedHash * fuzz testing expanded to use 5-99 char passwords, and 1/10000 are empty *
* updated test support & py3 compat code from an external libraryEli Collins2012-03-121-180/+251
| | | | | | | | | | | | | | | | passlib.tests ------------- * deprecated support for unittest 1... accumulated too many backports, planning to require unittest2 in next release. * case_prefix renamed to shortDescription * test case now archives & clears warning registry state in addition to warning filter state passlib.utils.compat -------------------- * a bunch of the bytes-related functions were renamed for clarity * NativeStringIO alias added * trange alias merged into irange
* misc bugfixes dealing with changes from last 8 or so commitsEli Collins2012-03-111-9/+10
|
* added hack to clear warnings registry so assertWarningList() tests will pass ↵Eli Collins2012-03-111-3/+28
| | | | reliably
* added support for Cisco PIX & Type 7 hashesEli Collins2012-03-101-14/+54
| | | | | | | | * Cisco Type 5 appears to be same as md5_crypt * added requires_user=False support to HandlerCase * added more through salt-generation test (since cisco_pix has only 4 bits of salt) * added HandlerCase test to ensure user is used as salt
* added mssql 2000/2005 hashes; enhanced HandlerCase's password case sensitive ↵Eli Collins2012-03-101-3/+17
| | | | test
* renamed test_handlers classes to match alg name + "_test" (tired of having ↵Eli Collins2012-03-091-16/+12
| | | | to guess capitalization)
* base HandlerCase class reworkedEli Collins2012-03-091-517/+977
| | | | | | | | | | | | * reworked warning-matching code into assertWarningList() method * reorganized HandlerCase hash tests based on cross-cutting topic, not per-function; this combined many tests together to eliminate redundant setup * added test of reported rounds limits * added better fuzz testing - tests random passwords & options using encrypt(), and verifies against any all available backends * added flags to properly support 'disabled' handlers, and other border cases. * added tests for password & user case-sensitivity * restores warning filters after every test
* consolidated some unit testsEli Collins2012-02-091-8/+107
|
* renamed passlib.exc warning classesEli Collins2012-02-081-2/+2
|
* documentation updates for last two commitsEli Collins2012-02-081-2/+3
|
* minor tweaks & fixesEli Collins2012-02-081-3/+5
|
* large refactor of GenericHandler internalsEli Collins2012-02-081-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strict keyword -------------- * GenericHandler's "strict" keyword had poorly defined semantics; replaced this with "use_defaults" and "relaxed" keywords. Most handlers' from_string() method specified strict=True. This is now the default behavior, use_defaults=True is enabled only for encrypt() and genconfig(). relaxed=True is enabled only for specific handlers (and unittests) whose code requires it. This *does* break backward compat with passlib 1.5 handlers, but this is mostly and internal class. * missing required settings now throws a TypeError instead of a ValueError, to be more in line with std python behavior. * The norm_xxx functions provided by the GenericHandler mixins (e.g. norm_salt) have been renamed to _norm_xxx() to reflect their private nature; and converted from class methods to instance methods, to simplify their call signature for subclassing. misc ---- * rewrote GenericHandler unittests to use constructor only, instead of poking into norm_salt/norm_rounds internals. * checksum/salt charset checks speed up using set comparison * some small cleanups to FHSP implementation
* simplified crypt.crypt() wrappersEli Collins2012-01-191-26/+26
| | | | | | | * safe_crypt() improved - accepts unicode/bytes for salt, checks for NULL, returns None on failure * added test_crypt() wrapper to simplify backend checks. * removed native=True from most to_string() implementations, unused now. * updated UTs
* split exceptions/warnings to separate module; added some additional warning ↵Eli Collins2012-01-181-3/+5
| | | | classes to make filtering easier
* import cleanupsEli Collins2012-01-181-12/+16
| | | | | | | | | | | | | | | * moved bytes compat functions from utils to utils.compat (bord, bjoin, bjoin_ints, bjoin_elems, ujoin) * renamed bord -> belem_ord for clarify * a bunch of to_native_str() always use ascii, and have fixed input types (always bytes or always unicode). these don't need overhead of to_native_str(), so replaced those calls with two new funcs: compat.bascii_to_str() / compat.uascii_to_str() * cleaned up a lot of imports from utils/utils.compat to pull from correct module * simplified the to_string() logic of a bunch of handlers to reduce unicode<->byte transitions
* renamed the utils.handlers.XX_CHARS constants to match utils.XX_CHARS (old ↵Eli Collins2012-01-181-2/+2
| | | | aliases kept for now)
* clarified border case where verify() accepted configuration strings instead ↵Eli Collins2012-01-091-7/+29
| | | | of throwing ValueError for some handlers
* tests use assertRegex instead of assertRegexpMatchesEli Collins2012-01-021-13/+18
|
* renamed test_drivers.py -> test_handlers.py to match name of module its testingEli Collins2011-12-281-1/+1
|
* deprecated to_hash_str, replaced all instances with to_native_strEli Collins2011-12-281-6/+6
| | | | | | decided that to_hash_str will always return native string, feature of hashes being returned as unicode under python 2 is better done through a CryptContext option.
* Merge from defaultEli Collins2011-12-281-0/+13
|\
| * CryptPolicy rewrite part 2Eli Collins2011-12-271-0/+13
| | | | | | | | | | | | | | | | | | | | * refactoring policy kwd parsing & separation with crypt context * internal record objects now part of context instead of policy. * min_verify_time now handled by record objects, now optimized away entirely if not used. * new interface to policy is currently private, will probably delay deprecated / revising public interface until next release. * creating policy & context objects is now 30% faster. * shortened code path when calling context objects now 14% faster.
* | replaced all #Py3k# conditional includesEli Collins2011-12-061-11/+5
| |
* | ran a custom 2to3 fixer to replace all u"" with u() and add an import from ↵Eli Collins2011-12-061-6/+7
| | | | | | | | compat.u
* | added compat.unicode imports in a number of placesEli Collins2011-12-061-1/+2
| | | | | | | | | | | | | | | | this distinguishes the types, so that for isinstance() tests... * 'unicode' always means the unicode type * 'bytes' always means the bytes type * 'str' always means the native string type
* | moved sys_bits to compat, added exc_err, removed utils.py32_langEli Collins2011-12-061-2/+3
| |
* | added compat.sb_types for testing isinstance(obj,(bytes,unicode))Eli Collins2011-12-061-2/+2
| |
* | added callable shim for 3.0-3.1Eli Collins2011-12-061-1/+1
| |
* | replaced xrange() instances with compat.irange() aliasEli Collins2011-12-061-2/+2
| |
* | added compatibility module (passlib.utils.compat)Eli Collins2011-12-061-1/+2
|/ | | | | | | | | exports specialized range & map aliases, and some dict helpers * all dict.iteritems() calls replaced with compat.iteritems(dict) * all xrange() calls replaced with compat.irange() * all range() calls replaced with compat.trange() and compat.lrange() as appropriate * all map() calls replaced with compat.lmap()
* bugfix (issue 25):Eli Collins2011-10-051-0/+39
| | | | | | | | | * bcrypt salts are now generated with padding bits set to 0 * bcrypt hashes with padding bits not set to 0 still same as before, but warning is issued * bcrypt.normhash() can be used to correct existing bcrypt hashes. TODO: documentation, verify against issue, look into verify_and_update() being able to take care of this.
* improvements to passlib.ext.djangoEli Collins2011-09-141-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | even though it hasn't been officially documented, some people are using it, so... major ----- * DEFAULT_CTX now uses SHA512-Crypt instead of PBKDF2-HMAC-SHA256, this should be natively supported on a larger number of platforms. * added full unittest suite for passlib.ext.django: - checks monkeypatch implementation - checks full plugin behavior - STOCK_CTX is compared against official Django behavior minor ----- * ``set_django_password_context()`` now patches ``django.contrib.auth.models.check_password()`` as well as User methods. * now exposes active context as ``User.password_context`` when patch is enabled. * replacement ``User.check_password`` now handles None and unusable passwords explicitly, even if context doesn't include support for django_disabled.
* test.utils: added backport of assertRegexpMatches for py26/25Eli Collins2011-08-131-0/+12
|
* fix class.__module__ for gaeunit class discoveryEli Collins2011-08-121-1/+2
|
* unittest fixesEli Collins2011-08-121-2/+53
| | | | | * backport of ut2's assertAlmostEquals delta kwd * test_context uses set_file so we can always write bytes
* added gae_env flag to disable some CryptPolicy.from_path() unittests under ↵Eli Collins2011-08-121-0/+14
| | | | Google App Engine.
* tidy up backend test case namesEli Collins2011-08-121-22/+25
|
* added backport of catch_warnings for py25; added testcase method ↵Eli Collins2011-08-101-11/+134
| | | | assertWarningMatches