Submit
Path:
~
/
/
usr
/
lib
/
python2.7
/
site-packages
/
passlib
/
tests
/
File Content:
test_apps.py
"""test passlib.apps""" #============================================================================= # imports #============================================================================= from __future__ import with_statement # core import logging; log = logging.getLogger(__name__) # site # pkg from passlib import apps, hash as hashmod from passlib.tests.utils import TestCase # module #============================================================================= # test predefined app contexts #============================================================================= class AppsTest(TestCase): """perform general tests to make sure contexts work""" # NOTE: these tests are not really comprehensive, # since they would do little but duplicate # the presets in apps.py # # they mainly try to ensure no typos # or dynamic behavior foul-ups. def test_master_context(self): ctx = apps.master_context self.assertGreater(len(ctx.schemes()), 50) def test_custom_app_context(self): ctx = apps.custom_app_context self.assertEqual(ctx.schemes(), ("sha512_crypt", "sha256_crypt")) for hash in [ ('$6$rounds=41128$VoQLvDjkaZ6L6BIE$4pt.1Ll1XdDYduEwEYPCMOBiR6W6' 'znsyUEoNlcVXpv2gKKIbQolgmTGe6uEEVJ7azUxuc8Tf7zV9SD2z7Ij751'), ('$5$rounds=31817$iZGmlyBQ99JSB5n6$p4E.pdPBWx19OajgjLRiOW0itGny' 'xDGgMlDcOsfaI17'), ]: self.assertTrue(ctx.verify("test", hash)) def test_django16_context(self): ctx = apps.django16_context for hash in [ 'pbkdf2_sha256$29000$ZsgquwnCyBs2$fBxRQpfKd2PIeMxtkKPy0h7SrnrN+EU/cm67aitoZ2s=', 'sha1$0d082$cdb462ae8b6be8784ef24b20778c4d0c82d5957f', 'md5$b887a$37767f8a745af10612ad44c80ff52e92', 'crypt$95a6d$95x74hLDQKXI2', '098f6bcd4621d373cade4e832627b4f6', ]: self.assertTrue(ctx.verify("test", hash)) self.assertEqual(ctx.identify("!"), "django_disabled") self.assertFalse(ctx.verify("test", "!")) def test_django_context(self): ctx = apps.django_context for hash in [ 'pbkdf2_sha256$29000$ZsgquwnCyBs2$fBxRQpfKd2PIeMxtkKPy0h7SrnrN+EU/cm67aitoZ2s=', ]: self.assertTrue(ctx.verify("test", hash)) self.assertEqual(ctx.identify("!"), "django_disabled") self.assertFalse(ctx.verify("test", "!")) def test_ldap_nocrypt_context(self): ctx = apps.ldap_nocrypt_context for hash in [ '{SSHA}cPusOzd6d5n3OjSVK3R329ZGCNyFcC7F', 'test', ]: self.assertTrue(ctx.verify("test", hash)) self.assertIs(ctx.identify('{CRYPT}$5$rounds=31817$iZGmlyBQ99JSB5' 'n6$p4E.pdPBWx19OajgjLRiOW0itGnyxDGgMlDcOsfaI17'), None) def test_ldap_context(self): ctx = apps.ldap_context for hash in [ ('{CRYPT}$5$rounds=31817$iZGmlyBQ99JSB5n6$p4E.pdPBWx19OajgjLRiOW0' 'itGnyxDGgMlDcOsfaI17'), '{SSHA}cPusOzd6d5n3OjSVK3R329ZGCNyFcC7F', 'test', ]: self.assertTrue(ctx.verify("test", hash)) def test_ldap_mysql_context(self): ctx = apps.mysql_context for hash in [ '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29', '378b243e220ca493', ]: self.assertTrue(ctx.verify("test", hash)) def test_postgres_context(self): ctx = apps.postgres_context hash = 'md55d9c68c6c50ed3d02a2fcf54f63993b6' self.assertTrue(ctx.verify("test", hash, user='user')) def test_phppass_context(self): ctx = apps.phpass_context for hash in [ '$P$8Ja1vJsKa5qyy/b3mCJGXM7GyBnt6..', '$H$8b95CoYQnQ9Y6fSTsACyphNh5yoM02.', '_cD..aBxeRhYFJvtUvsI', ]: self.assertTrue(ctx.verify("test", hash)) h1 = "$2a$04$yjDgE74RJkeqC0/1NheSSOrvKeu9IbKDpcQf/Ox3qsrRS/Kw42qIS" if hashmod.bcrypt.has_backend(): self.assertTrue(ctx.verify("test", h1)) self.assertEqual(ctx.default_scheme(), "bcrypt") self.assertEqual(ctx.handler().name, "bcrypt") else: self.assertEqual(ctx.identify(h1), "bcrypt") self.assertEqual(ctx.default_scheme(), "phpass") self.assertEqual(ctx.handler().name, "phpass") def test_phpbb3_context(self): ctx = apps.phpbb3_context for hash in [ '$P$8Ja1vJsKa5qyy/b3mCJGXM7GyBnt6..', '$H$8b95CoYQnQ9Y6fSTsACyphNh5yoM02.', ]: self.assertTrue(ctx.verify("test", hash)) self.assertTrue(ctx.hash("test").startswith("$H$")) def test_roundup_context(self): ctx = apps.roundup_context for hash in [ '{PBKDF2}9849$JMTYu3eOUSoFYExprVVqbQ$N5.gV.uR1.BTgLSvi0qyPiRlGZ0', '{SHA}a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', '{CRYPT}dptOmKDriOGfU', '{plaintext}test', ]: self.assertTrue(ctx.verify("test", hash)) #============================================================================= # eof #=============================================================================
Submit
FILE
FOLDER
Name
Size
Permission
Action
__init__.py
20 bytes
0644
__init__.pyc
181 bytes
0644
__init__.pyo
181 bytes
0644
__main__.py
82 bytes
0644
__main__.pyc
293 bytes
0644
__main__.pyo
293 bytes
0644
_test_bad_register.py
541 bytes
0644
_test_bad_register.pyc
919 bytes
0644
_test_bad_register.pyo
919 bytes
0644
backports.py
2513 bytes
0644
backports.pyc
1258 bytes
0644
backports.pyo
1258 bytes
0644
sample1.cfg
243 bytes
0644
sample1b.cfg
252 bytes
0644
sample1c.cfg
490 bytes
0644
sample_config_1s.cfg
238 bytes
0644
test_apache.py
25208 bytes
0644
test_apache.pyc
20198 bytes
0644
test_apache.pyo
20198 bytes
0644
test_apps.py
5281 bytes
0644
test_apps.pyc
5972 bytes
0644
test_apps.pyo
5972 bytes
0644
test_context.py
75039 bytes
0644
test_context.pyc
42392 bytes
0644
test_context.pyo
42392 bytes
0644
test_context_deprecated.py
29282 bytes
0644
test_context_deprecated.pyc
20648 bytes
0644
test_context_deprecated.pyo
20569 bytes
0644
test_crypto_builtin_md4.py
5660 bytes
0644
test_crypto_builtin_md4.pyc
6010 bytes
0644
test_crypto_builtin_md4.pyo
6010 bytes
0644
test_crypto_des.py
8874 bytes
0644
test_crypto_des.pyc
6692 bytes
0644
test_crypto_des.pyo
6692 bytes
0644
test_crypto_digest.py
18670 bytes
0644
test_crypto_digest.pyc
13552 bytes
0644
test_crypto_digest.pyo
13552 bytes
0644
test_crypto_scrypt.py
25655 bytes
0644
test_crypto_scrypt.pyc
21381 bytes
0644
test_crypto_scrypt.pyo
21302 bytes
0644
test_ext_django.py
32811 bytes
0644
test_ext_django.pyc
21620 bytes
0644
test_ext_django.pyo
21345 bytes
0644
test_ext_django_source.py
11034 bytes
0644
test_ext_django_source.pyc
7075 bytes
0644
test_ext_django_source.pyo
7028 bytes
0644
test_handlers.py
62786 bytes
0644
test_handlers.pyc
60928 bytes
0644
test_handlers.pyo
60928 bytes
0644
test_handlers_argon2.py
16951 bytes
0644
test_handlers_argon2.pyc
13606 bytes
0644
test_handlers_argon2.pyo
13514 bytes
0644
test_handlers_bcrypt.py
23507 bytes
0644
test_handlers_bcrypt.pyc
19655 bytes
0644
test_handlers_bcrypt.pyo
19493 bytes
0644
test_handlers_cisco.py
20471 bytes
0644
test_handlers_cisco.pyc
17618 bytes
0644
test_handlers_cisco.pyo
17618 bytes
0644
test_handlers_django.py
15109 bytes
0644
test_handlers_django.pyc
16025 bytes
0644
test_handlers_django.pyo
15911 bytes
0644
test_handlers_pbkdf2.py
18788 bytes
0644
test_handlers_pbkdf2.pyc
17158 bytes
0644
test_handlers_pbkdf2.pyo
17158 bytes
0644
test_handlers_scrypt.py
4124 bytes
0644
test_handlers_scrypt.pyc
4089 bytes
0644
test_handlers_scrypt.pyo
4089 bytes
0644
test_hosts.py
3906 bytes
0644
test_hosts.pyc
3852 bytes
0644
test_hosts.pyo
3852 bytes
0644
test_pwd.py
7190 bytes
0644
test_pwd.pyc
6456 bytes
0644
test_pwd.pyo
6456 bytes
0644
test_registry.py
9459 bytes
0644
test_registry.pyc
7715 bytes
0644
test_registry.pyo
7715 bytes
0644
test_totp.py
65562 bytes
0644
test_totp.pyc
40189 bytes
0644
test_totp.pyo
40005 bytes
0644
test_utils.py
40242 bytes
0644
test_utils.pyc
30495 bytes
0644
test_utils.pyo
30495 bytes
0644
test_utils_handlers.py
32134 bytes
0644
test_utils_handlers.pyc
29250 bytes
0644
test_utils_handlers.pyo
29188 bytes
0644
test_utils_md4.py
1474 bytes
0644
test_utils_md4.pyc
1588 bytes
0644
test_utils_md4.pyo
1588 bytes
0644
test_utils_pbkdf2.py
12108 bytes
0644
test_utils_pbkdf2.pyc
10552 bytes
0644
test_utils_pbkdf2.pyo
10552 bytes
0644
test_win32.py
1920 bytes
0644
test_win32.pyc
2030 bytes
0644
test_win32.pyo
2030 bytes
0644
tox_support.py
2473 bytes
0644
tox_support.pyc
2842 bytes
0644
tox_support.pyo
2842 bytes
0644
utils.py
138326 bytes
0644
utils.pyc
95162 bytes
0644
utils.pyo
94702 bytes
0644
N4ST4R_ID | Naxtarrr