Skip to content

Commit a63e87d

Browse files
committed
Remove Static Mock
These can cause infinite loops when running tests in an IDE.
1 parent 229c7bc commit a63e87d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.beans.factory.annotation.Autowired;
2828
import org.springframework.context.annotation.Bean;
2929
import org.springframework.context.annotation.Configuration;
30+
import org.springframework.context.annotation.Primary;
3031
import org.springframework.core.io.ClassPathResource;
3132
import org.springframework.security.config.ObjectPostProcessor;
3233
import org.springframework.security.config.annotation.SecurityContextChangedListenerConfig;
@@ -77,7 +78,8 @@ public class X509ConfigurerTests {
7778
@Test
7879
public void configureWhenRegisteringObjectPostProcessorThenInvokedOnX509AuthenticationFilter() {
7980
this.spring.register(ObjectPostProcessorConfig.class).autowire();
80-
verify(ObjectPostProcessorConfig.objectPostProcessor).postProcess(any(X509AuthenticationFilter.class));
81+
ObjectPostProcessor<Object> objectPostProcessor = this.spring.getContext().getBean(ObjectPostProcessor.class);
82+
verify(objectPostProcessor).postProcess(any(X509AuthenticationFilter.class));
8183
}
8284

8385
@Test
@@ -193,7 +195,7 @@ private <T extends Certificate> T loadCert(String location) {
193195
@EnableWebSecurity
194196
static class ObjectPostProcessorConfig {
195197

196-
static ObjectPostProcessor<Object> objectPostProcessor = spy(ReflectingObjectPostProcessor.class);
198+
ObjectPostProcessor<Object> objectPostProcessor = spy(ReflectingObjectPostProcessor.class);
197199

198200
@Bean
199201
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
@@ -205,8 +207,9 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
205207
}
206208

207209
@Bean
208-
static ObjectPostProcessor<Object> objectPostProcessor() {
209-
return objectPostProcessor;
210+
@Primary
211+
ObjectPostProcessor<Object> objectPostProcessor() {
212+
return this.objectPostProcessor;
210213
}
211214

212215
}

0 commit comments

Comments
 (0)