Browse Source

Remove Static Mock

These can cause infinite loops when running
tests in an IDE.
pull/17943/head
Josh Cummings 3 months ago
parent
commit
a63e87d8fb
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
  1. 11
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/X509ConfigurerTests.java

11
config/src/test/java/org/springframework/security/config/annotation/web/configurers/X509ConfigurerTests.java

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

Loading…
Cancel
Save