[jboss-cvs] JBossAS SVN: r108399 - in branches/JBPAPP_5_1/testsuite: src/main/org/jboss/test/cluster/defaultcfg/web/test and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 1 00:48:14 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-10-01 00:48:13 -0400 (Fri, 01 Oct 2010)
New Revision: 108399
Added:
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/PersistentManagerFormAuthTestCase.java
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/context.xml
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/jboss-web.xml
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/web.xml
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/error.html
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/index.jsp
branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/login.html
Modified:
branches/JBPAPP_5_1/testsuite/imports/sections/cluster.xml
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/testutil/DBSetupDelegate.java
Log:
[JBPAPP-5171] Add test of fix
Modified: branches/JBPAPP_5_1/testsuite/imports/sections/cluster.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/sections/cluster.xml 2010-10-01 02:55:05 UTC (rev 108398)
+++ branches/JBPAPP_5_1/testsuite/imports/sections/cluster.xml 2010-10-01 04:48:13 UTC (rev 108399)
@@ -698,6 +698,19 @@
</fileset>
</war>
+ <war warfile="${build.lib}/http-formauth-persistent.war"
+ webxml="${build.resources}/cluster/persistent/formauth/WEB-INF/web.xml">
+ <webinf dir="${build.resources}/cluster/persistent/formauth/WEB-INF">
+ <include name="jboss-web.xml"/>
+ <include name="context.xml"/>
+ </webinf>
+
+ <fileset dir="${build.resources}/cluster/persistent/formauth">
+ <include name="*.jsp"/>
+ <include name="*.html"/>
+ </fileset>
+ </war>
+
<jar destfile="${build.lib}/rdbmsstore-tablesetup.jar">
<metainf dir="${build.resources}/cluster/persistent">
<include name="rdbmsstore-tablesetup-jboss-beans.xml"/>
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/PersistentManagerFormAuthTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/PersistentManagerFormAuthTestCase.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/defaultcfg/web/test/PersistentManagerFormAuthTestCase.java 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.cluster.defaultcfg.web.test;
+
+import java.net.HttpURLConnection;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.jboss.test.cluster.testutil.DBSetupDelegate;
+import org.jboss.test.cluster.testutil.DelegatingClusteredTestCase;
+import org.jboss.test.cluster.testutil.TestSetupDelegate;
+import org.jboss.test.cluster.testutil.WebTestBase;
+import org.jboss.test.cluster.web.persistent.PersistentStoreSetupDelegate;
+
+/**
+ * Test for JBPAPP-5171
+ *
+ * @author Brian Stansberry
+ * @version $Id: UndeployTestCase.java 81084 2008-11-14 17:30:43Z dimitris at jboss.org $
+ */
+public class PersistentManagerFormAuthTestCase extends WebTestBase
+{
+ private String baseURLNoAuth;
+
+ public PersistentManagerFormAuthTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ baseURLNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080);
+ }
+
+ protected String getContextPath()
+ {
+ return "/http-formauth-persistent/";
+ }
+
+ protected String getWarName()
+ {
+ return "http-formauth-persistent.war";
+ }
+
+ public static Test suite() throws Exception
+ {
+ String dbAddress = System.getProperty(DBSetupDelegate.DBADDRESS_PROPERTY, DBSetupDelegate.DEFAULT_ADDRESS);
+ TestSetupDelegate dbDelegate = new DBSetupDelegate(dbAddress, DBSetupDelegate.DEFAULT_PORT);
+ TestSetupDelegate storeDelegate = new PersistentStoreSetupDelegate(dbAddress, DBSetupDelegate.DEFAULT_PORT);
+ List<TestSetupDelegate> list = Arrays.asList(new TestSetupDelegate[]{dbDelegate, storeDelegate});
+ return DelegatingClusteredTestCase.getDeploySetup(PersistentManagerFormAuthTestCase.class,
+ "httpsession-ds.xml, disable-manager-override.beans, " +
+ "http-formauth-persistent.war", list);
+ }
+
+ public void testFormAuthentication() throws Exception {
+
+ String url = baseURLNoAuth + "/http-formauth-persistent/";
+
+ // Start by accessing the secured index.html of war1
+ HttpClient httpConn = new HttpClient();
+
+ // Try to access protected resource
+ GetMethod indexGet = new GetMethod(url + "index.jsp");
+ int responseCode = httpConn.executeMethod(indexGet);
+ String body = indexGet.getResponseBodyAsString();
+ assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+ assertTrue("Redirected to login page", body.indexOf("j_security_check") > 0 );
+
+ // Submit the login form
+
+ PostMethod formPost = new PostMethod(url + "j_security_check");
+ formPost.addRequestHeader("Referer", url + "login.html");
+ formPost.addParameter("j_username", "admin");
+ formPost.addParameter("j_password", "admin");
+ responseCode = httpConn.executeMethod(formPost.getHostConfiguration(),
+ formPost, httpConn.getState());
+ assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
+ responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
+
+ // Follow the redirect to the index.html page
+ Header location = formPost.getResponseHeader("Location");
+ String indexURI = location.getValue();
+ GetMethod warIndex = new GetMethod(indexURI);
+ responseCode = httpConn.executeMethod(warIndex.getHostConfiguration(),
+ warIndex, httpConn.getState());
+ assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
+ body = warIndex.getResponseBodyAsString();
+ if( body.indexOf("j_security_check") > 0 )
+ fail("get of "+indexURI+" redirected to login page");
+ }
+
+}
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/testutil/DBSetupDelegate.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/testutil/DBSetupDelegate.java 2010-10-01 02:55:05 UTC (rev 108398)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/cluster/testutil/DBSetupDelegate.java 2010-10-01 04:48:13 UTC (rev 108399)
@@ -28,6 +28,8 @@
import java.sql.Statement;
import org.jboss.test.JBossTestServices;
+import org.jboss.test.cluster.web.persistent.PersistentStoreSetupDelegate;
+import org.jboss.test.cluster.web.persistent.PersistentStoreTableSetup;
/** A TestSetup that starts hypersonic before the testcase with a tcp
* listening port at 1701.
@@ -167,5 +169,18 @@
}
}
}
+
+ public static void main(String[] args) {
+ try
+ {
+ new DBSetupDelegate().setUp();
+ new PersistentStoreSetupDelegate().setUp();
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
}
Added: branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/context.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/context.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/context.xml 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,12 @@
+<!-- Ensure cross-context is true, it's the default but lets be sure -->
+<Context cookies="true" crossContext="true">
+
+ <Manager className="org.jboss.web.tomcat.service.session.persistent.DataSourcePersistentManager"
+ dataSourceJndiName="java:HttpSessionDS"/>
+
+ <!-- Install an InstanceListener to handle the establishment of the run-as
+ role for servlet init/destroy events.
+ -->
+ <InstanceListener>org.jboss.web.tomcat.security.RunAsListener</InstanceListener>
+
+</Context>
\ No newline at end of file
Added: branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/jboss-web.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/jboss-web.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/jboss-web.xml 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-web
+ PUBLIC "-//JBoss//DTD Web Application 2.3//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
+
+<jboss-web>
+ <!--
+ Use the jmx-console domain so this test doesn't need to create its own.
+ -->
+ <security-domain>java:/jaas/jmx-console</security-domain>
+</jboss-web>
Added: branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/web.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/web.xml (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/WEB-INF/web.xml 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+ <description>DataSourcePersistentManager FORM auth tests</description>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Restricted</web-resource-name>
+ <description>DataSourcePersistentManager</description>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <description>
+ Use a role in the jmx-console security domain so this test doesn't have
+ to define another one.
+ </description>
+ <role-name>JBossAdmin</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/login.html</form-login-page>
+ <form-error-page>/error.html</form-error-page>
+ </form-login-config>
+ </login-config>
+
+ <security-role>
+ <role-name>JBossAdmin</role-name>
+ </security-role>
+</web-app>
+
Added: branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/error.html
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/error.html (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/error.html 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Error Page For Examples</title>
+</head>
+
+ <body bgcolor="white">
+ Invalid username and/or password, please try again
+ </body>
+</html>
+
Added: branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/index.jsp
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/index.jsp (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/index.jsp 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,15 @@
+<%
+ // Give the session a quick timeout so the timeout test can be short
+ session.setMaxInactiveInterval(5);
+%>
+
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <title>A Secure Web App</title>
+</head>
+
+<body>
+<h1>A Secure Web App</h1>
+</body>
+</html>
Added: branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/login.html
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/login.html (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/resources/cluster/persistent/formauth/login.html 2010-10-01 04:48:13 UTC (rev 108399)
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Login Page for Examples</title>
+</head>
+
+ <body bgcolor="white">
+ <form method="POST" action="j_security_check">
+ <table border="0" cellspacing="5">
+ <tr>
+ <th align="right">Username:</th>
+ <td align="left"><input type="text" name="j_username"></td>
+ </tr>
+ <tr>
+ <th align="right">Password:</th>
+ <td align="left"><input type="password" name="j_password"></td>
+ </tr>
+ <tr>
+ <td align="right"><input type="submit" value="Log In"></td>
+ <td align="left"><input type="reset"></td>
+ </tr>
+ </table>
+ </form>
+ </body>
+</html>
+
More information about the jboss-cvs-commits
mailing list