HEX
Server: LiteSpeed
System: Linux s12787.usc1.stableserver.net 5.14.0-570.32.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 6 11:30:41 EDT 2025 x86_64
User: househiv (1652)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //lib64/python3.9/site-packages/borg/testsuite/__pycache__/file_integrity.cpython-39.pyc
a

�i��@sJddlZddlmZmZmZGdd�d�ZGdd�d�ZGdd	�d	�ZdS)
�N�)�IntegrityCheckedFile�DetachedIntegrityCheckedFile�FileIntegrityErrorc@s:eZdZdd�Zdd�Zdd�Zej�dd�d	d
��Z	dS)�TestReadIntegrityFilecCs.|�d�}|�d�t�t|��dus*J�dS)N�file�1234��join�writer�read_integrity_file�str��self�tmpdir�protected_file�r�C/usr/lib64/python3.9/site-packages/borg/testsuite/file_integrity.py�test_no_integritys

z'TestReadIntegrityFile.test_no_integritycCs`|�d�}|�d�|�d��d�t�t��t�t|��Wd�n1sR0YdS)Nrr�file.integrity��r
r�pytest�raisesrrrr
rrrr�test_truncated_integritys


z.TestReadIntegrityFile.test_truncated_integritycCs>|�d�}|�d�|�d��d�t�t|��dus:J�dS)Nrrrz4{"algorithm": "HMAC_SERIOUSHASH", "digests": "1234"}r	rrrr�test_unknown_algorithms

z,TestReadIntegrityFile.test_unknown_algorithm�json)z4{"ALGORITHM": "HMAC_SERIOUSHASH", "digests": "1234"}z[]z1234.5z
"A string"zInvalid JSONcCs`|�d�}|�d�|�d��|�t�t��t�t|��Wd�n1sR0YdS)Nrrrr)rrrrrrr�test_malformeds


z$TestReadIntegrityFile.test_malformedN)
�__name__�
__module__�__qualname__rrrr�mark�parametrizerrrrrrs
rc@sXeZdZejdd��Zdd�Zdd�Zdd�Zej	�
d	d
�dd��Zd
d�Zdd�Z
dS)� TestDetachedIntegrityCheckedFilecCsHt|�d��}t|dd��}|�d�Wd�n1s:0Y|S)NrT�r�foo and bar)r
r
rr�rr�path�fdrrr�integrity_protected_file)s(z9TestDetachedIntegrityCheckedFile.integrity_protected_filecCsl|�d�jdd�sJ�|�d�jdd�s,J�t|dd�� }|��dksJJ�Wd�n1s^0YdS)NrT)rrFr$r%)r
�checkr�read�rrr)r(rrr�test_simple0sz,TestDetachedIntegrityCheckedFile.test_simplec	Cs�t|d��}|�d�Wd�n1s*0Yt�t��Lt|dd�� }|��dks^J�Wd�n1sr0YWd�n1s�0YdS)N�ab� extra dataFr$sfoo and bar extra data)�openrrrrrr+)rr)r(rrr�test_corrupted_file6s
(z4TestDetachedIntegrityCheckedFile.test_corrupted_filec	Cs�t|d��}|�d�Wd�n1s*0Yt�t��Vt|dd��*}d}|�t|��|kshJ�Wd�n1s|0YWd�n1s�0YdS)Nr.r/Fr$r%)r0rrrrrr+�len)rr)r(�datarrr� test_corrupted_file_partial_read=s(zATestDetachedIntegrityCheckedFile.test_corrupted_file_partial_read�new_name)Zdifferent_filezdifferent_file.different_extc	Cs�|�|�}|�d��|�|�d��|d�t�t��Ptt|�dd�� }|��dks\J�Wd�n1sp0YWd�n1s�0YdS)Nrrz
.integrityFr$r%)r
�moverrrrr
r+)rrr)r5�new_pathr(rrr�test_renamed_fileEs
z2TestDetachedIntegrityCheckedFile.test_renamed_filecCs�|�d�}|�d��|�d��|�d��|�d��t|�d��}t|dd�� }|��dksbJ�Wd�n1sv0YdS)NZanother_directoryrrFr$r%)�mkdirr
r6r
rr+)rrr)Znew_dirr7r(rrr�test_moved_fileQs
z0TestDetachedIntegrityCheckedFile.test_moved_filecCsN|�d���t|dd�� }|��dks,J�Wd�n1s@0YdS)NrFr$r%)r
�removerr+r,rrrrYsz2TestDetachedIntegrityCheckedFile.test_no_integrityN)rrr r�fixturer)r-r1r4r!r"r8r:rrrrrr#(s

r#c@s@eZdZejdd��Zdd�Zdd�Zej�	dd�d	d
��Z
dS)�%TestDetachedIntegrityCheckedFilePartscCs\t|�d��}t|dd��.}|�d�|�d�|�d�Wd�n1sN0Y|S)NrTr$r%�foopart� other data)r
r
rr�	hash_partr&rrrr)`s

(z>TestDetachedIntegrityCheckedFileParts.integrity_protected_filecCsdt|dd��D}d}|�t|��|ks(J�|�d�|��dksBJ�Wd�n1sV0YdS)NFr$r%r>r?)rr+r2r@�rr)r(�data1rrrr-is

z1TestDetachedIntegrityCheckedFileParts.test_simplec
Cs�t�t���t|dd��^}d}|�t|��|ks4J�t�t��|�d�Wd�n1s^0YWd�n1s|0YWd�n1s�0YdS)NFr$r%Zbarpart)rrrrr+r2r@rArrr�test_wrong_part_namepsz:TestDetachedIntegrityCheckedFileParts.test_wrong_part_name�partial_read)FTc
Cs�t|d��}|�d�Wd�n1s*0Yt�t���t|dd��d}d}z$|�t|��|ksjJ�|�d�Wnty�ds�Jd��Yn0|s�|��Wd�n1s�0YWd�n1s�0YdS)Nr.s%some extra stuff that does not belongFr$r%r>z9This part must not raise, since this part is still valid.)	r0rrrrrr+r2r@)rr)rDr(rBrrr�test_part_independence}s(z<TestDetachedIntegrityCheckedFileParts.test_part_independenceN)rrr rr<r)r-rCr!r"rErrrrr=_s

r=)rZcrypto.file_integrityrrrrr#r=rrrr�<module>s"7