From e20d42a41192157c9e8d17a77131a76e796f10ad Mon Sep 17 00:00:00 2001
From: mkeyes <mkeyes@localhost>
Date: Mon, 23 Jul 2007 14:28:31 +0000
Subject: [PATCH] In preparation for the refactoring of the Security test suites to use dsconfig, the attached changes are made to the functional test library functions.

---
 opendj-sdk/opends/tests/functional-tests/config/config.py                 |    1 
 opendj-sdk/opends/tests/functional-tests/shared/functions/environment.xml |    5 
 opendj-sdk/opends/tests/functional-tests/shared/functions/dsconfig.xml    |  345 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 350 insertions(+), 1 deletions(-)

diff --git a/opendj-sdk/opends/tests/functional-tests/config/config.py b/opendj-sdk/opends/tests/functional-tests/config/config.py
index 2c499f2..6f4ea0e 100644
--- a/opendj-sdk/opends/tests/functional-tests/config/config.py
+++ b/opendj-sdk/opends/tests/functional-tests/config/config.py
@@ -28,3 +28,4 @@
 LOGS_URI                    = ''
 SEND_MAIL_AFTER_TEST_RUN    = 'false'
 SEND_MAIL_TO                = ''
+DSCONFIG                    = 'dsconfig'
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/functions/dsconfig.xml b/opendj-sdk/opends/tests/functional-tests/shared/functions/dsconfig.xml
new file mode 100755
index 0000000..33afc08
--- /dev/null
+++ b/opendj-sdk/opends/tests/functional-tests/shared/functions/dsconfig.xml
@@ -0,0 +1,345 @@
+<?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-2007 Sun Microsystems, Inc.
+ ! -->
+<stax>
+  
+  <function name="_dsconfigCommonArgs">
+    <function-prolog>
+      This function resolves common dsconfig arguments
+    </function-prolog>
+    <function-no-args/>
+  
+    <script>
+        if dsInstanceHost:
+          STAFCmdParamsList.append('-h %s' % dsInstanceHost)
+                  
+        if dsInstancePort:
+          STAFCmdParamsList.append('-p %s' % dsInstancePort)
+
+        if dsInstanceDn:
+          STAFCmdParamsList.append('-D "%s"' % dsInstanceDn)
+        
+        if dsInstancePswd:
+          STAFCmdParamsList.append('-w "%s"' % dsInstancePswd)
+    </script>
+              
+  </function>
+  
+  <!-- Modify password policy using dsconfig -->
+  <function name="modifyPwdPolicy">
+    <function-prolog>
+      This function modifies a password policy using dsconfig
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Location of target host
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname"/>
+      </function-arg-def>
+		
+      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath"/>
+      </function-arg-def>
+		
+      <function-arg-def name="dsInstanceHost" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Directory server hostname or IP address
+        </function-arg-description>
+		<function-arg-property name="type" value="hostname"/>
+      </function-arg-def>      
+		
+      <function-arg-def name="dsInstancePort" type="required">
+        <function-arg-description>
+          Directory server port number
+        </function-arg-description>		  
+        <function-arg-property name="type" value="Port number"/>
+      </function-arg-def>
+		
+      <function-arg-def name="dsInstanceDn" type="required">
+        <function-arg-description>
+          Bind DN
+        </function-arg-description>
+        <function-arg-property name="type" value="DN"/>
+      </function-arg-def> 
+		
+      <function-arg-def name="dsInstancePswd" type="required">
+        <function-arg-description>
+          Bind password
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>          
+		
+      <function-arg-def name="propertyName" type="required">
+        <function-arg-description>
+          Property to modify, e.g. enabled
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="attributeName" type="required">
+        <function-arg-description>
+          Attribute to modify, e.g. minimum-password-length
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="attributeValue" type="required">
+        <function-arg-description>
+          New attribute value
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="expectedRC" type="optional" default="0">
+      <function-arg-description>
+	 Expected return code value. Default value is 0
+      </function-arg-description>
+      <function-arg-property name="type" value="string"/>
+    </function-arg-def>			
+	
+    </function-map-args>
+    <sequence>
+    
+      <!-- Local variables -->
+      <script>
+        mylocation=location
+        STAFCmdParams=''	
+        STAFCmd=''			  	
+      
+        if dsPath:
+          dsBinPath='%s/%s' % (dsPath,fileFolder)
+          STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
+
+        if attributeValue:
+            attributeValue=attributeValue.replace('"','QUOT')
+            
+        STAFCmdParamsList=[]
+        STAFCmdParamsList.append('set-password-policy-prop ')
+        STAFCmdParamsList.append('--policy-name "%s" ' % (propertyName))
+        STAFCmdParamsList.append('--set "%s:%s"' % (attributeName,attributeValue))
+      </script>
+     
+      <call function="'_dsconfigCommonArgs'"/>
+      
+      <script>
+        STAFCmdParams=' '.join(STAFCmdParamsList)
+      </script>
+      
+      <message>
+        '%s %s' % (STAFCmd, STAFCmdParams)
+      </message>
+           
+      <process name="'Modify dsconfig object'">
+        <location>'%s' % location</location>
+        <command>'%s' % STAFCmd</command>
+        <parms>'%s' % STAFCmdParams</parms>
+        <workdir>'%s' % dsBinPath</workdir>
+        <envs>
+          ['PATH=/bin:/usr/bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME]
+        </envs>
+        <console use="'same'"/>
+        <stderr mode="'stdout'"/>
+        <returnstdout/>
+      </process>
+
+      <script>
+        STAXCode=RC
+        STAXReason=STAXResult
+      </script>
+      <if expr="expectedRC != 'noCheck'">
+        <call function="'checktestRC'">
+          { 'returncode' : STAXCode ,
+            'result'     : STAXReason ,
+            'expected'   : expectedRC }
+        </call>
+      </if>        
+      <return>
+        STAXReason
+      </return>
+      
+    </sequence>
+    
+  </function>
+
+  <!-- Set property value using dsconfig -->
+  <function name="dsconfigSet">
+    <function-prolog>
+      This function modifies a property value using dsconfig
+    </function-prolog>
+    <function-map-args>
+      <function-arg-def name="location" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Location of target host
+        </function-arg-description>
+        <function-arg-property name="type" value="hostname"/>
+      </function-arg-def>
+		
+      <function-arg-def name="dsPath" type="optional" default="'%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)">
+        <function-arg-description>
+          Pathname to installation root
+        </function-arg-description>
+        <function-arg-property name="type" value="filepath"/>
+      </function-arg-def>
+		
+      <function-arg-def name="dsInstanceHost" type="optional" default="'%s' % STAF_REMOTE_HOSTNAME">
+        <function-arg-description>
+          Directory server hostname or IP address
+        </function-arg-description>
+		<function-arg-property name="type" value="hostname"/>
+      </function-arg-def>      
+		
+      <function-arg-def name="dsInstancePort" type="required">
+        <function-arg-description>
+          Directory server port number
+        </function-arg-description>		  
+        <function-arg-property name="type" value="Port number"/>
+      </function-arg-def>
+		
+      <function-arg-def name="dsInstanceDn" type="required">
+        <function-arg-description>
+          Bind DN
+        </function-arg-description>
+        <function-arg-property name="type" value="DN"/>
+      </function-arg-def> 
+		
+      <function-arg-def name="dsInstancePswd" type="required">
+        <function-arg-description>
+          Bind password
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>          
+		
+      <function-arg-def name="objectName" type="required">
+        <function-arg-description>
+          Object to modify, e.g. password validator
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="propertyType" type="required">
+        <function-arg-description>
+          Property type to modify, e.g. validator
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="propertyName" type="required">
+        <function-arg-description>
+          Property to modify, e.g. enabled
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="attributeName" type="required">
+        <function-arg-description>
+          Attribute to modify, e.g. minimum-password-length
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="attributeValue" type="required">
+        <function-arg-description>
+          New attribute value
+        </function-arg-description>
+        <function-arg-property name="type" value="string"/>
+      </function-arg-def>
+			
+      <function-arg-def name="expectedRC" type="optional" default="0">
+      <function-arg-description>
+	 Expected return code value. Default value is 0
+      </function-arg-description>
+      <function-arg-property name="type" value="string"/>
+    </function-arg-def>			
+	
+    </function-map-args>
+    <sequence>
+    
+      <!-- Local variables -->
+      <script>
+        mylocation=location
+        STAFCmdParams=''	
+        STAFCmd=''			  	
+      
+        if dsPath:
+          dsBinPath='%s/%s' % (dsPath,fileFolder)
+          STAFCmd='%s/%s%s' % (dsBinPath,DSCONFIG,fileExt)
+
+        if attributeValue:
+            attributeValue=attributeValue.replace('"','QUOT')
+            
+        STAFCmdParamsList=[]
+        STAFCmdParamsList.append('set-%s-prop ' % (objectName))
+        STAFCmdParamsList.append('--%s-name "%s" ' % (propertyType,propertyName))
+        STAFCmdParamsList.append('--set "%s:%s"' % (attributeName,attributeValue))
+      </script>
+     
+      <call function="'_dsconfigCommonArgs'"/>
+      
+      <script>
+        STAFCmdParams=' '.join(STAFCmdParamsList)
+      </script>
+      
+      <message>
+        '%s %s' % (STAFCmd, STAFCmdParams)
+      </message>
+           
+      <process name="'Modify dsconfig object'">
+        <location>'%s' % location</location>
+        <command>'%s' % STAFCmd</command>
+        <parms>'%s' % STAFCmdParams</parms>
+        <workdir>'%s' % dsBinPath</workdir>
+        <envs>
+          ['PATH=/bin:/usr/bin:%s' % dsBinPath, 'JAVA_HOME=%s' % JAVA_HOME]
+        </envs>
+        <console use="'same'"/>
+        <stderr mode="'stdout'"/>
+        <returnstdout/>
+      </process>
+
+      <script>
+        STAXCode=RC
+        STAXReason=STAXResult
+      </script>
+      <call function="'checktestRC'">
+          { 'returncode' : STAXCode ,
+            'result'     : STAXReason ,
+            'expected'   : expectedRC }
+      </call>
+              
+      <return>
+        STAXReason
+      </return>
+      
+    </sequence>
+    
+  </function>
+
+</stax>
diff --git a/opendj-sdk/opends/tests/functional-tests/shared/functions/environment.xml b/opendj-sdk/opends/tests/functional-tests/shared/functions/environment.xml
index 155ead2..dfd3355 100755
--- a/opendj-sdk/opends/tests/functional-tests/shared/functions/environment.xml
+++ b/opendj-sdk/opends/tests/functional-tests/shared/functions/environment.xml
@@ -51,12 +51,15 @@
         file="'%s/dsadm.xml' % (TESTS_FUNCTIONS_DIR)" />
 
       <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
+        file="'%s/dsconfig.xml' % (TESTS_FUNCTIONS_DIR)" />
+
+      <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
         file="'%s/ldap.xml' % (TESTS_FUNCTIONS_DIR)" />
 
       <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
         file="'%s/security.xml' % (TESTS_FUNCTIONS_DIR)" />
 		
-	  <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
+      <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"
         file="'%s/topology.xml' % (TESTS_FUNCTIONS_DIR)" />
         
       <import machine="'%s' % (STAF_LOCAL_HOSTNAME)"

--
Gitblit v1.10.0