3030import org .springframework .security .authorization .AuthorizationManager ;
3131import org .springframework .security .config .test .SpringTestContext ;
3232import org .springframework .security .config .test .SpringTestContextExtension ;
33- import org .springframework .security .web .access .intercept .FilterInvocationSecurityMetadataSource ;
3433import org .springframework .test .web .servlet .MockMvc ;
3534import org .springframework .test .web .servlet .request .RequestPostProcessor ;
3635import org .springframework .web .bind .annotation .PathVariable ;
@@ -89,8 +88,6 @@ public void requestWhenMethodIsSpecifiedAndAuthorizationManagerThenItIsNotGivenP
8988 this .mvc .perform (get ("/path" ).with (userCredentials ()))
9089 .andExpect (status ().isOk ());
9190 // @formatter:on
92- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
93- .isEmpty ();
9491 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
9592 }
9693
@@ -124,8 +121,6 @@ public void requestWhenUsingPatchAndAuthorizationManagerThenAuthorizesRequestsAc
124121 this .mvc .perform (patch ("/path" ).with (adminCredentials ()))
125122 .andExpect (status ().isOk ());
126123 // @formatter:on
127- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
128- .isEmpty ();
129124 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
130125 }
131126
@@ -149,8 +144,6 @@ public void requestWhenUsingHasAnyRoleAndAuthorizationManagerThenAuthorizesReque
149144 this .mvc .perform (get ("/path" ).with (adminCredentials ()))
150145 .andExpect (status ().isForbidden ());
151146 // @formatter:on
152- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
153- .isEmpty ();
154147 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
155148 }
156149
@@ -185,8 +178,6 @@ public void requestWhenUsingPathVariablesAndAuthorizationManagerThenAuthorizesRe
185178 this .mvc .perform (get ("/path" ).with (userCredentials ()))
186179 .andExpect (status ().isForbidden ());
187180 // @formatter:on
188- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
189- .isEmpty ();
190181 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
191182 }
192183
@@ -221,8 +212,6 @@ public void requestWhenUsingCamelCasePathVariablesAndAuthorizationManagerThenAut
221212 this .mvc .perform (get ("/PATH/user/path" ).with (userCredentials ()))
222213 .andExpect (status ().isForbidden ());
223214 // @formatter:on
224- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
225- .isEmpty ();
226215 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
227216 }
228217
@@ -253,8 +242,6 @@ public void requestWhenUsingPathVariablesAndTypeConversionAndAuthorizationManage
253242 this .mvc .perform (get ("/path/2/path" ).with (userCredentials ()))
254243 .andExpect (status ().isForbidden ());
255244 // @formatter:on
256- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
257- .isEmpty ();
258245 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
259246 }
260247
@@ -272,8 +259,6 @@ public void requestWhenUsingMvcMatchersAndAuthorizationManagerThenAuthorizesRequ
272259 this .mvc .perform (get ("/path" )).andExpect (status ().isUnauthorized ());
273260 this .mvc .perform (get ("/path.html" )).andExpect (status ().isUnauthorized ());
274261 this .mvc .perform (get ("/path/" )).andExpect (status ().isUnauthorized ());
275- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
276- .isEmpty ();
277262 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
278263 }
279264
@@ -302,8 +287,6 @@ public void requestWhenUsingMvcMatchersAndPathVariablesAndAuthorizationManagerTh
302287 this .mvc .perform (get ("/PATH/user/path" ).with (userCredentials ()))
303288 .andExpect (status ().isForbidden ());
304289 // @formatter:on
305- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
306- .isEmpty ();
307290 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
308291 }
309292
@@ -338,8 +321,6 @@ public void requestWhenUsingMvcMatchersAndServletPathAndAuthorizationManagerThen
338321 this .mvc .perform (get ("/spring/path/" ).servletPath ("/spring" ))
339322 .andExpect (status ().isUnauthorized ());
340323 // @formatter:on
341- assertThat (this .spring .getContext ().getBeanNamesForType (FilterInvocationSecurityMetadataSource .class ))
342- .isEmpty ();
343324 assertThat (this .spring .getContext ().getBean (AuthorizationManager .class )).isNotNull ();
344325 }
345326
0 commit comments