Added some integration tests for Basic authentication, both alone and in combination with form login.

This commit is contained in:
Luke Taylor 2009-12-12 17:32:27 +00:00
parent 33e75d92b6
commit 282bfc3151
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?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-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http>
<intercept-url pattern="/**" access="ROLE_DEVELOPER,ROLE_USER" />
<http-basic />
</http>
</beans:beans>

View File

@ -0,0 +1,23 @@
package org.springframework.security.integration;
import org.testng.annotations.Test;
public class BasicAuthenticationTests extends AbstractWebServerIntegrationTests {
@Override
protected String getContextConfigLocations() {
return "/WEB-INF/http-security-basic.xml /WEB-INF/in-memory-provider.xml";
}
@Test
public void basicAuthenticationIsSuccessful() throws Exception {
tester.setIgnoreFailingStatusCodes(true);
beginAt("secure/index.html");
// Ignore the 401
tester.setIgnoreFailingStatusCodes(false);
tester.assertHeaderEquals("WWW-Authenticate", "Basic realm=\"Spring Security Application\"");
tester.getTestContext().setAuthorization("johnc", "johncspassword");
beginAt("secure/index.html");
}
}

View File

@ -29,6 +29,13 @@ public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTes
tester.gotoPage("/logout");
}
@Test
public void basicAuthenticationIsSuccessful() throws Exception {
tester.getTestContext().setAuthorization("johnc", "johncspassword");
beginAt("secure/index.html");
beginAt("secure/index.html");
}
/*
* Checks use of <jsp:include> with parameters in the secured page.
*/