ó
E®Uc           @   sð   d  Z  d d l Z d d l Z d d l m Z m Z d d l m Z m Z d d l m	 Z	 m
 Z
 d d l Z d d l Z d d l m Z d d l m Z d „  Z d	 „  Z d
 e	 f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   sF   Tests for the samba3sam LDB module, which maps Samba3 LDAP to AD LDAP.iÿÿÿÿN(   t   SCOPE_DEFAULTt
   SCOPE_BASE(   t   Ldbt   substitute_var(   t   TestCaseInTempDirt   env_loadparm(   t   system_session(   t
   attrgetterc         C   sv   d d g } xE | D]= } t  j j t  j j t ƒ | ƒ } t  j j | ƒ r Pq q Wt t  j j | |  ƒ d ƒ j ƒ  S(   Ns   ../../../../../testdata/samba3s   ../../../../testdata/samba3t   r(   t   ost   patht   joint   dirnamet   __file__t   existst   opent   read(   t   filenamet   pathst   pt   datadir(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   read_datafile"   s    	!c         C   s	   | GHd  S(   N(    (   t   lt   text(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt	   ldb_debug+   s    t   MapBaseTestCasec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s!   Base test case for mapping tests.c         C   sŽ   | j  i d d 6| j d 6d | j d 6ƒ | j  i d d 6d d 6ƒ | j  i d	 d 6d
 | j d
 | j g d 6d d g d 6d d 6ƒ d  S(   Ns   @MAP=samba3samt   dns   @FROMs   sambaDomainName=TESTS,s   @TOs   @MODULESs…   rootdse,paged_results,server_sort,asq,samldb,password_hash,operational,objectguid,rdn_name,samba3sam,samba3sid,show_deleted,partitions   @LISTs
   @PARTITIONs   %st	   partitions   @ATTRIBUTESs
   @INDEXLISTt   replicateEntriess   *:t   modules(   t   addt   basednt   basedn_casefold(   t   selft   ldbt   s3t   s4(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   setup_modules2   s    

c            sò   t  ƒ  |  _ |  j j d d ƒ |  j j d d ƒ t t |  ƒ j ƒ  d „  } d „  } t j j |  j	 d ƒ |  _
 d |  j
 |  _ |  j	 ‰  d d ‡  f d	 †  ƒ  Y} | d
 | |  j ƒ |  _ | d | |  j ƒ |  _ |  j j ƒ  |  j j ƒ  d  S(   Nt	   workgroupt   TESTSs   netbios namec         S   s   d | |  f S(   Ns   %s,sambaDomainName=TESTS,%s(    (   R   t   rdn(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   make_dnF   s    c         S   s   d | |  f S(   Ns   %s,%s(    (   R   R(   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt	   make_s4dnI   s    s   test.ldbs   tdb://t   Targetc              sS   e  Z d  Z ‡  f d †  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   sQ   Simple helper class that contains data for a specific SAM
            connection.c            s¤   t  d | d t ƒ  ƒ |  _ |  j j d d ƒ | |  _ t j |  j | ƒ j ƒ  |  _ i |  j d 6|  _	 t
 j j ˆ  d |  j ƒ |  _ d |  j |  _ | |  _ d  S(   Nt   lpt   session_infot   skip_allocate_sidst   truet   BASEDNs   %s.ldbs   tdb://(   R   R   t   dbt
   set_opaqueR   R"   t   Dnt   get_casefoldR    t	   substvarsR	   R
   R   t   filet   urlt   _dn(   R!   R   R   R,   (   t   tempdir(    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   __init__U   s    	c         S   s   |  j  |  j | ƒ S(   N(   R8   R   (   R!   R(   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR   _   s    c         S   s   |  j  j |  j ƒ S(   N(   R1   t   connectR7   (   R!   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR;   b   s    c         S   s   |  j  t | ƒ ƒ d  S(   N(   t   add_ldifR   (   R!   R
   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt
   setup_datae   s    c         S   s   t  | |  j ƒ S(   N(   R   R5   (   R!   R   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   substh   s    c         S   s   |  j  j |  j | ƒ ƒ d  S(   N(   R1   R<   R>   (   R!   t   ldif(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR<   k   s    c         S   s   |  j  j |  j | ƒ ƒ d  S(   N(   R1   t   modify_ldifR>   (   R!   R?   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR@   n   s    (
   t   __name__t
   __module__t   __doc__R:   R   R;   R=   R>   R<   R@   (    (   R9   (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR+   Q   s   
					s   dc=vernstok,dc=nls   cn=Samba3Sam(    (   R   R,   t   sett   superR   t   setUpR	   R
   R   R9   t   ldbfilet   ldburlt   samba4t   samba3R;   (   R!   R)   R*   R+   (    (   R9   s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyRF   @   s    			 c         C   sž   t  j |  j ƒ t  j |  j j ƒ t  j |  j j ƒ d |  j } t  j j | d ƒ } t  j j | ƒ r‡ t  j | ƒ t  j	 | ƒ n  t
 t |  ƒ j ƒ  d  S(   Ns   %s.ds   metadata.tdb(   R	   t   unlinkRG   RJ   R6   RI   R
   R   R   t   rmdirRE   R   t   tearDown(   R!   t   pdirt   mdata(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyRM   w   s    c         C   sQ   t  j j t  j j j t | d ƒ ƒ } t  j j j | ƒ } |  j | | ƒ d  S(   Ni    (   t   sambat   ndrt
   ndr_unpackt   dcerpct   securityt   dom_sidt   strt   assertEquals(   R!   R   t   ndr_sidt   sid_obj1t   sid_obj2(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   assertSidEquals‚   s    (   RA   RB   RC   R%   RF   RM   R[   (    (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR   /   s
   		7	t   Samba3SamTestCasec           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sÐ   t  t |  ƒ j ƒ  t |  j d |  j d t ƒ  ƒ} | j d d ƒ |  j j	 d ƒ t
 d ƒ } | j |  j j | ƒ ƒ |  j | |  j |  j ƒ ~ t |  j d |  j d t ƒ  ƒ|  _ |  j j d d ƒ d  S(   NR,   R-   R.   R/   s   samba3.ldifs   provision_samba3sam.ldif(   RE   R\   RF   R   RH   R,   R   R2   RJ   R=   R   R<   RI   R>   R%   R"   (   R!   R"   R?   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyRF   ‹   s    !$c         C   sG   |  j  j d d ƒ } |  j t | ƒ d ƒ |  j | d d d ƒ d S(   s"   Looking up by non-mapped attributet
   expressions   (cn=Administrator)i   i    t   cnt   AdministratorN(   R"   t   searchRW   t   len(   R!   t   msg(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_search_non_mapped—   s    c         C   sM   |  j  j d d ƒ } |  j t | ƒ d ƒ |  j t | d d ƒ d ƒ d S(   s   Looking up by mapped attributeR]   s   (name=Backup Operators)i   i    t   names   Backup OperatorsN(   R"   R`   RW   Ra   RV   (   R!   Rb   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyRc      s    c         C   s/   |  j  j d d ƒ } |  j t | ƒ d ƒ d S(   s+   Looking up by old name of renamed attributeR]   s   (displayName=Backup Operators)i    N(   R"   R`   RW   Ra   (   R!   Rb   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_old_name_of_renamed£   s    c         C   s¨   |  j  j d d ƒ } |  j t | ƒ d ƒ |  j t | d j ƒ d ƒ |  j d | d k ƒ |  j d | d d ƒ t | d d ƒ } |  j | t d	 g ƒ ƒ d
 S(   s&   Looking up mapped entry containing SIDR]   s   (cn=Replicator)i   i    s)   cn=Replicator,ou=Groups,dc=vernstok,dc=nlt	   objectSids.   S-1-5-21-4231626423-2410014848-2360679739-1052t   objectClasst   groupN(	   R"   R`   RW   Ra   RV   R   t
   assertTrueR[   RD   (   R!   Rb   t   oc(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_mapped_containing_sid¨   s    	c         C   sW   |  j  j d d ƒ } |  j t g  | D] } t | j ƒ ^ q% ƒ t d d g ƒ ƒ d S(   s   Looking up by objectClassR]   s'   (|(objectClass=user)(cn=Administrator))s1   unixName=Administrator,ou=Users,dc=vernstok,dc=nls*   unixName=nobody,ou=Users,dc=vernstok,dc=nlN(   R"   R`   RW   RD   RV   R   (   R!   Rb   t   m(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_search_by_objclass´   s    +c         C   sâ  |  j  j i d d 6d d 6d d 6d d 6d	 d
 6ƒ |  j  j d d d d d t d d d d d
 g ƒ } |  j t | ƒ d ƒ |  j t | d d
 ƒ d	 ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j  j i d d 6d d 6d d 6d d 6d d 6ƒ |  j  j d d d d d d d g ƒ } |  j t | ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j  j d d d d d d d g ƒ } |  j t | ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j  j d d d d d d d g ƒ } |  j t | ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j j j d d ƒ } |  j	 t | ƒ d k ƒ |  j t | d d ƒ d ƒ |  j t | d d  ƒ d ƒ |  j  j
 d! ƒ |  j  j d d ƒ } |  j	 t | ƒ d k ƒ |  j t | d d ƒ d ƒ |  j t | d d" ƒ d# ƒ |  j  j
 d$ ƒ |  j  j d d ƒ } |  j	 t | ƒ d k ƒ |  j t | d d" ƒ d ƒ |  j  j
 d% ƒ |  j  j d d ƒ } |  j	 t | ƒ d k ƒ |  j	 d" | d k ƒ |  j  j d d& ƒ |  j  j d d' ƒ } |  j t | ƒ d ƒ |  j t | d j ƒ d& ƒ |  j  j d& ƒ |  j  j d d' ƒ } |  j t | ƒ d ƒ d  S((   Ns   cn=FooR   t   bart   foot   Bliet   blaht   FooR^   t   TRUEt   showInAdvancedViewOnlyR]   s   (cn=Foo)t   baset   scopet   attrsi   i    s%   cn=Niemand,cn=Users,dc=vernstok,dc=nlt   userRg   t   bint   unixNamet   geheimt   sambaUnicodePwdt   Niemands   (unixName=bin)s)   (&(unixName=bin)(sambaUnicodePwd=geheim))s)   (|(unixName=bin)(sambaUnicodePwd=geheim))s   (cn=Niemand)t   sambaSIDs.   S-1-5-21-4231626423-2410014848-2360679739-2001t   displayNamesa   
dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
changetype: modify
add: description
description: Blah
t   descriptiont   Blahse   
dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
changetype: modify
replace: description
description: Blie
sR   
dn: cn=Niemand,cn=Users,dc=vernstok,dc=nl
changetype: modify
delete: description
s&   cn=Niemand2,cn=Users,dc=vernstok,dc=nls   (cn=Niemand2)(   R"   R   R`   R   RW   Ra   RV   RJ   R1   Ri   R@   t   renameR   t   delete(   R!   Rb   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_s3sam_modify»   s‚    				(   RA   RB   RF   Rc   Re   Rk   Rm   R„   (    (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR\   ‰   s   						t   MapTestCasec           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sÀ   t  t |  ƒ j ƒ  t |  j d |  j d t ƒ  ƒ} | j d d ƒ t d ƒ } | j	 |  j
 j | ƒ ƒ |  j | |  j |  j
 ƒ ~ t |  j d |  j d t ƒ  ƒ|  _ |  j j d d ƒ d  S(   NR,   R-   R.   R/   s   provision_samba3sam.ldif(   RE   R…   RF   R   RH   R,   R   R2   R   R<   RI   R>   R%   RJ   R"   (   R!   R"   R?   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyRF   4  s    !$c         C   sI%  |  j  j j i d |  j  j d 6d d g d 6d d 6d d	 6d
 d 6ƒ |  j j d |  j j d ƒ d ƒ |  j j d |  j j d ƒ d ƒ |  j j i	 |  j j d ƒ d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6ƒ |  j j i	 |  j j d ƒ d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6ƒ |  j  j j i	 |  j  j d  ƒ d 6d! d 6d" d 6d d	 6d d# 6d d$ 6d d 6d% d 6d& d' 6ƒ |  j  j j i |  j  j d( ƒ d 6d d 6d) d 6d d	 6d d# 6d d$ 6d d 6ƒ |  j  j j i |  j  j d* ƒ d 6d d 6d+ d 6d d	 6d d# 6d d$ 6d d 6ƒ |  j j d  ƒ } |  j j | d, t	 d- d d g ƒ} |  j
 t | ƒ d. ƒ |  j
 t | d/ j ƒ | ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j  j d  ƒ } |  j  j j | d, t	 d- d d d$ g ƒ} |  j
 t | ƒ d. ƒ |  j
 t | d/ j ƒ | ƒ |  j d | d/ k ƒ |  j d | d/ k ƒ |  j
 t | d/ d$ ƒ d ƒ |  j j d ƒ } |  j j | d, t	 d- d d g ƒ} |  j
 t | ƒ d. ƒ |  j
 t | d/ j ƒ | ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d ƒ d ƒ |  j  j d ƒ } |  j  j j | d, t	 d- d d d$ g ƒ} |  j
 t | ƒ d. ƒ |  j
 t | d/ j ƒ | ƒ |  j d | d/ k ƒ |  j d | d/ k ƒ |  j
 t | d/ d$ ƒ d ƒ |  j j d0 d1 d, t d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d ƒ ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 d4 d, t d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d* ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 d5 d, t d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 d6 d7 dY d, t d- d d d8 g ƒ } |  j
 t | ƒ d9 ƒ t | d3 t d ƒ ƒ} |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j d% | d. d8 ƒ |  j d8 | d. k ƒ |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j d% | d/ d8 ƒ |  j d8 | d/ k ƒ |  j j d0 d: d- d d d; g ƒ } |  j
 t | ƒ d. ƒ |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d; ƒ d< ƒ |  j j d0 d= d- d d g ƒ } |  j
 t | ƒ d/ ƒ d d d g } |  j j d0 d> d- | ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d d/ ƒ d? ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d d/ ƒ d? ƒ |  j j d0 d@ d- | ƒ } |  j
 t | ƒ dA ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 | d/ d d/ d? ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ t d g ƒ ƒ |  j
 t | d2 j ƒ |  j j d ƒ ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d d/ ƒ d? ƒ |  j j d0 dB d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d ƒ ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 dC d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 dD d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d ƒ ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ d d g } |  j j d0 dE d- | ƒ } |  j
 t | ƒ d/ ƒ |  j j d0 dF d- | ƒ } |  j
 t | ƒ d/ ƒ |  j j d0 dG d- d d g ƒ } |  j
 t | ƒ d2 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d ƒ ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 dH d- d d g ƒ } |  j
 t | ƒ dA ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d ƒ ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d ƒ d ƒ |  j j d0 dI d- d d g ƒ } |  j
 t | ƒ dA ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d( ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d ƒ ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d ƒ d ƒ |  j j d0 dJ d- d d g ƒ } |  j
 t | ƒ d/ ƒ |  j j d0 dK d- d d g ƒ } |  j
 t | ƒ dL ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d* ƒ ƒ |  j d | d2 k ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | dA j ƒ |  j j d ƒ ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | dA d ƒ d ƒ |  j j d0 dM d- d d g ƒ } |  j
 t | ƒ d9 ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d* ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j j d0 dN d- d d g ƒ } |  j
 t | ƒ dL ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d* ƒ ƒ |  j d | d2 k ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | dA j ƒ |  j j d ƒ ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | dA d ƒ d ƒ |  j j d0 dO d- d d g ƒ } |  j
 t | ƒ dL ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d( ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d* ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d ƒ ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | dA j ƒ |  j j d ƒ ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | dA d ƒ d ƒ |  j j d0 dP d- d d g ƒ } |  j
 t | ƒ dL ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d* ƒ ƒ |  j d | d2 k ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | dA j ƒ |  j j d ƒ ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | dA d ƒ d ƒ |  j j d0 dQ d- d d g ƒ } t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d* ƒ ƒ |  j d | d2 k ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | dA j ƒ |  j j d ƒ ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | dA d ƒ d ƒ |  j j d0 dR d- d d g ƒ } |  j
 t | ƒ dS ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d* ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d ƒ ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d ƒ ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d ƒ d ƒ |  j j d0 dT d- d d g ƒ } |  j
 t | ƒ dS ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d* ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d ƒ ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | d2 d ƒ d ƒ |  j j d0 dU d- d d g ƒ } |  j
 t | ƒ dV ƒ t | d3 t d ƒ ƒ} |  j
 t | d/ j ƒ |  j j d  ƒ ƒ |  j d | d/ k ƒ |  j
 t | d/ d ƒ d ƒ |  j
 t | d. j ƒ |  j j d( ƒ ƒ |  j d | d. k ƒ |  j
 t | d. d ƒ d ƒ |  j
 t | d2 j ƒ |  j j d* ƒ ƒ |  j d | d2 k ƒ |  j
 t | d2 d ƒ d ƒ |  j
 t | dA j ƒ |  j j d ƒ ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | dA d ƒ d ƒ |  j
 t | d9 j ƒ |  j j d ƒ ƒ |  j
 t | d9 d ƒ d ƒ |  j
 t | d9 d ƒ d ƒ g  d" d) d+ dW d d g D] } |  j j dX | ƒ ^ q%} x | D] } |  j j | ƒ q+%WdY S(Z   s$   Running search tests on mapped data.s   sambaDomainName=TESTS,R   t   sambaDomaint   topt   objectclasss)   S-1-5-21-4231626423-2410014848-2360679739R~   t   2000t   sambaNextRidR'   t   sambaDomainNames   
dn: s   cn=Domain Userss^   
objectClass: group
cn: Domain Users
objectSid: S-1-5-21-4231626423-2410014848-2360679739-513
s   cn=Xs¡   
objectClass: user
cn: X
codePage: x
revision: x
dnsHostName: x
nextRid: y
lastLogon: x
description: x
objectSid: S-1-5-21-4231626423-2410014848-2360679739-1052
s   cn=YRg   t   YR^   t   xt   codePaget   revisiont   yt   dnsHostNamet   nextRidt	   lastLogonR€   s   cn=Zt   Zt   zs   cn=At   posixAccountt   At   sambaBadPasswordCountt   sambaLogonTimes.   S-1-5-21-4231626423-2410014848-2360679739-1052s-   S-1-5-21-4231626423-2410014848-2360679739-512t   sambaPrimaryGroupSIDs   cn=Bt   Bs   cn=Ct   CRv   Rw   i   i    R]   s   (revision=x)i   t   keys   (description=y)s   (badPwdCount=x)s   (objectSid=*)Ru   Rf   i   s   (primaryGroupID=512)t   primaryGroupIDt   512s   (sambaBadPasswordCount=*)s   (objectClass=user)Rx   s$   (|(objectClass=user)(badPwdCount=x))i   s   (&(codePage=x)(revision=x))s   (&(lastLogon=x)(description=x))s   (&(codePage=x)(description=x))s   (&(codePage=x)(nextRid=x))s   (&(revision=x)(lastLogon=z))s   (|(revision=x)(dnsHostName=x))s   (|(badPwdCount=x)(lastLogon=x))s   (|(revision=x)(lastLogon=y))s   (|(codePage=y)(nextRid=z))s   (!(revision=x))i   s   (!(description=x))s   (!(&(codePage=x)(revision=x)))s"   (!(&(lastLogon=x)(description=x)))s!   (!(&(codePage=x)(description=x)))s!   (!(|(revision=x)(dnsHostName=x)))s"   (!(|(badPwdCount=x)(lastLogon=x)))i   s   (!(|(revision=x)(lastLogon=y)))sP   (|(&(revision=x)(dnsHostName=x))(!(&(description=x)(nextRid=y)))(badPwdCount=y))i   t   Xs   cn=%sN(   RJ   R1   R   R   R"   R<   RI   R   R`   R   RW   Ra   RV   Ri   R    t   sortedR   t   NoneR[   RD   t   assertFalseRƒ   (   R!   R   t   resRw   t   nt   dns(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_map_search?  sþ   		
))))))0)	)	))")"	))')"))))))		))))))))))))))))))))))))))))))))))))!)))));c         C   s6  d } |  j  j i | d 6d d 6d d 6d d 6d d	 6ƒ d d d	 g } |  j  j | d
 t d | ƒ} |  j t | ƒ d ƒ |  j t | d j ƒ | ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d	 ƒ d ƒ |  j j	 j d d d
 t
 d | ƒ } |  j t | ƒ d ƒ |  j j	 j d d d
 t
 d | ƒ } |  j t | ƒ d ƒ d | d } |  j  j | ƒ |  j  j | d
 t d | ƒ} |  j t | ƒ d ƒ |  j t | d j ƒ | ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d	 ƒ d ƒ d } |  j  j | | ƒ |  j  j | d
 t d | ƒ} |  j t | ƒ d ƒ |  j t | d j ƒ | ƒ |  j t | d d ƒ d ƒ |  j t | d d ƒ d ƒ |  j t | d d	 ƒ d ƒ |  j  j | ƒ |  j  j | d
 t ƒ} |  j t | ƒ d ƒ d S(   s   Modification of local records.s   cn=test,dc=idealx,dc=orgR   t   testR^   Rn   Ro   t   1R   R€   Rv   Rw   i   i    R]   s	   (cn=test)s   
dn: s=   
replace: foo
foo: baz
replace: description
description: foo
t   bazs   cn=toast,dc=idealx,dc=orgN(   R"   R   R`   R   RW   Ra   RV   R   RI   R1   R    RJ   R@   R‚   Rƒ   (   R!   R   Rw   R¤   R?   t   dn2(    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_map_modify_local,  sN    c         C   s¬  |  j  j d ƒ } |  j j d ƒ } |  j j j i | d 6d d 6d d 6d d 6d	 d
 6ƒ |  j j j | d t d d d d
 g ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d
 ƒ d	 ƒ d d d g } |  j
 j | d t d | d d ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d	 ƒ |  j  j j | d t d | ƒ} |  j t | ƒ d ƒ d | d } |  j
 j | ƒ |  j
 j | d t d d d d g ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d	 ƒ |  j j j | d t d d d d
 g ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d
 ƒ d	 ƒ |  j  j d ƒ } |  j
 j | | ƒ | } |  j
 j | d t d d d d g ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d	 ƒ |  j j d ƒ } |  j j j | d t d d d d
 g ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d
 ƒ d	 ƒ |  j
 j | ƒ |  j
 j | d t ƒ} |  j t | ƒ d ƒ |  j j j | d t ƒ} |  j t | ƒ d ƒ d S(   s-   Modification of remote data of remote recordss   cn=testR   R¨   R^   Ro   R€   t   3R˜   t   1001RŠ   Rv   Rw   i   i    t   badPwdCountR’   R]   t    s   
dn: sL   
replace: description
description: test
replace: badPwdCount
badPwdCount: 4
t   4s   cn=toastN(   RI   R   RJ   R1   R   R`   R   RW   Ra   RV   R"   R@   R‚   Rƒ   (   R!   R   R«   R¤   Rw   R?   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_map_modify_remote_remoteh  s~    $!c         C   s7  |  j  j d ƒ } |  j j d ƒ } |  j j j i | d 6d d 6d d 6d d 6d	 d
 6ƒ d | d } |  j j | ƒ d d g } |  j j | d t d | ƒ} |  j	 t
 | ƒ d ƒ |  j	 t | d j ƒ | ƒ |  j	 t | d d ƒ d ƒ |  j	 t | d d ƒ d ƒ |  j j j | d t d | ƒ} |  j	 t
 | ƒ d ƒ |  j	 t | d j ƒ | ƒ |  j	 t | d d ƒ d ƒ |  j d | d k ƒ |  j  j j | d t d | ƒ} |  j	 t
 | ƒ d ƒ |  j	 t | d j ƒ | ƒ |  j d | d k ƒ |  j	 t | d d ƒ d ƒ |  j j | ƒ d S(   s,   Modification of local data of remote recordss   cn=testR   R¨   R^   Ro   R€   R­   R˜   R®   RŠ   s   
dn: sC   
add: revision
revision: 1
replace: description
description: test

R   Rv   Rw   i   i    R©   N(   RI   R   RJ   R1   R   R"   R@   R`   R   RW   Ra   RV   Ri   Rƒ   (   R!   R   R«   R?   Rw   R¤   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_map_modify_remote_local¿  s6    !!c      	   C   s’  |  j  j d ƒ } |  j j d ƒ } |  j j i | d 6d d 6d d 6d d 6d	 d
 6d d 6ƒ d d d
 d g } |  j j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d
 ƒ d	 ƒ |  j t	 | d d ƒ d ƒ |  j  j
 j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j d | d k ƒ |  j d | d k ƒ |  j d
 | d k ƒ |  j t	 | d d ƒ d ƒ d d d d g } |  j j
 j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d	 ƒ |  j d | d k ƒ d | d } |  j j | ƒ d d d
 d g } |  j j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d
 ƒ d	 ƒ |  j t	 | d d ƒ d ƒ |  j  j
 j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j d | d k ƒ |  j d | d k ƒ |  j d
 | d k ƒ |  j t	 | d d ƒ d ƒ d d d d g } |  j j
 j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d	 ƒ |  j d | d k ƒ |  j  j d ƒ } |  j j | | ƒ | } d d d
 d g } |  j j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d
 ƒ d	 ƒ |  j t	 | d d ƒ d ƒ |  j  j
 j | d t d | ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j d | d k ƒ |  j d | d k ƒ |  j d
 | d k ƒ |  j t	 | d d ƒ d ƒ |  j j d ƒ } |  j j
 j | d t d d d d d g ƒ} |  j t | ƒ d ƒ |  j t	 | d j ƒ | ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d ƒ |  j t	 | d d ƒ d	 ƒ |  j d | d k ƒ |  j j | ƒ |  j j | d t ƒ} |  j t | ƒ d ƒ |  j  j
 j | d t ƒ} |  j t | ƒ d ƒ |  j j
 j | d t ƒ} |  j t | ƒ d ƒ d S(   s%   Testing modification of split recordss   cn=testR   R¨   R^   Ro   R€   R­   R¯   R®   R’   R©   R   Rv   Rw   i   i    R˜   RŠ   s   
dn: sj   
replace: description
description: test
replace: badPwdCount
badPwdCount: 4
replace: revision
revision: 2
R±   t   2s   cn=toastN(   RI   R   RJ   R"   R   R`   R   RW   Ra   RV   R1   Ri   R@   R‚   Rƒ   (   R!   R   R«   Rw   R¤   R?   (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   test_map_modify_splitë  s¾    !		!!		!!	(   RA   RB   RF   R§   R¬   R²   R³   Rµ   (    (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyR…   2  s   		ÿ î	<	W	,(   RC   R	   R"   R    R   RP   R   R   t   samba.testsR   R   t   samba.dcerpc.securityt	   samba.ndrt
   samba.authR   t   operatorR   R   R   R   R\   R…   (    (    (    s9   /usr/lib/python2.7/dist-packages/samba/tests/samba3sam.pyt   <module>   s   			Z©