mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

andrug
03.46.2007 a5d79535f9e4b07ad85e3670615c7f6216aed464
new testsuite
10 files added
3329 ■■■■■ changed files
opendj-sdk/opends/tests/functional-tests/testcases/groups/.mytest.xml.swp patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_cleanup.xml 103 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_dynamic.xml 484 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_lib.xml 85 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_setup.xml 121 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_static_member.xml 770 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_static_uniquemember.xml 767 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_virtual_static.xml 744 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/groups.xml 80 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/mytest.xml 175 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/tests/functional-tests/testcases/groups/.mytest.xml.swp
Binary files differ
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_cleanup.xml
New file
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="group_cleanup"/>
  <function name="group_cleanup">
    <function-map-args>
      <function-arg-def name="stopDS" type="optional" default="True">
        <function-arg-description>
          Optional stop the Directory Server
        </function-arg-description>
        <function-arg-property name="type" value="boolean"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <block name="'cleanup'">
        <sequence>
          <if expr="stopDS == True">
          <block name="'Block DS Process Stop'">
          <!--- Stop DS -->
            <sequence>
              <message>
                 '------ Stop DS running on port %s' % (DIRECTORY_INSTANCE_PORT)
              </message>
              <call function="'StopDsWithScript'">
                { 'location'  : STAF_REMOTE_HOSTNAME,
                  'dsHost'    : DIRECTORY_INSTANCE_HOST,
                  'dsPort'    : DIRECTORY_INSTANCE_PORT,
                  'dsBindDN'  : DIRECTORY_INSTANCE_DN,
                  'dsBindPwd' : DIRECTORY_INSTANCE_PSWD }
              </call>
              <call function="'checkRC'">
                  { 'returncode' : RC ,
                    'result'     : STAXResult }
              </call>
            </sequence>
          <!--- End Block DS Process Stop -->
          </block>
          </if>
          <block name="'Block Remove DS Topology'">
          <!-- Remove  the topology created for the test suite -->
            <sequence>
              <message>
                 '------ Remove DS topology created for the Test Suite'
              </message>
              <call function="'removeTopology'"/>
              <call function="'checkRC'">
                  { 'returncode' : RC ,
                    'result'     : STAXResult }
              </call>
            </sequence>
          <!-- End Block Remove DS Topology-->
          </block>
        </sequence>
      </block>
     </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_dynamic.xml
New file
@@ -0,0 +1,484 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main_dynamicgroup"/>
  <function name="main_dynamicgroup">
    <sequence>
      <block name="'dynamicgroup'">
        <sequence>
          <script>
            applicationDn='uid=my_application,dc=groups,dc=com'
            applicationPswd='pw_my_application'
            dynamicGroupDn='cn=my_dynamicgroup1,dc=groups,dc=com'
            newDynamicGroup='my_newDynamicGroup'
            newDynamicGroupDn='cn=%s,dc=groups,dc=com' % (newDynamicGroup)
            newDynamicGroupPswd='pw_%s' % (newDynamicGroup)
            user0='user_00'
            user0Dn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user0)
            user0Pswd='pw_00'
            user1='user_01'
            user1Dn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user1)
            user1Pswd='pw_01'
            user2='user_02'
            user2Dn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user2)
            user2Pswd='pw_02'
            user2Add='user_22'
            user2AddDn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user2Add)
            user2AddPswd='pw_22'
            user2AddRenamed='%s_bis' % (user2Add)
            user2AddRenamedDn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user2AddRenamed)
          </script>
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group']='groups'
            CurrentTestPath['suite']=STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Suite information
          #@TestSuiteName       Group test suite
          #@TestSuitePurpose    Test this feature
          #@TestSuiteID         Groups Tests
          #@TestSuiteGroup      Dynamic Group
          #@TestGroup           Dynamic Group
          #@TestScript          group_dynamic.xml
          #@TestHTMLLink        http://opends.dev.java.net/
          -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_setup.xml' % (TESTS_DIR)"/>
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_lib.xml' % (TESTS_DIR)"/>
          <call function="'group_setup'"> { 'startDS' : True } </call>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: add a dynamic group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: add a dynamic group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                listAttr = []
                listAttr.append('cn:%s' % newDynamicGroup)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:groupofurls')
                listAttr.append('description:this is the description of %s' % newDynamicGroup)
                listAttr.append('memberurl:ldap:///ou=dynamic,dc=groups,dc=com??sub?(uid=*0*)')
              </script>
              <message>
                '++++ Application add group entry %s' % newDynamicGroupDn
              </message>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : newDynamicGroupDn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application do a search to check the entry has been created'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newDynamicGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user0Dn ,
                  'string2find' : newDynamicGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: delete a dynamic group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: delete a dynamic group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Delete the group entry %s' % newDynamicGroupDn
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newDynamicGroupDn,
                }
              </call>
              <message>
                '++++ Check the group entry %s no more exist' % newDynamicGroup
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newDynamicGroupDn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 32 }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user0Dn ,
                  'string2find' : newDynamicGroupDn ,
                  'nbExpected'  : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: no group user do a search
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: no group user do a search'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ %s search itself (should PASS as not a member of dynamic group)' % user1
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user1Dn ,
                'dsInstancePswd'   : user1Pswd ,
                'dsBaseDN'         : user1Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 0 }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : dynamicGroupDn ,
                  'nbExpected'  : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: group user do a search
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: group user do a search'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ %s search itself (should be refused as dynamic group does not have the permission)' % user2
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user2Dn ,
                'dsInstancePswd'   : user2Pswd ,
                'dsBaseDN'         : user2Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user2Dn ,
                  'string2find' : dynamicGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: application add entry that belong to a group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: application add entry that belong to a group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application add a new user %s / %s ' % (user2AddDn,user2AddPswd)
              </message>
              <script>
                listAttr = []
                listAttr.append('uid:%s' % user2Add)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:person')
                listAttr.append('objectclass:inetOrgPerson')
                listAttr.append('cn:%s' % user2Add)
                listAttr.append('sn:sn of user %s' % user2Add)
                listAttr.append('description:this is the description of %s' % user2Add)
                listAttr.append('userPassword:%s' % user2AddPswd)
              </script>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : user2AddDn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ %s search itself (should be refused as dynamic group does not have permission)' % user2Add
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user2AddDn ,
                'dsInstancePswd'   : user2AddPswd ,
                'dsBaseDN'         : user2AddDn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user2AddDn ,
                  'string2find' : dynamicGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: application rename entry that belong to a group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: application rename entry that belong to a group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application rename %s into %s ' % (user2Add,user2AddRenamed)
              </message>
              <call function="'modifyDn'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : user2AddDn ,
                'newRDN'                    : user2AddRenamed,
                'deleteOldRDN'          : 1 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ %s search itself (should be refused as dynamic group does not have permission)' % user2AddRenamed
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user2AddRenamedDn ,
                'dsInstancePswd'   : user2AddPswd ,
                'dsBaseDN'         : user2AddRenamedDn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user2AddRenamedDn ,
                  'string2find' : dynamicGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Dynamic Group Tests
          #@TestName            Group: Dynamic: application delete entry belonging to a group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Dynamic: application delete entry belonging to a group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application delete user %s' % user2Add
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : user2AddDn
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check the entry %s no more exist' % user2Add
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : user2AddDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'dn',
                'expected'               : 32 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ %s do a search (should fail)' % user2Add
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user2AddDn ,
                'dsInstancePswd'   : user2AddPswd ,
                'dsBaseDN'         : user2AddDn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 49 }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
              file="'%s/testcases/groups/group_cleanup.xml' % (TESTS_DIR)"/>
          <call function="'group_cleanup'"> { 'stopDS' : True } </call>
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_lib.xml
New file
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <function name="CheckIsMemberOf">
    <function-prolog>
      check an entry got ismemberof attribute with a specific value
    </function-prolog>
    <function-map-args>
      <function-arg-def name="baseDn" type="required">
        <function-arg-description>
          entry to search
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="string2find" type="required">
        <function-arg-description>
          check if string appears in ldapsearch result
        </function-arg-description>
        <function-arg-property name="type" value="string"/>
      </function-arg-def>
      <function-arg-def name="nbExpected" type="optional" default="1">
        <function-arg-description>
          number of expected sub-string that must be in ldapsearch result
        </function-arg-description>
        <function-arg-property name="type" value="integer"/>
      </function-arg-def>
    </function-map-args>
    <sequence>
      <message>
        '++++ %s searchs isMemberOf attribute for entry %s' % (DIRECTORY_INSTANCE_DN,baseDn)
      </message>
      <call function="'ldapSearchWithScript'">
        { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
        'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
        'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
        'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
        'dsBaseDN'         : baseDn ,
        'dsFilter'         : 'objectclass=*'  ,
        'dsAttributes'     : 'isMemberOf',
        'expected'               : 0 }
      </call>
      <message>
        '++++ Check in ldapsearch result that string %s appears %s time(s)' % (string2find,nbExpected)
      </message>
      <call function="'CheckMatches'">
        { 'string2find' : string2find ,
        'mainString'    : STAXResult[0][1] ,
        'nbExpected'    : nbExpected
        }
      </call>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_setup.xml
New file
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="group_setup"/>
  <function name="group_setup">
    <function-map-args>
      <function-arg-def name="startDS" type="optional" default="True">
        <function-arg-description>
          Optional start the Directory Server
        </function-arg-description>
        <function-arg-property name="type" value="boolean"/>
      </function-arg-def>
        <function-arg-def name="loadBackend" type="optional" default="True">
            <function-arg-description>
                  Specifies whether the backend should be loaded with some data.
                </function-arg-description>
                <function-arg-property name="type" value="boolean"/>
          </function-arg-def>
        </function-map-args>
    <sequence>
      <block name="'setup'">
        <sequence>
          <block name="'Block Create DS Topology'">
            <!-- Create the topology necessary to the test group/suite -->
                <sequence>
              <message>
                 '------ Create DS topology as described in config.py'
              </message>
                    <call function="'createTopology'">
                        { 'initialiseInstance' : False }
                    </call>
                    <call function="'checkRC'">
                  { 'returncode' : RC ,
                    'result'     : STAXResult }
              </call>
            </sequence>
          <!--- End Block Create DS Topology -->
          </block>
          <if expr="loadBackend == True">
            <block name="'Block DS Load Data'">
                <!-- Load the data needed by the test suite -->
                    <sequence>
                <message>
                  '------ Load LDIF : groups.ldif'
                </message>
                <call function="'importLdif'">
                  { 'ldifFile'    : '%s/groups/groups.ldif' % logsRemoteDataDir }
                </call>
                <call function="'checkRC'">
                  { 'returncode' : RC ,
                    'result'     : STAXResult }
                </call>
              </sequence>
            <!--- End Block DS Load Data -->
                  </block>
            </if>
              <if expr="startDS == True">
                <block name="'Block DS Process Active'">
                <!--- Start DS -->
                    <sequence>
                <message>
                   '------ Start DS to run on port %s' % (DIRECTORY_INSTANCE_PORT)
                </message>
                <!--- Start DS -->
                <call function="'StartDsWithScript'">
                        { 'location'  : STAF_REMOTE_HOSTNAME }
                </call>
                <call function="'checkRC'">
                    { 'returncode' : RC ,
                      'result'     : STAXResult }
                </call>
                <!--- Check that DS started -->
                <call function="'isAlive'">
                      { 'noOfLoops'        : 5 ,
                      'noOfMilliSeconds' : 2000 }
                </call>
                </sequence>
            <!--- End Block DS Process Active -->
              </block>
              </if>
            </sequence>
      </block>
    </sequence>
    </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_static_member.xml
New file
@@ -0,0 +1,770 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main_staticgroup_member"/>
  <function name="main_staticgroup_member">
    <sequence>
      <block name="'staticgroup_member'">
        <sequence>
          <script>
            applicationDn='uid=my_application,dc=groups,dc=com'
            applicationPswd='pw_my_application'
            staticGroup2Dn='cn=my_staticgroup2,dc=groups,dc=com'
            newStaticGroup='my_newStaticGroup'
            newStaticGroupDn='cn=%s,dc=groups,dc=com' % (newStaticGroup)
            newStaticGroupPswd='pw_%s' % (newStaticGroup)
            user1='user_01'
            user1Dn='uid=%s,ou=static,dc=groups,dc=com' % (user1)
            user1Pswd='pw_01'
            user2='user_02'
            user2Dn='uid=%s,ou=static,dc=groups,dc=com' % (user2)
            user2Pswd='pw_02'
            user11='user_11'
            user11Dn='uid=%s,ou=static,dc=groups,dc=com' % (user11)
            user11Pswd='pw_11'
          </script>
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group']='groups'
            CurrentTestPath['suite']=STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Suite information
          #@TestSuiteName       Static group test suite
          #@TestSuitePurpose    Test this feature
          #@TestSuiteID         Groups Tests
          #@TestSuiteGroup      staticgroup
          #@TestGroup           Groups
          #@TestScript          group_static.xml
          #@TestHTMLLink        http://opends.dev.java.net/
          -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_setup.xml' % (TESTS_DIR)"/>
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_lib.xml' % (TESTS_DIR)"/>
          <call function="'group_setup'"> { 'startDS' : True } </call>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: member: add a static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: add a static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                listAttr = []
                listAttr.append('cn:%s' % newStaticGroup)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:groupofnames')
                listAttr.append('description:this is the description of %s' % newStaticGroup)
                listAttr.append('member:%s' % user11Dn)
              </script>
              <message>
                '++++ Application add group entry %s' % newStaticGroup
              </message>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : newStaticGroupDn,
                'listAttributes'   : listAttr
                }
              </call>
              <message>
                '++++ Application do a search to check the entry has been created'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'member' }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check the search return entry %s' % user11Dn
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1
                }
              </call>
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : newStaticGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: member: delete a static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: delete a static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Delete the group entry %s' % newStaticGroup
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn,
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check the group entry %s no more exist' % newStaticGroup
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'member',
                'expected'               : 32 }
              </call>
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : newStaticGroupDn ,
                  'nbExpected'  : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: member: ldapsearch out of the group
          #@TestID              search in group
          #@TestPurpose         user of group search members of its group
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: ldapsearch out of the group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ user %s, not member of the group, do a search, should pass' % user11
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user11Dn ,
                'dsInstancePswd'   : user11Pswd ,
                'dsBaseDN'         : user11Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 2
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: member: ldapsearch through group
          #@TestID              search in group
          #@TestPurpose         user of group search members of its group
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: ldapsearch through group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ user %s, member of the group do a search, should be denied has group have no permission' % user1
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user1Dn ,
                'dsInstancePswd'   : user1Pswd ,
                'dsBaseDN'         : user1Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : staticGroup2Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: member: application search in group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: application search in group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application do a search on static group, should work'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup2Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'member' }
              </call>
              <script>
                STAXReason = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result return 10 entries'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'member' ,
                'mainString'    : STAXReason ,
                'nbExpected'    : 10
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: member: application add user in group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: application add user in group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application add a new user %s / %s into the static group' % (user11Dn,user11Pswd)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : staticGroup2Dn ,
                'changetype'        : 'add' ,
                'attributeName'     : 'member' ,
                'newAttributeValue' : user11Dn
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users through the static group'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup2Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'dsAttributes'     : 'member' }
              </call>
              <script>
                STAXCode = RC
                ldapSearchResult = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result return the new entry uid'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check added user %s has no more privileges' % user11
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user11Dn ,
                'dsInstancePswd'   : user11Pswd ,
                'dsBaseDN'         : user11Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : staticGroup2Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: member: delete user entry belonging to the group
          #@TestID
          #@TestPurpose
          #@TestPreamble        previous testcase must be run before this one
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: delete user entry belonging to the group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <!-- ******************** -->
              <message>
                '++++ Application delete the user entry that belong to the static group'
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : user11Dn,
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users through the static group'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup2Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'dsAttributes'     : 'member' }
              </call>
              <script>
                STAXCode = RC
                ldapSearchResult = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result still return the deleted entry uid as referential integrity plugin is disabled'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result return 11 entries'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'member' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 11
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Add the deleted entry'
              </message>
              <script>
                listAttr = []
                listAttr.append('uid:%s' % user11)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:person')
                listAttr.append('objectclass:inetOrgPerson')
                listAttr.append('cn:%s' % user11)
                listAttr.append('sn:sn of user %s' % user11)
                listAttr.append('description:this is the description of %s' % user11)
                listAttr.append('userPassword:%s' % user11Pswd)
              </script>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : user11Dn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : staticGroup2Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: member: application delete user from group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: application delete user from group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application delete attribute member:%s from the static group' % user11
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : staticGroup2Dn ,
                'changetype'        : 'delete' ,
                'attributeName'     : 'member',
                'newAttributeValue' : user11Dn }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users through the static group'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup2Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'dsAttributes'     : 'member' }
              </call>
              <script>
                ldapSearchResult = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result should not return the deleted group entry'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ User %s should now be able to do search' % user11
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user11Dn ,
                'dsInstancePswd'   : user11Pswd ,
                'dsBaseDN'         : user11Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search returns entry'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : staticGroup2Dn ,
                  'nbExpected'  : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: member: delete all attributes in a static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: delete all attributes in a static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <!-- ******************** -->
              <message>
                '++++ Create a static group entry %s' % newStaticGroupDn
              </message>
              <script>
                listAttr = []
                listAttr.append('cn:%s' % newStaticGroup)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:groupofnames')
                listAttr.append('description:this is the description of %s' % newStaticGroup)
                listAttr.append('member:%s' % user1Dn)
                listAttr.append('member:%s' % user2Dn)
                listAttr.append('member:%s' % user11Dn)
              </script>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : newStaticGroupDn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Delete all attributes of the group entry'
              </message>
              <script>
                listAttr = []
                listAttr.append('member:%s' % user1Dn)
                listAttr.append('member:%s' % user2Dn)
                listAttr.append('member:%s' % user11Dn)
              </script>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : newStaticGroupDn ,
                'changetype'        : 'delete' ,
                'listAttributes'    : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Do a search on the group, should return no user entries'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'member' }
              </call>
              <script>
               STAXCode = RC
               ldapSearchResult = STAXResult[0][1]
              </script>
              <call function="'CheckMatches'">
                { 'string2find' : 'member' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : staticGroup2Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : newStaticGroupDn ,
                  'nbExpected'  : 0
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Delete the group entry created'
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: member: enable referential integrity plugin
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: member: enable referential integrity plugin'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ referential integrity plugin not yet implemented in opendDS'
              </message>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
              file="'%s/testcases/groups/group_cleanup.xml' % (TESTS_DIR)"/>
          <call function="'group_cleanup'"> { 'stopDS' : True } </call>
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_static_uniquemember.xml
New file
@@ -0,0 +1,767 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main_staticgroup_uniquemember"/>
  <function name="main_staticgroup_uniquemember">
    <sequence>
      <block name="'staticgroup_uniquemember'">
        <sequence>
          <script>
            applicationDn='uid=my_application,dc=groups,dc=com'
            applicationPswd='pw_my_application'
            staticGroup1Dn='cn=my_staticgroup1,dc=groups,dc=com'
            newStaticGroup='my_newStaticGroup'
            newStaticGroupDn='cn=%s,dc=groups,dc=com' % (newStaticGroup)
            newStaticGroupPswd='pw_%s' % (newStaticGroup)
            user1='user_01'
            user1Dn='uid=%s,ou=static,dc=groups,dc=com' % (user1)
            user1Pswd='pw_01'
            user2='user_02'
            user2Dn='uid=%s,ou=static,dc=groups,dc=com' % (user2)
            user2Pswd='pw_02'
            user11='user_11'
            user11Dn='uid=%s,ou=static,dc=groups,dc=com' % (user11)
            user11Pswd='pw_11'
          </script>
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group']='groups'
            CurrentTestPath['suite']=STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Suite information
          #@TestSuiteName       Static group test suite
          #@TestSuitePurpose    Test this feature
          #@TestSuiteID         Groups Tests
          #@TestSuiteGroup      staticgroup
          #@TestGroup           Groups
          #@TestScript          group_static.xml
          #@TestHTMLLink        http://opends.dev.java.net/
          -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_setup.xml' % (TESTS_DIR)"/>
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_lib.xml' % (TESTS_DIR)"/>
          <call function="'group_setup'"> { 'startDS' : True } </call>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: uniquemember: add a static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: add a static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                listAttr = []
                listAttr.append('cn:%s' % newStaticGroup)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:groupofuniquenames')
                listAttr.append('description:this is the description of %s' % newStaticGroup)
                listAttr.append('uniquemember:%s' % user11Dn)
              </script>
              <message>
                '++++ Application add group entry %s' % newStaticGroup
              </message>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : newStaticGroupDn,
                'listAttributes'   : listAttr
                }
              </call>
              <message>
                '++++ Application do a search to check the entry has been created'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <message>
                '++++ Check the search return entry %s' % user11Dn
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1
                }
              </call>
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : newStaticGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: uniquemember: delete a static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: delete a static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Delete the group entry %s' % newStaticGroup
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn,
                }
              </call>
              <message>
                '++++ Check the group entry %s no more exist' % newStaticGroup
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uniquemember',
                'expected'               : 32 }
              </call>
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : newStaticGroupDn ,
                  'nbExpected'  : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: uniquemember: ldapsearch out of the group
          #@TestID              search in group
          #@TestPurpose         user of group search members of its group
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: ldapsearch out of the group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ user %s, not member of the group, do a search, should pass' % user11
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user11Dn ,
                'dsInstancePswd'   : user11Pswd ,
                'dsBaseDN'         : user11Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 2
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: uniquemember: ldapsearch through group
          #@TestID              search in group
          #@TestPurpose         user of group search members of its group
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: ldapsearch through group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ user %s, member of the group do a search, should be denied has group have no permission' % user1
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user1Dn ,
                'dsInstancePswd'   : user1Pswd ,
                'dsBaseDN'         : user1Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : staticGroup1Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: uniquemember: application search in group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: application search in group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application do a search on static group, should work'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup1Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <script>
                STAXReason = STAXResult[0][1]
              </script>
              <message>
                '++++ Check ldapsearch result return 10 entries'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'uniquemember' ,
                'mainString'    : STAXReason ,
                'nbExpected'    : 10
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: uniquemember: application add user in group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: application add user in group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application add a new user %s / %s into the static group' % (user11Dn,user11Pswd)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : staticGroup1Dn ,
                'changetype'        : 'add' ,
                'attributeName'     : 'uniquemember' ,
                'newAttributeValue' : user11Dn
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users through the static group'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup1Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <script>
                STAXCode = RC
                ldapSearchResult = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result return the new entry uid'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check added user %s has no more privileges' % user11
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user11Dn ,
                'dsInstancePswd'   : user11Pswd ,
                'dsBaseDN'         : user11Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return nothing'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : staticGroup1Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: uniquemember: delete user entry belonging to the group
          #@TestID
          #@TestPurpose
          #@TestPreamble        previous testcase must be run before this one
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: delete user entry belonging to the group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <!-- ******************** -->
              <message>
                '++++ Application delete the user entry that belong to the static group'
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : user11Dn,
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users through the static group'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup1Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <script>
                STAXCode = RC
                ldapSearchResult = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result still return the deleted entry uid as referential integrity plugin is disabled'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result return 11 entries'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'uniquemember' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 11
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Add the deleted entry'
              </message>
              <script>
                listAttr = []
                listAttr.append('uid:%s' % user11)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:person')
                listAttr.append('objectclass:inetOrgPerson')
                listAttr.append('cn:%s' % user11)
                listAttr.append('sn:sn of user %s' % user11)
                listAttr.append('description:this is the description of %s' % user11)
                listAttr.append('userPassword:%s' % user11Pswd)
              </script>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : user11Dn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : staticGroup1Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: uniquemember: application delete user from group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: application delete user from group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application delete attribute uniquemember:%s from the static group' % user11
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : staticGroup1Dn ,
                'changetype'        : 'delete' ,
                'attributeName'     : 'uniquemember',
                'newAttributeValue' : user11Dn }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users through the static group'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : staticGroup1Dn ,
                'dsFilter'         : 'objectclass=*' ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <script>
                ldapSearchResult = STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check ldapsearch result should not return the deleted group entry'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user11Dn ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ User %s should now be able to do search' % user11
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : user11Dn ,
                'dsInstancePswd'   : user11Pswd ,
                'dsBaseDN'         : user11Dn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uid',
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search returns entry'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'dn' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user11Dn ,
                  'string2find' : staticGroup1Dn ,
                  'nbExpected'  : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Static Group Tests
          #@TestName            Group: Static: uniquemember: delete all attributes in a static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: delete all attributes in a static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <!-- ******************** -->
              <message>
                '++++ Create a static group entry %s' % newStaticGroupDn
              </message>
              <script>
                listAttr = []
                listAttr.append('cn:%s' % newStaticGroup)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:groupofuniquenames')
                listAttr.append('description:this is the description of %s' % newStaticGroup)
                listAttr.append('uniquemember:%s' % user1Dn)
                listAttr.append('uniquemember:%s' % user2Dn)
                listAttr.append('uniquemember:%s' % user11Dn)
              </script>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : newStaticGroupDn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Delete all attributes of the group entry'
              </message>
              <script>
                listAttr = []
                listAttr.append('uniquemember:%s' % user1Dn)
                listAttr.append('uniquemember:%s' % user2Dn)
                listAttr.append('uniquemember:%s' % user11Dn)
              </script>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : newStaticGroupDn ,
                'changetype'        : 'delete' ,
                'listAttributes'    : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Do a search on the group, should return no user entries'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <script>
               STAXCode = RC
               ldapSearchResult = STAXResult[0][1]
              </script>
              <call function="'CheckMatches'">
                { 'string2find' : 'uniquemember' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : staticGroup1Dn ,
                  'nbExpected'  : 1
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user1Dn ,
                  'string2find' : newStaticGroupDn ,
                  'nbExpected'  : 0
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Delete the group entry created'
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newStaticGroupDn
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Group StaticGroup Tests
          #@TestName            Group: Static: uniquemember: enable referential integrity plugin
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Static: uniquemember: enable referential integrity plugin'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ referential integrity plugin not yet implemented in opendDS'
              </message>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
              file="'%s/testcases/groups/group_cleanup.xml' % (TESTS_DIR)"/>
          <call function="'group_cleanup'"> { 'stopDS' : True } </call>
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/group_virtual_static.xml
New file
@@ -0,0 +1,744 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main_virtualStaticGroup"/>
  <function name="main_virtualStaticGroup">
    <sequence>
      <block name="'virtualStaticGroup'">
        <sequence>
          <script>
            applicationDn='uid=my_application,dc=groups,dc=com'
            applicationPswd='pw_my_application'
            dynamicGroupDn='cn=my_dynamicgroup1,dc=groups,dc=com'
            virtualStaticGroupDn='cn=my_virtualstaticgroup,dc=groups,dc=com'
            newVirtualStaticGroup='my_newVirtualStaticGroup'
            newVirtualStaticGroupDn='cn=%s,dc=groups,dc=com' % (newVirtualStaticGroup)
            newVirtualStaticGroupPswd='pw_%s' % (newVirtualStaticGroup)
            user2Add='user_22'
            user2AddDn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user2Add)
            user2AddPswd='pw_22'
            user2AddRenamed='%s_bis' % (user2Add)
            user2AddRenamedDn='uid=%s,ou=dynamic,dc=groups,dc=com' % (user2AddRenamed)
           </script>
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group']='groups'
            CurrentTestPath['suite']=STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <!--- Test Suite information
          #@TestSuiteName       Group test suite
          #@TestSuitePurpose    Test this feature
          #@TestSuiteID         Groups Tests
          #@TestSuiteGroup      Virtual Static Group
          #@TestGroup           Virtual Static Group
          #@TestScript          group_virtual_static.xml
          #@TestHTMLLink        http://opends.dev.java.net/
          -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_setup.xml' % (TESTS_DIR)"/>
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_lib.xml' % (TESTS_DIR)"/>
          <call function="'group_setup'"> { 'startDS' : True } </call>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: enable member virtual attribute
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: enable member virtual attribute'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : DIRECTORY_INSTANCE_DN ,
                'dsInstancePswd'    : DIRECTORY_INSTANCE_PSWD ,
                'DNToModify'        : 'cn=Virtual Static uniqueMember,cn=Virtual Attributes,cn=config' ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-cfg-allow-retrieving-membership' ,
                'newAttributeValue' : 'true'
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: add a Virtual Static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: add a Virtual Static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                listAttr = []
                listAttr.append('cn:%s' % newVirtualStaticGroup)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:groupOfUniqueNames')
                listAttr.append('objectclass:ds-virtual-static-group')
                listAttr.append('description:this is the description of %s' % newVirtualStaticGroup)
                listAttr.append('ds-target-group-dn:%s' % virtualStaticGroupDn)
              </script>
              <message>
                '++++ Application add group entry %s' % newVirtualStaticGroupDn
              </message>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : newVirtualStaticGroupDn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application do a search to check the entry has been created'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newVirtualStaticGroupDn ,
                'dsFilter'         : 'objectclass=*'  ,
                'dsAttributes'     : 'uniquemember' }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : 'uid=user_02,ou=dynamic,dc=groups,dc=com' ,
                  'string2find' : newVirtualStaticGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: delete a Virtual Static group entry
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: delete a Virtual Static group entry'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Delete the group entry %s' % newVirtualStaticGroupDn
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newVirtualStaticGroupDn,
                }
              </call>
              <message>
                '++++ Check the group entry %s no more exist' % newVirtualStaticGroup
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : newVirtualStaticGroupDn ,
                'dsFilter'         : 'objectclass=*' ,
                'expected'         : 32 }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: search members of group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: search members of group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Search members of group %s' % virtualStaticGroupDn
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <script>
                ldapSearchResult=STAXResult[0][1]
              </script>
              <!-- ******************** -->
              <message>
                '++++ Check uid=user_01,ou=dynamic,dc=groups,dc=com is NOT a group member'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_01,ou=dynamic,dc=groups,dc=com' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 0
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check uid=user_02,ou=dynamic,dc=groups,dc=com is a group member'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_02,ou=dynamic,dc=groups,dc=com' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Check uid=user_12,ou=dynamic,dc=groups,dc=com is a group member'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_12,ou=dynamic,dc=groups,dc=com' ,
                'mainString'    : ldapSearchResult ,
                'nbExpected'    : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: application add entry that belong to a group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: application add entry that belong to a group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application add a new user %s / %s ' % (user2AddDn,user2AddPswd)
              </message>
              <script>
                listAttr = []
                listAttr.append('uid:%s' % user2Add)
                listAttr.append('objectclass:top')
                listAttr.append('objectclass:person')
                listAttr.append('objectclass:inetOrgPerson')
                listAttr.append('cn:%s' % user2Add)
                listAttr.append('sn:sn of user %s' % user2Add)
                listAttr.append('description:this is the description of %s' % user2Add)
                listAttr.append('userPassword:%s' % user2AddPswd)
              </script>
              <call function="'addAnEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'DNToAdd'          : user2AddDn,
                'listAttributes'   : listAttr
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search the new user %s in the virtual static group entry (should be a member)' % user2Add
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return the added user'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user2AddDn ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user2AddDn ,
                  'string2find' : virtualStaticGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: application rename entry that belong to a group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: application rename entry that belong to a group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application rename %s into %s ' % (user2Add,user2AddRenamed)
              </message>
              <call function="'modifyDn'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : user2AddDn ,
                'newRDN'                    : user2AddRenamed,
                'deleteOldRDN'          : 1 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search the new user %s in the virtual static group entry (should be a member)' % user2Add
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return the added user'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user2AddRenamedDn ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1
                }
              </call>
              <!-- ******************** -->
              <call function="'CheckIsMemberOf'">
                { 'baseDn'      : user2AddRenamedDn ,
                  'string2find' : virtualStaticGroupDn ,
                  'nbExpected'  : 1
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: application delete entry belonging to a group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: application delete entry belonging to a group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application delete user %s' % user2Add
              </message>
              <call function="'DeleteEntry'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : user2AddDn
                }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search the deleted user %s in the virtual static group entry (should not be in)' % user2Add
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <message>
                '++++ Check the search return the added user'
              </message>
              <call function="'CheckMatches'">
                { 'string2find' : user2AddDn ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 0
                }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: Change ds-target-group-dn to another dynamic group
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: Change ds-target-group-dn to another dynamic group'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                dynamicGroup2Dn='cn=my_dynamicgroup2,dc=groups,dc=com'
              </script>
              <message>
                '++++ Application set a value %s to ds-target-group-dn attribute for group %s' % (dynamicGroup2Dn,virtualStaticGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : dynamicGroup2Dn }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users becoming to the updated virtual static group entry'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_03,ou=dynamic,dc=groups,dc=com' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application reset ds-target-group-dn attribute to default value %s' % (dynamicGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : dynamicGroupDn }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: Change ds-target-group-dn to static group (member type)
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: Change ds-target-group-dn to static group (uniquemember type)'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                staticGroupDn='cn=my_staticgroup1,dc=groups,dc=com'
              </script>
              <message>
                '++++ Application set a value %s to ds-target-group-dn attribute for group %s' % (staticGroupDn,virtualStaticGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : staticGroupDn }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users becoming to the updated virtual static group entry'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_09,ou=static,dc=groups,dc=com' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application reset ds-target-group-dn attribute to default value %s' % (dynamicGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : dynamicGroupDn }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: Change ds-target-group-dn to static group (member type)
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: Change ds-target-group-dn to static group (member type)'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <script>
                staticGroupDn='cn=my_staticgroup2,dc=groups,dc=com'
              </script>
              <message>
                '++++ Application set a value %s to ds-target-group-dn attribute for group %s' % (staticGroupDn,virtualStaticGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : staticGroupDn }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application search users becoming to the updated virtual static group entry'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_09,ou=static,dc=groups,dc=com' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application reset ds-target-group-dn attribute to default value %s' % (dynamicGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'replace' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : dynamicGroupDn }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!--- Test Case information
          #@TestMarker          Virtual Static Group Tests
          #@TestName            Group: Virtual Static: Remove ds-target-group-dn attribute
          #@TestID
          #@TestPurpose
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <testcase name="'Group: Virtual Static: Remove ds-target-group-dn attribute'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '++++ Application remove ds-target-group-dn attribute'
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'delete' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : dynamicGroupDn ,
                'expectedErrorCode' : 65 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Group should not be modified'
              </message>
              <call function="'ldapSearchWithScript'">
                { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : applicationDn ,
                'dsInstancePswd'   : applicationPswd ,
                'dsBaseDN'         : virtualStaticGroupDn ,
                'dsFilter'         : 'uniquemember=*' ,
                'expected'         : 0 }
              </call>
              <call function="'CheckMatches'">
                { 'string2find' : 'uid=user_02,ou=static,dc=groups,dc=com' ,
                'mainString'    : STAXResult[0][1] ,
                'nbExpected'    : 1 }
              </call>
              <!-- ******************** -->
              <message>
                '++++ Application reset ds-target-group-dn attribute to default value %s' % (dynamicGroupDn)
              </message>
              <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'  : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'    : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'      : applicationDn ,
                'dsInstancePswd'    : applicationPswd ,
                'DNToModify'        : virtualStaticGroupDn ,
                'changetype'        : 'add' ,
                'attributeName'     : 'ds-target-group-dn' ,
                'newAttributeValue' : dynamicGroupDn }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
              file="'%s/testcases/groups/group_cleanup.xml' % (TESTS_DIR)"/>
          <call function="'group_cleanup'"> { 'stopDS' : True } </call>
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/groups.xml
New file
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, exclude this CDDL HEADER in each
 ! file and exclude the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main_groups"/>
  <function name="main_groups">
    <sequence>
      <block name="'groups'">
        <sequence>
          <script>
            CurrentTestPath={}
            envAlreadyLoaded='true'
            CurrentTestPath['group']='groups'
          </script>
          <call function="'testGroup_Preamble'"/>
<!--GA
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/mytest.xml' % (TESTS_DIR)"/>
          <call function="'main_mytest'" />
-->
<!--GA
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_static_uniquemember.xml' % (TESTS_DIR)"/>
          <call function="'main_staticgroup_uniquemember'" />
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_static_member.xml' % (TESTS_DIR)"/>
          <call function="'main_staticgroup_member'" />
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_dynamic.xml' % (TESTS_DIR)"/>
          <call function="'main_dynamicgroup'" />
-->
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_virtual_static.xml' % (TESTS_DIR)"/>
          <call function="'main_virtualStaticGroup'" />
          <call function="'testGroup_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>
opendj-sdk/opends/tests/functional-tests/testcases/groups/mytest.xml
New file
@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../stax.dtd">
<!--
 ! CDDL HEADER START
 !
 ! The contents of this file are subject to the terms of the
 ! Common Development and Distribution License, Version 1.0 only
 ! (the "License").  You may not use this file except in compliance
 ! with the License.
 !
 ! You can obtain a copy of the license at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE
 ! or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 ! See the License for the specific language governing permissions
 ! and limitations under the License.
 !
 ! When distributing Covered Code, include this CDDL HEADER in each
 ! file and include the License file at
 ! trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 ! add the following below this CDDL HEADER, with the fields enclosed
 ! by brackets "[]" replaced with your own identifying information:
 !      Portions Copyright [yyyy] [name of copyright owner]
 !
 ! CDDL HEADER END
 !
 !      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 ! -->
<stax>
  <defaultcall function="main_mytest"/>
  <function name="main_mytest">
    <sequence>
      <block name="'mytest'">
        <sequence>
          <script>
            if not CurrentTestPath.has_key('group'):
              CurrentTestPath['group']='groups'
            CurrentTestPath['suite']=STAXCurrentBlock
          </script>
          <call function="'testSuite_Preamble'"/>
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
            file="'%s/testcases/groups/group_setup.xml' % (TESTS_DIR)"/>
          <call function="'group_setup'"> { 'startDS' : True } </call>
          <!--- Test Suite information
          #@TestSuiteName       Just a simple test
          #@TestSuitePurpose    Try some stuff to test the framework
          #@TestSuiteID         Groups Tests
          #@TestSuiteGroup      MyTest
          #@TestGroup           Groups
          #@TestScript          mytest.xml
          #@TestHTMLLink        http://opends.dev.java.net/
          -->
          <!--- Test Case information
          #@TestMarker          Group MyTest Tests
          #@TestName            Group: MyTest: hello world
          #@TestID              pouet
          #@TestPurpose         pouetpouet
          #@TestPreamble
          #@TestSteps
          #@TestPostamble
          #@TestResult
          -->
          <!-- *********************************************** -->
          <testcase name="'Group: MyTest: hello world'">
            <sequence>
              <message>'------ aa RC = %s' % RC</message>
              <call function="'testCase_Preamble'"/>
              <message>'------ bb RC = %s' % RC</message>
              <message log="1"> '------ Hello world log=1' </message>
              <message> '------ Hello world nolog' </message>
              <call function="'checktestRC'">
              { 'returncode' : RC ,
                'result' : STAXResult }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
          <testcase name="'Group: MyTest: call shell cmd'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <message>
                '------ do ls'
              </message>
              <process name="'just go into ds bin dir and run pwd cmd'">
                <location>'%s' % STAF_REMOTE_HOSTNAME </location>
                <!-- <command>'cd %s ; pwd' % dsBinPath</command> -->
                <command>'pwd'</command>
                <stderr mode="'stdout'"/>
                <returnstdout/>
              </process>
              <call function="'checktestRC'">
                { 'returncode' : RC ,
                'result'     : STAXResult }
               </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
          <testcase name="'Group: MyTest: do simple ldapsearch'">
            <sequence>
              <call function="'testCase_Preamble'"/>
              <call function="'SearchObject'">
                { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
                'dsInstanceDn'     : 'uid=scarter, ou=People, dc=example,dc=com' ,
                'dsInstancePswd'   : 'sprain' ,
                'dsBaseDN'         : 'uid=scarter, ou=People, dc=example,dc=com' ,
                'dsFilter'         : 'objectclass=*'  ,
                'extraParams'      : '-s base' ,
                'attributes'       : 'dn' }
              </call>
              <message>
                '++++ %s' % (STAXResult[0][1])
              </message>
              <call function="'CheckMatches'">
                { 'string2find'  : 'dc' ,
                'mainString'   : STAXResult[0][1] ,
                'nbExpected'        : 2
                }
              </call>
              <script>
                STAXCode, STAXReason=STAXResult
              </script>
              <call function="'checktestRC'">
                { 'returncode' : STAXCode ,
                  'result'     : STAXReason }
              </call>
              <call function="'testCase_Postamble'"/>
            </sequence>
          </testcase>
          <!-- *********************************************** -->
    <!--GA
          <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
              file="'%s/testcases/groups/group_cleanup.xml' % (TESTS_DIR)"/>
          <call function="'group_cleanup'"> { 'stopDS' : False } </call>
     -->
          <call function="'testSuite_Postamble'"/>
        </sequence>
      </block>
    </sequence>
  </function>
</stax>