Skip to content

Commit 1b81f6f

Browse files
committed
Fix security test with changes in SPR-16836
This commit replaces the use of a GET method by a DELETE method for testing that the HiddenHttpMethodFilter is ordered before the security filter. With SPR-16836 changes, only PUT DELETE and PATCH are now allowed.
1 parent 9d9acc9 commit 1b81f6f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfigurationTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -180,9 +180,9 @@ public void testHiddenHttpMethodFilterOrderedFirst() throws Exception {
180180
.postForEntity("http://localhost:" + port + "/", form, Object.class);
181181
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
182182

183-
// override method with GET
183+
// override method with DELETE
184184
form = new LinkedMultiValueMap<String, String>();
185-
form.add("_method", "GET");
185+
form.add("_method", "DELETE");
186186

187187
result = rest.postForEntity("http://localhost:" + port + "/", form, Object.class);
188188
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
@@ -337,7 +337,8 @@ protected static class DenyPostRequestConfig extends WebSecurityConfigurerAdapte
337337

338338
@Override
339339
protected void configure(HttpSecurity http) throws Exception {
340-
http.authorizeRequests().antMatchers(HttpMethod.POST, "/**").denyAll();
340+
http.authorizeRequests().mvcMatchers(HttpMethod.POST, "/**").denyAll().and()
341+
.csrf().disable();
341342
}
342343

343344
}

0 commit comments

Comments
 (0)