From af0400482a07e77d9a4f68122977d685143872cc Mon Sep 17 00:00:00 2001
From: el_kaboing <el_kaboing@localhost>
Date: Fri, 08 Dec 2006 19:41:39 +0000
Subject: [PATCH] Adding functional tests for Issue 322.

---
 opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/admin_add_BASE64.ldif             |   29 ++++
 opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_change_pwd_mult_schemes.ldif |   29 ++++
 opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_add_pwd.ldif                 |   29 ++++
 opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_pwd_storage.xml            |    4 
 opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_multiple_schemes.xml       |  277 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 368 insertions(+), 0 deletions(-)

diff --git a/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/admin_add_BASE64.ldif b/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/admin_add_BASE64.ldif
new file mode 100644
index 0000000..dc56c20
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/admin_add_BASE64.ldif
@@ -0,0 +1,29 @@
+# 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 Sun Microsystems, Inc.
+#
+
+dn: cn=Default Password Policy,cn=Password Policies,cn=config
+changetype: modify
+add: ds-cfg-default-password-storage-scheme
+ds-cfg-default-password-storage-scheme: BASE64
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_add_pwd.ldif b/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_add_pwd.ldif
new file mode 100644
index 0000000..7b75abe
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_add_pwd.ldif
@@ -0,0 +1,29 @@
+# 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 Sun Microsystems, Inc.
+#
+
+dn: uid=bhall,ou=People,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com
+changetype: modify
+add: userpassword
+userpassword: anotherorange
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_change_pwd_mult_schemes.ldif b/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_change_pwd_mult_schemes.ldif
new file mode 100644
index 0000000..e378a11
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/data/security/pwd_storage/user_change_pwd_mult_schemes.ldif
@@ -0,0 +1,29 @@
+# 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 Sun Microsystems, Inc.
+#
+
+dn: uid=bhall,ou=People,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com
+changetype: modify
+replace: userpassword
+userpassword: manyoranges
diff --git a/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_multiple_schemes.xml b/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_multiple_schemes.xml
new file mode 100755
index 0000000..f27c867
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_multiple_schemes.xml
@@ -0,0 +1,277 @@
+<?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 Sun Microsystems, Inc.
+ -->
+<stax>
+
+  <defaultcall function="multiple_schemes"/>
+
+  <function name="multiple_schemes">
+
+      <sequence>
+
+        <!--- Test case: Admin Add Base64 Storage Scheme -->
+        <testcase name="'Security: Mult Pwd Schemes: Preamble'">
+          <sequence>
+            <message>
+               'Security: Multiple Pwd Schemes: Preamble - Admin Adding BASE64 Storage Scheme'
+            </message>
+
+            <call function="'modifyEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'entryToBeModified'   : '%s/security/pwd_storage/admin_add_BASE64.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult }
+            </call>
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : Check for Multi-value for Pwd Schemes - SSHA-->
+        <testcase name="'Security: Mult Pwd Schemes: Check Pwd Schemes - SSHA'">
+          <sequence>
+            <message>
+               'Security: Multiple Pwd Schemes: Checking for Password Schemes - SSHA'
+            </message>
+
+            <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'dsBaseDN'         : 'cn=Default Password Policy,cn=Password Policies,cn=config' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'attributes'      : 'ds-cfg-default-password-storage-scheme' }
+            </call>
+
+            <script> 
+             returnString = STAXResult[0][1]
+            </script> 
+
+            <call function="'checktestString'">
+                { 'returnString'       : returnString ,
+                  'expectedString'     : 'SSHA' }
+            </call>
+          
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : Check for Multi-value for Pwd Schemes - BASE64-->
+        <testcase name="'Security: Mult Pwd Schemes: Check Pwd Schemes - BASE64'">
+          <sequence>
+            <message>
+               'Security: Multiple Pwd Schemes: Checking for Password Schemes - BASE64'
+            </message>
+
+            <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'dsBaseDN'         : 'cn=Default Password Policy,cn=Password Policies,cn=config' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'attributes'      : 'ds-cfg-default-password-storage-scheme' }
+            </call>
+
+            <script> 
+             returnString = STAXResult[0][1]
+            </script> 
+
+            <call function="'checktestString'">
+                { 'returnString'       : returnString ,
+                  'expectedString'     : 'BASE64' }
+            </call>
+          
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : User Change Password Multiple Schemes-->
+        <testcase name="'Security: Mult Pwd Schemes: Pwd Change'">
+          <sequence>
+            <message>
+               'Security: Multiple Pwd Schemes: User Changing Password'
+            </message>
+
+            <call function="'modifyEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=bhall,ou=people,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'oranges' ,
+                'entryToBeModified'   : '%s/security/pwd_storage/user_change_pwd_mult_schemes.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <if expr="RC != 0">
+                <tcstatus result="'fail'"/>
+            </if>
+
+            <message>
+               'Security: Multiple Pwd Schemes: User Binding With New Password'
+            </message>
+
+            <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=bhall,ou=people,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'manyoranges' ,
+                'dsBaseDN'   : 'dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'extraParams'      : '-s base' }
+            </call>
+
+            <if expr="RC != 0">
+                <tcstatus result="'fail'"/>
+            </if>
+
+            <message>
+               'Security: Multiple Pwd Schemes: Checking for SSHA Scheme On New Password'
+            </message>
+
+            <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'dsBaseDN'         : 'uid=bhall,ou=people,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'attributes'      : 'userpassword' }
+            </call>
+
+            <script> 
+             returnString = STAXResult[0][1]
+            </script> 
+
+            <call function="'checktestString'">
+                { 'returnString'       : returnString ,
+                  'expectedString'     : '{SSHA}' }
+            </call>
+          
+          </sequence>
+        </testcase>
+
+        <testcase name="'Security: Mult Pwd Schemes: Check for Second Scheme On Pwd Change'">
+          <sequence>
+            <message>
+               'Security: Multiple Pwd Schemes: Checking for BASE64 Scheme On New Password'
+            </message>
+
+            <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'dsBaseDN'         : 'uid=bhall,ou=people,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'attributes'      : 'userpassword' }
+            </call>
+
+            <script> 
+             returnString = STAXResult[0][1]
+            </script> 
+
+            <call function="'checktestString'">
+                { 'returnString'       : returnString ,
+                  'expectedString'     : '{BASE64}' }
+            </call>
+          
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : User Improperly Add a Password-->
+        <testcase name="'Security: Mult Pwd Schemes: Improper Pwd Add'">
+          <sequence>
+            <message>
+               'Security: Multiple Pwd Schemes: User Improperly Add Password'
+            </message>
+
+            <call function="'modifyEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=bhall,ou=people,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'manyoranges' ,
+                'entryToBeModified'   : '%s/security/pwd_storage/user_add_pwd.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult ,
+                  'expected'   : 53 }
+            </call>
+          </sequence>
+        </testcase>
+
+        <!--- Test case: Admin Reset To SSHA Storage Scheme -->
+        <testcase name="'Security: Mult Pwd Schemes: Postamble'">
+          <sequence>
+            <message>
+               'Security: Mult Pwd Schemes: Postamble - Admin Resetting to SSHA Storage Scheme'
+            </message>
+
+            <call function="'modifyEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'entryToBeModified'   : '%s/security/pwd_storage/admin_reset_SSHA.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <if expr="RC != 0">
+                <tcstatus result="'fail'"/>
+            </if>
+
+            <message>
+               'Security: Multiple Pwd Schemes: User Bind Final'
+            </message>
+
+            <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=bhall,ou=people,ou=password tests,o=Pwd Storage Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'manyoranges' ,
+                'dsBaseDN'   : 'dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'extraParams'      : '-s base' }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult }
+            </call>
+          </sequence>
+        </testcase>
+
+        <return>RC</return>
+
+     </sequence>
+
+  </function>
+
+</stax>
diff --git a/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_pwd_storage.xml b/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_pwd_storage.xml
index e00691e..9419318 100755
--- a/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_pwd_storage.xml
+++ b/opendj-sdk/opends/tests/functional-tests/testcases/security/pwd_storage/security_pwd_storage.xml
@@ -109,6 +109,10 @@
         <call function="'pwd_CLEAR'" />
 
         <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
+          file="'%s/testcases/security/pwd_storage/security_multiple_schemes.xml' % (TESTS_DIR)"/>
+        <call function="'multiple_schemes'" />
+
+        <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
           file="'%s/testcases/security/pwd_storage/security_teardown_pwd_storage.xml' % (TESTS_DIR)"/>
         <call function="'teardown_pwd_storage'" />
 

--
Gitblit v1.10.0