HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/borg/testsuite/__pycache__/remote.cpython-39.pyc
a

HZ�h�@s�ddlZddlZddlZddlZddlmZddlZddlmZm	Z	m
Z
ddlmZddl
mZddlmZddlmZd	d
lmZd	dlmZGdd
�d
�ZGdd�d�ZdS)�N)�patch�)�SleepingBandwidthLimiter�RepositoryCache�cache_if_remote)�
Repository)�PlaintextKey)�CompressionSpec)�IntegrityError�)�H)�TestKeyc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestSleepingBandwidthLimitercCs||_||_dS�N)�expected_fd�
expected_data��self�fd�data�r�;/usr/lib64/python3.9/site-packages/borg/testsuite/remote.py�expect_writesz)TestSleepingBandwidthLimiter.expect_writecCs$||jksJ�||jksJ�t|�Sr)rr�lenrrrr�check_writesz(TestSleepingBandwidthLimiter.check_writecCs4|�td|j�td�}|�dd�|�dd�dS)N�writer��test)�setattr�osrrrr�r�monkeypatch�itrrr�test_write_unlimitedsz1TestSleepingBandwidthLimiter.test_write_unlimitedcs�|�td|j�|�td�fdd��|�tddd��d�td�}|�dd	�|�dd	�|�dd
�|�dd�|�dd
�|�dd
��d7�|�dd
�|�dd
��d7�|�dd
�|�dd
��d7�|�dd
�|�dd
�dS)Nr�	monotoniccs�Srrr�Znowrr�<lambda>%�z9TestSleepingBandwidthLimiter.test_write.<locals>.<lambda>�sleepcSsdSrr)�xrrrr&&r'�drrs123456s
1234567890�
�1)rrr�timerrrr rr%r�
test_write#s(z'TestSleepingBandwidthLimiter.test_writeN)�__name__�
__module__�__qualname__rrr#r.rrrrrsrc@s�eZdZejdd��Zejdd��Zed�dd�Zed�dd	�Z	ed�d
d�Z
ejdd
��Zdd�Zejdd��Z
ejdd��Zejdd��Zejdd��Zed�dd�ZdS)�TestRepositoryCacheccs�tj�t|�d�|_t|jddd��J}|�td�d�|�td�d�|�td�td	��|VWd�n1st0YdS)
N�
repositoryT)Z	exclusive�creater�1234r�5678�r*)	r�path�join�strZrepository_locationr�putr�bytes)rZtmpdirr3rrrr3IszTestRepositoryCache.repositorycCst|�Sr)r)rr3rrr�cacheRszTestRepositoryCache.cache�r=cCs�|�td��dksJ�|jdks$J�|jdks2J�t|�td�g��dgksPJ�|jdks^J�|jdkslJ�t|�td�g��dgks�J�|jdks�J�|jdks�J�|�td��dks�J�|jdks�J�|jdks�J�dS)Nrr5rr)�getr�misses�hits�list�get_many)rr=rrr�test_simpleVszTestRepositoryCache.test_simplecs�fdd�}t��td�td�g��ddgks2J��jdks@J��jdksNJ���td�td�td�g�}t|�dkszJ��j}|�_���|�_�jdks�J�td��jvs�J�td��jvs�J�t|�t	d	�ks�J��j
dks�J�t|�dks�J��j
dk�sJ�dS)
Ncs
d�_dS)Nr)Z
size_limitrr>rr�query_size_limitisz:TestRepositoryCache.test_backoff.<locals>.query_size_limitrrr5r6rr7r*)rBrCrr@�	evictions�nextrEZbackoffr=r<Zslow_misses)rr=rE�iteratorZqslrr>r�test_backoffhs"&z TestRepositoryCache.test_backoffcCs�Gdd�d�}|�td�td�td�g�}t|�dks:J�td|��<t|�dksVJ�|jdksdJ�|jd	ksrJ�Wd�n1s�0Yt|�td
�ks�J�dS)Nc@s6eZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zd	S)
z4TestRepositoryCache.test_enospc.<locals>.enospc_opencWsdSrr)r�argsrrr�__init__�sz=TestRepositoryCache.test_enospc.<locals>.enospc_open.__init__cSs|Srr)rrrr�	__enter__�sz>TestRepositoryCache.test_enospc.<locals>.enospc_open.__enter__cSsdSrr)r�exc_typeZexc_valZexc_tbrrr�__exit__�sz=TestRepositoryCache.test_enospc.<locals>.enospc_open.__exit__cSsttjd��dS)NZfoo)�OSError�errno�ENOSPC)rrrrrr�sz:TestRepositoryCache.test_enospc.<locals>.enospc_open.writeNcSsdSrr)r�nrrr�truncate�sz=TestRepositoryCache.test_enospc.<locals>.enospc_open.truncate)N)r/r0r1rKrLrNrrSrrrr�enospc_open�s
rTrrr7r5z
builtins.openr6rr*)rCrrGrZenospcrFr<)rr=rTrHrrr�test_enospc�s,zTestRepositoryCache.test_enospccCs,|�dd�t�|t���}td�j|_|S)NZBORG_PASSPHRASE�testZnone)Zsetenvrr4r
ZMockArgsr	Z
compressor)rr3r!�keyrrrrW�szTestRepositoryCache.keycCs |�|�}|�||�|��|Sr)Zid_hashr;Zencrypt)rrWr3rZid_rrr�_put_encrypted_object�s
z)TestRepositoryCache._put_encrypted_objectcCs|�||d�S)Nr5�rX�rrWr3rrr�H1�szTestRepositoryCache.H1cCs|�||d�S)Nr6rYrZrrr�H2�szTestRepositoryCache.H2cCs|�||td��S)Nr*)rXr<rZrrr�H3�szTestRepositoryCache.H3cCst||dd�S)NT)�decrypted_cacheZforce_cache)rrZrrrr^�sz#TestRepositoryCache.decrypted_cache)r^cCs�t|�|||g��|�|||g�}t|�dks4J�t|�|�d��Z}|�dtj�t�	|�
�d�dA�dd�}|�dtj�|�|�|�
�Wd�n1s�0Yt�t�� t|�dks�J�Wd�n1s�0YdS)N)�r5za+b����littlerr)r_r6)rBrCrG�openZkey_filename�seek�io�SEEK_END�int�
from_bytes�read�to_bytesrrS�pytestZraisesr
)rr^r[r\r]rHrZ	corruptedrrr�test_cache_corruption�s
&z)TestRepositoryCache.test_cache_corruptionN)r/r0r1rjZfixturer3r=rrDrIrUrWrXr[r\r]r^rkrrrrr2Hs&






r2)rPrrdr-Z
unittest.mockrrjZremoterrrr3rZ
crypto.keyr�compressr	Zhelpersr
Z	hashindexrrWr
rr2rrrr�<module>s6