10139N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
10139N/A<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
10139N/A<!--
10139N/A ! CDDL HEADER START
10139N/A !
10139N/A ! The contents of this file are subject to the terms of the
10139N/A ! Common Development and Distribution License, Version 1.0 only
10139N/A ! (the "License"). You may not use this file except in compliance
10139N/A ! with the License.
10139N/A !
10139N/A ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
10139N/A ! or http://forgerock.org/license/CDDLv1.0.html.
10139N/A ! See the License for the specific language governing permissions
10615N/A ! and limitations under the License.
10615N/A !
10613N/A ! When distributing Covered Code, include this CDDL HEADER in each
10139N/A ! file and include the License file at legal-notices/CDDLv1_0.txt.
10139N/A ! If applicable, add the following below this CDDL HEADER, with the
10139N/A ! fields enclosed by brackets "[]" replaced with your own identifying
10139N/A ! information:
10613N/A ! Portions Copyright [yyyy] [name of copyright owner]
10139N/A !
10139N/A ! CDDL HEADER END
10139N/A !
10139N/A ! Copyright 2008-2010 Sun Microsystems, Inc.
10139N/A ! Portions Copyright 2012-2013 ForgeRock AS
10139N/A! -->
10139N/A<stax>
10139N/A
10139N/A <function name="main_snmp_setup">
10139N/A
10139N/A <sequence>
10139N/A
10139N/A <block name="'snmp_setup'">
10339N/A
10139N/A <try>
10139N/A
10139N/A <sequence>
10213N/A
10284N/A <!--- Test Suite information
10250N/A #@TestSuiteName setup
10284N/A #@TestSuitePurpose Setup for the snmp test suite.
10382N/A #@TestSuiteGroup setup
10382N/A #@TestScript snmp_setup.xml
10406N/A -->
10387N/A <script>
10438N/A if not CurrentTestPath.has_key('group'):
10476N/A CurrentTestPath['group'] = 'snmp'
10535N/A CurrentTestPath['suite'] = 'setup'
10535N/A </script>
10139N/A
10139N/A <call function="'testSuite_Preamble'"/>
10139N/A
10139N/A <!--- Define default value for manager -->
10139N/A <script>
10139N/A snmpPath = '%s/snmp' % remote.java,
10139N/A opendmkPath = '%s/jdmkrt.jar' % snmpPath
10139N/A </script>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: create DS topology
10139N/A #@TestIssue none
10139N/A #@TestPurpose Create the topology necessary to the
10139N/A test suite.
10139N/A #@TestPreamble none
10139N/A #@TestStep Create DS topology as described in config.py.
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if createTopology returns 0.
10139N/A -->
10139N/A <testcase name="getTestCaseName('setup: create DS topology')">
10139N/A <sequence>
10139N/A <try>
10139N/A <sequence>
10139N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'create DS topology as described in config.py.' }
10139N/A </call>
10139N/A
10139N/A <call function="'createTopology'">
10139N/A { 'initialiseInstance' : False }
10139N/A </call>
10139N/A
10139N/A <call function="'checktestRC'">
10139N/A {
10139N/A 'returncode' : RC ,
10139N/A 'result' : STAXResult
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!-- Check if 'opendmkPath' exists -->
10139N/A <call function="'GetEntry'">
10139N/A {
10139N/A 'location' : STAF_REMOTE_HOSTNAME ,
10139N/A 'entry' : opendmkPath ,
10139N/A 'attribute' : 'TYPE'
10139N/A }
10139N/A </call>
10139N/A <!-- 'opendmkPath' exists so we can continue -->
10139N/A <if expr="RC != 48 or not PRODUCTNAME.startswith('OpenDJ')">
10139N/A <sequence>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: start DS
10139N/A #@TestIssue none
10139N/A #@TestPurpose Start DS.
10139N/A #@TestPreamble none
10139N/A #@TestStep Start the server.
10213N/A #@TestStep Check that the server is alive.
10382N/A #@TestPostamble none
10387N/A #@TestResult Success if StartDsWithScript returns 0.
10418N/A -->
10139N/A <testcase name="getTestCaseName('setup: start DS')">
10535N/A <sequence>
10535N/A <try>
10535N/A <sequence>
10535N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'start DS to run on port %s.' % (DIRECTORY_INSTANCE_PORT) }
10139N/A </call>
10139N/A
10139N/A <!--- Start DS -->
10139N/A <call function="'StartDsWithScript'">
10139N/A { 'location' : STAF_REMOTE_HOSTNAME }
10139N/A </call>
10139N/A
10139N/A <!--- Check that DS started -->
10139N/A <call function="'isAlive'">
10139N/A {
10139N/A 'noOfLoops' : 10 ,
10139N/A 'noOfMilliSeconds' : 2000
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: add initial entries
10139N/A #@TestIssue none
10139N/A #@TestPurpose Load the data needed by the test suite.
10139N/A #@TestPreamble none
10139N/A #@TestStep Load the data needed by the test suite.
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if importLdif returns 0.
10139N/A -->
10139N/A <testcase name="getTestCaseName('setup: add initial entries')">
10139N/A <sequence>
10139N/A <try>
10139N/A <sequence>
10139N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'Add initial entries' }
10139N/A </call>
10139N/A
10139N/A <call function="'dsconfigSet'">
10139N/A {
10139N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
10139N/A 'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
10139N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
10139N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
10139N/A 'objectName' : 'password-policy',
10139N/A 'propertyType' : 'policy',
10139N/A 'propertyName' : 'Default Password Policy',
10139N/A 'attributeName' : 'allow-pre-encoded-passwords',
10139N/A 'attributeValue' : 'true'
10139N/A }
10139N/A </call>
10139N/A
10139N/A <call function="'addEntry'">
10139N/A { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
10139N/A 'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
10139N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
10139N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
10139N/A 'entryToBeAdded' : '%s/snmp/snmp_start.ldif'
10139N/A % remote.data,
10139N/A 'verbose' : False
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: get default SNMP connection handler
10139N/A properties
10139N/A #@TestIssue none
10139N/A #@TestPurpose Get default SNMP connection handler
10139N/A properties.
10139N/A #@TestPreamble none
10139N/A #@TestStep get default SNMP connection handler
10139N/A properties using dsconfig.
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if GetDSConfigProperties returns 0
10613N/A -->
10615N/A <testcase name="getTestCaseName
10535N/A ('setup: get default SNMP Connection Handler properties')">
10535N/A <sequence>
10476N/A <try>
10476N/A <sequence>
10476N/A
10436N/A <call function="'testCase_Preamble'"/>
10438N/A
10438N/A <call function="'testStep'">
10438N/A { 'stepMessage' : 'Get default SNMP Connection Handler properties' }
10436N/A </call>
10436N/A
10418N/A <script>
10418N/A options = '--handler-name "SNMP Connection Handler"'
10418N/A </script>
10418N/A
10418N/A <call function="'GetDSConfigProperties'">
10418N/A {
10339N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
10339N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
10283N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
10284N/A 'subcommand' : 'get-connection-handler-prop' ,
10169N/A 'optionsString' : options ,
10169N/A 'myVariableName' : 'DEFAULT_PROPERTIES'
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: check SNMP Connection Handler is
10139N/A disabled
10139N/A #@TestIssue none
10139N/A #@TestPurpose Check SNMP Connection Handler is disabled.
10139N/A #@TestPreamble none
10139N/A #@TestStep check SNMP Connection Handler is
10139N/A disabled using status command
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if output of status is correct.
10139N/A -->
10139N/A <testcase name="getTestCaseName
10139N/A ('setup: check SNMP Connection Handler is disabled')">
10139N/A <sequence>
10139N/A <try>
10139N/A <sequence>
10139N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'Check SNMP Connection Handler is disabled' }
10139N/A </call>
10139N/A
10139N/A <call function="'StatusWithScript'">
10139N/A {
10535N/A 'dsBindDN' : DIRECTORY_INSTANCE_DN ,
10139N/A 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
10139N/A }
10139N/A </call>
10139N/A
10139N/A <script>
10139N/A returnString = STAXResult[0][1]
10139N/A </script>
10139N/A
10139N/A <call function="'checktestString'">
10139N/A {
10139N/A 'returnString' : returnString ,
10139N/A 'expectedString' : ':\\s+SNMP\\s+:\\s+Disabled'
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: enable SNMP Connection Handler
10139N/A #@TestIssue none
10139N/A #@TestPurpose Enable SNMP Connection Handler.
10139N/A #@TestPreamble none
10139N/A #@TestStep enable SNMP Connection Handler using
10139N/A dsconfig.
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if dsconfig returns 0.
10139N/A -->
10139N/A <testcase name="getTestCaseName
10139N/A ('setup: enable SNMP Connection Handler')">
10139N/A <sequence>
10139N/A <try>
10139N/A <sequence>
10139N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'Enable SNMP Connection Handler' }
10139N/A </call>
10139N/A
10139N/A <call function="'dsconfig'">
10139N/A {
10139N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
10139N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
10139N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
10139N/A 'subcommand' : 'set-connection-handler-prop' ,
10139N/A 'objectType' : 'handler-name' ,
10139N/A 'objectName' : 'SNMP Connection Handler' ,
10139N/A 'optionsString' : '--set enabled:true \
10139N/A --set listen-port:%s \
10139N/A --set trap-port:%s \
10139N/A --set opendmk-jarfile:%s' \
10139N/A % (SNMP_PORT, SNMP_TRAP_PORT, opendmkPath)
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: check SNMP Connection Handler is
10139N/A enabled
10139N/A #@TestIssue none
10139N/A #@TestPurpose Check SNMP Connection Handler is enabled.
10139N/A #@TestPreamble none
10139N/A #@TestStep check SNMP Connection Handler is
10139N/A enabled using status command
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if output of status is correct.
10139N/A -->
10139N/A <testcase name="getTestCaseName
10139N/A ('setup: check SNMP Connection Handler is enabled')">
10139N/A <sequence>
10139N/A <try>
10139N/A <sequence>
10139N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'Check SNMP Connection Handler is enabled' }
10139N/A </call>
10139N/A
10139N/A <call function="'StatusWithScript'">
10139N/A {
10139N/A 'dsBindDN' : DIRECTORY_INSTANCE_DN ,
10139N/A 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
10139N/A }
10139N/A </call>
10139N/A
10139N/A <script>
10139N/A returnString = STAXResult[0][1]
10139N/A </script>
10139N/A
10139N/A <call function="'checktestString'">
10139N/A {
10139N/A 'returnString' : returnString ,
10139N/A 'expectedString' : ':\\s+SNMP\\s+:\\s+Enabled'
10139N/A }
10139N/A </call>
10139N/A
10139N/A </sequence>
10139N/A
10139N/A <catch exception="'STAXException'" typevar="eType" var="eInfo">
10139N/A <message log="1" level="'fatal'">
10139N/A '%s: Test failed. eInfo(%s)' % (eType,eInfo)
10139N/A </message>
10139N/A </catch>
10139N/A <finally>
10139N/A <sequence>
10139N/A <call function="'testCase_Postamble'"/>
10139N/A </sequence>
10139N/A </finally>
10139N/A </try>
10139N/A </sequence>
10139N/A
10139N/A </testcase>
10139N/A
10139N/A <!--- Test Case information
10139N/A #@TestMarker setup
10139N/A #@TestName setup: get SNMP connection handler
10139N/A properties
10139N/A #@TestIssue none
10139N/A #@TestPurpose Get SNMP connection handler properties.
10139N/A #@TestPreamble none
10139N/A #@TestStep get SNMP connection handler properties
10139N/A using dsconfig.
10139N/A #@TestPostamble none
10139N/A #@TestResult Success if GetDSConfigProperties returns 0
10139N/A -->
10139N/A <testcase name="getTestCaseName
10139N/A ('setup: get SNMP Connection Handler properties')">
10139N/A <sequence>
10139N/A <try>
10139N/A <sequence>
10139N/A
10139N/A <call function="'testCase_Preamble'"/>
10139N/A
10139N/A <call function="'testStep'">
10139N/A { 'stepMessage' : 'Copy snmp files to the remote host' }
10139N/A </call>
10139N/A <message>
10139N/A 'Copy file %s/snmp/agent.security (on %s) to %s/agent.security (on %s)' % \
10139N/A (local.data, STAXServiceMachine, remote.temp, STAF_REMOTE_HOSTNAME)
10139N/A </message>
10139N/A <call function="'copyFile'">
10139N/A {
10139N/A 'location' : STAXServiceMachine ,
10139N/A 'srcfile' : '%s/snmp/agent.security' % local.data ,
10139N/A 'destfile' : '%s/agent.security' % remote.temp ,
10139N/A 'remotehost' : STAF_REMOTE_HOSTNAME
10139N/A }
10139N/A </call>
<message>
'Copy file %s/snmp/manager.security (on %s) to %s/manager.security (on %s)' % \
(local.data, STAXServiceMachine, remote.temp, STAF_REMOTE_HOSTNAME)
</message>
<call function="'copyFile'">
{
'location' : STAXServiceMachine ,
'srcfile' : '%s/snmp/manager.security' % local.data ,
'destfile' : '%s/manager.security' % remote.temp ,
'remotehost' : STAF_REMOTE_HOSTNAME
}
</call>
<call function="'testStep'">
{ 'stepMessage' : 'Get SNMP Connection Handler properties' }
</call>
<script>
options = '--handler-name "SNMP Connection Handler"'
</script>
<call function="'GetDSConfigProperties'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'subcommand' : 'get-connection-handler-prop' ,
'optionsString' : options ,
'myVariableName' : 'SNMP_PROPERTIES'
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
</sequence>
<else>
<sequence>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: warning
#@TestIssue none
#@TestPurpose Warning
#@TestPreamble none
#@TestStep Print a warning message to indicate that
the SNMP_OPENDMK_LIBDIR is not set.
#@TestPostamble none
#@TestResult Always fails.
-->
<testcase name="getTestCaseName('setup: Warning')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<script>
STOP_RUN = 'True'
</script>
<call function="'testStep'">
{ 'stepMessage' : 'Print a warning message' }
</call>
<message log="1" level="'Error'">
'WARNING: Check if SNMP_OPENDMK_LIBDIR is set \
in the config.py.stubs file.'
</message>
<tcstatus result="'fail'"></tcstatus>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
</sequence>
</else>
</if>
</sequence>
<finally>
<call function="'testSuite_Postamble'"/>
</finally>
</try>
</block>
</sequence>
</function>
</stax>