403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/passlib/tests/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/passlib/tests/__pycache__/test_context.cpython-39.opt-1.pyc
a

f�Wc2#�@s�dZddlmZddlmZer.ddlmZnddlmZddlZddl	m
Z
ddlZe�e
�ZddlZddlZddlmZddlmZmZdd	lmZmZdd
lmZmZddlmZmZmZmZm Z m!Z!ddl"m#m$Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,dd
l-m.Z.m/Z0m1Z2m3Z3ej4�5ej4�6e7��Z8dd�Z9Gdd�de'�Z:ddl;Z;ddl<Z<Gdd�de%j=�Z>Gdd�de%j=�Z?Gdd�de'�Z@dS)ztests for passlib.context�)�with_statement)�PY3)�NoSectionErrorN)�partial)�hash)�CryptContext�LazyCryptContext)�PasslibConfigWarning�PasslibHashWarning)�tick�
to_unicode)�irange�u�unicode�
str_to_uascii�PY2�PY26)�TestCase�set_file�TICK_RESOLUTION�
quicksleep�	time_call�handler_derived_from)�register_crypt_handler_path�_has_crypt_handler�_unload_handler_name�get_crypt_handlercOs.|��}|D]}|�|�q|r*|�|�|S�N)�copy�update)�first�args�kwds�target�arg�r%�>/usr/lib/python3.9/site-packages/passlib/tests/test_context.py�merge_dicts&s
r'c
sjeZdZdZgd�Zdd�eD�Zeeddddd	d
d�Zeeed�Z	e
d
�Ze
d�Ze
j�ed�Ze�e
d�e
d��Ze
j�ed�Ze�e
d�e
d���d�Ze
j�ed�Zeddddd�ZdZeee�Zedd�Zeee�Zegd�d gd!d"d#d$d%d&d%d'd(d)�Z�fd*d+�Zd,d-�Z d.d/�Z!d0d1�Z"d2d3�Z#d4d5�Z$d6d7�Z%d8d9�Z&d:d;�Z'd<d=�Z(d>d?�Z)d@dA�Z*dBdC�Z+dDdE�Z,d}dGdH�Z-dIdJ�Z.dKdL�Z/dMdN�Z0dOdP�Z1dQdR�Z2dSdT�Z3dFifdFdUd ifdVifdWifgZ4dXdY�Z5dZd[�Z6d\d]�Z7d^d_�Z8d~dadb�Z9dcdd�Z:dedf�Z;dgdh�Z<didj�Z=dkdl�Z>dmdn�Z?dodp�Z@dqdr�ZAdsdt�ZBdudv�ZCdwdx�ZDdydz�ZEd{d|�ZF�ZGS)�CryptContextTestr)�	des_crypt�	md5_crypt�
bsdi_crypt�sha512_cryptcCsg|]}t|��qSr%)r��.0�namer%r%r&�
<listcomp>?�zCryptContextTest.<listcomp>r*皙�����?i1ui�aiP��@�)�schemes�default�all__vary_rounds�bsdi_crypt__max_rounds�bsdi_crypt__default_rounds�sha512_crypt__max_rounds�sha512_crypt__min_rounds�r4a[passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
; this is using %...
all__vary_rounds = 10%%
bsdi_crypt__default_rounds = 25001
bsdi_crypt__max_rounds = 30001
sha512_crypt__max_rounds = 50000
sha512_crypt__min_rounds = 40000
z�[passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
all__vary_rounds = 0.1
bsdi_crypt__default_rounds = 25001
bsdi_crypt__max_rounds = 30001
sha512_crypt__max_rounds = 50000
sha512_crypt__min_rounds = 40000

zsample1.cfg�
z
zsample1b.cfg�	[passlib]z
[mypolicy]�utf-16zsample1c.cfgiIqi��iyiȯ)Zbsdi_crypt__min_roundsr7r8r:z�[passlib]
bsdi_crypt__min_rounds = 29001
bsdi_crypt__max_rounds = 35001
bsdi_crypt__default_rounds = 31001
sha512_crypt__min_rounds = 45000
r,�r5)r)r*�phpassr+�sha256_cryptr)rA��r����H�)r4�
deprecatedr5r7r8�bsdi_crypt__vary_rounds�sha256_crypt__max_rounds�sha256_crypt__min_rounds�sha256_crypt__default_rounds�
phpass__ident�phpass__default_roundscs*tt|���t�dd�t�dd�dS)N�ignorez The 'all' scheme is deprecated.*z4.*'scheme' keyword is deprecated as of Passlib 1.7.*)�superr(�setUp�warnings�filterwarnings��self��	__class__r%r&rQ�szCryptContextTest.setUpcCs�t�}|�|��i�tfi|j��}|�|��|j�tfi|j��}|�|��|j�tfi|j��}|�|��|j�tfi|j��}|�|��|j�ttd�gd�}|�|��d�dS)ztest class constructorrAr;)rAN)	r�assertEqual�to_dict�
sample_1_dict�sample_1_resolved_dict�
sample_2_dict�
sample_3_dictrr4�rU�ctxr%r%r&�test_01_constructor�sz$CryptContextTest.test_01_constructorcCs�t�|j�}|�|��|j�t�|j�}|�|��|j�t�|j�d��}|�|��|j�t�|j�}|�|��|j�tj|j	ddd�}|�|��|j�|�
ttjd�|j
ttj|jdd�dS)ztest from_string() constructor�utf-8�mypolicyr>��section�encodingN�fakesection�rd)
r�from_string�sample_1_unicoderXrYrZ�sample_1_unnormalized�encode�sample_1b_unicode�sample_1c_bytes�assertRaises�	TypeErrorrr^r%r%r&�test_02_from_string�s 
�
�z$CryptContextTest.test_02_from_stringcCs�tj�|j�std|j��t�|j�}|�|��|j	�t�|j
�}|�|��|j	�tj|jddd�}|�|��|j	�|�t
tjtj�td��|jttj|jdd�dS)	ztest from_path() constructorzcan't find data file: %rrbr>rczsample1xxx.cfgrfrgN)�os�path�exists�
sample_1_path�RuntimeErrorrZ	from_pathrXrYrZ�sample_1b_path�sample_1c_pathrn�EnvironmentError�join�hererr^r%r%r&�test_03_from_path�s 
�
�
�z"CryptContextTest.test_03_from_pathcCstfi|j��}|jfi|j��}|�|��|j�|�|��|j�|jfi|j��}|�|��|j�|�|��|j�|jfi|j��}|�|��|j�|��}|�	||�|�|��|j�|�|��|j�|j
fi|j��|�|��|j�|�|��|j�dS)ztest copy() methodN)rrZrr\rXrY�sample_12_dictr]�sample_123_dictZassertIsNotr)rU�cc1�cc2Zcc2b�cc3�cc4r%r%r&�test_04_copys zCryptContextTest.test_04_copycCs$tfi|j��}|�t|�d�dS)ztest repr()z!^<CryptContext at 0x-?[0-9a-f]+>$N)rrZ�assertRegex�repr)rUr~r%r%r&�test_09_repr+szCryptContextTest.test_09_reprcCs�t�}|�|j�|�|��|j�|�|j�|�|��|j�|�|j�d��|�|��|j�|�t|jd�tfi|j��}|jidd�|�|��|j�t�}|�|j�|�|j	�|�|��|j	�dS)z test load() / load_path() methodraNT)r)
r�loadrZrXrYrirkrnror\r^r%r%r&�test_10_load4s
zCryptContextTest.test_10_loadcCs�tddgddd�}|��}|jt|jdd�|�|��|�|jt|jdd�|�|��|�|jt|jd	d
�|�|��|�dS)z$test load() errors restore old stater)rAi�r2)rLr6T)Ztoo__many__key__parts)Zfake_context_optioni'�rKN)r�	to_stringrnrorrX�KeyError�
ValueError)rU�cc�resultr%r%r&�test_11_load_rollback_s�z&CryptContextTest.test_11_load_rollbackcCstfi|j��}|��|�|��|j�tfi|j��}|jfi|j��|�|��|j�|jfi|j��|�|��|j�tfi|j��}|�|j�|�|��|j�tfi|j��}|�|j	�|�|��|j�|�
t|jii�|j
t|jidgd�|�
t|jd�dS)ztest update() methodr)r;N)rrZrrXrYr\r|r]r}�sample_2_unicodernror^r%r%r&�test_12_updatews"zCryptContextTest.test_12_updatecCs6dd�}|jttdd�|jttdd�|jttdd�|jttdd�|jttdd	�|jttd
d�|jt|fidd
i��tfiddd���}|�|�d�d�td
d�}|�|d
d�|�|�|d
d�|�|�|d
d�|�|�|fidd
i��|�|�|fidd
i��|�td
d�}|�|d
d�|�|�|fidd
i��|�tdd�}|�|dd�|�|�|dd�|�|�|fiddi��|�|�|fiddi��|�tdd�}|�|dd�|�|�|fiddi��|�tdd
gd d!�}|jt|jd d"�|jttdgd#d$�|jttdgd#d%�d&S)'ztest basic option parsingc[stfi|����Sr�rrY)r"r%r%r&�parse�sz/CryptContextTest.test_20_options.<locals>.parser2)�__�x)Zdefault__scheme__)Z__option)Zdefault____option)Z__scheme__optioni0u)Z!category__scheme__option__invalidzadmin.context__schemesr*�md5_crypt,des_cryptr))r4zadmin.context__default�adminr?)Zcontext__default)Zdefault__context__defaultzcontext.defaultzdefault.context.default��admin__context__defaultzadmin.context.default�r6)Zdefault__all__vary_roundszall.vary_roundszdefault.all.vary_rounds)�admin__all__vary_roundszadmin.all.vary_roundsr@�P)rM)Zmd5_crypt__ident�xx)r4Zdes_crypt__salt)r4Z	all__saltN)rnrorr�rX�default_scheme�dictr)rUr�r_r�r%r%r&�test_20_options�sR	���




��z CryptContextTest.test_20_optionscCs�tdd�}|�|��d�tddgd�}|�|��d�tdd�}|�|��d�ttjtjgd�}|�|��d�|jtttj	gd�Gdd	�d	tj	�}|jt
t|gd�Gd
d�dtj	�}|jtt||gd�|jttdgd�dS)
z%test 'schemes' context option parsingNr;r%r)r*)r)r*z des_crypt, md5_crypt, c@seZdZdZdS)z2CryptContextTest.test_21_schemes.<locals>.namelessN��__name__�
__module__�__qualname__r/r%r%r%r&�nameless�sr�c@seZdZdZdS)z1CryptContextTest.test_21_schemes.<locals>.dummy_1�dummy_1Nr�r%r%r%r&r�sr�)Zadmin__context__schemes)rrXr4rr)r*rnro�uh�
StaticHandlerr�r�)rUr�r�r�r%r%r&�test_21_schemes�s 

�z CryptContextTest.test_21_schemescCsddd�}tdgd�}|jddgd�|�||�dg�tdgddgd�}|�||�dg�|jtttjgddgd�td	gd
�d�}|�||�ddg�|jttdgdgd�|jttdgdgd�|jttddgddgd�|jttddgddd
�|jttddgddd�|jttddgddd�|jttddgddd�tddgddgd�|jttdd�tdgddgdgd�}|�||�dg�|�||d�dg�|�||d�dg�tdgddggd�}|�||�dg�|�||d�dg�|�||d�g�dS)z(test 'deprecated' context option parsingNcs��fdd����D�S)Ncsg|]}��|��jr|�qSr%��handlerrHr-��categoryr_r%r&r0s�zGCryptContextTest.test_22_deprecated.<locals>.getdep.<locals>.<listcomp>r;�r_r�r%r�r&�getdepsz3CryptContextTest.test_22_deprecated.<locals>.getdepr*�rHr)r;)rHr4r�)r*r)rA�r4rH)r4�admin__context__deprecated)r4r5rH)r4r5r�)r4r�rH)r4r�r�)r4rHr�r��{)rHr4r��userr�)N)	rrrXrnrorr*r�r�)rUr�r�r%r%r&�test_22_deprecateds~
�����������z#CryptContextTest.test_22_deprecatedcCs|�tdd���tdd��tdddgd�}|�|��d�ttjddgd�}|�|��d�tddgd�}|�|��d�|jdd�|�|��d�|jt	tdgdd�|jt
tdd�tdddgdd	�}|�|��d�|�|�d
�d�|�|�d�d�dS)
z%test 'default' context option parsingr*r?r))r5r4r;r�)r4r5�)r5r4r�r�r�N)rXrrYr�r�rr*rrnr�ror^r%r%r&�test_23_defaulths,���z CryptContextTest.test_23_defaultcCs\dd�}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)	z&test 'vary_rounds' hash option parsingcSst|d���dS)Nr�r6r�)�vr%r%r&r��sz3CryptContextTest.test_24_vary_rounds.<locals>.parser2z0.1z10%i�Z1000N)rX)rUr�r%r%r&�test_24_vary_rounds�sz$CryptContextTest.test_24_vary_roundsNcCs|jt||�|d�dS)N)�msg)�
assertTruer)rUr��baser�r%r%r&�assertHandlerDerivedFrom�sz)CryptContextTest.assertHandlerDerivedFromcCs�t�}|�|��d�|�|jdd�d�tfi|j��}|�|��t|j��|�|jddd�t|j��t|jdd�|j�D]\}}|�t	||��q�tfi|j
��}|�|��d�dS)ztest schemes() methodr%T��resolve�r��unconfiguredN)rrXr4rZ�tuple�sample_1_schemes�sample_1_handlers�zipr�rr\)rUr_r�Zcorrectr%r%r&�test_30_schemes�sz CryptContextTest.test_30_schemescCs�t�}|�t|j�tfi|j��}|�|��d�|�|jddd�tj�|�|jdd�tj�tfi|j	��}|�t|j�t|j
d�}|�|��d�dS)ztest default_scheme() methodr*Tr�r�r;r)N)rrnr�r�rZrXrr*r�r\r�r^r%r%r&�test_31_default_scheme�sz'CryptContextTest.test_31_default_schemecCsjt�}|�t|j�|�t|jd�tfi|j��}|�|jdd�tj�|�|��tj�|�|jddd�tj	�|�|�d�tj	�|�t|jd�tddd�}|�|jdd�tj
�|�|��tj
�|�|jddd	�tj
�|�|jdd
�tj
�|�|jddd	�tj�|�|jdd
�tj
�t�rf|�|jtd�dd	�tj
�|�|jtd�dd	�tj�dS)
ztest handler() methodr*T)r�r)�mysql323�sha256_crypt,md5_cryptr��staff)r�r��r�r�N)
rrnr�r�rZrXrr*r�r)rArrr^r%r%r&�test_32_handler�s&z CryptContextTest.test_32_handlercCs<ddd�}tdgd�ddgdd	d
ddgdd
dd�
}|�|jjd�|�||d�tddd
d��|�||dd�tddd
d��|�||dd�tddd��|�||d�tddd��|�||dd�tddd��|�||dd�tddd��|�||d�td	d��|�||dd�td	d��|�||dd�td
dd��dS)z*test internal _get_record_options() methodNcSs|j�||�dS)Nr)�_configZ_get_record_options_with_flag)r_�schemer�r%r%r&�options�sz1CryptContextTest.test_33_options.<locals>.optionsT)r,r)r+r,r)r2皙�����?i Nr+皙�����?g333333�?r3)
�truncate_errorr4rHr6rIr9r�r�Zadmin__bsdi_crypt__vary_roundsZadmin__sha512_crypt__max_rounds)r�)rH�vary_rounds�
max_roundsr�r�)r�r�)rHr�)r�)r�rH)N)rrXr��
categoriesr�)rUr�r�r%r%r&�test_33_options�sd
����
������z CryptContextTest.test_33_optionscCs<tfi|j��}|�|��|j�|�|jdd�|j�dS)ztest to_dict() methodTr�N)rrZrXrYr[r^r%r%r&�test_34_to_dictCsz CryptContextTest.test_34_to_dictcCs�tfi|j��}|��}ts*|�||j�t�|�}|�|��|j�|jdd�}|�||�dd��ddl	m
}t|dg�}|��}|�|d�d	S)
ztest to_string() methodzpassword-securityrgr=z[password-security]r)�UnsaltedHashr*zM# NOTE: the 'unsalted_test_hash' handler\(s\) are not registered with PasslibN)rrZr�rrXrirhrY�replaceZ!passlib.tests.test_utils_handlersr�r�)rUr_�dump�ctx2�otherr�Zctx3r%r%r&�test_35_to_stringJs
z"CryptContextTest.test_35_to_stringr�r�r%cCstjtjtjg}t|dd�}|D]z}|jd|jd�}|�|�|�|j�|�|j|ddd�|�|�|j|dd�|�|�	|�
d|��|�|�
d|��q |�d�}|�|�|�d	�|�d
|�
��}|�|�|�d	�|jd
|�
�d	d�}|�|�|�d	�|jt|jd
|�
�dd�dS)
z-test basic hash/identify/verify functionality��r8�test�r�Tr�r��notestr*�secretr)N)rr*r)r+rr/rX�identifyr�r��verify�assertFalse�genhash�	genconfigrnr�)rU�handlersr�Zcrypt�hr%r%r&�
test_40_basicqs 
zCryptContextTest.test_40_basiccCsHtddgdddd�}|�|���d��|�|jdd��d	��|�|jdd
d��d��|�|jdd
d��d	��|�|jddddd�d�tr�|jdd�}|�|jtd
�d��d��|�|jtd
�d��d	��|�t	t�j�|jt	t�jdd�|jt	|jdd�|jt
|jdd
d�|jt
|jdd�|jt
|jdd�dS)ztest genconfig() methodr*r@rFrGr�)r4rMrNZadmin__phpass__identz$1$r�z$H$5r�)r�r�z$P$5r��........�)r��salt�rounds�identz"$P$6........22zGEuacuPOqEpYPDeR0R/r?r��faker�N)rr�r��
startswithrXrrrrnr�ro�rUr��c2r%r%r&�test_41_genconfig�s.��z"CryptContextTest.test_41_genconfigcCs�tdg�}|�d�}|jD]"\}}|jt|j||fi|��qtdg�}|jD],\}}|dur`qN|jt|jd|fi|��qNtdg�}|�t|jdd�|�tt�jdd�|jt|jd|dd�|jt|jd|d	d�|jt|jd|d	d
�dS)ztest genhash() methodr)�stubNr�r�rr�r�r�r�)rr�nonstring_vectorsrnror�r�r�)rUr�rr�r"Zconfigr%r%r&�test_42_genhash�s



z CryptContextTest.test_42_genhashcCs�tfi|j��}|�d�}|�|�d��|�|�d|��|�|�d|��|jt|j	dd�tdg�}|j
D] \}}|jt|j|fi|��qp|�tt�jd�|jt|jddd	�d
S)ztest hash() method�passwordz$5$rounds=3000$Z	passwordxi��rLr)r�r�r�N)
r�
sample_4_dictrr�r�r�r�rnr�rr�ror�)rUr�rr�r"r%r%r&�test_43_hash�s

�
zCryptContextTest.test_43_hashFc	CsPtfi|j��}|�dg��(|�|jdddd�d�Wd�n1sJ0Y|�dg��*|�|jddddd	�d
�Wd�n1s�0Y|�dg��(|�|jdddd
�d�Wd�n1s�0Y|�dg��(|�|jdddd
�d�Wd�n1�s0Y|jt|jddd�|jt|jddd�dS)z;test hash() method -- legacy 'scheme' and settings keywords�"passing settings to.*is deprecatedr�r@r�)r�r�z"$H$5........De04R5Egz0aq8Tf.1eVhY/Nr�)r�r�r�z"$P$5........De04R5Egz0aq8Tf.1eVhY/���nacl�r�r�z?$5$rounds=1999$nacl$nmfwJIxqj0csloAAvSER0B8LU0ERCAbhmMug4Twl609��z?$5$rounds=2001$nacl$8PdeoPL4aXQnJ0woHhqgIw/efyfCKC2WHneOpnvF.31r�r�r�r�)rr��assertWarningListrXrrnr�ro)rUZ
use_16_legacyr�r%r%r&�test_43_hash_legacy�s.�"�"�"�$z$CryptContextTest.test_43_hash_legacycCs�gd�}t|dd�}|�|�d�d�|jt|jddd�tdg�}|jD] \}}|jt|j|fi|��qJt�}|�|�d	�d�|jt|jd	dd�|jt|jdd
d�dS)ztest identify() border cases�r*r)r+r�r�z$9$232323123$1287319827NT)�requiredr)rr�r�)	rrXr�rnr�r�ro�assertIsr�)rUr�r�rr"r%r%r&�test_44_identify.s
z!CryptContextTest.test_44_identifycCs�gd�}t|dd�}tj�d�}|�|�d|��|�|�d|��|�|jd|dd��|�|jd|dd��|jt|jd|dd�|�t|jd	d
�tdg�}|�d	�}}|jD]"\}}|jt|j||fi|��q�|�	|�|d��tdg�}|jD]2\}}|du�r�q|jt|jd
|fi|���q|�t
t�jd
d�|jt
|jd
|dd�|jt|jd
|dd�|jt|jd
|dd�dS)ztest verify() scheme kwdrr�r�r�r�r*r�r+r�z$6$232323123$1287319827r)Nr�rr�r�r�)rrr*r�r�rnr�r�ror�r�)rUr�r�r��refhashr�r"r%r%r&�test_45_verifyHs.


zCryptContextTest.test_45_verifycs�tfi|j��}|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��g�G�fdd�dtj�}t|g�}|�d	�}}|�|�|��|��|d
fg��d
d
�=|�|j|dd��|��|dfg��d
d
�=|�|j|d
d��|��|d
fg��d
d
�=tdg�}|j	D]"\}}|j
t|j|fi|���q>|�
tt�jd�|j
t|j|dd�|j
t|j|dd�|j
t|j|dd�d
S)ztest needs_update() methodZ
9XXD4trGYeGJAz"$1$J8HC2RCr$HcmM.7NxB2weSvlw2FgzU0zK$5$rounds=1999$jD81UCoo.zI.UETs$Y7qSTQ6mTiU9qZB4fRr43wRgQq4V.5AAf7F97Pzxey/zK$5$rounds=2000$228SSRje04cnNCaQ$YGV4RYu.5sNiBvorQDlO0WWQjyJVGKBcJXz3OtyQ2u8zK$5$rounds=3000$fS9iazEwTKi7QPW4$VasgBC8FqlOvD7x2HhABaMXCTh9jwHclPA9j5YQdns.zK$5$rounds=3001$QlFHHifXvpFX4PLs$/0ekt7lSs/lOikSerQ0M/1porEHxYq7W/2hdFpxA3fAcs.eZdZdZdZed�fdd�	�Zdd�ZdS)	z4CryptContextTest.test_46_needs_update.<locals>.dummy�dummy�@Ncs��||f�|dkS)N�nu)�append)�clsrr��Zcheck_stater%r&�needs_update�szACryptContextTest.test_46_needs_update.<locals>.dummy.needs_updatecSs0ddlm}t|t�r |�d�}t||����S)Nr)�md5ra)�hashlibr�
isinstancerrkr�	hexdigest)rUr�rr%r%r&�_calc_checksum�s

zCCryptContextTest.test_46_needs_update.<locals>.dummy._calc_checksum)N)r�r�r�r/�_hash_prefix�classmethodrrr%rr%r&r	�s
r	r�NZbob)r�rr)rr�r�r�r�)
rr�r�rr�r�r�rrXr�rnror�)rUr�r	r_rrr"r%rr&�test_46_needs_update{s6




z%CryptContextTest.test_46_needs_updatec
Cs�tfi|j��}|�d��d�}|�d��d�}|�d|�\}}|�|�|�|d�|�d|�\}}|�|�|�|d�|�d|�\}}|�|�|�|�|�d�|�d|�\}}|�|�|�|d�tdg�}|�d�}}|j	D]"\}}	|j
t|j||fi|	��q�|�|�|d�d�tdg�}|j	D]2\}}	|du�rJ�q4|j
t|jd|fi|	���q4|�
t
t�jdd	�|j
t
|jd|d
d�|j
t|jd|dd�|j
t|jd|dd
�dS)ztest verify_and_update()r)r�rAZ	wrongpassNr��FNr�rr�r�r�r�)rr�r�r�verify_and_updater�rr�r�r�rnrorXr�)
rUr�Zh1Zh2�okZnew_hashrrr�r"r%r%r&�test_47_verify_and_update�s:






z*CryptContextTest.test_47_verify_and_updatec
Cs�ddlm}m}m}|�d�}|jddd�}|jddd�}t||g�}|�|jt��|�	|�
|�d��d�|�	|�d|��|�|�d|�d�|�
d	g��$|jt|jddd�Wd
�n1s�0Y|jt|jd|dd�|jt|jd|dd�t||g�}|�|jtdg��|�	|�
|�d��d�|�	|�d|��|�|�d|�d�|�	|�
|jddd��d�|�	|jd|dd��|�|jd|dd�d�|�
d	g��$|jt|jddd�Wd
�n1�s�0Y|jt|jd|dd�|jt|jd|dd�t||gd
d�}	|�|	jtdg��|�t|	jd�|�t|	jd|�|�t|	jd|�|�|	jddd�|�|�	|	jd|dd��|�|	jd|dd�d�|�|	jd|dd�d�|�|	jd|dd�d|f�d
S)zLhash(), verify(), and verify_and_update() -- discard unused context keywordsr)r)r*�postgres_md5r��root)r�r�r))TNr�Nr�)Zbadkwd�autor�rT)�passlib.hashr)r*rrrrXZcontext_kwds�setr�r�r�rrrnro)
rUr)r*rZdes_hashZpg_root_hashZ
pg_admin_hashr~rr�r%r%r&�test_48_context_kwds�sJ
24�z%CryptContextTest.test_48_context_kwdscCsftdgdddd�}d}|�dd�}|�|jd�|�|jd�|�|jd�|�tgd�� |jd	dd	d
�}Wd�n1s�0Y|�|j	dd�d
|�|�g��*|�|j	ddd�d|�Wd�n1s�0Y|�|j	ddd�d|�|�|j	ddd�d|�|�tgd��0|jt
d�d	dt
d�d	d�}Wd�n1�sd0Y|�|j	dd�d|�|�g��*|�|j	ddd�d|�Wd�n1�s�0Y|�|j	ddd�d|�|�|j	ddd�d|�|�|j	dd�d|�tjj}|jd|d>d�}|�|j	dd�d||f�|jddd�}|�|j	dd�d|�|j
t|jdd �|jdd �|jdd �|j
t|jdd �tdgd!�}|j
t|jddd"�|j
ttd#d$�|j
ttd#d%�|j
ttd#d&�|j
ttd#d �tj��}|j
ttd|d$�|j
ttd|d%�|j
ttd|d&�|j
ttd|d �dS)'ztest rounds limitsrArErDi�	�r4rKrJrLz+...........................................N�i�)rKrJrLr��r�z$5$rounds=1000$nacl$r�r�z$5$rounds=1999$nacl$z$5$rounds=2000$nacl$rz$5$rounds=2001$nacl$ge��A)rJrKrLz$5$rounds=999999999$nacl$i�z$5$rounds=3001$nacl$z$5$rounds=3000$nacl$i�z$5$rounds=2999$nacl$z$5$rounds=2500$nacl$r�)rLrJz$5$rounds=%d$nacl$%sr�r;)rKrJr�r�)rJr�)r�_get_recordrXZmin_desired_roundsZmax_desired_roundsZdefault_roundsrr
rr��intrrArnr��datetimeZnowro)rUr�ZSTUBZcustom_handlerr�ZdfZbadr%r%r&�test_50_rounds_limitsQs~��$�"��
�&�$���
z&CryptContextTest.test_50_rounds_limitscCsxtdgdddd�}|jt|jdd�|jt|jdd�|jt|jd	d�|jd
d�}|�|�dd�jd
�|�|ddd�|jdd�}|�|�dd�jd
�|�|ddd�|jd
d�}|�|�dd�jd
�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�dS)ztest linear vary roundsrAi�i�rEr"���r��-1%�101%rN�0%r�r�r�dz0.1%g����MbP?i�i��100%��?�rrnr�rrXr%r��assert_rounds_ranger�r%r%r&�test_51_linear_vary_rounds�s4�z+CryptContextTest.test_51_linear_vary_roundscCs�tdgdddd�}|jt|jdd�|jt|jdd�|jt|jd	d�|jd
d�}|�|�dd�jd
�|�|ddd�|jdd�}|�|�dd�jd
�|�|ddd�|jd
d�}|�|�dd�jd
�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�|jdd�}|�|�dd�jd�|�|ddd�dS)ztest log2 vary roundsZbcrypt�rC�)r4Zbcrypt__min_roundsZbcrypt__max_roundsZbcrypt__default_roundsr)r�r*r+rNr,r���r-z1%g{�G�z�?z49%g\��(\�?z50%g�?r.r/r0r�r%r%r&�test_52_log2_vary_rounds�s@�z)CryptContextTest.test_52_log2_vary_roundscCs~|�|�}|jdd�|j}t�}td�D](}|j||d�}	|�|	�j}
|�|
�q,|�	t
|�|d�|�	t|�|d�dS)z2helper to check vary_rounds covers specified rangerr�i,r$z"vary_rounds had wrong lower limit:z"vary_rounds had wrong upper limit:N)r�Zdefault_salt_charsZ
max_salt_sizer r
r�rhr��addrX�min�max)rU�contextr��lower�upperr�r��seen�ir��rr%r%r&r1s
z$CryptContextTest.assert_rounds_rangecCsptjddtd�tdgd�}|�|jd�|�|jdd�jd�|�|jd	d�jd�|�|jd
d�jd�dS)zharden_verify -- parsingrOz.*harden_verify.*r�rAr;N�)�
harden_verify�trueZfalse)rRrS�DeprecationWarningrrXrB�usingr^r%r%r&�test_harden_verify_parsing-s�z+CryptContextTest.test_harden_verify_parsingcCsPd}d}t��}||_t|gd�}|��t|j�\}}|j||||d�dS)z'
        dummy_verify() method
        r�r�r;)ZdeltaN)�	DelayHashrE�delayrZdummy_verifyrZassertAlmostEqual)rUZexpectedZaccuracyr�r_�elapsed�_r%r%r&�test_dummy_verify9sz"CryptContextTest.test_dummy_verifycCsddd�}tddd�}|�||d�gd��|�||d�gd��|jd	d
�|�||d�gd��|�||d�gd��|jdd
�|�||d�gd��|�||d�gd��tdgdd�}|�||d�dg�|�||d�dg�|jttddd�|jttddd�dS)z+test deprecated='auto' is handled correctlyNcs��fdd����D�S)Ncsg|]}��|��j�qSr%r�)r.r�r�r%r&r0Qr1zLCryptContextTest.test_61_autodeprecate.<locals>.getstate.<locals>.<listcomp>r;r�r%r�r&�getstatePsz8CryptContextTest.test_61_autodeprecate.<locals>.getstatez sha256_crypt,md5_crypt,des_cryptrr�)FTTr�r*r?)TFTr)r�)TTFrAFr�zauto,md5_cryptzmd5_crypt,auto)N)rrXrrnr�)rUrLr_r%r%r&�test_61_autodeprecateMs&

�
�z&CryptContextTest.test_61_autodeprecatecCs&ddlm}ddlm}m}tdg�}tddg�}|�d�}|�d�}|�td|j	�|�td|j	|�|�td|j	|�|�	�}|�
||j�|�	|�}	|�
|	|j|�|�	|�}
|�
|
|j|�|�
|�	|	�|	�|�|�
|��|�||j
|�|�||j
|�|�||j
|	�|�|�
|��|�||j
|�|�|�
|��|�|�
|	��|�||jd�|�t|jd	�|�
|�|�|�|�||j|�|�||j|�|�||j|	�|�||jd�|�t|jd	�|�
|�|�|�|�||j|�|�td
|j|�|�
|�|	�|�d	S)zdisabled hash supportr)�UnknownHashError)r*�
unix_disabledr)rOZfoozno disabled hasher presentrANzcannot restore original hash)�passlib.excrNrr*rOrrZassertRaisesRegexru�disablerXZdefault_markerr�Z
is_enabledrnr��enableror�)rUrNr*rOr_r�Zh_refZh_otherZh_disZ	h_dis_refZh_dis_otherr%r%r&�test_disabled_hashesmsX


���

�z%CryptContextTest.test_disabled_hashes)N)F)Hr�r�r��descriptionPrefixr�r�r�rZr'r[rrjrirqrrryrzrtr�rlrvrkrmrwrr\r�r|r]r}r�rQr`rpr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr!r(r2r7r1rFrKrMrS�
__classcell__r%r%rVr&r(1s��
�
���		
�
�	+%L$\%
$O!
�1$
13G:Uv&/ r(c@s2eZdZdZdZejZdZdZ	e
d�Zdd�ZdS)	rGz-dummy hasher which delays by specified amountZ
delay_hash�(rz$x$cCs6t�|j�t|t�r |�d�}tt�d|��	��S)Nrasprefix)
�time�sleeprHrrrkrrZsha1r)rUr�r%r%r&r�s

zDelayHash._calc_checksumN)
r�r�r��__doc__r/r�ZLOWER_HEX_CHARSZchecksum_charsZ
checksum_sizerHrrrr%r%r%r&rG�srGc@seZdZdZdS)�dummy_2Nr�r%r%r%r&rZ�srZc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�LazyCryptContextTestrcCstd�|�td�dS)NrZ)�unload_handler_nameZ
addCleanuprTr%r%r&rQ�szLazyCryptContextTest.setUpcCst|�td��tdd�ttddg�dgd�}|�tdd��|�|��d�|�|�d�j	�|�tdd��dS)ztest plain kwdsrZ�passlib.tests.test_contextr)r�T�rZr)N)
r��has_crypt_handlerrr�iterrXr4r�r�rH)rUr�r%r%r&�test_kwd_constructor�s
z)LazyCryptContextTest.test_kwd_constructorcsx��td��tdd�d
�fdd�	}t|dd�}��tdd����|��d���|�d	�j���tdd��dS)NrZr]Fcs ��|�ttddg�dgd�S)NrZr)r�)r�r�r`)�flagrTr%r&�onload�s
z>LazyCryptContextTest.test_callable_constructor.<locals>.onloadT)rcrbr^r))F)	r�r_rrrXr4r�r�rH)rUrcr�r%rTr&�test_callable_constructor�s
z.LazyCryptContextTest.test_callable_constructorN)r�r�r�rTrQrardr%r%r%r&r[�sr[)ArYZ
__future__rZpasslib.utils.compatrZconfigparserrZConfigParserr'�	functoolsrZloggingZ	getLoggerr��logrqrRZpasslibrZpasslib.contextrrrPr	r
Z
passlib.utilsrrr
rrrrrZpasslib.utils.handlersZutilsr�r�Zpasslib.tests.utilsrrrrrrZpasslib.registryrrr_rr\rrr�abspath�dirname�__file__rzr'r(rrWr�rGrZr[r%r%r%r&�<module>sL  	

Youez - 2016 - github.com/yon3zu
LinuXploit