[jboss-cvs] JBossAS SVN: r114669 - in branches/JBPAPP_5/testsuite: src/main/org/jboss/test/scripts/test and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 20 06:18:20 EST 2014
Author: zroubali
Date: 2014-01-20 06:18:20 -0500 (Mon, 20 Jan 2014)
New Revision: 114669
Added:
branches/JBPAPP_5/testsuite/src/main/org/jboss/test/scripts/test/AuthShutdownTestCase.java
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-roles.properties
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-users.properties
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/deploy/
branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/deploy/jmx-invoker-service.xml
Modified:
branches/JBPAPP_5/testsuite/build.xml
Log:
JBQA-8607 Test for PRODMGT-40: Use of Encrypted Password with Shutdown Script
Modified: branches/JBPAPP_5/testsuite/build.xml
===================================================================
--- branches/JBPAPP_5/testsuite/build.xml 2014-01-20 11:15:06 UTC (rev 114668)
+++ branches/JBPAPP_5/testsuite/build.xml 2014-01-20 11:18:20 UTC (rev 114669)
@@ -4554,8 +4554,70 @@
</fileset>
</batchtest>
</junit>
+
+ <antcall target="tests-scripts-auth-noserver"/>
+
</target>
+ <!-- script tests which start their own servers with enabled authentication -->
+ <target name="tests-scripts-auth-noserver">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${build.testlog}"/>
+
+ <create-config baseconf="default" newconf="scripts-auth-noserver">
+ <patternset>
+ <include name="conf/**"/>
+ <include name="deploy/**"/>
+ <include name="deployers/**"/>
+ <include name="lib/**"/>
+ </patternset>
+ </create-config>
+
+ <!-- script tests which start their own servers -->
+ <junit dir="${module.output}" printsummary="${junit.printsummary}" haltonerror="${junit.haltonerror}"
+ haltonfailure="${junit.haltonfailure}" fork="${junit.fork}"
+ timeout="${junit.timeout}" jvm="${junit.jvm}">
+
+ <jvmarg value="${junit.jvm.options}"/>
+ <!-- Used for JGroups -->
+ <jvmarg value="-Dbind.address=${node0}"/>
+ <sysproperty key="jboss.dist" value="${jboss.dist}"/>
+ <sysproperty key="jbosstest.server.config" value="scripts-auth-noserver"/>
+ <sysproperty key="jbosstest.deploy.dir" file="${build.lib}"/>
+ <sysproperty key="build.testlog" value="${build.testlog}"/>
+ <sysproperty key="log4j.configuration" value="file:${build.resources}/log4j.xml"/>
+ <sysproperty key="java.naming.provider.url" value="${node0.jndi.url}"/>
+ <sysproperty key="jbosstest.server.host" value="${node0}"/>
+ <sysproperty key="jbosstest.server.host.url" value="${node0.url}"/>
+ <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/>
+ <sysproperty key="java.net.preferIPv6Addresses" value="${java.net.preferIPv6Addresses}"/>
+ <!-- Pass along any jbosstest.* system properties -->
+ <syspropertyset>
+ <propertyref prefix="jbosstest."/>
+ </syspropertyset>
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <pathelement location="${build.resources}"/>
+ <path refid="tests.classpath"/>
+ </classpath>
+
+ <!--sysproperty key="jboss-junit-configuration" value="classloader-leak"/-->
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ usefile="${junit.formatter.usefile}" extension="-scripts-noserver.xml"/>
+
+ <batchtest todir="${build.reports}" haltonerror="${junit.batchtest.haltonerror}"
+ haltonfailure="${junit.batchtest.haltonfailure}" fork="${junit.batchtest.fork}">
+
+ <fileset dir="${build.classes}">
+ <include name="**/test/scripts/test/AuthShutdownTestCase.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+</target>
+
+
+
+
<!--
| Run all database related tests
-->
Added: branches/JBPAPP_5/testsuite/src/main/org/jboss/test/scripts/test/AuthShutdownTestCase.java
===================================================================
--- branches/JBPAPP_5/testsuite/src/main/org/jboss/test/scripts/test/AuthShutdownTestCase.java (rev 0)
+++ branches/JBPAPP_5/testsuite/src/main/org/jboss/test/scripts/test/AuthShutdownTestCase.java 2014-01-20 11:18:20 UTC (rev 114669)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009 Red Hat Middleware, Inc. and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.scripts.test;
+
+import org.jboss.test.security.vault.VaultHandler;
+
+import javax.xml.transform.sax.SAXSource;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Properties;
+
+
+/**
+ * Unit tests of shutdown.sh and shutdown.bat.
+ * <p/>
+ * Need to test the following features (in order of importance):
+ * 1. error-free statup on non-loopback bind address
+ * (-c <server> -b <non-loopback IP>)
+ * 2. error-free startup on loopback bind address
+ * (-c <server> without -b param)
+ * 3. default server assignment (i.e. production)
+ * (-b <non-loopback IP>
+ * 4. options for configuring partition, multicast address and port
+ * (-g <partition name> -u <mcast IP addr> -m <mcast port>)
+ * 5. options for configuring startup directories
+ * (-d <boot patch directory> -p <patch directory> -B <bootlib> -L <loader lib> -C <clapsspath lib>)
+ * 6. help and version text
+ * (-h)
+ *
+ * @author Zbynek Roubalik 2014, zroubali at redhat.com
+ * @version $Revision: $
+ */
+public class AuthShutdownTestCase extends ScriptsTestBase {
+ private static final int STOP_TIMEOUT = Integer.parseInt(System.getProperty(SYSTEM_PROPERTY_JBOSSAS_SHUTDOWN_TIMEOUT, "30"));
+ private static final int START_TIMEOUT = Integer.parseInt(System.getProperty(SYSTEM_PROPERTY_JBOSSAS_STARTUP_TIMEOUT, "120"));
+
+ /**
+ * Create a new AuthShutdownTestCase.
+ *
+ * @param name
+ */
+ public AuthShutdownTestCase(String name) {
+ super(name);
+ }
+
+ /**
+ * Tests shutdown command with correct credentials for authenticated user
+ * -u admin -p admin
+ *
+ * @throws Exception
+ */
+ public void testAuthenticatedUserShutdown() throws Exception {
+ // build the shell command to execute
+ // supply the command name prefix, any options as a string, and any args
+ String[] shellCommand = getShellCommand("run", "-c " + getServerConfig() + " -b " + getServerHost(), null);
+ String[] envp = null;
+ File workingDir = new File(getBinDir());
+
+ // execute command
+ getAsyncShellScriptExecutor().startShellCommand(shellCommand, envp, workingDir);
+
+ // waitForServerStart kills the process and throws an exception if server does not start
+ try {
+ waitForServerStart(getAsyncShellScriptExecutor(), getServerHost(), START_TIMEOUT);
+ System.out.println("Server started successfully");
+ } catch (IOException e) {
+ System.out.println("IOException: message = " + e.getMessage());
+ writeServerLogsToTestCase();
+ fail("Server failed to start");
+ }
+
+ // check assertions on the console output generated by the run command
+ getAsyncShellScriptExecutor().assertOnOutputStream("Started in", "Started string not found in command output");
+
+ // shutdown the server using the shutdown command
+ String[] shutdownCommand = getShellCommand("shutdown", "-s " + getJndiURL() + " -S -u admin -p admin", null);
+ getShellScriptExecutor().runShellCommand(shutdownCommand, envp, workingDir);
+
+ System.out.println("shutdown output = " + getShellScriptExecutor().getOutput());
+ System.out.println("shutdown error = " + getShellScriptExecutor().getError());
+
+ // waitForServerStop kills the process and throws an exception if server does not stop
+ try {
+ waitForServerStop(getAsyncShellScriptExecutor(), STOP_TIMEOUT);
+ System.out.println("Server stopped successfully");
+ getAsyncShellScriptExecutor().assertOnOutputStream(SERVER_STOPPED_MESSAGE, "Server shutdown message did not appear in logs");
+ } catch (IOException e) {
+ System.out.println("IOException: message = " + e.getMessage());
+ writeServerLogsToTestCase();
+ fail("Server failed to stop");
+ }
+ }
+
+ /**
+ * Tests shutdown command with correct credentials stored in a properties file
+ * -P shutdown.properties
+ * propfile content: "shutdown.user" "admin"
+ * "shutdown.password" "admin"
+ *
+ * @throws Exception
+ */
+ public void testPropertiesAuthenticatedUserShutdown() throws Exception {
+ // build the shell command to execute
+ // supply the command name prefix, any options as a string, and any args
+ String[] shellCommand = getShellCommand("run", "-c " + getServerConfig() + " -b " + getServerHost(), null);
+ String[] envp = null;
+ File workingDir = new File(getBinDir());
+
+ // execute command
+ getAsyncShellScriptExecutor().startShellCommand(shellCommand, envp, workingDir);
+
+ // waitForServerStart kills the process and throws an exception if server does not start
+ try {
+ waitForServerStart(getAsyncShellScriptExecutor(), getServerHost(), START_TIMEOUT);
+ System.out.println("Server started successfully");
+ } catch (IOException e) {
+ System.out.println("IOException: message = " + e.getMessage());
+ writeServerLogsToTestCase();
+ fail("Server failed to start");
+ }
+
+ // check assertions on the console output generated by the run command
+ getAsyncShellScriptExecutor().assertOnOutputStream("Started in", "Started string not found in command output");
+
+ File propFile = new File("shutdown.properties");
+
+ // set properties
+ Properties props = new Properties();
+ props.setProperty("shutdown.user", "admin");
+ props.setProperty("shutdown.password", "admin");
+ props.store(new FileWriter(propFile), null);
+
+ // shutdown the server using the shutdown command
+ String[] shutdownCommand = getShellCommand("shutdown", "-s " + getJndiURL() + " -P " + propFile.getCanonicalPath() + " -S", null);
+ getShellScriptExecutor().runShellCommand(shutdownCommand, envp, workingDir);
+
+ System.out.println("shutdown output = " + getShellScriptExecutor().getOutput());
+ System.out.println("shutdown error = " + getShellScriptExecutor().getError());
+
+ // waitForServerStop kills the process and throws an exception if server does not stop
+ try {
+ waitForServerStop(getAsyncShellScriptExecutor(), STOP_TIMEOUT);
+ System.out.println("Server stopped successfully");
+ getAsyncShellScriptExecutor().assertOnOutputStream(SERVER_STOPPED_MESSAGE, "Server shutdown message did not appear in logs");
+ } catch (IOException e) {
+ System.out.println("IOException: message = " + e.getMessage());
+ writeServerLogsToTestCase();
+ fail("Server failed to stop");
+ }
+ }
+
+ public void writeServerLogsToTestCase() {
+ // write the logs to output for diagnosis
+ System.out.println("============================== system.out ==============================");
+ System.out.println(getAsyncShellScriptExecutor().getOutput());
+ System.out.println("============================== system.err ==============================");
+ System.out.println(getAsyncShellScriptExecutor().getError());
+ System.out.println("========================================================================");
+ }
+
+}
Added: branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-roles.properties
===================================================================
--- branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-roles.properties (rev 0)
+++ branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-roles.properties 2014-01-20 11:18:20 UTC (rev 114669)
@@ -0,0 +1,2 @@
+# A sample roles.properties file for use with the UsersRolesLoginModule
+admin=JBossAdmin,HttpInvoker
Added: branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-users.properties
===================================================================
--- branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-users.properties (rev 0)
+++ branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/conf/props/jmx-console-users.properties 2014-01-20 11:18:20 UTC (rev 114669)
@@ -0,0 +1,2 @@
+# A sample users.properties file for use with the UsersRolesLoginModule
+admin=admin
Added: branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/deploy/jmx-invoker-service.xml
===================================================================
--- branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/deploy/jmx-invoker-service.xml (rev 0)
+++ branches/JBPAPP_5/testsuite/src/resources/test-configs/scripts-auth-noserver/deploy/jmx-invoker-service.xml 2014-01-20 11:18:20 UTC (rev 114669)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- $Id: jboss-service.xml 59451 2007-01-09 19:13:25Z dimitris at jboss.org $ -->
+<server>
+
+ <!-- The JRMP invoker proxy configuration for the InvokerAdaptorService -->
+ <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
+ name="jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory">
+ <!-- Use the standard JRMPInvoker from conf/jboss-service.xxml -->
+ <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp</depends>
+ <!-- The target MBean is the InvokerAdaptorService configured below -->
+ <depends optional-attribute-name="TargetName">jboss.jmx:type=adaptor,name=Invoker</depends>
+ <!-- Where to bind the RMIAdaptor proxy -->
+ <attribute name="JndiName">jmx/invoker/RMIAdaptor</attribute>
+ <!-- The RMI compabitle MBeanServer interface -->
+ <attribute name="ExportedInterfaces">org.jboss.jmx.adaptor.rmi.RMIAdaptor,
+ org.jboss.jmx.adaptor.rmi.RMIAdaptorExt
+ </attribute>
+ <attribute name="ClientInterceptors">
+ <interceptors>
+ <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
+ <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
+ <interceptor>org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor</interceptor>
+ <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
+ </interceptors>
+ </attribute>
+ <depends>jboss:service=Naming</depends>
+ </mbean>
+
+ <!--
+ Choose the remote proxy to expose mbean proxies over
+ -->
+ <mbean code="org.jboss.jmx.connector.invoker.MBeanProxyRemote"
+ name="jboss.jmx:type=adaptor,name=MBeanProxyRemote,protocol=jrmp">
+ <depends optional-attribute-name="MBeanServerConnection">jboss.jmx:type=adaptor,name=Invoker,protocol=jrmp,service=proxyFactory</depends>
+ </mbean>
+
+ <!-- Create a mapping from the legacy jmx-rmi-adaptor.sar binding to the
+ jmx-invoker-adaptor-server.sar JndiName specified above for backwards
+ portability.
+ -->
+ <mbean code="org.jboss.naming.NamingAlias" name="jboss.jmx:alias=jmx/rmi/RMIAdaptor">
+ <attribute name="FromName">jmx/rmi/RMIAdaptor</attribute>
+ <attribute name="ToName">jmx/invoker/RMIAdaptor</attribute>
+ <depends>jboss:service=Naming</depends>
+ </mbean>
+
+ <!-- This is the service that handles the RMIAdaptor invocations by routing
+ them to the MBeanServer the service is deployed under. -->
+ <mbean code="org.jboss.jmx.connector.invoker.InvokerAdaptorService"
+ name="jboss.jmx:type=adaptor,name=Invoker"
+ xmbean-dd="">
+ <xmbean>
+ <description>The JMX Detached Invoker Service</description>
+ <class>org.jboss.jmx.connector.invoker.InvokerAdaptorService</class>
+
+ <!-- Attributes -->
+ <attribute access="read-only" getMethod="getName">
+ <description>The class name of the MBean</description>
+ <name>Name</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute access="read-only" getMethod="getState">
+ <description>The status of the MBean</description>
+ <name>State</name>
+ <type>int</type>
+ </attribute>
+ <attribute access="read-only" getMethod="getStateString">
+ <description>The status of the MBean in text form</description>
+ <name>StateString</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute access="read-write" getMethod="getExportedInterfaces" setMethod="setExportedInterfaces">
+ <description>The interfaces the invoker proxy supports</description>
+ <name>ExportedInterfaces</name>
+ <type>[Ljava.lang.Class;</type>
+ </attribute>
+ <attribute access="read-only" getMethod="getMethodMap">
+ <description>Map(Long hash, Method) of the proxy interface methods</description>
+ <name>MethodMap</name>
+ <type>java.util.Map</type>
+ </attribute>
+ <!-- Operations -->
+ <operation>
+ <description>The start lifecycle operation</description>
+ <name>start</name>
+ </operation>
+ <operation>
+ <description>The stop lifecycle operation</description>
+ <name>stop</name>
+ </operation>
+ <operation>
+ <description>The detyped lifecycle operation (for internal use only)</description>
+ <name>jbossInternalLifecycle</name>
+ <parameter>
+ <description>The lifecycle operation</description>
+ <name>method</name>
+ <type>java.lang.String</type>
+ </parameter>
+ <return-type>void</return-type>
+ </operation>
+
+ <operation>
+ <description>The detached invoker entry point</description>
+ <name>invoke</name>
+ <parameter>
+ <description>The method invocation context</description>
+ <name>invocation</name>
+ <type>org.jboss.invocation.Invocation</type>
+ </parameter>
+ <return-type>java.lang.Object</return-type>
+ <descriptors>
+ <interceptors>
+ <!-- Uncomment to require authenticated users -->
+ <interceptor code="org.jboss.jmx.connector.invoker.AuthenticationInterceptor"
+ securityDomain="java:/jaas/jmx-console"/>
+
+ <!-- Interceptor that deals with non-serializable results -->
+ <interceptor code="org.jboss.jmx.connector.invoker.SerializableInterceptor"
+ policyClass="StripModelMBeanInfoPolicy"/>
+ </interceptors>
+ </descriptors>
+ </operation>
+ </xmbean>
+
+ <attribute name="ExportedInterfaces">org.jboss.jmx.adaptor.rmi.RMIAdaptor,
+ org.jboss.jmx.adaptor.rmi.RMIAdaptorExt
+ </attribute>
+ </mbean>
+
+</server>
More information about the jboss-cvs-commits
mailing list