
    b(                         d Z ddlmZ ddlZddlmZmZ ddlZddl	Z	 G d de
          Z G d dej        j                  Z G d	 d
ej        j                  ZdS )zOTests for string and unicode handling in PIDL generated bindings
samba.dcerpc.*    )drsblobsN)
ndr_unpackndr_packc                       e Zd ZdS )TestExceptionN)__name__
__module____qualname__     A/usr/lib/python3/dist-packages/samba/tests/dcerpc/string_tests.pyr   r      s        Dr   r   c                   F     e Zd Z fdZ fdZd Zd Zd Zd Zd Z	 xZ
S )StringTestsc                     t          t          |                                            t          j                     t          j                    | _        d S N)superr   setUptallocenable_null_trackingtotal_blocksstartup_blocksself	__class__s    r   r   zStringTests.setUp"   sE    k4  &&(((#%%%$133r   c                    t          t          |                                            t          j                     t          j                    | j        k    r*t          j                     | 	                    d           d S d S )Nz it appears we are leaking memory)
r   r   tearDowngccollectr   r   r   report_fullfailr   s    r   r   zStringTests.tearDown'   sq    k4  ))+++

  D$777   II899999 87r   c                    t          j                    }d|_        d|_        t	          j                     |                     |           |                     |j        d           |                     |j        d           d|_        d|_        |                     |j        d           |                     |j        d           d |_        |                     |j        d           |                     |j                   d S )Nzhello.example.comzgoodbye.example.com )	r   repsFromTo2OtherInfo	dns_name1	dns_name2r   r   assertIsNotNoneassertEqualassertIsNoner   infos     r   test_string_from_pythonz#StringTests.test_string_from_python.   s    ,..,.

T""")<===)>???.,,,)>???,,,$.)))))r   c                 j    	 |                                   t                      # t          $ r Y d S w xY wr   )r+   r   )r   s    r   test_string_with_exceptionz&StringTests.test_string_with_exceptionB   sE    	((***//! 	 	 	DD	s   "$ 
22c                     d } |            }t          j                     |                     |           |                     |j        d           |                     |j        d           d S )Nc                  H    t          j                    } d| _        d| _        | S N1.example.com2.example.com)r   r#   r$   r%   )r*   s    r   get_infoz>StringTests.test_string_from_python_function.<locals>.get_infoJ   s#    022D,DN,DNKr   r1   r2   )r   r   r&   r'   r$   r%   )r   r3   r*   s      r    test_string_from_python_functionz,StringTests.test_string_from_python_functionI   ss    	 	 	 xzz

T"""99999999r   c                    t          j                    }d|_        d|_        t	          j                     |                     |           |                     |j        d           |                     |j        d           |xj        dz  c_        |xj        dz  c_        |                     |j        d           |                     |j        d           ~d S )Nr1   z%s.example.comz.co.nz   z1.example.com.co.nzr2   )r   r#   r$   r%   r   r   r&   r'   r)   s     r   test_string_modify_in_placez'StringTests.test_string_modify_in_placeV   s    ,..()

T"""999)9:::("!)>???999DDr   c                 6   t          j                     t          j                    }d|_        d|_        d |_        	 |`n# t          $ r Y nw xY w|                     |           |                     |j                   |                     |j                   d S r0   )	r   r   r   r#   r$   r%   AttributeErrorr&   r(   r)   s     r   test_string_deletezStringTests.test_string_deleted   s    

,..((	 	 	 	D	 	T"""$.)))T^,,,,,s   A   
AA)r   r	   r
   r   r   r+   r-   r4   r7   r:   __classcell__)r   s   @r   r   r       s        4 4 4 4 4
: : : : :* * *(  : : :  - - - - - - -r   r   c                       e Zd ZdZd ZdS )StringTestsWithoutLeakCheckzWe know that the ndr unpacking test leaves stuff in the
    autofree_context, and we don't want to worry about that. So for
    this test we don't make meory leak assertions.c                 V   t          j                    }d|_        d|_        t	          |          }t          j                     t          t           j        |          }|                     |           | 	                    |j        d           | 	                    |j        d           d S r0   )
r   r#   r$   r%   r   r   r   r   r&   r'   )r   r*   packedinfo_unpackeds       r   test_string_from_ndrz0StringTestsWithoutLeakCheck.test_string_from_ndry   s    ,..(($

"8#@&II]+++0/BBB0/BBBBBr   N)r   r	   r
   __doc__rA   r   r   r   r=   r=   t   s2        6 6C C C C Cr   r=   )rB   samba.dcerpcr   samba.testssamba	samba.ndrr   r   r   r   	Exceptionr   testsTestCaser   r=   r   r   r   <module>rJ      s   $  " ! ! ! ! !     * * * * * * * *  					 	 	 	 	I 	 	 	Q- Q- Q- Q- Q-%+& Q- Q- Q-hC C C C C%+"6 C C C C Cr   