From e44115d81e0ecff3c86357d00a3d7111be2df6d4 Mon Sep 17 00:00:00 2001
From: gary_williams <gary_williams@localhost>
Date: Mon, 22 Oct 2007 13:05:36 +0000
Subject: [PATCH] new test suite for base64 tool
---
opends/tests/functional-tests/shared/functions/dsadm.xml | 217 +++++++++++++++++++
opends/tests/functional-tests/testcases/clu/cluBase64.xml | 206 ++++++++++++++++++
opends/tests/functional-tests/shared/data/clu/data/clu_start.ldif | 8
opends/tests/functional-tests/testcases/clu/clu_setup.xml | 216 ++++++++++---------
opends/tests/functional-tests/testcases/clu/commands.xml | 4
5 files changed, 545 insertions(+), 106 deletions(-)
diff --git a/opends/tests/functional-tests/shared/data/clu/data/clu_start.ldif b/opends/tests/functional-tests/shared/data/clu/data/clu_start.ldif
index 58de636..2efca3e 100644
--- a/opends/tests/functional-tests/shared/data/clu/data/clu_start.ldif
+++ b/opends/tests/functional-tests/shared/data/clu/data/clu_start.ldif
@@ -23,6 +23,14 @@
# Portions Copyright 2006-2007 Sun Microsystems, Inc.
#
+dn: dc=com
+dc: com
+objectclass: domain
+
+dn: dc=example,dc=com
+dc: example
+objectclass: domain
+
dn: o=core tests,dc=example,dc=com
o: core tests
objectclass: top
diff --git a/opends/tests/functional-tests/shared/functions/dsadm.xml b/opends/tests/functional-tests/shared/functions/dsadm.xml
index 40b4145..e9c6833 100755
--- a/opends/tests/functional-tests/shared/functions/dsadm.xml
+++ b/opends/tests/functional-tests/shared/functions/dsadm.xml
@@ -3070,5 +3070,220 @@
</function>
-
+ <!-- This function shows server status using the status script -->
+ <function name="StatusWithScript">
+ <function-prolog>
+ This function shows server status using the status script
+ </function-prolog>
+ <function-map-args>
+ <function-arg-def name="location" type="optional" default="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="dsBindDN" type="optional">
+ <function-arg-description>
+ Bind DN
+ </function-arg-description>
+ <function-arg-property name="type" value="DN"/>
+ </function-arg-def>
+ <function-arg-def name="dsBindPwd" type="optional">
+ <function-arg-description>
+ Bind password
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="dsHelp" type="optional">
+ <function-arg-description>
+ Help option
+ </function-arg-description>
+ <function-arg-property name="help" value="option"/>
+ </function-arg-def>
+ </function-map-args>
+
+ <sequence>
+
+ <!-- Build the Command -->
+ <script>
+ STAFCmdParamsList=[]
+ STAFCmdParams=''
+
+ STAFCmdParamsList.append('-n')
+ if dsPath:
+ dsBinPath='%s/%s' % (dsPath,fileFolder)
+ STAFCmd='%s/status%s' % (dsBinPath,fileExt)
+
+ if dsBindDN:
+ STAFCmdParamsList.append('-D "%s"' % dsBindDN)
+
+ if dsBindPwd:
+ STAFCmdParamsList.append('-w "%s"' % dsBindPwd)
+
+ if dsHelp:
+ STAFCmdParamsList.append('-H')
+
+ STAFCmdParams=' '.join(STAFCmdParamsList)
+ </script>
+
+ <message>
+ '%s %s' % (STAFCmd, STAFCmdParams)
+ </message>
+ <call function="'runCommand'">
+ { 'location' : location,
+ 'name' : 'Status Script',
+ 'command' : STAFCmd,
+ 'arguments' : STAFCmdParams,
+ 'path' : dsPath
+ }
+ </call>
+
+ <call function="'checkRC'">
+ { 'returncode' : RC ,
+ 'result' : STAXResult }
+ </call>
+
+ </sequence>
+
+ </function>
+
+ <!-- This function executes the base64 encode decode utility with script -->
+ <function name="Base64WithScript">
+ <function-prolog>
+ This function executes the base64 encode decode utility with script
+ </function-prolog>
+ <function-map-args>
+ <function-arg-def name="location" type="optional" default="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="subcommand" type="required">
+ <function-arg-description>
+ The subcommand for base64 (encode or decode)
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="rawData" type="optional">
+ <function-arg-description>
+ The raw data to be base64 encoded
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="rawDataFile" type="optional">
+ <function-arg-description>
+ The path to a file containing the raw data to be base64 encoded
+ </function-arg-description>
+ <function-arg-property name="type" value="filename"/>
+ </function-arg-def>
+ <function-arg-def name="toEncodedFile" type="optional">
+ <function-arg-description>
+ The path to a file to which the base64-encoded data should be written
+ </function-arg-description>
+ <function-arg-property name="type" value="filename"/>
+ </function-arg-def>
+ <function-arg-def name="encodedData" type="optional">
+ <function-arg-description>
+ The base64-encoded data to be decoded
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="encodedDataFile" type="optional">
+ <function-arg-description>
+ The path to a file containing the base64-encoded data to be decoded
+ </function-arg-description>
+ <function-arg-property name="type" value="filename"/>
+ </function-arg-def>
+ <function-arg-def name="toRawFile" type="optional">
+ <function-arg-description>
+ The path to a file to which the raw base64-decoded data should be written
+ </function-arg-description>
+ <function-arg-property name="type" value="filename"/>
+ </function-arg-def>
+ <function-arg-def name="toolHelp" type="optional">
+ <function-arg-description>
+ Help option
+ </function-arg-description>
+ <function-arg-property name="help" value="option"/>
+ </function-arg-def>
+ </function-map-args>
+
+ <sequence>
+
+ <!-- Build the Command -->
+ <script>
+ STAFCmdParamsList=[]
+ STAFCmdParams=''
+
+ if dsPath:
+ dsBinPath='%s/%s' % (dsPath,fileFolder)
+ STAFCmd='%s/base64%s' % (dsBinPath,fileExt)
+
+ if subcommand:
+ STAFCmdParamsList.append(subcommand)
+
+ if rawData:
+ STAFCmdParamsList.append('-d "%s"' % rawData)
+
+ if rawDataFile:
+ STAFCmdParamsList.append('-f "%s"' % rawDataFile)
+
+ if toEncodedFile:
+ STAFCmdParamsList.append('-o "%s"' % toEncodedFile)
+
+ if encodedData:
+ STAFCmdParamsList.append('-d "%s"' % encodedData)
+
+ if encodedDataFile:
+ STAFCmdParamsList.append('-f "%s"' % encodedDataFile)
+
+ if toRawFile:
+ STAFCmdParamsList.append('-o "%s"' % toRawFile)
+
+ if toolHelp:
+ STAFCmdParamsList.append('-H')
+
+ STAFCmdParams=' '.join(STAFCmdParamsList)
+ </script>
+
+ <message>
+ '%s %s' % (STAFCmd, STAFCmdParams)
+ </message>
+ <call function="'runCommand'">
+ { 'location' : location,
+ 'name' : 'Base 64 %s Script' % subcommand,
+ 'command' : STAFCmd,
+ 'arguments' : STAFCmdParams,
+ 'path' : dsPath
+ }
+ </call>
+
+ <script>
+ CmdRC=RC
+ CmdResult=STAXResult
+ </script>
+
+ <call function="'checkRC'">
+ { 'returncode' : CmdRC ,
+ 'result' : CmdResult }
+ </call>
+
+ <return>CmdResult</return>
+
+ </sequence>
+ </function>
+
</stax>
diff --git a/opends/tests/functional-tests/testcases/clu/cluBase64.xml b/opends/tests/functional-tests/testcases/clu/cluBase64.xml
new file mode 100644
index 0000000..a519885
--- /dev/null
+++ b/opends/tests/functional-tests/testcases/clu/cluBase64.xml
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE stax SYSTEM "../../shared/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, exclude this CDDL HEADER in each
+ ! file and exclude 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 2007 Sun Microsystems, Inc.
+ ! -->
+
+<stax>
+
+ <defaultcall function="main_cluBase64"/>
+
+ <function name="main_cluBase64">
+
+ <sequence>
+
+ <block name="'cluBase64'">
+
+ <sequence>
+
+ <script>
+ if not CurrentTestPath.has_key('group'):
+ CurrentTestPath['group']='clu'
+ CurrentTestPath['suite']=STAXCurrentBlock
+ </script>
+
+ <call function="'testSuite_Preamble'"/>
+
+ <!--- Test Suite information
+ #@TestSuiteName Clu: Base64
+ #@TestSuitePurpose Check the base64 command with common options
+ #@TestSuiteID Clu Base64 Command
+ #@TestSuiteGroup cluBase64
+ #@TestGroup clu
+ #@TestScript cluBase64.xml
+ #@TestHTMLLink http://opends.dev.java.net/
+ -->
+
+
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/testcases/clu/clu_setup.xml' % (TESTS_DIR)"/>
+
+ <call function="'clu_setup'">
+ { 'startDS' : False,
+ 'loadBackend' : False }
+ </call>
+
+ <!--- Test Case information
+ #@TestMarker Clu Base64 Tests
+ #@TestName Clu: Base64: Encode
+ #@TestID Encode
+ #@TestPurpose Verify that raw data can be base64 encoded.
+ #@TestPreamble
+ #@TestSteps
+ #@TestPostamble
+ #@TestResult Success if status returns 0
+ -->
+
+ <testcase name="getTestCaseName('Encode')">
+
+ <sequence>
+
+ <call function="'testCase_Preamble'"/>
+
+ <message>
+ 'Clu: Base64: Encode'
+ </message>
+
+ <call function="'Base64WithScript'">
+ {
+ 'subcommand' : 'encode',
+ 'rawData' : 'hello world'
+ }
+ </call>
+
+ <!-- STAXResult is not always a list-->
+ <script>
+ try:
+ RC,Result=STAXResult[0]
+ except AttributeError,details:
+ Result='AttributeError: can not parse STAXResult %s' % details
+ RC='1'
+ </script>
+
+ <script>
+ pattern=re.compile('aGVsbG8gd29ybGQ=')
+ </script>
+
+ <if expr="pattern.match(Result)">
+ <sequence>
+ <message>'Base64 returns matching encoded data (%s)' % Result</message>
+ <tcstatus result="'pass'"></tcstatus>
+ </sequence>
+ <else>
+ <sequence>
+ <message>'Base64 returns non matching data (%s)' % Result</message>
+ <tcstatus result="'fail'"></tcstatus>
+ </sequence>
+ </else>
+ </if>
+
+ <call function="'testCase_Postamble'"/>
+
+ </sequence>
+
+ </testcase>
+
+ <!--- Test Case information
+ #@TestMarker Clu Base64 Tests
+ #@TestName Clu: Base64: Decode
+ #@TestID Decode
+ #@TestPurpose Verify that base64 encoded data can be decoded.
+ #@TestPreamble
+ #@TestSteps
+ #@TestPostamble
+ #@TestResult Success if status returns 0
+ -->
+
+ <testcase name="getTestCaseName('Decode')">
+
+ <sequence>
+
+ <call function="'testCase_Preamble'"/>
+
+ <message>
+ 'Clu: Base64: Decode'
+ </message>
+
+ <call function="'Base64WithScript'">
+ {
+ 'subcommand' : 'decode',
+ 'encodedData' : 'aGVsbG8gd29ybGQ='
+ }
+ </call>
+
+ <!-- STAXResult is not always a list-->
+ <script>
+ try:
+ RC,Result=STAXResult[0]
+ except AttributeError,details:
+ Result='AttributeError: can not parse STAXResult %s' % details
+ RC='1'
+ </script>
+
+ <script>
+ pattern=re.compile('hello world')
+ </script>
+
+ <if expr="pattern.match(Result)">
+ <sequence>
+ <message>'Base64 returns matching decoded data (%s)' % Result</message>
+ <tcstatus result="'pass'"></tcstatus>
+ </sequence>
+ <else>
+ <sequence>
+ <message>'Base64 returns non matching data (%s)' % Result</message>
+ <tcstatus result="'fail'"></tcstatus>
+ </sequence>
+ </else>
+ </if>
+
+ <call function="'testCase_Postamble'"/>
+
+ </sequence>
+
+ </testcase>
+
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/testcases/clu/clu_cleanup.xml' % (TESTS_DIR)"/>
+ <call function="'clu_cleanup'">
+ {
+ 'stopDS' : False
+ }
+ </call>
+
+ <call function="'testSuite_Postamble'"/>
+
+ </sequence>
+
+ </block>
+
+ </sequence>
+
+ </function>
+
+</stax>
diff --git a/opends/tests/functional-tests/testcases/clu/clu_setup.xml b/opends/tests/functional-tests/testcases/clu/clu_setup.xml
index eae0226..3545f07 100644
--- a/opends/tests/functional-tests/testcases/clu/clu_setup.xml
+++ b/opends/tests/functional-tests/testcases/clu/clu_setup.xml
@@ -1,137 +1,143 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "../../shared/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 2007 Sun Microsystems, Inc.
- ! -->
+ ! 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 2007 Sun Microsystems, Inc.
+ ! -->
<stax>
- <defaultcall function="clu_setup"/>
+ <defaultcall function="clu_setup" />
<function name="clu_setup">
-
+ <function-description>
+ Setup the command line test suite
+ </function-description>
+ <function-map-args>
+ <function-arg-def name="startDS" type="optional" default="True">
+ <function-arg-description>
+ Start the Directory Server
+ </function-arg-description>
+ </function-arg-def>
+ <function-arg-def name="loadBackend" type="optional" default="True">
+ <function-arg-description>
+ Load the backend with user data
+ </function-arg-description>
+ </function-arg-def>
+ </function-map-args>
+
<sequence>
<block name="'setup'">
-
- <sequence>
-
-
- <block name="'Block Create DS Topology'">
- <!-- Create the topology necessary to the test group/suite -->
- <sequence>
-
- <message>
- 'Create DS topology as described in config.py'
- </message>
-
- <call function="'createTopology'">
- { 'initialiseInstance' : True }
- </call>
-
- <call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
- </call>
-
- </sequence>
- <!--- End Block Create DS Topology -->
- </block>
-
- <block name="'Block DS Process Active'">
- <!--- Start DS -->
<sequence>
-
+
+ <!-- Create the topology necessary to the test group/suite -->
+ <sequence>
+
+ <message>
+ 'Create DS topology as described in config.py'
+ </message>
+
+ <call function="'createTopology'">
+ { 'initialiseInstance' : False }
+ </call>
+
+ <call function="'checkRC'">
+ { 'returncode' : RC , 'result' : STAXResult }
+ </call>
+
+ </sequence>
+
+ <if expr="startDS == True">
+
+ <!--- Start DS -->
+ <sequence>
+
<message>
- 'Start DS to run on port %s' % (DIRECTORY_INSTANCE_PORT)
+ 'Start DS to run on port %s' % (DIRECTORY_INSTANCE_PORT)
</message>
-
+
<!--- Start DS -->
<call function="'StartDsWithScript'">
- { 'location' : STAF_REMOTE_HOSTNAME }
+ { 'location' : STAF_REMOTE_HOSTNAME }
</call>
-
+
<call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
+ { 'returncode' : RC ,
+ 'result' : STAXResult }
</call>
-
+
<!--- Check that DS started -->
<call function="'isAlive'">
{ 'noOfLoops' : 5 ,
'noOfMilliSeconds' : 2000 }
- </call>
-
+ </call>
+
</sequence>
- <!--- End Block DS Process Active -->
- </block>
-
+
+ </if>
- <block name="'Block DS Load Data'">
- <!-- Load the data needed by the test suite -->
- <sequence>
-
+ <if expr="loadBackend == True">
+
+ <!-- Load the data needed by the test suite -->
+ <sequence>
+
<message>
- 'Add many entries needed for Testcase 18 in cluSearch tests'
- </message>
-
- <call function="'addEntry'">
- { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
- 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
- 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
- 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
- 'entryToBeAdded' : '%s/clu/data/clu_start.ldif' % logsRemoteDataDir }
- </call>
-
- <message>
- 'Add entries for cluSearch Tests'
+ 'Add many entries needed for Testcase 18 in cluSearch tests'
</message>
-
- <call function="'addEntry'">
- { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
- 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
- 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
- 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
- 'entryToBeAdded' : '%s/clu/data/ldif_mod.ldif' % logsRemoteDataDir }
- </call>
-
- <call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
- </call>
-
-
- </sequence>
- <!-- End Block DS Load Data -->
- </block>
-
- </sequence>
+ <call function="'addEntry'">
+ { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ 'entryToBeAdded' : '%s/clu/data/clu_start.ldif' % logsRemoteDataDir }
+ </call>
+
+ <message>'Add entries for cluSearch Tests'</message>
+
+ <call function="'addEntry'">
+ { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ 'entryToBeAdded' : '%s/clu/data/ldif_mod.ldif' % logsRemoteDataDir }
+ </call>
+
+ <call function="'checkRC'">
+ { 'returncode' : RC ,
+ 'result' : STAXResult }
+ </call>
+
+ </sequence>
+
+ </if>
+
+ </sequence>
</block>
-
- </sequence>
+
+ </sequence>
</function>
diff --git a/opends/tests/functional-tests/testcases/clu/commands.xml b/opends/tests/functional-tests/testcases/clu/commands.xml
index 5b8b158..aa42911 100644
--- a/opends/tests/functional-tests/testcases/clu/commands.xml
+++ b/opends/tests/functional-tests/testcases/clu/commands.xml
@@ -59,6 +59,10 @@
file="'%s/testcases/clu/cluDelete.xml' % (TESTS_DIR)"/>
<call function="'main_cluDelete'" /> -->
+ <import machine="STAF_LOCAL_HOSTNAME"
+ file="'%s/testcases/clu/cluBase64.xml' % (TESTS_DIR)"/>
+ <call function="'main_cluBase64'" />
+
<call function="'testGroup_Postamble'"/>
</sequence>
--
Gitblit v1.10.0