HEX
Server: LiteSpeed
System: Linux s3.sitechai.com 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: workzeni (2217)
PHP: 8.1.32
Disabled: mail, show_source, system, shell_exec, passthru, exec, eval, shell
Upload Files
File: //usr/lib64/python3.6/site-packages/borg/testsuite/__pycache__/remote.cpython-36.opt-1.pyc
3

y��b�@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.6/remote.py�expect_writesz)TestSleepingBandwidthLimiter.expect_writecCst|�S)N)�len)rrrrrr�check_writesz(TestSleepingBandwidthLimiter.check_writecCs4|jtd|j�td�}|jdd�|jdd�dS)N�writer�stest)�setattr�osrrrr)r�monkeypatch�itrrr�test_write_unlimitedsz1TestSleepingBandwidthLimiter.test_write_unlimitedcs�|jtd|j�|jtd�fdd��|jtddd��d�td�}|jdd	�|jdd	�|jdd
�|jdd�|jdd
�|jdd
��d7�|jdd
�|jdd
��d7�|jdd
�|jdd
��d7�|jdd
�|jdd
�dS)NrZ	monotoniccs�S)Nrr)�nowrr�<lambda>%sz9TestSleepingBandwidthLimiter.test_write.<locals>.<lambda>ZsleepcSsdS)Nr)�xrrrr&s�drstests123456s
1234567890�
�1)rrr�timerrr)rrrr)rr�
test_write#s(z'TestSleepingBandwidthLimiter.test_writeN)�__name__�
__module__�__qualname__rrrr%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)�TestRepositoryCacheccsntjjt|�d�|_t|jddd��@}|jtd�d�|jtd�d�|jtd�td	��|VWdQRXdS)
N�
repositoryT)Z	exclusive�creaters1234rs5678�r!)	r�path�join�strZrepository_locationr�putr�bytes)rZtmpdirr*rrrr*IszTestRepositoryCache.repositorycCst|�S)N)r)rr*rrr�cacheRszTestRepositoryCache.cache)r2cCsdS)Nr)rr2rrr�test_simpleVszTestRepositoryCache.test_simplecsF�fdd�}�jtd�td�td�g�}�j}|�_�j�|�_dS)Ncs
d�_dS)Nr)Z
size_limitr)r2rr�query_size_limitisz:TestRepositoryCache.test_backoff.<locals>.query_size_limitrr,r)�get_manyrr4Zbackoff)rr2r4�iteratorZqslr)r2r�test_backoffhs
z TestRepositoryCache.test_backoffc	CsDGdd�d�}|jtd�td�td�g�}td|��WdQRXdS)Nc@s6eZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zd	S)
z4TestRepositoryCache.test_enospc.<locals>.enospc_opencWsdS)Nr)r�argsrrr�__init__�sz=TestRepositoryCache.test_enospc.<locals>.enospc_open.__init__cSs|S)Nr)rrrr�	__enter__�sz>TestRepositoryCache.test_enospc.<locals>.enospc_open.__enter__cSsdS)Nr)r�exc_typeZexc_valZexc_tbrrr�__exit__�sz=TestRepositoryCache.test_enospc.<locals>.enospc_open.__exit__cSsttjd��dS)NZfoo)�OSError�errnoZENOSPC)rrrrrr�sz:TestRepositoryCache.test_enospc.<locals>.enospc_open.writeNcSsdS)Nr)r�nrrr�truncate�sz=TestRepositoryCache.test_enospc.<locals>.enospc_open.truncate)N)r&r'r(r9r:r<rr@rrrr�enospc_open�s
rArrr,z
builtins.open)r5rr)rr2rAr6rrr�test_enospc�s

zTestRepositoryCache.test_enospccCs,|jdd�tj|tj��}td�j|_|S)NZBORG_PASSPHRASEZtestZnone)Zsetenvrr+r
ZMockArgsr	Z
compressor)rr*r�keyrrrrC�szTestRepositoryCache.keycCs |j|�}|j||j|��|S)N)Zid_hashr0Zencrypt)rrCr*rZid_rrr�_put_encrypted_object�s
z)TestRepositoryCache._put_encrypted_objectcCs|j||d�S)Ns1234)rD)rrCr*rrr�H1�szTestRepositoryCache.H1cCs|j||d�S)Ns5678)rD)rrCr*rrr�H2�szTestRepositoryCache.H2cCs|j||td��S)Nr!)rDr1)rrCr*rrr�H3�szTestRepositoryCache.H3cCst||dd�S)NT)�decrypted_cacheZforce_cache)r)rrCr*rrrrH�sz#TestRepositoryCache.decrypted_cache)rHcCs�t|j|||g��|j|||g�}t|j|�d��P}|jdtj�tj|j	�d�dAj
dd�}|jdtj�|j|�|j�WdQRXt
jt��WdQRXdS)Nza+br�littler���rJ)�listr5�openZkey_filename�seek�io�SEEK_END�int�
from_bytes�read�to_bytesrr@�pytestZraisesr
)rrHrErFrGr6rZ	corruptedrrr�test_cache_corruption�s
z)TestRepositoryCache.test_cache_corruptionN)r&r'r(rTZfixturer*r2rr3r7rBrCrDrErFrGrHrUrrrrr)Hs	r))r>rrNr$Z
unittest.mockrrTZremoterrrr*rZ
crypto.keyr�compressr	Zhelpersr
Z	hashindexrrCr
rr)rrrr�<module>s6