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__/dsdb_schema_attributes.cpython-310.pyc
o

��9a�#�@sHddlZddlZddlZddlZddlmZmZGdd�dejj�Z	dS)�N)�
SCOPE_BASE�LdbErrorcsreZdZ�fdd�Z�fdd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�SchemaAttributesTestCasecs�tt|���tj��|_tj�|j���|_	|j	j
ddtdgd�}|�t
|�d�|ddd|_|ddd|_t|ddd�|_dS)	N��*)�base�
expression�scope�attrs�r�schemaNamingContext�defaultNamingContext�forestFunctionality)�superr�setUp�samba�tests�env_loadparm�lp�
connect_samdb�	samdb_url�samdb�searchr�assertEqual�len�	schema_dn�base_dn�int�forest_level)�self�res��	__class__��D/usr/lib/python3/dist-packages/samba/tests/dsdb_schema_attributes.pyr$szSchemaAttributesTestCase.setUpcstt|���dS�N)rr�tearDown)rr!r#r$r&1sz!SchemaAttributesTestCase.tearDowncCsd}|j�|�dS)Nz@
dn:
changetype: modify
add: schemaUpdateNow
schemaUpdateNow: 1
)r�modify_ldif)r�ldifr#r#r$�_ldap_schemaUpdateNow4sz.SchemaAttributesTestCase._ldap_schemaUpdateNowcCs8|t�dt���}|�dd�}d||jf}|||fS)Nz%s�-rzCN=%s,%s)�time�strftime�gmtime�replacer)r�prefix�obj_name�
obj_ldap_name�obj_dnr#r#r$�_make_obj_names=s
z(SchemaAttributesTestCase._make_obj_namesNcCsTd|d|d|d|d|tt�dd��d}|dur(||d	7}|S)
Nz
dn: zA
objectClass: top
objectClass: attributeSchema
adminDescription: z
adminDisplayName: z
cn: z*
attributeId: 1.3.6.1.4.1.7165.4.6.1.8.%d.ri��z_
attributeSyntax: 2.5.5.12
omSyntax: 64
instanceType: 4
isSingleValued: TRUE
systemOnly: FALSE
�
)�str�random�randint)r�	attr_name�attr_dn�sub_oid�extrar(r#r#r$�_make_attr_ldifCs4�����������z(SchemaAttributesTestCase._make_attr_ldifcCs�|�d�\}}}|�||ddtjj�}|j�|�|��|jjdt	j
d�}|�||d�|�t
|d|�d�|�t|d|d�d�|jjdt	j
d�}|�|d	d
�|ddD��dS)NzschemaAttributes-IdxAttr-r�searchFlags: %d�@ATTRIBUTES�rr	r�CASE_INSENSITIVE�
@INDEXLISTcS�g|]}t|��qSr#�r5��.0�xr#r#r$�
<listcomp>n�zESchemaAttributesTestCase.test_AddIndexedAttribute.<locals>.<listcomp>�@IDXATTR�r3r<r�dsdb�SEARCH_FLAG_ATTINDEXr�add_ldifr)r�ldbr�assertInrrr5�rr8�attr_ldap_namer9r(�attr_res�idx_resr#r#r$�test_AddIndexedAttributeXs

�"z1SchemaAttributesTestCase.test_AddIndexedAttributecCs�|�d�\}}}|�||d�}|j�|�|��|jjdtjd�}|�||d�|�	t
|d|�d�|�	t|d|d�d�|jjdtjd�}|�|d	d
�|ddD��dS)NzschemaAttributes-UnIdxAttr-�r>r?rrr@rAcSrBr#rCrDr#r#r$rG�rHzGSchemaAttributesTestCase.test_AddUnIndexedAttribute.<locals>.<listcomp>rI)
r3r<rrMr)rrNrrOrrr5�assertNotInrPr#r#r$�test_AddUnIndexedAttributeps"z3SchemaAttributesTestCase.test_AddUnIndexedAttributec
Csd|�d�\}}}|�||ddtjj�}|j�|�|��|�d�\}}}|�||ddtjj�}|j�|�|��|jjdt	j
d�}|�||d�|�t
|d|�d	�|�t|d|d�d
�|�||d�|�t
|d|�d	�|�t|d|d�d
�|jjdt	j
d�}	|�|dd
�|	ddD��|�|dd
�|	ddD��dS)NzschemaAttributes-2IdxAttr-�r=zschemaAttributes-Attr-�r>r?rrr@rAcSrBr#rCrDr#r#r$rG�rHzISchemaAttributesTestCase.test_AddTwoIndexedAttributes.<locals>.<listcomp>rIcSrBr#rCrDr#r#r$rG�rHrJ)
rr8rQr9r(�
attr_name2�attr_ldap_name2�attr_dn2rRrSr#r#r$�test_AddTwoIndexedAttributes�s,

�

�"z5SchemaAttributesTestCase.test_AddTwoIndexedAttributescC�Jddgd�}tj�|j|tj�}|j�|�|jjdtjdgd�}|�t	|�d�|�t
|dj�d�|�t	|d�d�|�d|dv�|�t	|dd�d�|�t
|ddd�d�t
j�|j���}|��|��|jjdtjdgd�}|�t	|�d�|�t
|dj�d�|�t	|d�d�|�d|dv�dS)Nr>�HIDDEN��dn�@TEST_EXTRArb�rr	r
rr�rN�Message�	from_dictr�FLAG_MOD_ADD�modifyrrrrr5ra�
assertTruerrrrr�transaction_start�transaction_commit�assertFalse�r�m�msgr �samdb2r#r#r$�test_modify_at_attributes��0���z2SchemaAttributesTestCase.test_modify_at_attributescCr^)NrA�1r`rbrcrrrdrmr#r#r$�test_modify_at_indexlist�rrz1SchemaAttributesTestCase.test_modify_at_indexlistc
Cs|ddgd�}tj�|j|tj�}z|j�|�|�d�WdSty=}z|jd}|�	|tj
�WYd}~dSd}~ww)NrArs)raz@TEST_NOT_EXTRAz9modify of @INDEXLIST with a failed constraint should failr)rNrerfr�FLAG_MOD_DELETErh�failr�argsr�ERR_NO_SUCH_ATTRIBUTE)rrnro�err�enumr#r#r$� test_modify_fail_of_at_indexlist�s�
��z9SchemaAttributesTestCase.test_modify_fail_of_at_indexlistr%)�__name__�
__module__�__qualname__rr&r)r3r<rTrWr]rqrtr{�
__classcell__r#r#r!r$r"s
	
&""r)
r+r6�samba.testsrrNrrr�TestCaserr#r#r#r$�<module>s