mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-10 11:29:20 +00:00
Merge branch '4.0.x'
Closes gh-49988
This commit is contained in:
+2
-1
@@ -23,6 +23,7 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.MockMvcBuilderCustomizer;
|
||||
import org.springframework.boot.webmvc.test.autoconfigure.MockMvcHtmlUnitDriverCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -43,7 +44,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
* @author Andy Wilkinson
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@AutoConfiguration(after = ServletWebSecurityAutoConfiguration.class)
|
||||
@ConditionalOnClass(MockMvc.class)
|
||||
public final class SecurityMockMvcAutoConfiguration {
|
||||
|
||||
|
||||
+10
@@ -18,6 +18,7 @@ package org.springframework.boot.security.test.autoconfigure.webmvc;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,6 +27,7 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.web.servlet.assertj.MockMvcTester;
|
||||
|
||||
@@ -43,6 +45,9 @@ class MockMvcSecurityIntegrationTests {
|
||||
@Autowired
|
||||
private MockMvcTester mvc;
|
||||
|
||||
@Autowired
|
||||
private PathPatternRequestMatcher.@Nullable Builder pathPatternRequestMatcherBuilder;
|
||||
|
||||
@Test
|
||||
@WithMockUser(username = "test", password = "test", roles = "USER")
|
||||
void okResponseWithMockUser() {
|
||||
@@ -62,4 +67,9 @@ class MockMvcSecurityIntegrationTests {
|
||||
.hasStatusOk();
|
||||
}
|
||||
|
||||
@Test
|
||||
void pathPatternRequestMatcherBuilderIsAvailable() {
|
||||
assertThat(this.pathPatternRequestMatcherBuilder).isNotNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ dependencies {
|
||||
optional(project(":module:spring-boot-rsocket"))
|
||||
optional(project(":module:spring-boot-webflux"))
|
||||
optional(project(":module:spring-boot-webmvc"))
|
||||
optional(project(":module:spring-boot-webmvc-test"))
|
||||
optional(project(":module:spring-boot-web-server"))
|
||||
optional("jakarta.servlet:jakarta.servlet-api")
|
||||
optional("org.springframework:spring-messaging")
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ import static org.springframework.security.config.Customizer.withDefaults;
|
||||
* @since 4.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = UserDetailsServiceAutoConfiguration.class,
|
||||
afterName = "org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration")
|
||||
afterName = { "org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration",
|
||||
"org.springframework.boot.webmvc.test.autoconfigure.MockMvcAutoConfiguration" })
|
||||
@ConditionalOnClass(EnableWebSecurity.class)
|
||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||
public final class ServletWebSecurityAutoConfiguration {
|
||||
|
||||
Reference in New Issue
Block a user