Browse Source

Merge branch '3.5.x'

Closes gh-48055
pull/48068/head
Andy Wilkinson 1 month ago
parent
commit
756a6408fe
  1. 2
      module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes
  2. 41
      module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleWebSecurityConfigurer.java
  3. 37
      module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleWebSecurityCustomizer.java
  4. 57
      module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityWebMvcTestIntegrationTests.java
  5. 4
      module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilter.java

2
module/spring-boot-security-test/src/main/resources/META-INF/spring/org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest.includes

@ -1 +1,3 @@ @@ -1 +1,3 @@
org.springframework.security.config.annotation.web.WebSecurityConfigurer
org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer
org.springframework.security.web.SecurityFilterChain

41
module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleWebSecurityConfigurer.java

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.security.test.autoconfigure.webmvc;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.stereotype.Component;
/**
* {@link WebSecurityConfigurer} used to test their inclusion in
* {@link WebMvcTest @WebMvcTest}.
*
* @author Andy Wilkinson
*/
@Component
class ExampleWebSecurityConfigurer implements WebSecurityConfigurer<WebSecurity> {
@Override
public void init(WebSecurity builder) {
}
@Override
public void configure(WebSecurity builder) {
}
}

37
module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/ExampleWebSecurityCustomizer.java

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.security.test.autoconfigure.webmvc;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.stereotype.Component;
/**
* {@link WebSecurityCustomizer} used to test their inclusion in
* {@link WebMvcTest @WebMvcTest}.
*
* @author Andy Wilkinson
*/
@Component
class ExampleWebSecurityCustomizer implements WebSecurityCustomizer {
@Override
public void customize(WebSecurity web) {
}
}

57
module/spring-boot-security-test/src/test/java/org/springframework/boot/security/test/autoconfigure/webmvc/SecurityWebMvcTestIntegrationTests.java

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.security.test.autoconfigure.webmvc;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.security.web.SecurityFilterChain;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for SpringSecurity with {@link WebMvcTest @WebMvcTest}.
*
* @author Andy Wilkinson
*/
@WebMvcTest
class SecurityWebMvcTestIntegrationTests {
@Autowired
private ConfigurableApplicationContext context;
@Test
void includesWebSecurityConfigurer() {
assertThat(AssertableApplicationContext.get(() -> this.context))
.hasSingleBean(ExampleWebSecurityConfigurer.class);
}
@Test
void includesWebSecurityCustomizer() {
assertThat(AssertableApplicationContext.get(() -> this.context))
.hasSingleBean(ExampleWebSecurityCustomizer.class);
}
@Test
void includesSecurityFilterChain() {
assertThat(AssertableApplicationContext.get(() -> this.context)).hasSingleBean(SecurityFilterChain.class);
}
}

4
module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/WebMvcTypeExcludeFilter.java

@ -50,9 +50,7 @@ class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF @@ -50,9 +50,7 @@ class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizableTypeExcludeF
private static final Class<?>[] NO_CONTROLLERS = {};
private static final String[] OPTIONAL_INCLUDES = { "tools.jackson.databind.JacksonModule",
"org.springframework.boot.jackson.JacksonComponent",
"org.springframework.security.config.annotation.web.WebSecurityConfigurer",
"org.springframework.security.web.SecurityFilterChain", "org.thymeleaf.dialect.IDialect",
"org.springframework.boot.jackson.JacksonComponent", "org.thymeleaf.dialect.IDialect",
"com.fasterxml.jackson.databind.Module", "org.springframework.boot.jackson2.JsonComponent" };
private static final Set<Class<?>> KNOWN_INCLUDES;

Loading…
Cancel
Save