From fd1a5529996f5a0757593aeea8e86e5efcf94468 Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Sun, 03 Mar 2013 20:52:23 +0000
Subject: [PATCH] [Opendj-777] CR-1353 Update ldapcompare testscases following fix for issue OPENDJ-777

---
 opendj-sdk/opends/tests/staf-tests/shared/functions/ldap.xml                                          |   13 ++
 opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_ldapcompare_checkbehavior.xml   |  301 ++++++++++++++++++++++++++++++++++++++++++++++++-
 opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml |    2 
 opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml                                         |    3 
 4 files changed, 305 insertions(+), 14 deletions(-)

diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_ldapcompare_checkbehavior.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_ldapcompare_checkbehavior.xml
index 2cbff65..7c6037a 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_ldapcompare_checkbehavior.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_ldapcompare_checkbehavior.xml
@@ -24,6 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2008-2009 Sun Microsystems, Inc.
+ !      Portions Copyright 2013 ForgeRock AS
  ! -->
 <stax>
   
@@ -69,17 +70,131 @@
             <script>
               dsdn = 'uid=user.0,ou=ldapcompare,o=clu tests,dc=example,dc=com'
             </script>
-            
+
             <!--- Test Case information
               #@TestMarker          ldapcompare check behavior tests
               #@TestName            ldapcompare: comparison successful
-              #@TestIssue           2761
+              #@TestIssue           none
+              #@TestPurpose         Verify that the operation is successful and 
+                                    that the comparison is successful with 
+                                    useCompareResultCode option.
+              #@TestPreamble        none
+              #@TestStep            Do an ldapcompare with useCompareResultCode
+                                    option.
+              #@TestPostamble       none
+              #@TestResult          Success if ldapcompare returns 6.
+            -->
+            <testcase name="getTestCaseName
+            ('ldapcompare: comparison successful with useCompareResultCode option')">
+              
+              <sequence>
+                
+                <call function="'testCase_Preamble'"/>
+                
+                <message>
+                  'ldapcompare: comparison successful'
+                </message>
+                
+                <call function="'ldapCompareWithScript'">
+                  { 
+                  'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                  'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                  'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                  'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                  'dsDn'             : ['postalCode:63792' ,
+                                        '%s' % dsdn] ,
+                  'useCmpRC'         : 'True' ,
+                  'expectedRC'       : 6
+                  }
+                </call>
+  
+                <script>
+                  returnString = STAXResult[0][1]
+                </script>
+                
+                <script>
+                  msg = 'Compare operation returned true'
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+                
+                <call function="'testCase_Postamble'"/>
+                
+              </sequence>
+              
+            </testcase> 
+  
+            <!--- Test Case information
+              #@TestMarker          ldapcompare check behavior tests
+              #@TestName            ldapcompare: comparison unsuccessful
+              #@TestIssue           none
+              #@TestPurpose         Verify that the operation is successful and 
+                                    that the comparison is unsuccessful with 
+                                    useCompareResultCode option.
+              #@TestPreamble        none
+              #@TestStep            Do an ldapcompare with with 
+                                    useCompareResultCode option.
+              #@TestPostamble       none
+              #@TestResult          Success if ldapcompare returns 5.
+            -->
+            <testcase name="getTestCaseName
+            ('ldapcompare: comparison unsuccessful with useCompareResultCode option')">
+              
+              <sequence>
+                
+                <call function="'testCase_Preamble'"/>
+                
+                <message>
+                  'ldapcompare: comparison unsuccessful'
+                </message>
+                
+                <call function="'ldapCompareWithScript'">
+                  { 
+                  'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                  'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                  'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                  'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                  'dsDn'             : ['postalCode:00000' ,
+                                        '%s' % dsdn] ,
+                  'useCmpRC'         : 'True' ,
+                  'expectedRC'       : 5
+                  }
+                </call>
+ 
+                <script>
+                  returnString = STAXResult[0][1]
+                </script>
+                
+                <script>
+                  msg = 'Compare operation returned false'
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+                
+                <call function="'testCase_Postamble'"/>
+                
+              </sequence>
+              
+            </testcase> 
+
+            <!--- Test Case information
+              #@TestMarker          ldapcompare check behavior tests
+              #@TestName            ldapcompare: comparison successful
+              #@TestIssue           none
               #@TestPurpose         Verify that the operation is successful and 
                                     that the comparison is successful.
               #@TestPreamble        none
               #@TestStep            Do an ldapcompare with correct options.
               #@TestPostamble       none
-              #@TestResult          Success if ldapcompare returns 6.
+              #@TestResult          Success if ldapcompare returns 0.
             -->
             <testcase name="getTestCaseName
             ('ldapcompare: comparison successful')">
@@ -100,11 +215,24 @@
                   'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
                   'dsDn'             : ['postalCode:63792' ,
                                         '%s' % dsdn] ,
-                  'expectedRC'       : 6,
-                  'knownIssue'       : '2761'
+                  'expectedRC'       : 0
                   }
                 </call>
-  
+
+                <script>
+                  returnString = STAXResult[0][1]
+                </script>
+                
+                <script>
+                  msg = 'Compare operation returned true'
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+
                 <call function="'testCase_Postamble'"/>
                 
               </sequence>
@@ -114,13 +242,13 @@
             <!--- Test Case information
               #@TestMarker          ldapcompare check behavior tests
               #@TestName            ldapcompare: comparison unsuccessful
-              #@TestIssue           2761
+              #@TestIssue           none
               #@TestPurpose         Verify that the operation is successful and 
                                     that the comparison is unsuccessful.
               #@TestPreamble        none
               #@TestStep            Do an ldapcompare with correct options.
               #@TestPostamble       none
-              #@TestResult          Success if ldapcompare returns 5.
+              #@TestResult          Success if ldapcompare returns 0.
             -->
             <testcase name="getTestCaseName
             ('ldapcompare: comparison unsuccessful')">
@@ -141,8 +269,21 @@
                   'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
                   'dsDn'             : ['postalCode:00000' ,
                                         '%s' % dsdn] ,
-                  'expectedRC'       : 5,
-                  'knownIssue'       : '2761'
+                  'expectedRC'       : 0
+                  }
+                </call>
+  
+                <script>
+                  returnString = STAXResult[0][1]
+                </script>
+                
+                <script>
+                  msg = 'Compare operation returned false'
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
                   }
                 </call>
   
@@ -151,6 +292,146 @@
               </sequence>
               
             </testcase> 
+
+            <!--- Define default value for dn1 and dn2 -->
+            <script>
+              dn1 = 'uid=user.162,ou=ldapsearch,o=clu tests,dc=example,dc=com'
+              dn2 = 'uid=user.1,ou=ldapdelete,o=clu tests,dc=example,dc=com'
+            </script>
+            
+
+            <!--- Test Case information
+              #@TestMarker          ldapcompare check behavior tests
+              #@TestName            ldapcompare: multiple comparison successful
+              #@TestIssue           none
+              #@TestPurpose         Verify that the operation is successful and 
+                                    that the multiple comparison is successful.
+              #@TestPreamble        none
+              #@TestStep            Do an ldapcompare with correct options.
+              #@TestPostamble       none
+              #@TestResult          Success if ldapcompare returns 6.
+            -->
+            <testcase name="getTestCaseName
+            ('ldapcompare: multiple comparison successful')">
+              
+              <sequence>
+                
+                <call function="'testCase_Preamble'"/>
+                
+                <message>
+                  'ldapcompare: multiple comparison successful'
+                </message>
+
+                
+                <call function="'ldapCompareWithScript'">
+                  { 
+                  'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                  'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                  'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                  'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                  'dsDn'             : ['st:NY' ,
+                                        '%s' % dn1 ,
+                                        '%s' % dn2] ,
+                  'useCmpRC'         : 'True' ,
+                  'expectedRC'       : 6
+                  }
+                </call>
+
+                <script>
+                  returnString = STAXResult[0][1]
+                </script>
+
+                <script>
+                  msg = 'Compare operation returned true for entry uid=user.162' 
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+
+                <script>
+                  msg = 'Compare operation returned true for entry uid=user.1' 
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+
+                <call function="'testCase_Postamble'"/>
+                
+              </sequence>
+              
+            </testcase> 
+  
+            <!--- Test Case information
+              #@TestMarker          ldapcompare check behavior tests
+              #@TestName            ldapcompare: multiple comparison unsuccessful
+              #@TestIssue           none
+              #@TestPurpose         Verify that the operation is successful and 
+                                    that the multiple comparison is unsuccessful.
+              #@TestPreamble        none
+              #@TestStep            Do an ldapcompare with correct options.
+              #@TestPostamble       none
+              #@TestResult          Success if ldapcompare returns 5.
+            -->
+            <testcase name="getTestCaseName
+            ('ldapcompare: multiple comparison unsuccessful')">
+              
+              <sequence>
+                
+                <call function="'testCase_Preamble'"/>
+                
+                <message>
+                  'ldapcompare: multiple comparison unsuccessful'
+                </message>
+                
+                <call function="'ldapCompareWithScript'">
+                  { 
+                  'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                  'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                  'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                  'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                  'dsDn'             : ['postalCode:89759' ,
+                                        '%s' % dn1 ,
+                                        '%s' % dn2] ,
+                  'useCmpRC'         : 'True' ,
+                  'expectedRC'       : 5
+                  }
+                </call>
+
+                <script>
+                  returnString = STAXResult[0][1]
+                </script>
+
+                <script>
+                  msg = 'Compare operation returned true for entry uid=user.162' 
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+
+                <script>
+                  msg = 'Compare operation returned false for entry uid=user.1' 
+                </script>                  
+                <call function="'searchString'">
+                  { 
+                  'returnString'   : returnString ,
+                  'expectedString' : msg
+                  }
+                </call>
+
+                <call function="'testCase_Postamble'"/>
+                
+              </sequence>
+              
+            </testcase>
             
           </sequence>
 
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml
index 0f9dab8..aff5f5e 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/clu/clu_rebuild-index_checkbehavior.xml
@@ -1847,7 +1847,7 @@
                 </call>
 
                 <script>
-                  msg1 = 'Option \"--rebuildDegraded\" option cannot be specified'
+                  msg1 = 'Option \"--rebuildDegraded\" cannot be specified'
                   msg2 = 'with the \"--index\" option'
                 </script>
                 <call function="'searchString'">
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/ldap.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/ldap.xml
index 0be0f76..a8ae902 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/ldap.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/ldap.xml
@@ -24,7 +24,7 @@
  ! CDDL HEADER END
  !
  !      Copyright 2007-2010 Sun Microsystems, Inc.
- !      Portions Copyright 2012 ForgeRock AS.
+ !      Portions Copyright 2012-2013 ForgeRock AS.
  ! -->
 <stax>
   <function name="addEntry">
@@ -2106,6 +2106,14 @@
         </function-arg-description>
         <function-arg-property name="type" value="dn"/>
       </function-arg-def>
+      <function-arg-def name="useCmpRC" type="optional">
+        <function-arg-description>
+          Use an exit code that indicates whether comparison is successful.
+          Results are an exit code of 6 (COMPARE_TRUE) or
+          an exit code of 5 (COMPARE_FALSE).
+        </function-arg-description>
+        <function-arg-property name="type" value="option"/>
+      </function-arg-def>
       <function-arg-def name="expectedRC" type="optional" default="0">
         <function-arg-description>
           Expected return code value. Default value is 0
@@ -2214,6 +2222,9 @@
                           
         if dsUseSSL:
           STAFCmdParamsList.append('-Z')
+
+        if useCmpRC:
+          STAFCmdParamsList.append('--useCompareResultCode')
           
         if dsDn:
           for dn in dsDn:
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml
index 2a362cd..e933cea 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/tools.xml
@@ -1741,8 +1741,7 @@
       </function-arg-def>
       <function-arg-def name="useCmpRC" type="optional">
         <function-arg-description>
-          Use an exit code that indicates whether a given clear-text password
-          matched a provided encoded password.
+          Use an exit code that indicates whether difference were not found.
           Results are an exit code of 6 (COMPARE_TRUE) or
           an exit code of 5 (COMPARE_FALSE).
         </function-arg-description>

--
Gitblit v1.10.0