Some reorganization of itest module
This commit is contained in:
parent
3ee8733261
commit
2fa991c44f
|
@ -14,6 +14,7 @@
|
||||||
<version>2.0.3-SNAPSHOT</version>
|
<version>2.0.3-SNAPSHOT</version>
|
||||||
<modules>
|
<modules>
|
||||||
<module>web</module>
|
<module>web</module>
|
||||||
|
<!-- module>webflow</module-->
|
||||||
<!--module>context</module-->
|
<!--module>context</module-->
|
||||||
</modules>
|
</modules>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -92,12 +93,59 @@
|
||||||
<artifactId>apacheds-core</artifactId>
|
<artifactId>apacheds-core</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.2</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.directory.server</groupId>
|
<groupId>org.apache.directory.server</groupId>
|
||||||
<artifactId>apacheds-server-jndi</artifactId>
|
<artifactId>apacheds-server-jndi</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0.2</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jwebunit</groupId>
|
||||||
|
<artifactId>jwebunit</artifactId>
|
||||||
|
<version>1.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jetty</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jetty-naming</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jetty-plus</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jsp-2.1</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jsp-api-2.1</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.ldap</groupId>
|
<groupId>org.springframework.ldap</groupId>
|
||||||
|
@ -113,6 +161,10 @@
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-beans</artifactId>
|
<artifactId>spring-beans</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -125,7 +177,7 @@
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>jcl104-over-slf4j</artifactId>
|
<artifactId>jcl104-over-slf4j</artifactId>
|
||||||
<version>1.4.3</version>
|
<version>1.4.3</version>
|
||||||
<scope>provided</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
|
@ -144,6 +196,19 @@
|
||||||
<target>1.5</target>
|
<target>1.5</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>test-jar</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
@ -169,4 +234,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<properties>
|
||||||
|
<jetty.version>6.1.11</jetty.version>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -10,34 +10,41 @@
|
||||||
<artifactId>spring-security-itest-web</artifactId>
|
<artifactId>spring-security-itest-web</artifactId>
|
||||||
<name>Spring Security - Web Integration Tests</name>
|
<name>Spring Security - Web Integration Tests</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
<!--
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jwebunit</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>jwebunit</artifactId>
|
<artifactId>jstl</artifactId>
|
||||||
<version>1.2</version>
|
<scope>runtime</scope>
|
||||||
<scope>test</scope>
|
<version>1.1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
<groupId>taglibs</groupId>
|
||||||
<artifactId>jetty</artifactId>
|
<artifactId>standard</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<scope>runtime</scope>
|
||||||
<scope>test</scope>
|
<version>1.1.2</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
|
||||||
<artifactId>jetty-naming</artifactId>
|
|
||||||
<version>${jetty.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
|
||||||
<artifactId>jetty-plus</artifactId>
|
|
||||||
<version>${jetty.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
-->
|
||||||
<jetty.version>6.1.7</jetty.version>
|
<!--
|
||||||
</properties>
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>maven-jetty-jspc-plugin</artifactId>
|
||||||
|
<version>6.1.11</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>jspc</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jspc</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
-->
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
log4j.rootCategory=INFO, stdout
|
log4j.rootCategory=DEBUG, stdout
|
||||||
|
|
||||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n
|
log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n
|
||||||
|
|
||||||
log4j.category.org.mortbay.log=INFO
|
log4j.category.org.apache.jasper=DEBUG
|
||||||
|
log4j.category.org.mortbay.log=DEBUG
|
||||||
log4j.category.org.springframework.security=DEBUG
|
log4j.category.org.springframework.security=DEBUG
|
|
@ -1,18 +1,16 @@
|
||||||
dn: ou=groups,dc=springframework,dc=org
|
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: groups
|
|
||||||
|
|
||||||
dn: ou=subgroups,ou=groups,dc=springframework,dc=org
|
# Users
|
||||||
objectclass: top
|
|
||||||
objectclass: organizationalUnit
|
|
||||||
ou: subgroups
|
|
||||||
|
|
||||||
dn: ou=people,dc=springframework,dc=org
|
dn: ou=people,dc=springframework,dc=org
|
||||||
objectclass: top
|
objectclass: top
|
||||||
objectclass: organizationalUnit
|
objectclass: organizationalUnit
|
||||||
ou: people
|
ou: people
|
||||||
|
|
||||||
|
dn: ou=musicians,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: people
|
||||||
|
|
||||||
dn: uid=ben,ou=people,dc=springframework,dc=org
|
dn: uid=ben,ou=people,dc=springframework,dc=org
|
||||||
objectclass: top
|
objectclass: top
|
||||||
objectclass: person
|
objectclass: person
|
||||||
|
@ -33,24 +31,76 @@ sn: Hamilton
|
||||||
uid: bob
|
uid: bob
|
||||||
userPassword: bobspassword
|
userPassword: bobspassword
|
||||||
|
|
||||||
|
dn: uid=miles,ou=musicians,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Miles Davis
|
||||||
|
sn: Davis
|
||||||
|
uid: miles
|
||||||
|
userPassword: milespassword
|
||||||
|
|
||||||
|
dn: uid=johnc,ou=musicians,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: John Coltrane
|
||||||
|
sn: Coltrane
|
||||||
|
uid: johnc
|
||||||
|
userPassword: johncspassword
|
||||||
|
|
||||||
|
dn: uid=jimi,ou=musicians,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
cn: Jimi Hendrix
|
||||||
|
sn: Hendrix
|
||||||
|
uid: jimi
|
||||||
|
userPassword: {SSHA}S6jnyvykw4K5eF35OXvAkQsf3y2fPrRQ
|
||||||
|
|
||||||
|
|
||||||
|
# Groups
|
||||||
|
|
||||||
|
dn: ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: organizationalUnit
|
||||||
|
ou: groups
|
||||||
|
|
||||||
dn: cn=developers,ou=groups,dc=springframework,dc=org
|
dn: cn=developers,ou=groups,dc=springframework,dc=org
|
||||||
objectclass: top
|
objectclass: top
|
||||||
objectclass: groupOfNames
|
objectclass: groupOfUniqueNames
|
||||||
cn: developers
|
cn: developers
|
||||||
ou: developer
|
ou: developer
|
||||||
member: uid=ben,ou=people,dc=springframework,dc=org
|
uniqueMember: uid=ben,ou=people,dc=springframework,dc=org
|
||||||
member: uid=bob,ou=people,dc=springframework,dc=org
|
uniqueMember: uid=bob,ou=people,dc=springframework,dc=org
|
||||||
|
|
||||||
dn: cn=managers,ou=groups,dc=springframework,dc=org
|
dn: cn=managers,ou=groups,dc=springframework,dc=org
|
||||||
objectclass: top
|
objectclass: top
|
||||||
objectclass: groupOfNames
|
objectclass: groupOfUniqueNames
|
||||||
cn: managers
|
cn: managers
|
||||||
ou: manager
|
ou: manager
|
||||||
member: uid=ben,ou=people,dc=springframework,dc=org
|
uniqueMember: uid=ben,ou=people,dc=springframework,dc=org
|
||||||
|
|
||||||
dn: cn=submanagers,ou=subgroups,ou=groups,dc=springframework,dc=org
|
dn: ou=genres,ou=groups,dc=springframework,dc=org
|
||||||
objectclass: top
|
objectclass: top
|
||||||
objectclass: groupOfNames
|
objectclass: organizationalUnit
|
||||||
cn: submanagers
|
ou: genres
|
||||||
ou: submanager
|
|
||||||
member: uid=ben,ou=people,dc=springframework,dc=org
|
dn: cn=rock,ou=genres,ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: groupOfUniqueNames
|
||||||
|
cn: rock
|
||||||
|
ou: rock
|
||||||
|
uniqueMember: uid=jimi,ou=musicians,dc=springframework,dc=org
|
||||||
|
|
||||||
|
dn: cn=jazz,ou=genres,ou=groups,dc=springframework,dc=org
|
||||||
|
objectclass: top
|
||||||
|
objectclass: groupOfUniqueNames
|
||||||
|
cn: jazz
|
||||||
|
ou: jazz
|
||||||
|
uniqueMember: uid=miles,ou=musicians,dc=springframework,dc=org
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,15 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<http>
|
<http>
|
||||||
|
<intercept-url pattern="/login.jsp*" filters="none" />
|
||||||
<intercept-url pattern="/secure/**" access="ROLE_DEVELOPER,ROLE_USER" />
|
<intercept-url pattern="/secure/**" access="ROLE_DEVELOPER,ROLE_USER" />
|
||||||
<intercept-url pattern="/**" access="ROLE_DEVELOPER,ROLE_USER" />
|
<intercept-url pattern="/**" access="ROLE_DEVELOPER,ROLE_USER" />
|
||||||
|
|
||||||
<form-login />
|
<form-login login-page="/login.jsp" authentication-failure-url="/login.jsp?login_error=true"/>
|
||||||
<http-basic/>
|
<http-basic/>
|
||||||
|
|
||||||
<!-- Default logout configuration -->
|
<!-- Default logout configuration -->
|
||||||
<logout />
|
<logout logout-url="/logout"/>
|
||||||
|
|
||||||
<concurrent-session-control max-sessions="1" />
|
<concurrent-session-control max-sessions="1" />
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<beans:beans xmlns="http://www.springframework.org/schema/security"
|
||||||
|
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||||
|
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.2.xsd">
|
||||||
|
|
||||||
|
<authentication-provider>
|
||||||
|
<user-service>
|
||||||
|
<user name="miles" password="milespassword" authorities="ROLE_USER,ROLE_JAZZ,ROLE_TRUMPETER"/>
|
||||||
|
<user name="johnc" password="johncspassword" authorities="ROLE_USER,ROLE_JAZZ,ROLE_SAXOPHONIST"/>
|
||||||
|
<user name="jimi" password="jimispassword" authorities="ROLE_USER,ROLE_ROCK,ROLE_GUITARIST"/>
|
||||||
|
</user-service>
|
||||||
|
</authentication-provider>
|
||||||
|
|
||||||
|
</beans:beans>
|
|
@ -1,9 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
- Sample namespace-based configuration
|
- LDAP Provider configuration snippet
|
||||||
-
|
-
|
||||||
- $Id: applicationContext-security-ns.xml 2371 2007-12-14 02:26:27Z benalex $
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<beans:beans xmlns="http://www.springframework.org/schema/security"
|
<beans:beans xmlns="http://www.springframework.org/schema/security"
|
||||||
|
@ -14,8 +13,8 @@
|
||||||
|
|
||||||
<ldap-server ldif="classpath*:test-server.ldif"/>
|
<ldap-server ldif="classpath*:test-server.ldif"/>
|
||||||
|
|
||||||
<ldap-authentication-provider user-search-filter="(uid={0})" group-search-filter='member={0}' group-role-attribute="ou"/>
|
<ldap-authentication-provider user-search-filter="(uid={0})" group-role-attribute="ou" />
|
||||||
|
|
||||||
<ldap-user-service user-search-filter="(uid={0})" group-search-filter='member={0}' group-role-attribute="ou"/>
|
<ldap-user-service user-search-filter="(uid={0})" group-role-attribute="ou"/>
|
||||||
|
|
||||||
</beans:beans>
|
</beans:beans>
|
|
@ -1,8 +1,9 @@
|
||||||
<!DOCTYPE web-app PUBLIC
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
|
||||||
"http://java.sun.com/dtd/web-app_2_3.dtd" >
|
|
||||||
|
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||||
|
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
|
||||||
|
|
||||||
<web-app>
|
|
||||||
<display-name>Integration Tests Webapp</display-name>
|
<display-name>Integration Tests Webapp</display-name>
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!-- %@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" % -->
|
||||||
|
|
||||||
|
<!-- Not used unless you declare a <form-login login-page="/login.jsp"/> element -->
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Custom Spring Security Login</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Custom Spring Security Login</h1>
|
||||||
|
|
||||||
|
<%
|
||||||
|
if (request.getParameter("login_error") != null) {
|
||||||
|
%>
|
||||||
|
<font color="red">
|
||||||
|
Your login attempt was not successful, try again.<br/><br/>
|
||||||
|
</font>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
|
||||||
|
<form action="j_spring_security_check" method="POST">
|
||||||
|
<table>
|
||||||
|
<tr><td>User:</td><td><input type='text' name='j_username' value=''/></td></tr>
|
||||||
|
<tr><td>Password:</td><td><input type='password' name='j_password'></td></tr>
|
||||||
|
<tr><td><input type="checkbox" name="_spring_security_remember_me"></td><td>Don't ask for my password for two weeks</td></tr>
|
||||||
|
<tr><td colspan='2'><input name="submit" type="submit"></td></tr>
|
||||||
|
<tr><td colspan='2'><input name="reset" type="reset"></td></tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html
|
||||||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<title>A secure page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<jsp:include page="secure1body.jsp?x=1&y=2"/>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,2 @@
|
||||||
|
Params: x=<%= request.getParameter("x") %>, y=<%= request.getParameter("y") %>
|
||||||
|
xcount=<%= request.getParameterValues("x").length %>
|
|
@ -1,31 +0,0 @@
|
||||||
package org.springframework.security.integration;
|
|
||||||
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Luke Taylor
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public abstract class AbstractWebLoginTests extends AbstractWebServerIntegrationTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void loginFailsWithinvalidPassword() {
|
|
||||||
beginAt("secure/index.html");
|
|
||||||
assertFormPresent();
|
|
||||||
setFormElement("j_username", "bob");
|
|
||||||
setFormElement("j_password", "wrongpassword");
|
|
||||||
submit();
|
|
||||||
assertTextPresent("Your login attempt was not successful");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void loginSucceedsWithCorrectPassword() {
|
|
||||||
beginAt("secure/index.html");
|
|
||||||
assertFormPresent();
|
|
||||||
setFormElement("j_username", "bob");
|
|
||||||
setFormElement("j_password", "bobspassword");
|
|
||||||
submit();
|
|
||||||
assertTextPresent("A Secure Page");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,6 +3,7 @@ package org.springframework.security.integration;
|
||||||
import org.springframework.web.context.ContextLoaderListener;
|
import org.springframework.web.context.ContextLoaderListener;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import net.sourceforge.jwebunit.WebTester;
|
import net.sourceforge.jwebunit.WebTester;
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.testng.annotations.*;
|
import org.testng.annotations.*;
|
||||||
|
|
||||||
|
import com.meterware.httpunit.WebConversation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -20,9 +23,12 @@ import org.testng.annotations.*;
|
||||||
public abstract class AbstractWebServerIntegrationTests {
|
public abstract class AbstractWebServerIntegrationTests {
|
||||||
private Server server;
|
private Server server;
|
||||||
private final Object SERVER_LOCK = new Object();
|
private final Object SERVER_LOCK = new Object();
|
||||||
protected final WebTester tester = new WebTester();;
|
protected final WebTester tester = new WebTester();
|
||||||
|
|
||||||
/** Override to set the application context files that should be loaded */
|
/**
|
||||||
|
* Override to set the application context files that should be loaded or return null
|
||||||
|
* to use web.xml.
|
||||||
|
*/
|
||||||
protected abstract String getContextConfigLocations();
|
protected abstract String getContextConfigLocations();
|
||||||
|
|
||||||
protected String getContextPath() {
|
protected String getContextPath() {
|
||||||
|
@ -33,20 +39,28 @@ public abstract class AbstractWebServerIntegrationTests {
|
||||||
public void startServer() throws Exception {
|
public void startServer() throws Exception {
|
||||||
synchronized(SERVER_LOCK) {
|
synchronized(SERVER_LOCK) {
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
|
//System.setProperty("DEBUG", "true");
|
||||||
|
//System.setProperty("VERBOSE", "true");
|
||||||
|
//System.setProperty("IGNORED", "true");
|
||||||
server = new Server(0);
|
server = new Server(0);
|
||||||
WebAppContext webCtx = new WebAppContext("src/main/webapp", getContextPath());
|
server.addHandler(createWebContext());
|
||||||
|
|
||||||
webCtx.addEventListener(new ContextLoaderListener());
|
|
||||||
webCtx.getInitParams().put("contextConfigLocation", getContextConfigLocations());
|
|
||||||
|
|
||||||
server.addHandler(webCtx);
|
|
||||||
server.start();
|
server.start();
|
||||||
|
|
||||||
tester.getTestContext().setBaseUrl(getBaseUrl());
|
tester.getTestContext().setBaseUrl(getBaseUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected WebAppContext createWebContext() {
|
||||||
|
WebAppContext webCtx = new WebAppContext("src/main/webapp", getContextPath());
|
||||||
|
|
||||||
|
if (StringUtils.hasText(getContextConfigLocations())) {
|
||||||
|
webCtx.addEventListener(new ContextLoaderListener());
|
||||||
|
webCtx.getInitParams().put("contextConfigLocation", getContextConfigLocations());
|
||||||
|
}
|
||||||
|
|
||||||
|
return webCtx;
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void stopServer() throws Exception {
|
public void stopServer() throws Exception {
|
||||||
synchronized(SERVER_LOCK) {
|
synchronized(SERVER_LOCK) {
|
||||||
|
@ -57,7 +71,12 @@ public abstract class AbstractWebServerIntegrationTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final String getBaseUrl() {
|
@AfterMethod
|
||||||
|
public void resetWebConversation() {
|
||||||
|
tester.getTestContext().setWebClient(new WebConversation());
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String getBaseUrl() {
|
||||||
int port = server.getConnectors()[0].getLocalPort();
|
int port = server.getConnectors()[0].getLocalPort();
|
||||||
return "http://localhost:" + port + getContextPath() + "/";
|
return "http://localhost:" + port + getContextPath() + "/";
|
||||||
}
|
}
|
||||||
|
@ -73,6 +92,10 @@ public abstract class AbstractWebServerIntegrationTests {
|
||||||
return appCtx;
|
return appCtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// protected final HttpUnitDialog getDialog() {
|
||||||
|
// return tester.getDialog();
|
||||||
|
// }
|
||||||
|
|
||||||
protected final void submit() {
|
protected final void submit() {
|
||||||
tester.submit();
|
tester.submit();
|
||||||
}
|
}
|
||||||
|
@ -92,4 +115,15 @@ public abstract class AbstractWebServerIntegrationTests {
|
||||||
protected final void assertTextPresent(String text) {
|
protected final void assertTextPresent(String text) {
|
||||||
tester.assertTextPresent(text);
|
tester.assertTextPresent(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Security-specific utility methods
|
||||||
|
|
||||||
|
protected void login(String username, String password) {
|
||||||
|
assertFormPresent();
|
||||||
|
setFormElement("j_username", username);
|
||||||
|
setFormElement("j_password", password);
|
||||||
|
submit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package org.springframework.security.integration;
|
||||||
|
|
||||||
|
import org.testng.annotations.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luke Taylor
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTests {
|
||||||
|
|
||||||
|
protected String getContextConfigLocations() {
|
||||||
|
return "/WEB-INF/http-security.xml /WEB-INF/in-memory-provider.xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loginFailsWithinvalidPassword() {
|
||||||
|
beginAt("secure/index.html");
|
||||||
|
login("jimi", "wrongPassword");
|
||||||
|
assertTextPresent("Your login attempt was not successful");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loginSucceedsWithCorrectPassword() {
|
||||||
|
beginAt("secure/index.html");
|
||||||
|
login("jimi", "jimispassword");
|
||||||
|
assertTextPresent("A Secure Page");
|
||||||
|
tester.gotoPage("/logout");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks use of <jsp:include> with parameters in the secured page.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void savedRequestWithJspIncludeSeesCorrectParams() {
|
||||||
|
beginAt("secure/secure1.jsp?x=0");
|
||||||
|
login("jimi", "jimispassword");
|
||||||
|
// Included JSP has params ?x=1&y=2
|
||||||
|
assertTextPresent("Params: x=1, y=2");
|
||||||
|
assertTextPresent("xcount=2");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ import org.testng.annotations.*;
|
||||||
* @author Luke Taylor
|
* @author Luke Taylor
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class LdapWebLoginTests extends AbstractWebLoginTests {
|
public class LdapWebAppTests extends AbstractWebServerIntegrationTests {
|
||||||
|
|
||||||
protected String getContextConfigLocations() {
|
protected String getContextConfigLocations() {
|
||||||
return "/WEB-INF/http-security.xml /WEB-INF/ldap-provider.xml";
|
return "/WEB-INF/http-security.xml /WEB-INF/ldap-provider.xml";
|
Loading…
Reference in New Issue