Improvements to itest-web subproject.
Added to gradle build. Updated deps (testng and jwebunit). New test added for persistent remember-me.
This commit is contained in:
parent
70ef0d8b3e
commit
e678ba7283
|
@ -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"]
|
||||
}
|
||||
}
|
|
@ -14,14 +14,14 @@
|
|||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>5.8</version>
|
||||
<version>5.11</version>
|
||||
<scope>test</scope>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.jwebunit</groupId>
|
||||
<artifactId>jwebunit-htmlunit-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
<version>2.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -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<Cookie> cookies = (List<Cookie>) 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();
|
||||
|
|
|
@ -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 ******* ");
|
||||
|
|
|
@ -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()
|
||||
}
|
Loading…
Reference in New Issue