mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-14 06:13:30 +00:00
Added some integration tests for Basic authentication, both alone and in combination with form login.
This commit is contained in:
parent
33e75d92b6
commit
282bfc3151
14
itest/web/src/main/webapp/WEB-INF/http-security-basic.xml
Normal file
14
itest/web/src/main/webapp/WEB-INF/http-security-basic.xml
Normal 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>
|
@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,6 +29,13 @@ public class InMemoryProviderWebAppTests extends AbstractWebServerIntegrationTes
|
|||||||
tester.gotoPage("/logout");
|
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.
|
* Checks use of <jsp:include> with parameters in the secured page.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user