diff --git a/itest/web/itest-web.gradle b/itest/web/itest-web.gradle
new file mode 100644
index 0000000000..68074f4ba8
--- /dev/null
+++ b/itest/web/itest-web.gradle
@@ -0,0 +1,29 @@
+
+dependencies {
+ compile "org.springframework:spring-context:$springVersion",
+ "org.springframework:spring-web:$springVersion",
+ 'javax.servlet:servlet-api:2.5'
+
+ testCompile project(':spring-security-core'),
+ project(':spring-security-web'),
+ "org.springframework:spring-core:$springVersion",
+ "org.springframework:spring-beans:$springVersion",
+ "org.springframework:spring-webmvc:$springVersion",
+ "org.mortbay.jetty:jetty:$jettyVersion",
+ "org.mortbay.jetty:jetty-util:$jettyVersion",
+ 'net.sourceforge.jwebunit:jwebunit-core:2.2',
+ "org.testng:testng:5.11:jdk15"
+
+ testRuntime project(':spring-security-config'),
+ project(':spring-security-ldap'),
+ "org.mortbay.jetty:jsp-2.1-jetty:$jettyVersion",
+ 'net.sourceforge.jwebunit:jwebunit-htmlunit-plugin:2.2'
+}
+
+test {
+ useTestNG();
+ options {
+ jvmArgs = ["-ea", '-Xms128m', '-Xmx500m']
+ systemProperties = ['webapp.dir': "$projectDir/src/main/webapp"]
+ }
+}
\ No newline at end of file
diff --git a/itest/web/pom.xml b/itest/web/pom.xml
index 879dc05a6c..7eeb63abb5 100644
--- a/itest/web/pom.xml
+++ b/itest/web/pom.xml
@@ -14,14 +14,14 @@
org.testng
testng
- 5.8
+ 5.11
test
jdk15
net.sourceforge.jwebunit
jwebunit-htmlunit-plugin
- 2.1
+ 2.2
test
diff --git a/itest/web/src/test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java b/itest/web/src/test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java
index ac06273f3d..011f2c269d 100644
--- a/itest/web/src/test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java
+++ b/itest/web/src/test/java/org/springframework/security/integration/AbstractWebServerIntegrationTests.java
@@ -1,6 +1,9 @@
package org.springframework.security.integration;
+import java.util.List;
+
import javax.servlet.ServletContext;
+import javax.servlet.http.Cookie;
import net.sourceforge.jwebunit.junit.WebTester;
@@ -16,6 +19,7 @@ import org.springframework.web.servlet.DispatcherServlet;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
/**
* Base class which allows the application to be started with a particular Spring application
@@ -50,14 +54,15 @@ public abstract class AbstractWebServerIntegrationTests {
server = new Server(0);
server.addHandler(createWebContext());
server.start();
- tester.getTestContext().setBaseUrl(getBaseUrl());
}
}
}
@SuppressWarnings("unchecked")
private WebAppContext createWebContext() {
- WebAppContext webCtx = new WebAppContext("src/main/webapp", getContextPath());
+ String webappDir = System.getProperty("webapp.dir");
+
+ WebAppContext webCtx = new WebAppContext(webappDir == null ? "src/main/webapp" : webappDir, getContextPath());
if (StringUtils.hasText(getContextConfigLocations())) {
webCtx.addEventListener(new ContextLoaderListener());
@@ -83,9 +88,15 @@ public abstract class AbstractWebServerIntegrationTests {
}
}
+ @BeforeMethod
+ public void initializeTester() {
+ tester.getTestContext().setBaseUrl(getBaseUrl());
+ }
+
@AfterMethod
public void resetWebConversation() {
tester.closeBrowser();
+ tester.setTestContext(null);
}
protected final String getBaseUrl() {
@@ -104,9 +115,16 @@ public abstract class AbstractWebServerIntegrationTests {
return appCtx;
}
-// protected final HttpUnitDialog getDialog() {
-// return tester.getDialog();
-// }
+ @SuppressWarnings("unchecked")
+ protected Cookie getRememberMeCookie() {
+ List cookies = (List) tester.getTestingEngine().getCookies();
+ for (Cookie c : cookies) {
+ if (c.getName().equals("SPRING_SECURITY_REMEMBER_ME_COOKIE")) {
+ return c;
+ }
+ }
+ return null;
+ }
protected final void submit() {
tester.submit();
diff --git a/itest/web/src/test/java/org/springframework/security/integration/InMemoryProviderWebAppTests.java b/itest/web/src/test/java/org/springframework/security/integration/InMemoryProviderWebAppTests.java
index a215489678..bbeaab393a 100644
--- a/itest/web/src/test/java/org/springframework/security/integration/InMemoryProviderWebAppTests.java
+++ b/itest/web/src/test/java/org/springframework/security/integration/InMemoryProviderWebAppTests.java
@@ -1,5 +1,9 @@
package org.springframework.security.integration;
+import static org.testng.Assert.*;
+
+import javax.servlet.http.Cookie;
+
import net.sourceforge.jwebunit.junit.WebTester;
import org.testng.annotations.Test;
@@ -55,6 +59,20 @@ public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTes
assertTextPresent("I'm file?with?special?chars.htm");
}
+ @Test
+ public void persistentLoginIsSuccesful() throws Exception {
+ beginAt("secure/index.html");
+ tester.checkCheckbox("_spring_security_remember_me");
+ login("jimi", "jimispassword");
+ Cookie rememberMe = getRememberMeCookie();
+ assertNotNull(rememberMe);
+ tester.closeBrowser();
+
+ tester.getTestContext().addCookie(rememberMe);
+ beginAt("secure/index.html");
+ assertTextPresent("A Secure Page");
+ }
+
@Test
public void maxConcurrentLoginsValueIsRespected() throws Exception {
System.out.println("Client: ******* First login ******* ");
diff --git a/settings.gradle b/settings.gradle
index 259615bc63..fa951f7607 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -20,6 +20,10 @@ def String[] docs = [
'manual'
]
+def String[] itest = [
+ 'web'
+]
+
include modules
modules.each {name ->
@@ -37,15 +41,24 @@ samples.each {name ->
p.projectDir = new File(settingsDir, "samples/${name}");
}
+include itest
+
+itest.each { name ->
+ p = findProject(":${name}")
+ p.name = "itest-${name}"
+ p.buildFileName = "itest-${name}.gradle"
+ p.projectDir = new File(settingsDir, "itest/${name}");
+}
+
include docs
-docs.each{ name ->
+docs.each { name ->
p = findProject(":${name}")
p.buildFileName = "${name}.gradle"
p.projectDir = new File(settingsDir, "docs/${name}");
}
rootProject.children.each {project ->
- assert project.buildFile.isFile()
assert project.projectDir.isDirectory()
+ assert project.buildFile.isFile()
}
\ No newline at end of file