
    b                         d Z ddlZddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlZddlZddlZ G d de          Z G d	 d
e          ZdS )z1Tests for samba.xattr_native and samba.xattr_tdb.    N)copytree_with_xattrs)xattr)ndr_pack)SkipTestTestCaseTestCaseInTempDirc                   D    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )
XattrTestsc                     t          j                     t          j        d         }t          j                            |dt          t          dt          j                     z                      z             S )NSELFTEST_PREFIXpytestsi )randomseedosenvironpathjoinstrint)selfr   s     3/usr/lib/python3/dist-packages/samba/tests/xattr.py_tmpfilenamezXattrTests._tmpfilename&   sP    z+,w||D)SVfmoo5M1N1N-O-O"OPPP    c                 b    t           j                            t           j        d         d          S )Nr   eadb.tdb)r   r   r   r   )r   s    r   	_eadbpathzXattrTests._eadbpath+   s     w||BJ'89:FFFr   c                    t           j                                        st                      t	          j                    }d|_        |                                 }t          |d          	                    d           	 t           j        
                    |dt          |                     n# t          $ r t          d          w xY wt          j        |           d S )N   wemptyuser.unittests>the filesystem where the tests are runned do not support XATTR)sambaxattr_nativeis_xattr_supportedr   r   NTACLversionr   openwritewrap_setxattrr   IOErrorr   unlink)r   ntacltempfs      r   test_set_xattr_nativez XattrTests.test_set_xattr_native.   s    !4466 	**!!##UCw'''	],,U4D-5e__> > > > 	] 	] 	][\\\	]
	%s   ?.B. .Cc                    t           j                                        st                      |                                 }d}t          |d                              d           	 t           j                            |d|           t           j                            |d          }| 	                    ||           n# t          $ r t          d          w xY wt          j        |           d S )N   this is a testr   r    r!   r"   )r#   r$   r%   r   r   r(   r)   r*   wrap_getxattrassertEqualr+   r   r,   )r   r.   reftxttexts       r   test_set_and_get_nativez"XattrTests.test_set_and_get_native<   s    !4466 	**!!##"UCw'''	],,U4DfMMM%33E;KLLDT6**** 	] 	] 	][\\\	]
	%s   'AB? ?Cc                    |                                  }|                                 }t          j                    }d|_        t          |d                              d           	 t          j        	                    ||dt          |                     t          j        |           n# t          j        |           w xY wt          j        |           d S Nr   r   r    r!   )r   r   r   r&   r'   r(   r)   r#   	xattr_tdbr*   r   r   r,   r   r.   	eadb_pathr-   s       r   test_set_xattr_tdbzXattrTests.test_set_xattr_tdbJ   s    !!##NN$$	UCw'''	O)))*/1A8E??T T T IeBIe
	)   '/B+ +Cc           
         |                                  }t          j                    }d|_        t	          |d                              d           	 |                     t          t          j	        j
        t          j                            dd          |dt          |                     t          j        |           d S # t          j        |           w xY w)Nr   r   r    nonexistentr   r!   )r   r   r&   r'   r(   r)   assertRaisesr+   r#   r9   r*   r   r   r   r   r,   )r   r.   r-   s      r   test_set_tdb_not_openz XattrTests.test_set_tdb_not_openW   s    !!##UCw'''	gu'D gll=*EEu.A A A IeBIes   AC Cc                    |                                  }|                                 }d}t          |d                              d           	 t          j                            ||d|           t          j                            ||d          }|                     ||           t          j
        |           n# t          j
        |           w xY wt          j
        |           d S Nr1   r   r    r!   )r   r   r(   r)   r#   r9   r*   r2   r3   r   r,   r   r.   r;   r4   r5   s        r   test_set_and_get_tdbzXattrTests.test_set_and_get_tdbc   s    !!##NN$$	"UCw'''	O)))U<L*02 2 2?00E1AC CDT6***IeBIe
	)   AB= =Cc                    |                                  }|                                 }t          j                    }d|_        t          |d                              d           	 t          j        	                    ||dt          |                     t          j        |           n# t          j        |           w xY wt          j        |           d S r8   )r   r   r   r&   r'   r(   r)   r#   
posix_eadbr*   r   r   r,   r:   s       r   test_set_posix_eadbzXattrTests.test_set_posix_eadbr   s    !!##NN$$	UCw'''	**9+02BHUOOU U U IeBIe
	)r=   c                    |                                  }|                                 }d}t          |d                              d           	 t          j                            ||d|           t          j                            ||d          }|                     ||           t          j
        |           n# t          j
        |           w xY wt          j
        |           d S rC   )r   r   r(   r)   r#   rH   r*   r2   r3   r   r,   rD   s        r   test_set_and_get_posix_eadbz&XattrTests.test_set_and_get_posix_eadb   s    !!##NN$$	"UCw'''	**9e=M+13 3 3#11)U2BD DDT6***IeBIe
	)rF   N)__name__
__module____qualname__r   r   r/   r6   r<   rA   rE   rI   rK    r   r   r
   r
   $   s        Q Q Q
G G G      
 
 
        r   r
   c                       e Zd Zd ZdS )TestCopyTreeWithXattrsc                    t          j        | j                   t          j        d           t          j        d           t          j        d           t	          dd          }	 |                    d           |                                 n# |                                 w xY wt          dd           t          j	        d           t          j	        d           d S )Naza/bza/b/cza/b/c/dr   foob)
r   chdirtempdirmkdirr(   r)   closer   shutilrmtree)r   fs     r   test_simplez"TestCopyTreeWithXattrs.test_simple   s    



C  	GGENNNGGIIIIAGGIIIIS#&&&ccs   'B B'N)rL   rM   rN   r]   rO   r   r   rQ   rQ      s#            r   rQ   )__doc__samba.xattr_nativer#   samba.xattr_tdbsamba.posix_eadbsamba.xattrr   samba.dcerpcr   	samba.ndrr   samba.testsr   r   r   r   rZ   r   r
   rQ   rO   r   r   <module>rf      s  $ 8 7             , , , , , ,                     
   				h h h h h h h hV    .     r   