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_apache.cpython-39.opt-1.pyc
a

f�Wc�r�@sdZddlmZddlmZddlZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZdd	lmZmZmZmZdd
lmZddlmZddlmZee�Zddd�Zej�d�p�dZddd�Z dd�Z!dd�Z"e"�\Z#Z$e�%e#d�Z&Gdd�de�Z'Gdd�de�Z(dS)z@tests for passlib.apache -- (c) Assurance Technologies 2008-2011�)�with_statement)�	getLoggerN)�apache�registry)�MissingBackendError)�irange)�unittest)�TestCase�get_file�set_file�ensure_mtime_changed)�u)�to_bytes)�to_unicode_for_identify�
cCs0tj�|�}tj�|�|}t�|||f�dS)z)backdate file's mtime by specified amountN)�os�path�getatime�getmtime�utime)r�offsetZatime�mtime�r�=/usr/lib/python3.9/site-packages/passlib/tests/test_apache.py�backdate_file_mtimesrZPASSLIB_TEST_HTPASSWD_PATHZhtpasswdcCsb|dur|�d�}tjtg|tjtj|r0tjndd�}|�|�\}}|��}t|pVd�}||fS)z$
    helper to run htpasswd cmd
    N�utf-8)�stdout�stderr�stdin�)	�encode�
subprocess�Popen�
htpasswd_path�PIPEZSTDOUTZcommunicate�waitr)�argsr�proc�out�err�rcrrr�_call_htpasswd+s
�r+cCstd||g|�\}}|S)z%
    wrapper for htpasswd verify
    z-vi)r+)r�user�passwordr(r*rrr�_call_htpasswd_verify9sr.cCsDztg�\}}Wnty$YdS0|s4t�d�d|v}d|fS)z0
    helper to check if htpasswd is present
    )FFz htpasswd test returned with rc=0z -B T)r+�OSError�logZwarning)r(r*Zhave_bcryptrrr�_detect_htpasswdAs
r1z requires `htpasswd` cmdline toolc@s�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zed.d/��Zee �!e"�#d0�d1�d2d3���Z$d4S)5�HtpasswdFileTestztest HtpasswdFile class�HtpasswdFilestuser2:2CHkkwa2AtqGs
user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
user1:$apr1$t4tc7jTh$GPIWVUo8sQKJlUdV8V5vu0
s4user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
syuser2:pass2x
user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
user1:$apr1$t4tc7jTh$GPIWVUo8sQKJlUdV8V5vu0
user5:pass5
suseræ:2CHkkwa2AtqGs
suser�:2CHkkwa2AtqGs
suser1:pass1
user1:pass2
suser2:2CHkkwa2AtqGs
user3:{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=
user4:pass4
user1:$apr1$t4tc7jTh$GPIWVUo8sQKJlUdV8V5vu0
user5:$2a$12$yktDxraxijBZ360orOyCOePFGhuis/umyPNJoL5EbsLk.s6SWdrRO
user6:$5$rounds=110000$cCRp/xUUGVgwR4aP$p0.QKFS5qLNRqw1/47lXYiAcgIjJK.WjCO8nrEKuUK.
cCs*|��}t||j�t�|�}|�|��|j�|�|j|�|�|j	�|d|_|�|j|d�|�
|j	�tj|dd�}|�|��d�|�|j|�|�
|j	�|�d��tj|dd�}Wd�n1s�0Y|�|��d�|�|j|�|�
|j	�t�
|�|�ttj|�dS)	�test constructor autoload�xT��new�z ``autoload=False`` is deprecatedF)ZautoloadN)�mktempr�	sample_01rr3�assertEqual�	to_stringr�
assertTruer�assertFalse�assertWarningListr�remove�assertRaises�IOError��selfr�htrrr�test_00_constructor_autoload}s(

,
z-HtpasswdFileTest.test_00_constructor_autoloadcCsP|��}t||j�tj�|�}|�|��|j�|�|jd�|�	|j
�dS�N)r9rr:rr3Z	from_pathr;r<rr>rrCrrr�test_00_from_path�sz"HtpasswdFileTest.test_00_from_pathcCsdtj�|j�}|�|�d��|�|�d��|�|�d��|�|��|j	�|�
t|jd�dS)�
test delete()�user1�user2�user5�user:N)rr3�from_stringr:r=�deleter>r;r<�	sample_02rA�
ValueError�rDrErrr�test_01_delete�szHtpasswdFileTest.test_01_deletecCsf|��}d}t||�t�|�}|�d�|�t|�|�tj|dd�}|�d�|�t|�d�dS)Nsuser1:pass1
user2:pass2
rJT)�autosavesuser2:pass2
)r9rrr3rOr;r
�rDrZsamplerErrr�test_01_delete_autosave�s



z(HtpasswdFileTest.test_01_delete_autosavecCstjj|jdd�}|�|�dd��|�|�dd��|�|��|j	�|�
d��"tjj|jdd�}Wd	�n1sz0Y|�|�dd��|�|�dd��|�|��|j	�|�t|jd
d�|�
d��|�
dd
�Wd	�n1s�0Y|�|�dd
��d	S)ztest set_password()�	plaintext��default_schemerK�pass2xrL�pass5z``default`` is deprecated)�defaultNrM�pass�update\(\) is deprecated�test)rr3rNr:r=�set_passwordr>r;r<�	sample_03r?rArQ�update�check_passwordrRrrr�test_02_set_password�s�0*z%HtpasswdFileTest.test_02_set_passwordcCsl|��}d}t||�t�|�}|�dd�|�t|�|�tj|ddd�}|�dd�|�t|�d�dS)N�user1:pass1
rJ�pass2rWT)rYrTsuser1:pass2
)r9rrr3r`r;r
rUrrr�test_02_set_password_autosave�s

z.HtpasswdFileTest.test_02_set_password_autosavecCs�dd�}|�|d�d�|�|d�d�|�t|d�|�|d�tjd�|�|d�tjd�|�|d�tjd�|�|d	�tjd�d	S)
z%test set_password() -- default_schemecSs*tj|d�}|�dd�|j�|�d��S)NrXrJ�pass1)rr3r`�contextZidentify�get_hash)�schemerErrr�check�szCHtpasswdFileTest.test_02_set_password_default_scheme.<locals>.checkZsha256_cryptZ	des_cryptZxxxZportableZportable_apache_22�host_apache_22N)r;rA�KeyErrorr�htpasswd_defaults)rDrlrrr�#test_02_set_password_default_scheme�sz4HtpasswdFileTest.test_02_set_password_default_schemecCsLtj�|j�}|�dd�|�d�|�dd�|�t|���gd��dS)�test users()rLr[�user3�pass3�rJrKrr�user4rLN)	rr3rNr:r`rOr;�sorted�usersrRrrr�
test_03_users�s

zHtpasswdFileTest.test_03_usersc	Cstj�|j�}|�t|jdd�|�|�dd�du�tdd�D]f}t	|�}z8|�|�d|d|��|�|�d|d�du�Wq@t
y�|d	kr�Yq@�Yq@0q@|�t|jd
d�|�dgd��4|�|�
d
d��|�|�
d
d��Wd�n1�s0YdS)�test check_password()�Zpass9Zuser9N�r,r]F�5rM�verify\(\) is deprecated�rJrhrf)rr3rN�	sample_05rA�	TypeErrorrcr=r�strrrQr?�verifyr>�rDrE�irrr�test_04_check_passwords 
z'HtpasswdFileTest.test_04_check_passwordcCs|��}t|d�t|d�tj|dd�}|�|��d�|�dd�|��|�|��d�t||j	�|��|�|��|j	�|�d	d
�|�
�|�|��|j	�t��}|�t|j
�|�t|j�t||j
�t��}|�
|�|�|�dd��dS)�test load()r�rWrXr8rJrhrerLr[N)r9rrrr3r;r<r`�load_if_changedr:�loadrA�RuntimeError�
sample_dupr=rc�rDrZha�hbZhcrrr�test_05_loads*


zHtpasswdFileTest.test_05_loadcCs�|��}t||j�t�|�}|�d�|�d�|��|�t|�|j	�tjdd�}|�
dd�|�t|j�|�|�|�t|�d�dS)�test save()rJrKrWrXrhreN)
r9rr:rr3rO�saver;r
rPr`rAr��rDrrEr�rrr�test_06_saveAs



zHtpasswdFileTest.test_06_savecCs�|jttjdd�tjj|jddd�}|�|��td�g�|�	d��"tjj|jdd�}Wd�n1sn0Y|�|��d	g�tjj|j
d
dd�}|�|��td�g�dS)ztest 'encoding' kwd�utf-16��encodingrT�r�Zreturn_unicode�useræz``encoding=None`` is deprecatedNsuseræ�latin-1)rArQrr3rN�sample_04_utf8r;rwr
r?�sample_04_latin1rRrrr�test_07_encodingsWs�0
�z"HtpasswdFileTest.test_07_encodingscCs�tj�|j�}|�|�d�d�|�|�d�d�|�|�d�d�|�d��"|�|�d�d�Wd�n1sv0YdS)�test get_hash()rrs!{SHA}3ipNV1GrBtxPmHFC21fCbVCSXIo=ruspass4rLN�find\(\) is deprecated)rr3rNr:r;rjr?�findrRrrr�test_08_get_hashksz!HtpasswdFileTest.test_08_get_hashcCs<tj�|j�}|�|��|j�t��}|�|��d�dS)ztest to_stringr8N)rr3rNr:r;r<rRrrr�test_09_to_stringusz"HtpasswdFileTest.test_09_to_stringcCstjddddd�}t|�dS)NZfakepathTr�)rTr7r�)rr3�reprrRrrr�test_10_repr�szHtpasswdFileTest.test_10_reprcCs(|�ttjjd�|�ttjjd�dS)Nsrealm:user1:pass1
spass1
)rArQrr3rN�rDrrr�test_11_malformed�s��z"HtpasswdFileTest.test_11_malformedcCs|jttjjddd�dS)Nr8)r)rAr�rr3rNr�rrr�test_12_from_string�s�z$HtpasswdFileTest.test_12_from_stringcCs�td�}tj�|�}|�t|���gd��|�dd�|�t|���gd��|�dd�|�t|���gd��|�d�|�t|���gd	��td
�}|�|�	�|�dS)zwhitespace & comment handlingz`
user2:pass2
user4:pass4
user7:pass7
 	 
user1:pass1
 # legacy users
#user6:pass6
user5:pass5

)rJrKrurL�user7ruZalthash4�user6Zalthash6)rJrKrurLr�r�r�)rJrKrurLr�zd
user2:pass2
user4:althash4
 	 
user1:pass1
 # legacy users
#user6:pass6
user5:pass5
user6:althash6
N)
rrr3rNr;rvrw�set_hashrOr<)rD�sourcerE�targetrrr�test_13_whitespace�s�

�z#HtpasswdFileTest.test_13_whitespacecs|��}tj|dd���fdd�}��d|dd��tjd}��d	|d|��tjd
}��d|d|����dd
����|�t|dd��|�t|d	d��|�t|dd��|�t|dd��|�t|dd��|�t|d	d��|�t|dd��dS)z;
        verify "htpasswd" command can read output
        T�rr7cs�j�|��|�SrG�riZhandler�hash��pwdrk�rErr�hash_scheme�sz>HtpasswdFileTest.test_htpasswd_cmd_verify.<locals>.hash_schemerJr-Z
apr_md5_cryptrmrK�hostrrruz$xxx$foo$bar$baz�wrongN)	r9rr3r�ror�r>r.r=)rDrr�Zhost_no_bcryptZ	host_bestrr�r�test_htpasswd_cmd_verify�s"

z)HtpasswdFileTest.test_htpasswd_cmd_verify�bcryptzbcrypt support requiredcs||��}tj|dd���fdd�}��d|dd�����|�t|dd��trf|�t|dd��n|�t|dd��d	S)
z�
        verify "htpasswd" command can read bcrypt format

        this tests for regression of issue 95, where we output "$2b$" instead of "$2y$";
        fixed in v1.7.2.
        Tr�cs�j�|��|�SrGr�r�r�rrr��szEHtpasswdFileTest.test_htpasswd_cmd_verify_bcrypt.<locals>.hash_schemerJr-r�r�N)	r9rr3r�r�r>r.�HAVE_HTPASSWD_BCRYPTr=)rDrr�rr�r�test_htpasswd_cmd_verify_bcrypt�s	z0HtpasswdFileTest.test_htpasswd_cmd_verify_bcryptN)%�__name__�
__module__�__qualname__�__doc__�descriptionPrefixr:rPrar�r�r�rrFrHrSrVrdrgrprxr�r�r�r�r�r�r�r�r�r��requires_htpasswd_cmdr�r�
skipUnlessrZhas_backendr�rrrrr2Zs@"

%
/
$r2c@s�eZdZdZdZdZdZdZdZdZ	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�HtdigestFileTestztest HtdigestFile class�HtdigestFiles�user2:realm:549d2a5f4659ab39a80dac99e159ab19
user3:realm:a500bb8c02f6a9170ae46af10c898744
user4:realm:ab7b5d5f28ccc7666315f508c7358519
user1:realm:2a6cf53e7d8f8cf39d946dc880b14128
sZuser3:realm:a500bb8c02f6a9170ae46af10c898744
user4:realm:ab7b5d5f28ccc7666315f508c7358519
s�user2:realm:5ba6d8328943c23c64b50f8b29566059
user3:realm:a500bb8c02f6a9170ae46af10c898744
user4:realm:ab7b5d5f28ccc7666315f508c7358519
user1:realm:2a6cf53e7d8f8cf39d946dc880b14128
user5:realm:03c55fdc6bf71552356ad401bdb9af19
s0useræ:realmæ:549d2a5f4659ab39a80dac99e159ab19
s.user�:realm�:549d2a5f4659ab39a80dac99e159ab19
cCsl|��}t||j�t�|�}|�|��|j�tj|dd�}|�|��d�t�|�|�	t
tj|�dS)r4Tr6r8N)r9rr:rr�r;r<rr@rArBrCrrrrFs

z-HtdigestFileTest.test_00_constructor_autoloadcCs�tj�|j�}|�|�dd��|�|�dd��|�|�dd��|�|�dd��|�|��|j	�|�
t|jdd�|�
t|jdd	�d
S)rIrJ�realmrKrLrr�realm5rMr,�realm:N)rr�rNr:r=rOr>r;r<rPrArQrRrrrrS+szHtdigestFileTest.test_01_deletecCs�|��}t||j�t�|�}|�|�dd��|�|�dd��|�|�dd��|�t	|�|j�d|_
|�|�dd��|�t	|�|j�dS)NrJr�rrr�rLTrK)r9rr:rr�r=rOr>r;r
rTrPrCrrrrV:s
z(HtdigestFileTest.test_01_delete_autosavecCstj�|j�}|�|�ddd��|�|�ddd��|�|��|j	�|�
t|jdd�d|_|�dd�|�
ddd�|�
t|jddd	�|�
t|jd
dd	�|�
t|jddd	�|�
t|jdd
d	�|�d��|�ddd�Wd�n1s�0Y|�|�
dd��dS)z
test update()rKr�rZrLr[rsZrealm2rMr]Auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuur,r�Arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr^r_N)rr�rNr:r=r`r>r;r<rarAr��
default_realmrcrQr?rbrRrrrrdHs,z%HtdigestFileTest.test_02_set_passwordcCsdtj�|j�}|�ddd�|�dd�|�ddd�|�t|�d��gd��|�	t
|jd�dS)	rqrLr�r[rrrsrtrzN)rr�rNr:r`rOr;rvrwrAr�rRrrrrxdszHtdigestFileTest.test_03_usersc	CsJtj�|j�}|�t|jddd�|�t|jddd�|�|�ddd�d�tdd�D]B}t	|�}|�
|�d|dd|��|�|�d|dd�d	�qV|�t|jdd�d|_|�
|�d
d��|�|�dd�d�|�dgd
��8|�
|�
d
dd��|�|�
d
dd��Wd�n1�s(0Y|�t|jddd�dS)ryrzr�r[r,rLNr�r]FrJrhr}r~rfrM)rr�rNr:rAr�rcZassertIsrr�r=r�r?r�r>rQr�rrrr�ns 4z'HtdigestFileTest.test_04_check_passwordcCsP|��}t|d�t|d�t�|�}|�|��d�|�ddd�|��|�|��d�t||j	�|��|�|��|j	�|�ddd	�|�
�|�|��|j	�t��}|�t|j
�|�t|j�t��}|�
|�|�|��|j	�t
|�t|d�|�d
��|j
dd�Wd
�n1�s20Y|�|��d�d
S)r�rr�r8rJr�rhs-user1:realm:2a6cf53e7d8f8cf39d946dc880b14128
rLr[z!load\(force=False\) is deprecatedF)�forceN)r9rrrr�r;r<r`r�r:r�rAr�rr?r�rrrr��s2




,zHtdigestFileTest.test_05_loadcCs�|��}t||j�t�|�}|�dd�|�dd�|��|�t|�|j	�t��}|�
ddd�|�t|j�|�|�|�t|�|�
��dS)r�rJr�rKrhN)r9rr:rr�rOr�r;r
rPr`rAr�r<r�rrrr��s

zHtdigestFileTest.test_06_savecCshtj�|j�}|�|�d�d�|�|��dg�|�|�d�d�|�|��g�|�|��d�dS)ztest realms() & delete_realm()r5rr��r8N)rr�rNr:r;Zdelete_realm�realmsr<rRrrr�test_07_realms�szHtdigestFileTest.test_07_realmscCs�tj�|j�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|�d��$|�|�dd�d�Wd�n1s~0YdS)	r�rrr�Z a500bb8c02f6a9170ae46af10c898744ruZ ab7b5d5f28ccc7666315f508c7358519rLNr�)rr�rNr:r;rjr?r�rRrrrr��sz!HtdigestFileTest.test_08_get_hashcCs�|jttjdd�tjj|jddd�}|�|��td�g�|�|�	td��td�g�tjj|j
ddd�}|�|��td�g�|�|�	td��td�g�d	S)
ztest encoding parameterr�r�rTr�urealmær�r�N)rArQrr�rNr�r;r�r
rwr�rRrrr�test_09_encodings�sz"HtdigestFileTest.test_09_encodingscCs<tj�|j�}|�|��|j�t��}|�|��d�dS)ztest to_string()r8N)rr�rNr:r;r<rRrrr�test_10_to_string�sz"HtdigestFileTest.test_10_to_stringcCs(|�ttjjd�|�ttjjd�dS)Nsrealm:user1:pass1:other
re)rArQrr�rNr�rrrr��s��z"HtdigestFileTest.test_11_malformedN)r�r�r�r�r�r:rPrar�r�rFrSrVrdrxr�r�r�r�r�r�r�r�rrrrr�s(
)
r�)r)N))r�Z
__future__rZloggingrrr!ZpasslibrrZpasslib.excrZpasslib.utils.compatrZpasslib.tests.backportsrZpasslib.tests.utilsr	r
rrr
Z
passlib.utilsrZpasslib.utils.handlersrr�r0r�environ�getr#r+r.r1Z
HAVE_HTPASSWDr�r�r�r2r�rrrr�<module>s2



)

Youez - 2016 - github.com/yon3zu
LinuXploit