48
48
import org .springframework .web .bind .annotation .RestController ;
49
49
import org .springframework .web .context .support .AnnotationConfigWebApplicationContext ;
50
50
import org .springframework .web .servlet .config .annotation .EnableWebMvc ;
51
- import org .springframework .web .servlet .config .annotation .PathMatchConfigurer ;
52
- import org .springframework .web .servlet .config .annotation .WebMvcConfigurer ;
53
51
import org .springframework .web .servlet .handler .HandlerMappingIntrospector ;
54
52
55
53
import static org .assertj .core .api .Assertions .assertThat ;
@@ -160,67 +158,6 @@ public void roleHiearchy() throws Exception {
160
158
assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_OK );
161
159
}
162
160
163
- @ Test
164
- public void mvcMatcher () throws Exception {
165
- loadConfig (MvcMatcherConfig .class , LegacyMvcMatchingConfig .class );
166
- this .request .setRequestURI ("/path" );
167
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
168
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
169
- setup ();
170
- this .request .setRequestURI ("/path.html" );
171
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
172
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
173
- setup ();
174
- this .request .setServletPath ("/path/" );
175
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
176
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
177
- }
178
-
179
- @ Test
180
- public void requestWhenMvcMatcherDenyAllThenRespondsWithUnauthorized () throws Exception {
181
- loadConfig (MvcMatcherInLambdaConfig .class , LegacyMvcMatchingConfig .class );
182
- this .request .setRequestURI ("/path" );
183
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
184
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
185
- setup ();
186
- this .request .setRequestURI ("/path.html" );
187
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
188
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
189
- setup ();
190
- this .request .setServletPath ("/path/" );
191
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
192
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
193
- }
194
-
195
- @ Test
196
- public void requestWhenMvcMatcherServletPathDenyAllThenMatchesOnServletPath () throws Exception {
197
- loadConfig (MvcMatcherServletPathInLambdaConfig .class , LegacyMvcMatchingConfig .class );
198
- this .request .setServletPath ("/spring" );
199
- this .request .setRequestURI ("/spring/path" );
200
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
201
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
202
- setup ();
203
- this .request .setServletPath ("/spring" );
204
- this .request .setRequestURI ("/spring/path.html" );
205
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
206
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
207
- setup ();
208
- this .request .setServletPath ("/spring" );
209
- this .request .setRequestURI ("/spring/path/" );
210
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
211
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
212
- setup ();
213
- this .request .setServletPath ("/foo" );
214
- this .request .setRequestURI ("/foo/path" );
215
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
216
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_OK );
217
- setup ();
218
- this .request .setServletPath ("/" );
219
- this .request .setRequestURI ("/path" );
220
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
221
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_OK );
222
- }
223
-
224
161
@ Test
225
162
public void mvcMatcherPathVariables () throws Exception {
226
163
loadConfig (MvcMatcherPathVariablesConfig .class );
@@ -245,35 +182,6 @@ public void requestWhenMvcMatcherPathVariablesThenMatchesOnPathVariables() throw
245
182
assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
246
183
}
247
184
248
- @ Test
249
- public void mvcMatcherServletPath () throws Exception {
250
- loadConfig (MvcMatcherServletPathConfig .class , LegacyMvcMatchingConfig .class );
251
- this .request .setServletPath ("/spring" );
252
- this .request .setRequestURI ("/spring/path" );
253
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
254
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
255
- setup ();
256
- this .request .setServletPath ("/spring" );
257
- this .request .setRequestURI ("/spring/path.html" );
258
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
259
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
260
- setup ();
261
- this .request .setServletPath ("/spring" );
262
- this .request .setRequestURI ("/spring/path/" );
263
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
264
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_UNAUTHORIZED );
265
- setup ();
266
- this .request .setServletPath ("/foo" );
267
- this .request .setRequestURI ("/foo/path" );
268
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
269
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_OK );
270
- setup ();
271
- this .request .setServletPath ("/" );
272
- this .request .setRequestURI ("/path" );
273
- this .springSecurityFilterChain .doFilter (this .request , this .response , this .chain );
274
- assertThat (this .response .getStatus ()).isEqualTo (HttpServletResponse .SC_OK );
275
- }
276
-
277
185
public void loadConfig (Class <?>... configs ) {
278
186
this .context = new AnnotationConfigWebApplicationContext ();
279
187
this .context .register (configs );
@@ -639,15 +547,4 @@ String path() {
639
547
640
548
}
641
549
642
- @ Configuration
643
- static class LegacyMvcMatchingConfig implements WebMvcConfigurer {
644
-
645
- @ Override
646
- public void configurePathMatch (PathMatchConfigurer configurer ) {
647
- configurer .setUseSuffixPatternMatch (true );
648
- configurer .setUseTrailingSlashMatch (true );
649
- }
650
-
651
- }
652
-
653
550
}
0 commit comments