HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/samba/tests/__pycache__/samdb_api.cpython-310.pyc
o

�/a��@sLddlmZddlmZddlmZmZddlZddlZGdd�de�Z	dS)�)�TestCaseInTempDir)�SamDB)�LdbError�ERR_OPERATIONS_ERRORNcsXeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�SamDBApiTestCasecstt|���dS)N)�superr�setUp)�self��	__class__��7/usr/lib/python3/dist-packages/samba/tests/samdb_api.pyrszSamDBApiTestCase.setUpc
s�z
t�|jd�Wnty$}z|�|jtj�WYd}~nd}~wwz
t�|jd�WntyI}z|�|jtj�WYd}~nd}~wwtt|��	�dS)N�/test.db�/existing.db)
�os�remove�tempdir�OSError�assertEqual�errno�ENOENTrr�tearDown)r	�er
rr
rs����zSamDBApiTestCase.tearDownc
Cs�|jd}t|d�}|�d�|��ztd|d�|�d�Wnty>}z|j\}}|�|t	�WYd}~nd}~wwt|d�}|�
�}|�d|�dS)Nr�wzThis is not a tdb file!!!!!!
�tdb://��url�Exception not thrown �r)r�open�write�closer�failr�argsrr�readline)r	�
existing_name�existingr�err�_�contentsrrr
�)test_dont_create_db_existing_non_tdb_file2s



��
z:SamDBApiTestCase.test_dont_create_db_existing_non_tdb_filecCsX|jd}t|d�}|�d�|��td|dd�t|d�}|��}|�d|�dS)	Nr�wbsThis is not a tdb file!!!!!!rr�r�flags�rb�	TDB file
)rrr r!rr$r)r	r%r&r)rrr
�)test_create_db_existing_file_non_tdb_fileIs



z:SamDBApiTestCase.test_create_db_existing_file_non_tdb_filecCsp|jd}td|dd�}d}|�|dd��|�d|�}|�d	|�td|d
�}|�d|�}|�d	|�dS)Nrrrr,�,dn=,cn=test_dont_create_db_existing_tdb_file�%test_dont_create_db_existing_tdb_file��dn�cnr5�%test_dont_create_db_existing_tdb_filer�rr�add�	searchoner�r	r%�initialr4r5�secondrrr
r2\s
�z6SamDBApiTestCase.test_dont_create_db_existing_tdb_filecCsr|jd}td|dd�}d}|�|dd��|�d|�}|�d	|�td|dd�}|�d|�}|�d	|�dS)
Nrrrr,r1r2r3r5r6r7r:rrr
�%test_create_db_existing_file_tdb_filess
�z6SamDBApiTestCase.test_create_db_existing_file_tdb_filec
Cs�ztd|jdd�|�d�Wnty.}z|j\}}|�|t�WYd}~nd}~wwzt|jdd�}|�d�WdStyZ}z|�|j	t	j
�WYd}~dSd}~ww)NrrrrrzNew database file created)rrr"rr#rrr�IOErrorrr)r	�e1r'r(�filerrrr
�test_dont_create_db_new_file�s
����z-SamDBApiTestCase.test_dont_create_db_new_filecCs@td|jddd�t|jddd�}|��}|�d|�dS)Nrrrr,r.)�moder/)rrrr$r)r	r&r)rrr
�test_create_db_new_file�sz(SamDBApiTestCase.test_create_db_new_file)�__name__�
__module__�__qualname__rrr*r0r2r=rArC�
__classcell__rrr
r
rsr)
�samba.testsr�samba.samdbr�ldbrrrrrrrrr
�<module>s