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_deprecated.cpython-39.pyc
a

f�Wcbr�@sdZddlmZddlmZddlZddlZzddlmZWne	yRdZYn0ddl
mZddlm
Z
mZmZddlmZmZddlmmZdd	lmZmZdd
lmZmZmZee �Z!Gdd�de�Z"Gd
d�de�Z#Gdd�dej$�Z%Gdd�de�Z&dS)atests for passlib.context

this file is a clone of the 1.5 test_context.py,
containing the tests using the legacy CryptPolicy api.
it's being preserved here to ensure the old api doesn't break
(until Passlib 1.8, when this and the legacy api will be removed).
�)�with_statement)�	getLoggerN)�resource_filename)�hash)�CryptContext�CryptPolicy�LazyCryptContext)�to_bytes�
to_unicode)�TestCase�set_file)�register_crypt_handler_path�_has_crypt_handler�_unload_handler_namec
@s
eZdZdZdZdZej�ej�	ej�
e�d��Zej�
e�sLerLedd�Ze�d�sZJ�egd�dd	d
ddd
d�Zddd	d
ddd
d�Zeejejejejgdd	d
ddd
d�ZdZeddddd�Zegd�dd	dddddd�Zedd�Zegd�dd	dddddd�ZdZedgd	ddd
d�ZedZ e�!�Z"e"j#dgdd gd!�e�!�Z$e$�#dd"d#��e�!�Z%e%�#dgdd gd!��d$d%�Z&d&d'�Z'd(d)�Z(d*d+�Z)d,d-�Z*d.d/�Z+d0d1�Z,d2d3�Z-d4d5�Z.d6d7�Z/d8d9�Z0d:d;�Z1d<d=�Z2d>d?�Z3d@dA�Z4dBdC�Z5dDdE�Z6dFdG�Z7dHS)I�CryptPolicyTestztest CryptPolicy objectrz�[passlib]
schemes = des_crypt, md5_crypt, bsdi_crypt, sha512_crypt
default = md5_crypt
all.vary_rounds = 10%%
bsdi_crypt.max_rounds = 30000
bsdi_crypt.default_rounds = 25000
sha512_crypt.max_rounds = 50000
sha512_crypt.min_rounds = 40000
zsample_config_1s.cfgz
passlib.testsz[passlib]
schemes��	des_crypt�	md5_crypt�
bsdi_crypt�sha512_cryptr皙�����?�0ui�a�P��@�)�schemes�default�all__vary_rounds�bsdi_crypt__max_rounds�bsdi_crypt__default_rounds�sha512_crypt__max_rounds�sha512_crypt__min_roundsz.des_crypt, md5_crypt, bsdi_crypt, sha512_crypt)rrzall.vary_roundszbsdi_crypt.max_roundszbsdi_crypt.default_roundszsha512_crypt.max_roundszsha512_crypt.min_roundsz�[passlib]
bsdi_crypt.min_rounds = 29000
bsdi_crypt.max_rounds = 35000
bsdi_crypt.default_rounds = 31000
sha512_crypt.min_rounds = 45000
�Hq鸈�y�ȯ)�bsdi_crypt__min_roundsrrr )rrrr%rrrr r�rz�
[passlib]
schemes = sha512_crypt
all.vary_rounds = 10%%
default.sha512_crypt.max_rounds = 20000
admin.all.vary_rounds = 5%%
admin.sha512_crypt.max_rounds = 40000
� N皙�����?)rrrZadmin__all__vary_roundsZadmin__sha512_crypt__max_roundszJdeprecated = des_crypt
admin__context__deprecated = des_crypt, bsdi_crypt
rr)�
deprecatedZadmin__context__deprecatedzdes_crypt, bsdi_crypt)r)zadmin.context.deprecatedcCs>t�|�t�dd�t�dd�t�dd�t�dd�dS)N�ignorez)The CryptPolicy class has been deprecated�,the method.*hash_needs_update.*is deprecatedz The 'all' scheme is deprecated.*zbsdi_crypt rounds should be odd�r�setUp�warnings�filterwarnings��self�r2�I/usr/lib/python3.9/site-packages/passlib/tests/test_context_deprecated.pyr-�s
��zCryptPolicyTest.setUpcCstfi|j��}|�|��|j�t|j�}|�|��|j�|�ttii�|jttidd�|jttgd�dd�Gdd�dtj�}|jtt|gd�|jtttjgd�Gd	d
�d
tj�}|jt	t||gd�|jt	tdgdgd
�|jt	tdgdd�dS)ztest CryptPolicy() constructor�)Zdummyrr)rZ bad__key__bsdi_crypt__max_roundsc@seZdZdZdS)z5CryptPolicyTest.test_00_constructor.<locals>.namelessN��__name__�
__module__�__qualname__�namer2r2r2r3�nameless�sr:�rc@seZdZdZdS)z4CryptPolicyTest.test_00_constructor.<locals>.dummy_1�dummy_1Nr5r2r2r2r3r<�sr<rr�rr)�rrN)
r�sample_config_1pd�assertEqual�to_dict�assertRaises�	TypeError�uh�
StaticHandler�
ValueError�KeyError)r1�policyr:r<r2r2r3�test_00_constructor�s.
���z#CryptPolicyTest.test_00_constructorcCs:|j}t�|�}|�|��|j�|�ttj|d�dS)z(test CryptPolicy.from_path() constructorZxxxN)�sample_config_1s_pathr�	from_pathr@rAr?rB�EnvironmentError)r1�pathrHr2r2r3�test_01_from_path_simples
z(CryptPolicyTest.test_01_from_path_simplecCs�|��}t||j�t�|�}|�|��|j�t||j�dd��t�|�}|�|��|j�t	|jddd�}t||�tj|dd�}|�|��|j�dS)z7test CryptPolicy.from_path() constructor with encodings�
�
�utf-16�utf-8�Zsource_encoding��encodingN)
Zmktempr�sample_config_1srrKr@rAr?�replacer	)r1rMrH�uc2r2r2r3�test_01_from_paths


z!CryptPolicyTest.test_01_from_pathcCs�t�|j�}|�|��|j�t�|j�dd��}|�|��|j�t|j�}t�|�}|�|��|j�t|jddd�}tj|dd�}|�|��|j�t�|j	�}|�|��|j
�dS)z*test CryptPolicy.from_string() constructorrOrPrQrRrSrTN)r�from_stringrVr@rAr?rWr
r	�sample_config_4s�sample_config_4pd)r1rH�datarXr2r2r3�test_02_from_string"s�

z#CryptPolicyTest.test_02_from_stringcCs�t�|j�}|�|��|j�t�|j�}|�|��|j�t�|j���}|�|��|j�t�|�}|�||�|�	t
tjd�|�	t
tjg�dS)z*test CryptPolicy.from_source() constructorr4N)rZfrom_sourcerJr@rAr?rV�copy�assertIsrBrC)r1rH�p2r2r2r3�test_03_from_source;s
z#CryptPolicyTest.test_03_from_sourcecCs\|�ttjg�t�|jg�}|�|��|j�t�|j|j	|j
g�}|�|��|j�dS)z+test CryptPolicy.from_sources() constructorN)rBrFrZfrom_sourcesrVr@rAr?rJ�sample_config_2s�sample_config_3pd�sample_config_123pd)r1rHr2r2r3�test_04_from_sourcesQs��z$CryptPolicyTest.test_04_from_sourcescCsztfi|j��}|jfi|j��}|�|��|j�|jfi|j��}|�|��|j�|�|j�}|�|��|j�dS)z&test CryptPolicy.replace() constructorN)	rr?rW�sample_config_2pdr@rA�sample_config_12pdrdre)r1�p1raZp2b�p3r2r2r3�test_05_replacedszCryptPolicyTest.test_05_replacecCsB|jttdgdd�|jttdgdd�|jttdgdgd�dS)z!test CryptPolicy() forbidden kwdsr�xx)rZdes_crypt__salt)rZ	all__saltr)rZuser__context__schemesN)rBrGrr0r2r2r3�test_06_forbiddenus���z!CryptPolicyTest.test_06_forbiddencCsBtfi|j��}|�|���tfi|j��}|�|���dS)ztest has_schemes() methodN)rr?�
assertTrueZhas_schemesrd)r1rirjr2r2r3�test_10_has_schemes�sz#CryptPolicyTest.test_10_has_schemescCsVtfi|j��}|jd}|�t|���|�tfi|j��}|�t|���g�dS)ztest iter_handlers() methodrN)rr?�sample_config_1prdr@�list�
iter_handlersrd)r1ri�srjr2r2r3�test_11_iter_handlers�s

z%CryptPolicyTest.test_11_iter_handlerscCs`tfi|j��}|�|�d�tj�|�|�d�d�|jt|jddd�|�|��tj�dS)ztest get_handler() methodr�sha256_cryptNT��required)	rr?r`�get_handlerrrrBrGr)r1rir2r2r3�test_12_get_handler�s
z#CryptPolicyTest.test_12_get_handlerc	Cs�tfi|j��}|�|�d�tddddd��|�|�d�tddd	d
��t�|j�}|�|�d�tddd��|�|�dd
�tddd��|�|�dd�tddd��dS)ztest get_options() methodrrr!r"r#)�vary_rounds�
min_rounds�
max_roundsZdefault_roundsrr$r)rzr{r|r')rzr|�user�adminr(rN)rrhr@Zget_options�dictrZr[)r1Zp12Zp4r2r2r3�test_13_get_options�s2�����z#CryptPolicyTest.test_13_get_optionscCs*tfi|j��}tfi|j��}|�|�d��|�|�tj��|�|�d��|�|�d��|�|�tj��|�|�d��|�|�dd��|�|�dd��|�|�dd��|�|�dd��tddgdgdgd�}|�|�d��|�|�d��|�|�dd��|�|�dd��dS)	z#test handler_is_deprecated() methodrrr}rr~r)rr)Zuser__context__deprecatedN)rr?�sample_config_5pd�assertFalse�handler_is_deprecatedrrrn)r1�pa�pbZpcr2r2r3�test_14_handler_is_deprecated�s*�z-CryptPolicyTest.test_14_handler_is_deprecatedcCshtjdtd�t�}|�|��d�|�|�d�d�|jdd�}|�|��d�|�|�d�d�dS)z!test get_min_verify_time() methodr*)�categoryrr~r)Zmin_verify_timeN)r.r/�DeprecationWarningrr@Zget_min_verify_timerW)r1r�r�r2r2r3�test_15_min_verify_time�sz'CryptPolicyTest.test_15_min_verify_timecCs^tfi|j��}|�t|���|j�|�t|jdd��|j�|�t|jdd��|j�dS)ztest iter_config() methodT��resolve)ZiniN)rr�r@rZiter_config�sample_config_5prd�sample_config_5pid�r1Zp5r2r2r3�test_20_iter_configsz#CryptPolicyTest.test_20_iter_configcCs<tfi|j��}|�|��|j�|�|jdd�|j�dS)ztest to_dict() methodTr�N)rr�r@rAr�r�r2r2r3�test_21_to_dict	szCryptPolicyTest.test_21_to_dictcCsPtfi|j��}|��}t�|�}|�|��|j�|jdd�}|�|t�dS)ztest to_string() methodzlatin-1rTN)rr�Z	to_stringrZr@rAZassertIsInstance�bytes)r1r�rsr�r2r2r3�test_22_to_strings
z!CryptPolicyTest.test_22_to_stringN)8r6r7r8�__doc__�descriptionPrefixrV�osrM�abspath�join�dirname�__file__rJ�existsr�
startswithrr?Zsample_config_1pidrrrrrrprcrgrhrdrer[r\Zsample_config_5sr_r��updater�r�r-rIrNrYr^rbrfrkrmrortryr�r�r�r�r�r�r2r2r2r3r%s�

������	���	�
���
	(	
'rc
@sheZdZdZdZdd�Zdd�Zdd�Zd	d
�Ze	gd�dgd
ddddddddd�Z
dd�Zdd�ZdS)�CryptContextTestztest CryptContext classrcCs>t�|�t�dd�t�dd�t�dd�t�dd�dS)Nr*z3CryptContext\(\)\.replace\(\) has been deprecated.*z9The CryptContext ``policy`` keyword has been deprecated.*�=.*(CryptPolicy|context\.policy).*(has|have) been deprecated.*r+r,r0r2r2r3r-$s
���zCryptContextTest.setUpcCsttjtjtjg�}|j��\}}}|�|tj�|�|tj�|�|tj�tgd��}|j��\}}}|�|tj�|�|tj�|�|tj�|j}t|d�}|�|�	�|�	��t|dd�}|�
|�	�|�	��|�|�	�tgd�dd��|�t
t|dd�|jt
tdd�dS)	ztest constructor�rrr)rHr)rHrr>rHN�x)rrrrrrHrrr`r@rAZassertNotEqualrrBrC�setattr)r1�cc�c�b�arHr2r2r3rI1s(
�z$CryptContextTest.test_00_constructorcCsdtgd��}|�|j��tj�|��}|�||�|jdd�}|�||�|�|j��tj�dS)ztest replace()r�rr&N)	rr`rHrxrrrWZassertIsNotr)r1r��cc2Zcc3r2r2r3�test_01_replaceNsz CryptContextTest.test_01_replacecCs�t�}|jt|jddd�|�t|jd�|�t|jdd�tdg�}tgd�}||_|jt|jddd�|�t|jd�|�t|jdd�dS)ztest no handlersrTrvZsecretrr;N)rrBrGZidentifyrZverifyrrH)r1r��pr2r2r3�test_02_no_handlers_s

z$CryptContextTest.test_02_no_handlers)rrZphpassrrurru��ri�i��H�)rr)rrrZbsdi_crypt__vary_roundsZsha256_crypt__max_roundsZsha256_crypt__min_roundsZsha256_crypt__default_roundsZ
phpass__identZphpass__default_roundscCsttfi|j��}|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��dS)ztest hash_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/2hdFpxA3fAN)r�sample_policy_1rn�hash_needs_updater��r1r�r2r2r3�test_12_hash_needs_update�sz*CryptContextTest.test_12_hash_needs_updatecCsvt�dd�tdg�}difdddifdifdiffD] \}}|jt|j|fi|��q6tdg�}|�t|jd�dS)	z'test non-string hash values cause errorr*z0.*needs_update.*'scheme' keyword is deprecated.*rN�schemer4r2Zmysql323)r.r/rrBrCr�)r1r�r�kwdsr�r2r2r3�test_30_nonstring_hash�s

�
z'CryptContextTest.test_30_nonstring_hashN)
r6r7r8r�r�r-rIr�r�rr�r�r�r2r2r2r3r� s*
�r�c@seZdZdZdS)�dummy_2Nr5r2r2r2r3r��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�LazyCryptContextTestrcCs:t�|�td�|�td�t�dd�t�dd�dS)Nr�r*z1CryptContext\(\)\.replace\(\) has been deprecatedr�)rr-�unload_handler_nameZ
addCleanupr.r/r0r2r2r3r-�s
�zLazyCryptContextTest.setUpcCsz|�td��tdd�ttddg�dgd�}|�tdd��|�|j�d��|�|j�	�ddg�|�tdd��dS)ztest plain kwdsr��passlib.tests.test_contextr)r)TN)
r��has_crypt_handlerr
r�iterrnrHr�r@rr�r2r2r3�test_kwd_constructor�s
z)LazyCryptContextTest.test_kwd_constructorcs~��td��tdd�d
�fdd�	}t|dd�}��tdd����|j�d����|j��ddg���tdd��d	S)z0test create_policy() hook, returning CryptPolicyr�r�Fcs ��|�ttddg�dgd�S)Nr�rr=)rnrr�)�flagr0r2r3�
create_policy�s
zELazyCryptContextTest.test_callable_constructor.<locals>.create_policyT)r�r�rN)F)	r�r�r
rrnrHr�r@r)r1r�r�r2r0r3�test_callable_constructor�s
z.LazyCryptContextTest.test_callable_constructorN)r6r7r8r�r-r�r�r2r2r2r3r��sr�)'r�Z
__future__rZloggingrr�r.Z
pkg_resourcesr�ImportErrorZpasslibrZpasslib.contextrrrZ
passlib.utilsr	r
Zpasslib.utils.handlersZutils�handlersrDZpasslib.tests.utilsrrZpasslib.registryr
rr�rr�r6�logrr�rEr�r�r2r2r2r3�<module>s.

~

Youez - 2016 - github.com/yon3zu
LinuXploit