Remove Static Mock

These can cause infinite loops when running
tests in an IDE.
This commit is contained in:
Josh Cummings 2025-09-19 17:44:50 -06:00
parent 229c7bca5b
commit a63e87d8fb
No known key found for this signature in database
GPG Key ID: 869B37A20E876129

View File

@ -27,6 +27,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.security.config.ObjectPostProcessor; import org.springframework.security.config.ObjectPostProcessor;
import org.springframework.security.config.annotation.SecurityContextChangedListenerConfig; import org.springframework.security.config.annotation.SecurityContextChangedListenerConfig;
@ -77,7 +78,8 @@ public class X509ConfigurerTests {
@Test @Test
public void configureWhenRegisteringObjectPostProcessorThenInvokedOnX509AuthenticationFilter() { public void configureWhenRegisteringObjectPostProcessorThenInvokedOnX509AuthenticationFilter() {
this.spring.register(ObjectPostProcessorConfig.class).autowire(); this.spring.register(ObjectPostProcessorConfig.class).autowire();
verify(ObjectPostProcessorConfig.objectPostProcessor).postProcess(any(X509AuthenticationFilter.class)); ObjectPostProcessor<Object> objectPostProcessor = this.spring.getContext().getBean(ObjectPostProcessor.class);
verify(objectPostProcessor).postProcess(any(X509AuthenticationFilter.class));
} }
@Test @Test
@ -193,7 +195,7 @@ public class X509ConfigurerTests {
@EnableWebSecurity @EnableWebSecurity
static class ObjectPostProcessorConfig { static class ObjectPostProcessorConfig {
static ObjectPostProcessor<Object> objectPostProcessor = spy(ReflectingObjectPostProcessor.class); ObjectPostProcessor<Object> objectPostProcessor = spy(ReflectingObjectPostProcessor.class);
@Bean @Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
@ -205,8 +207,9 @@ public class X509ConfigurerTests {
} }
@Bean @Bean
static ObjectPostProcessor<Object> objectPostProcessor() { @Primary
return objectPostProcessor; ObjectPostProcessor<Object> objectPostProcessor() {
return this.objectPostProcessor;
} }
} }