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.opt-1.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)Zexpected_fdZ
expected_data��self�fd�data�r�;/usr/lib64/python3.9/site-packages/borg/testsuite/remote.py�expect_writesz)TestSleepingBandwidthLimiter.expect_writecCst|�Sr)�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�timerrrrrr#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)rZtmpdirr1rrrr1IszTestRepositoryCache.repositorycCst|�Sr)r)rr1rrr�cacheRszTestRepositoryCache.cache�r;cCsdSrr)rr;rrr�test_simpleVszTestRepositoryCache.test_simplecsF�fdd�}��td�td�td�g�}�j}|�_���|�_dS)Ncs
d�_dS)Nr)Z
size_limitrr<rr�query_size_limitisz:TestRepositoryCache.test_backoff.<locals>.query_size_limitrr5r)�get_manyrr>Zbackoff)rr;r>�iteratorZqslrr<r�test_backoffhs
z TestRepositoryCache.test_backoffcCsXGdd�d�}|�td�td�td�g�}td|��Wd�n1sJ0YdS)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-r.r/rCrDrFrrKrrrr�enospc_open�s
rLrrr5z
builtins.open)r?rr)rr;rLr@rrr�test_enospc�s
zTestRepositoryCache.test_enospccCs,|�dd�t�|t���}td�j|_|S)NZBORG_PASSPHRASE�testZnone)Zsetenvrr2r
ZMockArgsr	Z
compressor)rr1r�keyrrrrO�szTestRepositoryCache.keycCs |�|�}|�||�|��|Sr)Zid_hashr9Zencrypt)rrOr1rZid_rrr�_put_encrypted_object�s
z)TestRepositoryCache._put_encrypted_objectcCs|�||d�S)Nr3�rP�rrOr1rrr�H1�szTestRepositoryCache.H1cCs|�||d�S)Nr4rQrRrrr�H2�szTestRepositoryCache.H2cCs|�||td��S)Nr()rPr:rRrrr�H3�szTestRepositoryCache.H3cCst||dd�S)NT)�decrypted_cacheZforce_cache)rrRrrrrV�sz#TestRepositoryCache.decrypted_cache)rVcCs�t|�|||g��|�|||g�}t|�|�d��Z}|�dtj�t�|�	�d�dA�
dd�}|�dtj�|�|�|��Wd�n1s�0Yt
�t��Wd�n1s�0YdS)Nza+b����littlerr)�listr?�openZkey_filename�seek�io�SEEK_END�int�
from_bytes�read�to_bytesrrK�pytestZraisesr
)rrVrSrTrUr@rZ	corruptedrrr�test_cache_corruption�s
&z)TestRepositoryCache.test_cache_corruptionN)r-r.r/rbZfixturer1r;rr=rArMrOrPrSrTrUrVrcrrrrr0Hs&






r0)rHrr\r+Z
unittest.mockrrbZremoterrrr1rZ
crypto.keyr�compressr	Zhelpersr
Z	hashindexrrOr
rr0rrrr�<module>s6