Skip to content

Commit e8a7b65

Browse files
committed
Add Configuration Test
Issue gh-11327
1 parent 01ffc93 commit e8a7b65

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

config/src/test/java/org/springframework/security/config/http/MiscHttpConfigTests.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@
3434
import javax.security.auth.callback.CallbackHandler;
3535
import javax.security.auth.spi.LoginModule;
3636

37-
import ch.qos.logback.classic.Logger;
38-
import ch.qos.logback.classic.spi.ILoggingEvent;
39-
import ch.qos.logback.core.Appender;
4037
import jakarta.servlet.Filter;
4138
import jakarta.servlet.ServletException;
4239
import jakarta.servlet.http.HttpServletRequest;
4340
import jakarta.servlet.http.HttpServletResponse;
4441
import jakarta.servlet.http.HttpServletResponseWrapper;
42+
43+
import ch.qos.logback.classic.Logger;
44+
import ch.qos.logback.classic.spi.ILoggingEvent;
45+
import ch.qos.logback.core.Appender;
4546
import org.apache.http.HttpStatus;
4647
import org.assertj.core.api.iterable.Extractor;
4748
import org.jetbrains.annotations.NotNull;
@@ -546,6 +547,14 @@ public void configureWhenProtectingLoginPageThenWarningLogged() {
546547
assertThat(baos.toString()).contains("[WARN]");
547548
}
548549

550+
@Test
551+
public void configureWhenProtectingLoginPageAuthorizationManagerThenWarningLogged() {
552+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
553+
redirectLogsTo(baos, DefaultFilterChainValidator.class);
554+
this.spring.configLocations(xml("ProtectedLoginPageAuthorizationManager")).autowire();
555+
assertThat(baos.toString()).contains("[WARN]");
556+
}
557+
549558
@Test
550559
public void configureWhenUsingDisableUrlRewritingThenRedirectIsNotEncodedByResponse()
551560
throws IOException, ServletException {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2002-2018 the original author or authors.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xmlns="http://www.springframework.org/schema/security"
21+
xsi:schemaLocation="
22+
http://www.springframework.org/schema/security
23+
https://www.springframework.org/schema/security/spring-security.xsd
24+
http://www.springframework.org/schema/beans
25+
https://www.springframework.org/schema/beans/spring-beans.xsd">
26+
27+
<http use-authorization-manager="true">
28+
<form-login login-page="/login"/>
29+
<intercept-url pattern="/login*" access="hasRole('ROLE_A')"/>
30+
</http>
31+
32+
<b:import resource="userservice.xml"/>
33+
</b:beans>

0 commit comments

Comments
 (0)