diff --git a/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml b/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml new file mode 100644 index 0000000000..460950b09f --- /dev/null +++ b/itest/web/src/main/webapp/WEB-INF/http-security-basic.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/itest/web/src/test/java/org/springframework/security/integration/BasicAuthenticationTests.java b/itest/web/src/test/java/org/springframework/security/integration/BasicAuthenticationTests.java new file mode 100644 index 0000000000..4886386e17 --- /dev/null +++ b/itest/web/src/test/java/org/springframework/security/integration/BasicAuthenticationTests.java @@ -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"); + } + +} 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 a9ac66676f..5f5b3c03fb 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 @@ -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 with parameters in the secured page. */