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

Gary Williams
07.45.2011 24e60ede26bf2a623e6aa41617106f9df918d1bc
New functional tests for schema structural objects
2 files added
2 files modified
625 ■■■■■ changed files
opends/tests/staf-tests/functional-tests/shared/data/schema/ldifs/schema_start.ldif 6 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/testcases/schema/schema.xml 1 ●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/testcases/schema/structure/schema_structure.xml 138 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/testcases/schema/structure/schema_structure_tests.xml 480 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/functional-tests/shared/data/schema/ldifs/schema_start.ldif
@@ -21,6 +21,7 @@
# CDDL HEADER END
#
#      Copyright 2006-2009 Sun Microsystems, Inc.
#      Portions Copyright 2011 ForgeRock AS
#
dn: dc=com
@@ -41,6 +42,11 @@
objectclass: top
objectclass: organizationalunit
dn: o=schema structure tests,dc=example,dc=com
o: extensible object tests
objectclass: top
objectclass: organization
dn: o=rfc tests,dc=example,dc=com
o: extensible object tests
objectclass: top
opends/tests/staf-tests/functional-tests/testcases/schema/schema.xml
@@ -53,6 +53,7 @@
              suiteList.append('rfc')
              suiteList.append('dynamic')
              suiteList.append('solaris')
              suiteList.append('structure')
            </script>
    
            <!-- Run the test suites -->
opends/tests/staf-tests/functional-tests/testcases/schema/structure/schema_structure.xml
New file
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../../../shared/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/CDDLv1_0.txt
 ! or http://forgerock.org/license/CDDLv1.0.html.
 ! 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/CDDLv1_0.txt.  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
 !
 !      Copyright 2011 ForgeRock AS
 ! -->
<stax>
  <defaultcall function="main_schema_structure"/>
  <function name="main_schema_structure" scope="local">
    <sequence>
      <block name="'main_schema_structure'">
        <try>
          <sequence>
            <script>
              CurrentTestPath['group']='schema'
              CurrentTestPath['suite']='structure'
              __group=CurrentTestPath['group']
              __groupdir='%s/testcases/%s' % (TESTS_DIR,__group)
            </script>
            <!--- Test Suite information
            #@TestSuiteName       Native schema test suite
            #@TestSuitePurpose    Verify LDAP Naming Services Schema Elements
            #@TestSuiteID         Suite
            #@TestSuiteGroup      Example
            #@TestGroup           Example
            #@TestScript          suite.xml
            #@TestHTMLLink        http://opends.dev.java.net/
            -->
            <call function="'testSuite_Preamble'"/>
            <try>
              <sequence>
                <call function="'common_setup'">
                  {
                    'quickStart'    : False ,
                    'startServer'   : True  ,
                    'loadData'      : True  ,
                    'ldifFile'      : '%s/schema/ldifs/schema_start.ldif' % remote.data ,
                    'stopServer'    : False
                  }
                </call>
                <!-- List of Import of Test Functions -->
                <script>
                  importList=[]
                  importList.append('structure/schema_structure_tests')
                </script>
                <!-- Import the files for this test suite -->
                <iterate var="__import" in="importList">
                  <import machine="STAF_LOCAL_HOSTNAME"
                    file="'%s/%s.xml' % (__groupdir,__import)"/>
                </iterate>
                <!-- Specific to structure schema tests -->
                <script>
                  __baseDN='o=Schema Structure tests, dc=example,%s' % server.suffix
                </script>
                <!-- List of Test Cases -->
                <script>
                  testsList=[]
                  testsList.append('schema_structure_001')
                  testsList.append('schema_structure_002')
                </script>
                <!-- Execute the Tests -->
                <iterate var="__test" in="testsList">
                  <sequence>
                    <call function="'%s' % (__test)" />
                  </sequence>
                </iterate>
              </sequence>
            <catch exception="'STAFException.TestSuite.SetupException'">
              <sequence>
                <message log="1" level="'fatal'">
                  'Setup of test suite failed.'
                </message>
                <rethrow/>
              </sequence>
            </catch>
            <finally>
              <message>'Test Cases Completed.'</message>
            </finally>
            </try>
          </sequence>
          <finally>
            <sequence>
              <!-- Test Suite Cleanup -->
              <message>'Finally: Global Schema Cleanup.'</message>
              <try>
                <call function="'common_cleanup'" />
              <catch exception="'STAFException'">
                <sequence>
                  <message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
                </sequence>
              </catch>
              <finally>
                <call function="'testSuite_Postamble'"/>
              </finally>
              </try>
            </sequence>
          </finally>
        </try>
      </block>
    </sequence>
  </function>
</stax>
opends/tests/staf-tests/functional-tests/testcases/schema/structure/schema_structure_tests.xml
New file
@@ -0,0 +1,480 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../../../shared/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/CDDLv1_0.txt
 ! or http://forgerock.org/license/CDDLv1.0.html.
 ! 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/CDDLv1_0.txt.  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
 !
 !      Copyright 2011 ForgeRock AS
 ! -->
<stax>
  <!-- Definition of Test Cases -->
  <!--- Test Case : Schema: Modify Add Core Auxiliary Object -->
  <!--- Test Case information
  #@TestMarker          Schema
  #@TestName            Schema: Modify Add Core Auxiliary Object
  #@TestID              Modify Add Core Auxiliary Object
  #@TestPurpose         Add a core auxiliary schema object to an existing entry
  #@TestPreamble
  #@TestSteps           Modify schema object LDAP protocol by Adding Auxiliary schema object
  #@TestPostamble
  #@TestResult          Test is successful if the result code is 0
  -->
  <function name="schema_structure_001" scope="local">
    <testcase name="getTestCaseName('Modify Add Core Auxiliary Object')">
      <sequence>
        <try>
          <sequence>
            <call function="'testCase_Preamble'"/>
            <message>
               'Test Name = %s' % STAXCurrentTestcase
            </message>
            <!-- Add the new account object  -->
            <script>
              ldapObject=[]
              ldapObject.append('objectclass:top')
              ldapObject.append('objectclass:domain')
              ldapObject.append('dc:accounts')
           </script>
            <call function="'addAnEntry'">
              { 'dsInstanceHost' : server.host,
                'dsInstancePort' : server.port,
                'dsInstanceDn'   : server.dn,
                'dsInstancePswd' : server.password,
                'DNToAdd'        : 'dc=accounts,%s' % __baseDN,
                'listAttributes' : ldapObject
              }
            </call>
            <script>
              ldapObject=[]
              ldapObject.append('objectclass:account')
              ldapObject.append('uid:fsmart')
              ldapObject.append('description:New account holder')
           </script>
            <call function="'addAnEntry'">
              { 'dsInstanceHost' : server.host,
                'dsInstancePort' : server.port,
                'dsInstanceDn'   : server.dn,
                'dsInstancePswd' : server.password,
                'DNToAdd'        : 'uid=fsmart,dc=accounts,%s' % __baseDN,
                'listAttributes' : ldapObject
              }
            </call>
            <!-- Read back the new account object  -->
            <call function="'ldapSearchWithScript'">
              { 'dsInstanceHost'   : server.host ,
                'dsInstancePort'   : server.port ,
                'dsInstanceDn'     : server.dn ,
                'dsInstancePswd'   : server.password ,
                'dsBaseDN'         : 'dc=accounts,%s' % __baseDN ,
                'dsFilter'         : 'objectclass=*'
              }
            </call>
            <script>
             returnString = STAXResult[0][1]
            </script>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'objectClass: account',
                'searchType'     : 'substring'
              }
            </call>
            <!-- Modify by adding an auxiliary schema object -->
            <script>
              ldapObject=[]
              ldapObject.append('objectclass:simpleSecurityObject')
              ldapObject.append('userpassword:secret12')
           </script>
            <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'         : server.host ,
                  'dsInstancePort'         : server.port ,
                  'dsInstanceDn'           : server.dn ,
                  'dsInstancePswd'         : server.password ,
                  'DNToModify'             : 'uid=fsmart,dc=accounts,%s' % __baseDN ,
                  'listAttributes'         : ldapObject ,
                  'changetype'             : 'add' }
            </call>
            <!-- Read back the changed object -->
            <call function="'ldapSearchWithScript'">
              { 'dsInstanceHost'   : server.host ,
                'dsInstancePort'   : server.port ,
                'dsInstanceDn'     : server.dn ,
                'dsInstancePswd'   : server.password ,
                'dsBaseDN'         : 'uid=fsmart,dc=accounts,%s' % __baseDN ,
                'dsFilter'         : 'objectclass=*'
              }
            </call>
            <script>
             returnString = STAXResult[0][1]
            </script>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'objectClass: simpleSecurityObject',
                'searchType'     : 'substring'
              }
            </call>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'userPassword',
                'searchType'     : 'substring'
              }
            </call>
            <!-- Delete accounts objects -->
            <call function="'ldapDeleteWithScript'">
              { 'dsDeleteSubtree' : 'TRUE'                          ,
                'dsInstanceHost'  : server.host                     ,
                'dsInstancePort'  : server.port                     ,
                'dsInstanceDn'    : server.dn                       ,
                'dsInstancePswd'  : server.password                 ,
                'dsDn'            : ['dc=accounts,%s' % __baseDN] ,
                'expectedRC'      : 'noCheck'
              }
            </call>
          </sequence>
          <catch exception="'STAXException'" typevar="eType" var="eInfo">
            <message log="1" level="'fatal'">
              '%s: Test failed. eInfo(%s)' % (eType,eInfo)
            </message>
          </catch>
          <finally>
            <call function="'testCase_Postamble'"/>
          </finally>
        </try>
      </sequence>
    </testcase>
  </function>
  <!--- Test Case : Schema: Modify Delete Core Auxiliary Object -->
  <!--- Test Case information
  #@TestMarker          Schema
  #@TestName            Schema: Modify Delete Core Auxiliary Object
  #@TestID              Modify Delete Core Auxiliary Object
  #@TestPurpose         Delete a core auxiliary schema object to an existing entry
  #@TestPreamble
  #@TestSteps           Modify schema object LDAP protocol by deleting Auxiliary schema object
  #@TestPostamble
  #@TestResult          Test is successful if the result code is 0
  -->
  <function name="schema_structure_002" scope="local">
    <testcase name="getTestCaseName('Modify Delete Core Auxiliary Object')">
      <sequence>
        <try>
          <sequence>
            <call function="'testCase_Preamble'"/>
            <message>
               'Test Name = %s' % STAXCurrentTestcase
            </message>
            <!-- Read back the new account object  -->
            <call function="'ldapSearchWithScript'">
              { 'dsInstanceHost'   : server.host ,
                'dsInstancePort'   : server.port ,
                'dsInstanceDn'     : server.dn ,
                'dsInstancePswd'   : server.password ,
                'dsBaseDN'         : 'dc=accounts,%s' % __baseDN ,
                'dsFilter'         : 'objectclass=*',
                'expectedRC'      : 'noCheck'
              }
            </call>
            <if expr="RC == 32">
              <sequence>
                <!-- Add the new account object  -->
                <script>
                  ldapObject=[]
                  ldapObject.append('objectclass:top')
                  ldapObject.append('objectclass:domain')
                  ldapObject.append('dc:accounts')
                </script>
                <call function="'addAnEntry'">
                  { 'dsInstanceHost' : server.host,
                    'dsInstancePort' : server.port,
                    'dsInstanceDn'   : server.dn,
                    'dsInstancePswd' : server.password,
                    'DNToAdd'        : 'dc=accounts,%s' % __baseDN,
                    'listAttributes' : ldapObject
                  }
                </call>
              </sequence>
            </if>
            <!-- Read back the new account object  -->
            <call function="'ldapSearchWithScript'">
              { 'dsInstanceHost'   : server.host ,
                'dsInstancePort'   : server.port ,
                'dsInstanceDn'     : server.dn ,
                'dsInstancePswd'   : server.password ,
                'dsBaseDN'         : 'uid=fsmart,dc=accounts,%s' % __baseDN ,
                'dsFilter'         : 'objectclass=*',
                'expectedRC'      : 'noCheck'
              }
            </call>
            <if expr="RC == 32">
              <sequence>
                <script>
                  ldapObject=[]
                  ldapObject.append('objectclass:account')
                  ldapObject.append('objectclass:simpleSecurityObject')
                  ldapObject.append('uid:fsmart')
                  ldapObject.append('description:Another new account holder')
                  ldapObject.append('userpassword:secret12')
                </script>
                <call function="'addAnEntry'">
                  { 'dsInstanceHost' : server.host,
                    'dsInstancePort' : server.port,
                    'dsInstanceDn'   : server.dn,
                    'dsInstancePswd' : server.password,
                    'DNToAdd'        : 'uid=fsmart,dc=accounts,%s' % __baseDN,
                    'listAttributes' : ldapObject
                  }
                </call>
              </sequence>
            </if>
            <!-- Read back the new account object  -->
            <call function="'ldapSearchWithScript'">
              { 'dsInstanceHost'   : server.host ,
                'dsInstancePort'   : server.port ,
                'dsInstanceDn'     : server.dn ,
                'dsInstancePswd'   : server.password ,
                'dsBaseDN'         : 'dc=accounts,%s' % __baseDN ,
                'dsFilter'         : 'objectclass=*'
              }
            </call>
            <script>
             returnString = STAXResult[0][1]
            </script>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'objectClass: account',
                'searchType'     : 'substring'
              }
            </call>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'objectClass: simpleSecurityObject',
                'searchType'     : 'substring'
              }
            </call>
            <!-- Modify by adding an auxiliary schema object -->
            <script>
              ldapObject=[]
              ldapObject.append('objectclass:simpleSecurityObject')
              ldapObject.append('userpassword:secret12')
           </script>
            <call function="'modifyAnAttribute'">
                { 'dsInstanceHost'         : server.host ,
                  'dsInstancePort'         : server.port ,
                  'dsInstanceDn'           : server.dn ,
                  'dsInstancePswd'         : server.password ,
                  'DNToModify'             : 'uid=fsmart,dc=accounts,%s' % __baseDN ,
                  'listAttributes'         : ldapObject ,
                  'changetype'             : 'delete' }
            </call>
            <!-- Read back the changed object -->
            <call function="'ldapSearchWithScript'">
              { 'dsInstanceHost'   : server.host ,
                'dsInstancePort'   : server.port ,
                'dsInstanceDn'     : server.dn ,
                'dsInstancePswd'   : server.password ,
                'dsBaseDN'         : 'uid=fsmart,dc=accounts,%s' % __baseDN ,
                'dsFilter'         : 'objectclass=*'
              }
            </call>
            <script>
             returnString = STAXResult[0][1]
            </script>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'objectClass: simpleSecurityObject',
                'searchType'     : 'substring' ,
                'expectedRC'     : 1
              }
            </call>
            <call function="'searchString'">
              { 'returnString'   : returnString ,
                'expectedString' : 'userPassword',
                'searchType'     : 'substring',
                'expectedRC'     : 1
              }
            </call>
            <!-- Delete accounts objects -->
            <call function="'ldapDeleteWithScript'">
              { 'dsDeleteSubtree' : 'TRUE'                          ,
                'dsInstanceHost'  : server.host                     ,
                'dsInstancePort'  : server.port                     ,
                'dsInstanceDn'    : server.dn                       ,
                'dsInstancePswd'  : server.password                 ,
                'dsDn'            : ['dc=accounts,%s' % __baseDN] ,
                'expectedRC'      : 'noCheck'
              }
            </call>
          </sequence>
          <catch exception="'STAXException'" typevar="eType" var="eInfo">
            <message log="1" level="'fatal'">
              '%s: Test failed. eInfo(%s)' % (eType,eInfo)
            </message>
          </catch>
          <finally>
            <call function="'testCase_Postamble'"/>
          </finally>
        </try>
      </sequence>
    </testcase>
  </function>
  <!--- Test Case : Schema: Add Structural Schema Entries -->
  <!--- Test Case information
  #@TestMarker          Schema
  #@TestName            Schema: Add Structural Schema Entries
  #@TestID              Test
  #@TestPurpose         Add Structural schema entries
  #@TestPreamble
  #@TestSteps           Add over LDAP protocol Structural schema entries
  #@TestPostamble
  #@TestResult          Test is successful if the result code is 0
  -->
  <function name="schema_structure_003" scope="local">
    <testcase name="getTestCaseName('Structural Object Superclass Chain')">
      <sequence>
        <try>
          <sequence>
            <call function="'testCase_Preamble'"/>
            <message>
               'Test Name = %s' % STAXCurrentTestcase
            </message>
            <!-- Define a custom object user account-->
            <script>
              schema=[]
              schema.append('attributeTypes: ( accountnameattr-oid NAME \'account-name\' )')
              schema.append('attributeTypes: ( accountnumattr-oid NAME \'account-num\' )')
              schema.append('attributeTypes: ( accounttypeattr-oid NAME \'account-type\' )')
              schema.append('objectClasses: ( accountoc-oid NAME \'bankaccount\' SUP Person STRUCTURAL MUST account-name MAY account-number account-type)')
            </script>
            <!-- Add a custom object user account-->
            <call function="'modifyAnAttribute'">
              { 'dsInstanceHost' : server.host      ,
                'dsInstancePort' : server.port      ,
                'dsInstanceDn'   : server.dn        ,
                'dsInstancePswd' : server.password  ,
                'DNToModify'     : 'cn=schema'      ,
                'listAttributes' : schema           ,
                'changetype'     : 'add'
              }
            </call>
            <!-- Add the new account object  -->
            <script>
              ldapObject=[]
              ldapObject.append('objectclass:top')
              ldapObject.append('objectclass:domain')
              ldapObject.append('dc:accounts')
           </script>
            <call function="'addAnEntry'">
              { 'dsInstanceHost' : server.host,
                'dsInstancePort' : server.port,
                'dsInstanceDn'   : server.dn,
                'dsInstancePswd' : server.password,
                'DNToAdd'        : 'dc=accounts,dc=example,dc=com',
                'listAttributes' : ldapObject
              }
            </call>
            <script>
              ldapObject=[]
              ldapObject.append('objectclass:bankaccount')
              ldapObject.append('account-name: Mr Finbar Soap')
              ldapObject.append('cn: Finbar Soap')
              ldapObject.append('sn: Soap')
           </script>
            <call function="'addAnEntry'">
              { 'dsInstanceHost' : server.host,
                'dsInstancePort' : server.port,
                'dsInstanceDn'   : server.dn,
                'dsInstancePswd' : server.password,
                'DNToAdd'        : 'cn=dc=accounts,dc=example,dc=com',
                'listAttributes' : ldapObject
              }
            </call>
            <!-- Read back the new account object  -->
            <!-- Add a new auxillary schema object -->
            <!-- Read back the changed object -->
          </sequence>
          <catch exception="'STAXException'" typevar="eType" var="eInfo">
            <message log="1" level="'fatal'">
              '%s: Test failed. eInfo(%s)' % (eType,eInfo)
            </message>
          </catch>
          <finally>
            <call function="'testCase_Postamble'"/>
          </finally>
        </try>
      </sequence>
    </testcase>
  </function>
</stax>