27
27
import org .springframework .beans .factory .annotation .Autowired ;
28
28
import org .springframework .context .annotation .Bean ;
29
29
import org .springframework .context .annotation .Configuration ;
30
+ import org .springframework .context .annotation .Primary ;
30
31
import org .springframework .core .io .ClassPathResource ;
31
32
import org .springframework .security .config .ObjectPostProcessor ;
32
33
import org .springframework .security .config .annotation .SecurityContextChangedListenerConfig ;
@@ -77,7 +78,8 @@ public class X509ConfigurerTests {
77
78
@ Test
78
79
public void configureWhenRegisteringObjectPostProcessorThenInvokedOnX509AuthenticationFilter () {
79
80
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 ));
81
83
}
82
84
83
85
@ Test
@@ -193,7 +195,7 @@ private <T extends Certificate> T loadCert(String location) {
193
195
@ EnableWebSecurity
194
196
static class ObjectPostProcessorConfig {
195
197
196
- static ObjectPostProcessor <Object > objectPostProcessor = spy (ReflectingObjectPostProcessor .class );
198
+ ObjectPostProcessor <Object > objectPostProcessor = spy (ReflectingObjectPostProcessor .class );
197
199
198
200
@ Bean
199
201
SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
@@ -205,8 +207,9 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
205
207
}
206
208
207
209
@ Bean
208
- static ObjectPostProcessor <Object > objectPostProcessor () {
209
- return objectPostProcessor ;
210
+ @ Primary
211
+ ObjectPostProcessor <Object > objectPostProcessor () {
212
+ return this .objectPostProcessor ;
210
213
}
211
214
212
215
}
0 commit comments