2727import org .springframework .beans .factory .annotation .Autowired ;
2828import org .springframework .context .annotation .Bean ;
2929import org .springframework .context .annotation .Configuration ;
30+ import org .springframework .context .annotation .Primary ;
3031import org .springframework .core .io .ClassPathResource ;
3132import org .springframework .security .config .ObjectPostProcessor ;
3233import 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