From 3173bc27e85d1dbf26621bba19a95444d82a6e8c Mon Sep 17 00:00:00 2001
From: el_kaboing <el_kaboing@localhost>
Date: Mon, 20 Nov 2006 15:17:02 +0000
Subject: [PATCH] Adding functional tests for Issue 320.

---
 opends/tests/functional-tests/shared/data/security/pwd_policy/admin_disable_preencoded_pwds.ldif |   29 ++++
 opends/tests/functional-tests/testcases/security/pwd_policy/security_preencoded_pwds.xml         |  204 ++++++++++++++++++++++++++++++++++
 opends/tests/functional-tests/testcases/security/pwd_policy/security_pwd_policy.xml              |    4 
 opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd.ldif      |   43 +++++++
 opends/tests/functional-tests/shared/data/security/pwd_policy/admin_enable_preencoded_pwds.ldif  |   29 ++++
 opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd2.ldif     |   43 +++++++
 6 files changed, 352 insertions(+), 0 deletions(-)

diff --git a/opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd.ldif b/opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd.ldif
new file mode 100644
index 0000000..216fa03
--- /dev/null
+++ b/opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd.ldif
@@ -0,0 +1,43 @@
+# 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=pguy,ou=People,ou=password tests,o=Pwd Policy Tests,dc=example,dc=com
+objectClass: person
+objectClass: inetOrgPerson
+objectClass: top
+objectClass: organizationalPerson
+ou: Accounting
+ou: People
+sn: Guy
+facsimiletelephonenumber: +1 408 555 9751
+roomnumber: 4612
+userpassword: {SSHA}oos/npB0lBtdF1hZxBlavB9m5c7Gczn+LOf41Q==
+l: Sunnyvale
+cn: Precoded Guy
+telephonenumber: +1 408 555 4798
+givenname: Precoded
+uid: pguy
+mail: pguy@example.com
+
diff --git a/opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd2.ldif b/opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd2.ldif
new file mode 100644
index 0000000..1110c69
--- /dev/null
+++ b/opends/tests/functional-tests/shared/data/security/pwd_policy/add_entry_preencoded_pwd2.ldif
@@ -0,0 +1,43 @@
+# 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=pgal,ou=People,ou=password tests,o=Pwd Policy Tests,dc=example,dc=com
+objectClass: person
+objectClass: inetOrgPerson
+objectClass: top
+objectClass: organizationalPerson
+ou: Accounting
+ou: People
+sn: Gal
+facsimiletelephonenumber: +1 408 555 9751
+roomnumber: 4612
+userpassword: {SSHA}h0RC6mR25hr6Kqe/j3Wsqt7KR6TkKTO/9LYTUQ==
+l: Sunnyvale
+cn: Precoded Gal
+telephonenumber: +1 408 555 4798
+givenname: Precoded
+uid: pgal
+mail: pguy@example.com
+
diff --git a/opends/tests/functional-tests/shared/data/security/pwd_policy/admin_disable_preencoded_pwds.ldif b/opends/tests/functional-tests/shared/data/security/pwd_policy/admin_disable_preencoded_pwds.ldif
new file mode 100644
index 0000000..e867f49
--- /dev/null
+++ b/opends/tests/functional-tests/shared/data/security/pwd_policy/admin_disable_preencoded_pwds.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
+replace: ds-cfg-allow-pre-encoded-passwords
+ds-cfg-allow-pre-encoded-passwords: false
diff --git a/opends/tests/functional-tests/shared/data/security/pwd_policy/admin_enable_preencoded_pwds.ldif b/opends/tests/functional-tests/shared/data/security/pwd_policy/admin_enable_preencoded_pwds.ldif
new file mode 100644
index 0000000..cd2c38d
--- /dev/null
+++ b/opends/tests/functional-tests/shared/data/security/pwd_policy/admin_enable_preencoded_pwds.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
+replace: ds-cfg-allow-pre-encoded-passwords
+ds-cfg-allow-pre-encoded-passwords: true
diff --git a/opends/tests/functional-tests/testcases/security/pwd_policy/security_preencoded_pwds.xml b/opends/tests/functional-tests/testcases/security/pwd_policy/security_preencoded_pwds.xml
new file mode 100755
index 0000000..f15db96
--- /dev/null
+++ b/opends/tests/functional-tests/testcases/security/pwd_policy/security_preencoded_pwds.xml
@@ -0,0 +1,204 @@
+<?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="preencoded_pwds"/>
+
+  <function name="preencoded_pwds">
+
+      <sequence>
+
+        <!--- Test Case : Preamble 1 - Check Default-->
+        <testcase name="'Security: Preencoded Pwds: Preamble'">
+          <sequence>
+            <message>
+               'Security: Preencoded Pwds: Preamble - Check for existence of ds-cfg-allow-pre-encoded-passwords'
+            </message>
+
+            <call function="'compareEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'attrToBeCompared'   : 'ds-cfg-allow-pre-encoded-passwords:false',
+                'entryToBeCompared'   : 'cn=Default Password Policy,cn=Password Policies,cn=config' }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult }
+            </call>
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : Add Entry With Pre-encoded Password -->
+        <testcase name="'Security: Preencoded Pwds: Default - Add New Entry'">
+          <sequence>
+            <message>
+               'Security: Preencoded Pwds: Adding New Entry With a Pre-encoded Password'
+            </message>
+
+            <call function="'addEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'entryToBeAdded'   : '%s/security/pwd_policy/add_entry_preencoded_pwd.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <if expr="RC != 19">
+                <tcstatus result="'fail'"/>
+            </if>
+
+             <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=pguy,ou=people,ou=password tests,o=Pwd Policy Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'superguy' ,
+                'dsBaseDN'   : 'dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'extraParams'      : '-s base' }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult ,
+                  'expected'   : 1}
+            </call>
+
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : Enable Pre-encoded Passwords -->
+        <testcase name="'Security: Preencoded Pwds: Enable Preencoded Pwds'">
+          <sequence>
+            <message>
+               'Security: Preencoded Pwds: Admin Enabling Preencoded Pwds'
+            </message>
+
+            <call function="'modifyEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'entryToBeModified'   : '%s/security/pwd_policy/admin_enable_preencoded_pwds.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult }
+            </call>
+
+          </sequence>
+        </testcase>
+
+            
+        <!--- Test Case : Test Enabled Pre-encoded Passwords -->
+        <testcase name="'Security: Preencoded Pwds: Enabled - Add New Entry'">
+          <sequence>
+            <message>
+               'Security: Preencoded Pwds: Add New Entry With Pre-encoded Password'
+            </message>
+
+            <call function="'addEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'entryToBeAdded'   : '%s/security/pwd_policy/add_entry_preencoded_pwd.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <if expr="RC != 0">
+                <tcstatus result="'fail'"/>
+            </if>
+
+             <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=pguy,ou=people,ou=password tests,o=Pwd Policy Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'superguy' ,
+                'dsBaseDN'   : 'dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'extraParams'      : '-s base' }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult }
+            </call>
+
+          </sequence>
+        </testcase>
+
+        <!--- Test Case : Disable Pre-encoded Passwordds -->
+        <testcase name="'Security: Preencoded Pwds: Disable Preencoded Pwds'">
+          <sequence>
+            <message>
+               'Security: Preencoded Pwds: Admin Disabling Pre-encoded Pwds'
+            </message>
+
+            <call function="'modifyEntry'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : DIRECTORY_INSTANCE_DN ,
+                'dsInstancePswd'   : DIRECTORY_INSTANCE_PSWD ,
+                'entryToBeModified'   : '%s/security/pwd_policy/admin_disable_preencoded_pwds.ldif' % STAGED_DATA_DIR }
+            </call>
+
+            <if expr="RC != 0">
+                <tcstatus result="'fail'"/>
+            </if>
+
+             <call function="'SearchObject'">
+              { 'dsInstanceHost'   : DIRECTORY_INSTANCE_HOST ,
+                'dsInstancePort'   : DIRECTORY_INSTANCE_PORT ,
+                'dsInstanceDn'     : 'uid=pgal,ou=people,ou=password tests,o=Pwd Policy Tests,dc=example,dc=com' ,
+                'dsInstancePswd'   : 'supergal' ,
+                'dsBaseDN'   : 'dc=example,dc=com' ,
+                'dsFilter'         : 'objectclass=*'  ,
+                'extraParams'      : '-s base' }
+            </call>
+
+            <call function="'checktestRC'">
+                { 'returncode' : RC ,
+                  'result'     : STAXResult ,
+                  'expected'   : 1}
+            </call>
+
+         </sequence>
+        </testcase>
+
+
+        <return>RC</return>
+
+     </sequence>
+
+  </function>
+
+</stax>
diff --git a/opends/tests/functional-tests/testcases/security/pwd_policy/security_pwd_policy.xml b/opends/tests/functional-tests/testcases/security/pwd_policy/security_pwd_policy.xml
index 1ba4152..f462834 100755
--- a/opends/tests/functional-tests/testcases/security/pwd_policy/security_pwd_policy.xml
+++ b/opends/tests/functional-tests/testcases/security/pwd_policy/security_pwd_policy.xml
@@ -111,6 +111,10 @@
           file="'%s/testcases/security/pwd_policy/security_mult_pwd_policies.xml' % (TESTS_DIR)"/>
         <call function="'mult_pwd_policies'" />
 
+        <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
+          file="'%s/testcases/security/pwd_policy/security_preencoded_pwds.xml' % (TESTS_DIR)"/>
+        <call function="'preencoded_pwds'" />
+
         <!--- Test Case : Stop DS -->
         <testcase name="'StopDS'">
           <sequence>

--
Gitblit v1.10.0