From f04de5a7fab2c7ce0410f2fb2c90565eaee8b12f Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Wed, 13 Feb 2008 09:35:22 +0000
Subject: [PATCH] Add testcase to clu_ldapsearch_checkbahavior testsuite for issue 2934

---
 opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_ldapsearch_checkbehavior.xml |  299 ++++++++++++++++++++++++++++++++
 opendj-sdk/opends/tests/functional-tests/shared/data/clu/ldapsearch_checkbehavior.ldif  |  187 ++++++++++++++++++++
 2 files changed, 482 insertions(+), 4 deletions(-)

diff --git a/opendj-sdk/opends/tests/functional-tests/shared/data/clu/ldapsearch_checkbehavior.ldif b/opendj-sdk/opends/tests/functional-tests/shared/data/clu/ldapsearch_checkbehavior.ldif
new file mode 100644
index 0000000..039ee22
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/data/clu/ldapsearch_checkbehavior.ldif
@@ -0,0 +1,187 @@
+dn: dc=mycom
+objectClass: top
+objectClass: domain
+dc: mycom
+
+dn: dc=example,dc=mycom
+objectClass: top
+objectClass: domain
+dc: example
+
+dn: o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: organization
+o: clu tests
+
+dn: ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: organizationalunit
+ou: ldapsearch
+
+dn: uid=user.0,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Aaccf
+sn: Amar
+cn: Aaccf Amar
+initials: APA
+employeeNumber: 0
+uid: user.0
+mail: user.0@example.mycom
+userPassword: password
+telephoneNumber: +1 140 374 9062
+homePhone: +1 413 500 4984
+pager: +1 250 147 3106
+mobile: +1 086 604 6557
+street: 83837 Central Street
+l: Santa Barbara
+st: NJ
+postalCode: 57656
+postalAddress: Aaccf Amar$83837 Central Street$Santa Barbara, NJ  57656
+description: This is the description for Aaccf Amar.
+
+dn: uid=user.1,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Aaren
+sn: Atp
+cn: Aaren Atp
+initials: AVA
+employeeNumber: 1
+uid: user.1
+mail: user.1@example.mycom
+userPassword: password
+telephoneNumber: +1 705 284 6303
+homePhone: +1 119 705 9603
+pager: +1 575 714 2075
+mobile: +1 206 947 0972
+street: 90369 Lincoln Street
+l: Lafayette
+st: RI
+postalCode: 61381
+postalAddress: Aaren Atp$90369 Lincoln Street$Lafayette, RI  61381
+description: This is the description for Aaren Atp.
+
+dn: uid=user.2,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Aarika
+sn: Atpco
+cn: Aarika Atpco
+initials: AQA
+employeeNumber: 2
+uid: user.2
+mail: user.2@example.mycom
+userPassword: password
+telephoneNumber: +1 240 116 1006
+homePhone: +1 524 998 9690
+pager: +1 808 020 8342
+mobile: +1 885 252 0855
+street: 64447 Spruce Street
+l: Providence
+st: WA
+postalCode: 89035
+postalAddress: Aarika Atpco$64447 Spruce Street$Providence, WA  89035
+description: This is the description for Aarika Atpco.
+
+dn: uid=user.3,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Aaron
+sn: Atrc
+cn: Aaron Atrc
+initials: AAA
+employeeNumber: 3
+uid: user.3
+mail: user.3@example.mycom
+userPassword: password
+telephoneNumber: +1 980 000 3369
+homePhone: +1 870 933 0016
+pager: +1 096 390 4404
+mobile: +1 863 963 6402
+street: 96369 Sixth Street
+l: San Antonio
+st: ND
+postalCode: 07852
+postalAddress: Aaron Atrc$96369 Sixth Street$San Antonio, ND  07852
+description: This is the description for Aaron Atrc.
+
+dn: uid=user.4,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Aartjan
+sn: Aalders
+cn: Aartjan Aalders
+initials: AYA
+employeeNumber: 4
+uid: user.4
+mail: user.4@example.mycom
+userPassword: password
+telephoneNumber: +1 428 104 9299
+homePhone: +1 239 749 1115
+pager: +1 205 023 3110
+mobile: +1 188 661 6039
+street: 38248 Johnson Street
+l: North Platte
+st: LA
+postalCode: 03941
+postalAddress: Aartjan Aalders$38248 Johnson Street$North Platte, LA  03941
+description: This is the description for Aartjan Aalders.
+
+dn: uid=user.5,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Abagael
+sn: Aasen
+cn: Abagael Aasen
+initials: AEA
+employeeNumber: 5
+uid: user.5
+mail: user.5@example.mycom
+userPassword: password
+telephoneNumber: +1 093 200 1952
+homePhone: +1 691 947 3811
+pager: +1 932 721 7390
+mobile: +1 614 906 3581
+street: 23182 Park Street
+l: Albany
+st: ID
+postalCode: 12135
+postalAddress: Abagael Aasen$23182 Park Street$Albany, ID  12135
+description: This is the description for Abagael Aasen.
+
+dn: uid=user.6,ou=ldapsearch,o=clu tests,dc=example,dc=mycom
+objectClass: top
+objectClass: person
+objectClass: organizationalperson
+objectClass: inetorgperson
+givenName: Abagail
+sn: Abadines
+cn: Abagail Abadines
+initials: AMA
+employeeNumber: 6
+uid: user.6
+mail: user.6@example.mycom
+userPassword: password
+telephoneNumber: +1 694 083 3855
+homePhone: +1 500 993 9169
+pager: +1 533 256 0160
+mobile: +1 230 330 8000
+street: 26941 Spring Street
+l: Odessa
+st: NC
+postalCode: 83936
+postalAddress: Abagail Abadines$26941 Spring Street$Odessa, NC  83936
+description: This is the description for Abagail Abadines.
diff --git a/opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_ldapsearch_checkbehavior.xml b/opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_ldapsearch_checkbehavior.xml
index 4582080..fc2e3a6 100644
--- a/opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_ldapsearch_checkbehavior.xml
+++ b/opendj-sdk/opends/tests/functional-tests/testcases/clu/clu_ldapsearch_checkbehavior.xml
@@ -51,10 +51,12 @@
           </script>
           
           <call function="'testSuite_Preamble'"/>
-                    
+          
           <!--- Define default value for dsdn -->
           <script>
-            basedn = 'ou=ldapsearch,o=clu tests,dc=example,dc=com'
+            basedn     = 'ou=ldapsearch,o=clu tests,dc=example,dc=com'
+            ldifFile   = '%s/clu/ldapsearch_checkbehavior.ldif' \
+            % logsRemoteDataDir
           </script>
           
           <!--- Test Case information
@@ -91,7 +93,7 @@
                 'dsFilter'         : 'uid=user.1*'
                 }                
               </call>
-             
+              
               <script>
                 returnString = STAXResult[0][1]
               </script>
@@ -112,7 +114,296 @@
             </sequence>
             
           </testcase> 
-        
+          
+          <!--- Test Case information
+            #@TestMarker          ldapsearch check behavior tests
+            #@TestName            ldapsearch: check behavior with a basedn of ""
+            #@TestIssue           2934
+            #@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 base-dn')">
+            
+            <sequence>
+              
+              <call function="'testCase_Preamble'"/>
+
+              <message>
+                'ldapsearch: add a new base dn to userRoot backend'
+              </message>
+              
+              <call function="'dsconfigSet'">
+                { 
+                'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'objectName'       : 'backend' ,
+                'propertyType'     : 'backend' ,
+                'propertyName'     : 'userRoot' ,
+                'attributeName'    : 'base-dn' ,
+                'attributeValue'   : 'dc=mycom' ,
+                'modifyType'       : 'add'
+                }
+              </call>
+
+              <message>
+                'ldapsearch: import data into this new base dn'
+              </message>
+              
+              <call function="'StopDsWithScript'">
+                { 'location' : STAF_REMOTE_HOSTNAME }
+              </call>
+
+              <call function="'ImportLdifWithScript'">
+                { 
+                'location'    : STAF_REMOTE_HOSTNAME ,
+                'dsAppend'    : 'True' ,
+                'dsLdifFile'  : ldifFile ,
+                'dsBackEnd'   : 'userRoot'
+                }
+              </call>
+         
+              <call function="'StartDsWithScript'">
+                { 'location' : STAF_REMOTE_HOSTNAME }
+              </call>
+       
+              <!--- Check that DS started -->
+              <call function="'isAlive'">
+                {
+                'noOfLoops'        : 5 ,
+                'noOfMilliSeconds' : 2000
+                }
+              </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'         : 'dc=com' ,
+                '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 ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                '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 ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                '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 ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'objectName'       : 'root-dse-backend' ,
+                'modifyType'       : 'reset' ,
+                'attributeName'    : 'subordinate-base-dn'
+                }
+              </call>
+              
+              <script>
+                knownIssue(2934)
+              </script>
+              
+              <call function="'testCase_Postamble'"/>
+              
+            </sequence>
+            
+          </testcase> 
+          
           <call function="'testSuite_Postamble'"/>
           
         </sequence>

--
Gitblit v1.10.0