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