<?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 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 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 2008-2009 Sun Microsystems, Inc.
! Portions Copyright 2013 ForgeRock AS
! -->
<stax>
<defaultcall function="clu_ldapsearch_checkbehavior"/>
<function name="clu_ldapsearch_checkbehavior">
<sequence>
<block name="'clu_ldapsearch_checkbehavior'">
<try>
<sequence>
<!--- Test Suite information
#@TestSuiteName ldapsearch check behavior tests
#@TestSuitePurpose Test the results of ldapsearch command.
#@TestSuiteGroup ldapsearch check behavior tests
#@TestScript clu_ldapsearch_checkbehavior.xml
-->
<script>
if not CurrentTestPath.has_key('group'):
CurrentTestPath['group'] = 'clu'
CurrentTestPath['suite'] = STAXCurrentBlock
</script>
<call function="'testSuite_Preamble'"/>
<call function="'common_setup'">
{
'quickStart' : False ,
'loadData' : True ,
'ldifFile' : '%s/clu/clu_start.ldif' % remote.data ,
'startServer' : True ,
'stopServer' : False ,
'allowPreEncodePassword' : True
}
</call>
<!--- Define default value for dsdn -->
<script>
basedn = 'ou=ldapsearch,o=clu tests,dc=example,dc=com'
ldifFile = '%s/clu/ldapsearch_checkbehavior.ldif' \
% remote.data
filterfile = '%s/clu/filters.ldif' % remote.data
mfilterfile = '%s/clu/multiple_filters.ldif' % remote.data
</script>
<!--- Test Case information
#@TestMarker ldapsearch check behavior tests
#@TestName ldapsearch: check number of entries
#@TestIssue none
#@TestPurpose Verify that the operation is successful and
the number of returned entries is correct.
#@TestPreamble none
#@TestStep Do an ldapsearch with countEntries option.
#@TestPostamble none
#@TestResult Success if the number of entries is 111.
-->
<testcase name="getTestCaseName
('ldapsearch: check number of entries')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'ldapsearch: check number of entries'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsTypesOnly' : 'True' ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : basedn ,
'dsFilter' : 'uid=user.1*'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 111'
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker ldapsearch check behavior tests
#@TestName ldapsearch: check behavior with default basedn
#@TestIssue none
#@TestPurpose Verify that the number of returned entries is
correct with a base DN of "".
#@TestPreamble none
#@TestStep Add a new basedn (dc=mycom) to userRoot
backend.
#@TestStep Import data into this new basedn.
#@TestStep Do an ldapsearch with a basedn of dc=com and
check that the number of entries is correct
#@TestStep Do an ldapsearch with a basedn of dc=mycom and
check that the number of entries is correct
#@TestStep Do an ldapsearch with a basedn of "" and check
that the number of entries is correct (equal
to: entries of dc=com + entries of dc=mycom)
#@TestStep Set value of subordinate-base-dn to dc=com
#@TestStep Do an ldapsearch with a basedn of "" and check
that the number of entries is correct (equal
to: entries of dc=com)
#@TestStep Set value of subordinate-base-dn to dc=mycom
#@TestStep Do an ldapsearch with a basedn of "" and check
that the number of entries is correct (equal
to: entries of dc=mycom)
#@TestStep Reset value of subordinate-base-dn
#@TestPostamble none
#@TestResult Success if OpenDS returns 0 for all ldap
operations, and if the number entries retuned
is correct with a basedn of "".
-->
<testcase name="getTestCaseName
('ldapsearch: check default basedn')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'ldapsearch: add a new base dn to userRoot backend'
</message>
<call function="'dsconfigSet'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'objectName' : 'backend' ,
'propertyType' : 'backend' ,
'propertyName' : DIRECTORY_INSTANCE_BE ,
'attributeName' : 'base-dn' ,
'attributeValue' : 'dc=mycom' ,
'modifyType' : 'add'
}
</call>
<message>
'ldapsearch: import data into this new base dn'
</message>
<call function="'ldapModifyWithScript'">
{ 'dsAdd' : 'True',
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsFilename' : ldifFile,
'dsContinueOnError' : 'true',
'expectedRC' : 0
}
</call>
<message>
'ldapsearch: check number of entries with a basedn of dc=com'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : DIRECTORY_INSTANCE_SFX ,
'dsFilter' : 'objectclass=*' ,
'dsAttributes' : 'dn' ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 1048'
}
</call>
<message>
'ldapsearch: check number of entries with a basedn of dc=mycom'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : 'dc=mycom' ,
'dsFilter' : 'objectclass=*' ,
'dsAttributes' : 'dn' ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 11'
}
</call>
<message>
'ldapsearch: check number of entries with a basedn of ""'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : ' ' ,
'dsFilter' : 'objectclass=*' ,
'dsAttributes' : 'dn' ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 1059'
}
</call>
<message>
'ldapsearch: set value of subordinate-base-dn to dc=com'
</message>
<call function="'dsconfigSet'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'objectName' : 'root-dse-backend' ,
'attributeName' : 'subordinate-base-dn' ,
'attributeValue' : 'dc=com'
}
</call>
<message>
'ldapsearch: check number of entries with a basedn of ""'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : ' ' ,
'dsFilter' : 'objectclass=*' ,
'dsAttributes' : 'dn' ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 1048'
}
</call>
<message>
'ldapsearch: set value of subordinate-base-dn to dc=mycom'
</message>
<call function="'dsconfigSet'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'objectName' : 'root-dse-backend' ,
'attributeName' : 'subordinate-base-dn' ,
'attributeValue' : 'dc=mycom'
}
</call>
<message>
'ldapsearch: check number of entries with a basedn of ""'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : ' ' ,
'dsFilter' : 'objectclass=*' ,
'dsAttributes' : 'dn' ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 11'
}
</call>
<message>
'ldapsearch: reset value of subordinate-base-dn'
</message>
<call function="'dsconfigSet'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'objectName' : 'root-dse-backend' ,
'modifyType' : 'reset' ,
'attributeName' : 'subordinate-base-dn'
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker ldapsearch check behavior tests
#@TestName ldapsearch: check behavior with a scope of
base and a basedn of ''
#@TestIssue none
#@TestPurpose Verify that the Root DSE entry is returned.
#@TestPreamble none
#@TestStep Do an ldapsearch with a scope of "base" and
a basedn of "" and check that the number of
entries is correct
#@TestPostamble none
#@TestResult Success if only one entry is returned and if
this entry is the Root DSE entry.
-->
<testcase name="getTestCaseName
('ldapsearch: check with scope of base and empty basedn')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'ldapsearch: check number of entries with scope \
of base and basedn of ""'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsScope' : 'base' ,
'dsBaseDN' : ' ' ,
'dsFilter' : 'objectclass=*' ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 1'
}
</call>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'objectClass: ds-root-dse'
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker ldapsearch check behavior tests
#@TestName ldapsearch: check behavior with a simple
page size of 30 and 1
#@TestIssue none
#@TestPurpose Verify the output of ldapsearch with
simplePageSize option.
#@TestPreamble none
#@TestStep Do an ldapsearch with a simple page size of 30
#@TestStep Compare the output of the previous command to
a reference file
#@TestStep Do an ldapsearch with a simple page size of 1
#@TestStep Compare the output of the previous command to
a reference file
#@TestPostamble none
#@TestResult Success if the outputs for ldapsearch matche
the refenrence outputs.
-->
<testcase name="getTestCaseName
('ldapsearch: check output with simplePageSize of 30 and 1')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'ldapsearch: check output with simplePageSize of 30'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsSimplePageSize' : '30' ,
'dsBaseDN' : basedn ,
'dsFilter' : 'uid=user.1*' ,
'expectedRC' : 'noCheck' ,
'outputFile' : 'ldapsearch_simplepagesize_30.out' ,
'outputPath' : remote.temp
}
</call>
<call function="'LdifDiffWithScript'">
{
'sourceLdif' : '%s/ldapsearch_simplepagesize_30.out' \
% remote.temp ,
'targetLdif' : '%s/clu/ldapsearch_simplepagesize_30.ref' \
% remote.data ,
'outputLdif' : '%s/ldapsearch_simplepagesize_30.diff' \
% remote.temp
}
</call>
<message>
'ldapsearch: check output with simplePageSize of 1'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsSimplePageSize' : '1' ,
'dsBaseDN' : basedn ,
'dsFilter' : 'uid=user.1*' ,
'expectedRC' : 'noCheck' ,
'outputFile' : 'ldapsearch_simplepagesize_1.out' ,
'outputPath' : remote.temp
}
</call>
<call function="'LdifDiffWithScript'">
{
'sourceLdif' : '%s/ldapsearch_simplepagesize_1.out' \
% remote.temp ,
'targetLdif' : '%s/clu/ldapsearch_simplepagesize_1.ref' \
% remote.data ,
'outputLdif' : '%s/ldapsearch_simplepagesize_1.diff' \
% remote.temp
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker ldapsearch check behavior tests
#@TestName ldapsearch: check behavior with a filter file
(containing one filter) and search attribute
#@TestIssue none
#@TestPurpose Verify the output of ldapsearch with
filter option.
#@TestPreamble none
#@TestStep Do an ldapsearch with filter file option and
a search attribute, and check that the number
of entries is correct
#@TestStep Compare the output of the previous command to
a reference file
#@TestPostamble none
#@TestResult Success if the outputs for ldapsearch matche
the refenrence outputs.
-->
<testcase name="getTestCaseName
('ldapsearch: check output using --filename and a search attribute')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'ldapsearch: check output using --filename and a \
search attribute'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsBaseDN' : basedn ,
'dsFilename' : filterfile ,
'dsAttributes' : 'dn' ,
'outputFile' : 'ldapsearch_filterfile_and_attribute.out' ,
'outputPath' : remote.temp
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'CheckMatches'">
{
'string2find' : 'dn: ' ,
'mainString' : returnString ,
'nbExpected' : 8
}
</call>
<call function="'LdifDiffWithScript'">
{
'sourceLdif' : '%s/ldapsearch_filterfile_and_attribute.out' \
% remote.temp ,
'targetLdif' : '%s/clu/ldapsearch_filterfile_and_attribute.ref'\
% remote.data ,
'outputLdif' : '%s/ldapsearch_filterfile_and_attribute.diff' \
% remote.temp
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker ldapsearch check behavior tests
#@TestName ldapsearch: check behavior with a filter file
containing multiple filters
#@TestIssue none
#@TestPurpose Verify the output of ldapsearch with
filter option.
#@TestPreamble none
#@TestStep Do an ldapsearch with filter file option and
check that the number of entries is correct
#@TestPostamble none
#@TestResult Success if the number of entries is 222.
-->
<testcase name="getTestCaseName
('ldapsearch: check with a filter file containing multiple filters')">
<sequence>
<call function="'testCase_Preamble'"/>
<message>
'ldapsearch: check with a filter file containing multiple \
filters'
</message>
<call function="'ldapSearchWithScript'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsCountEntries' : 'True' ,
'dsBaseDN' : basedn ,
'dsFilename' : mfilterfile ,
'expectedRC' : 'noCheck'
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : 'Total number of matching entries: 222'
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
</sequence>
<finally>
<sequence>
<!-- Test Suite Cleanup -->
<message>'Finally: Global CLU 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>