From e8a7b654b42333616fdb0e528e7c0860b5ed17a0 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Thu, 7 Jul 2022 14:42:07 -0600 Subject: [PATCH] Add Configuration Test Issue gh-11327 --- .../config/http/MiscHttpConfigTests.java | 15 +++++++-- ...ProtectedLoginPageAuthorizationManager.xml | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-ProtectedLoginPageAuthorizationManager.xml diff --git a/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java b/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java index 6204fb2835..39d0275146 100644 --- a/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java +++ b/config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java @@ -34,14 +34,15 @@ import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.spi.LoginModule; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.Appender; import jakarta.servlet.Filter; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponseWrapper; + +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.Appender; import org.apache.http.HttpStatus; import org.assertj.core.api.iterable.Extractor; import org.jetbrains.annotations.NotNull; @@ -546,6 +547,14 @@ public class MiscHttpConfigTests { assertThat(baos.toString()).contains("[WARN]"); } + @Test + public void configureWhenProtectingLoginPageAuthorizationManagerThenWarningLogged() { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + redirectLogsTo(baos, DefaultFilterChainValidator.class); + this.spring.configLocations(xml("ProtectedLoginPageAuthorizationManager")).autowire(); + assertThat(baos.toString()).contains("[WARN]"); + } + @Test public void configureWhenUsingDisableUrlRewritingThenRedirectIsNotEncodedByResponse() throws IOException, ServletException { diff --git a/config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-ProtectedLoginPageAuthorizationManager.xml b/config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-ProtectedLoginPageAuthorizationManager.xml new file mode 100644 index 0000000000..4eda89b3e8 --- /dev/null +++ b/config/src/test/resources/org/springframework/security/config/http/MiscHttpConfigTests-ProtectedLoginPageAuthorizationManager.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + +