__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
"""test passlib.hosts"""
#=============================================================================
# imports
#=============================================================================
from __future__ import with_statement
# core
import logging; log = logging.getLogger(__name__)
# site
# pkg
from passlib import hosts, hash as hashmod
from passlib.utils import unix_crypt_schemes
from passlib.tests.utils import TestCase
# module
#=============================================================================
# test predefined app contexts
#=============================================================================
class HostsTest(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 check_unix_disabled(self, ctx):
for hash in [
"",
"!",
"*",
"!$1$TXl/FX/U$BZge.lr.ux6ekjEjxmzwz0",
]:
self.assertEqual(ctx.identify(hash), 'unix_disabled')
self.assertFalse(ctx.verify('test', hash))
def test_linux_context(self):
ctx = hosts.linux_context
for hash in [
('$6$rounds=41128$VoQLvDjkaZ6L6BIE$4pt.1Ll1XdDYduEwEYPCMOBiR6W6'
'znsyUEoNlcVXpv2gKKIbQolgmTGe6uEEVJ7azUxuc8Tf7zV9SD2z7Ij751'),
('$5$rounds=31817$iZGmlyBQ99JSB5n6$p4E.pdPBWx19OajgjLRiOW0itGny'
'xDGgMlDcOsfaI17'),
'$1$TXl/FX/U$BZge.lr.ux6ekjEjxmzwz0',
'kAJJz.Rwp0A/I',
]:
self.assertTrue(ctx.verify("test", hash))
self.check_unix_disabled(ctx)
def test_bsd_contexts(self):
for ctx in [
hosts.freebsd_context,
hosts.openbsd_context,
hosts.netbsd_context,
]:
for hash in [
'$1$TXl/FX/U$BZge.lr.ux6ekjEjxmzwz0',
'kAJJz.Rwp0A/I',
]:
self.assertTrue(ctx.verify("test", hash))
h1 = "$2a$04$yjDgE74RJkeqC0/1NheSSOrvKeu9IbKDpcQf/Ox3qsrRS/Kw42qIS"
if hashmod.bcrypt.has_backend():
self.assertTrue(ctx.verify("test", h1))
else:
self.assertEqual(ctx.identify(h1), "bcrypt")
self.check_unix_disabled(ctx)
def test_host_context(self):
ctx = getattr(hosts, "host_context", None)
if not ctx:
return self.skipTest("host_context not available on this platform")
# validate schemes is non-empty,
# and contains unix_disabled + at least one real scheme
schemes = list(ctx.schemes())
self.assertTrue(schemes, "appears to be unix system, but no known schemes supported by crypt")
self.assertTrue('unix_disabled' in schemes)
schemes.remove("unix_disabled")
self.assertTrue(schemes, "should have schemes beside fallback scheme")
self.assertTrue(set(unix_crypt_schemes).issuperset(schemes))
# check for hash support
self.check_unix_disabled(ctx)
for scheme, hash in [
("sha512_crypt", ('$6$rounds=41128$VoQLvDjkaZ6L6BIE$4pt.1Ll1XdDYduEwEYPCMOBiR6W6'
'znsyUEoNlcVXpv2gKKIbQolgmTGe6uEEVJ7azUxuc8Tf7zV9SD2z7Ij751')),
("sha256_crypt", ('$5$rounds=31817$iZGmlyBQ99JSB5n6$p4E.pdPBWx19OajgjLRiOW0itGny'
'xDGgMlDcOsfaI17')),
("md5_crypt", '$1$TXl/FX/U$BZge.lr.ux6ekjEjxmzwz0'),
("des_crypt", 'kAJJz.Rwp0A/I'),
]:
if scheme in schemes:
self.assertTrue(ctx.verify("test", hash))
#=============================================================================
# eof
#=============================================================================
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 20 B | 0644 |
|
| __main__.py | File | 82 B | 0644 |
|
| _test_bad_register.py | File | 541 B | 0644 |
|
| backports.py | File | 2.53 KB | 0644 |
|
| sample1.cfg | File | 243 B | 0644 |
|
| sample1b.cfg | File | 252 B | 0644 |
|
| sample1c.cfg | File | 490 B | 0644 |
|
| sample_config_1s.cfg | File | 238 B | 0644 |
|
| test_apache.py | File | 28.75 KB | 0644 |
|
| test_apps.py | File | 5.16 KB | 0644 |
|
| test_context.py | File | 72.8 KB | 0644 |
|
| test_context_deprecated.py | File | 28.6 KB | 0644 |
|
| test_crypto_builtin_md4.py | File | 5.53 KB | 0644 |
|
| test_crypto_des.py | File | 8.67 KB | 0644 |
|
| test_crypto_digest.py | File | 20 KB | 0644 |
|
| test_crypto_scrypt.py | File | 26.02 KB | 0644 |
|
| test_ext_django.py | File | 40.4 KB | 0644 |
|
| test_ext_django_source.py | File | 10.78 KB | 0644 |
|
| test_handlers.py | File | 67.02 KB | 0644 |
|
| test_handlers_argon2.py | File | 22.3 KB | 0644 |
|
| test_handlers_bcrypt.py | File | 28.86 KB | 0644 |
|
| test_handlers_cisco.py | File | 19.99 KB | 0644 |
|
| test_handlers_django.py | File | 15.17 KB | 0644 |
|
| test_handlers_pbkdf2.py | File | 18.35 KB | 0644 |
|
| test_handlers_scrypt.py | File | 4.09 KB | 0644 |
|
| test_hosts.py | File | 3.81 KB | 0644 |
|
| test_pwd.py | File | 7.02 KB | 0644 |
|
| test_registry.py | File | 9.03 KB | 0644 |
|
| test_totp.py | File | 64.25 KB | 0644 |
|
| test_utils.py | File | 45.04 KB | 0644 |
|
| test_utils_handlers.py | File | 31.38 KB | 0644 |
|
| test_utils_md4.py | File | 1.44 KB | 0644 |
|
| test_utils_pbkdf2.py | File | 11.91 KB | 0644 |
|
| test_win32.py | File | 1.88 KB | 0644 |
|
| tox_support.py | File | 2.42 KB | 0644 |
|
| utils.py | File | 144.17 KB | 0644 |
|