mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-24 04:52:16 +00:00
Use String to specify custom HTTP method in test
Closes gh-8592
This commit is contained in:
parent
fb936e2780
commit
e902be7ab9
@ -23,7 +23,6 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
|
||||||
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
|
||||||
import org.springframework.mock.web.server.MockServerWebExchange;
|
import org.springframework.mock.web.server.MockServerWebExchange;
|
||||||
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
|
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
|
||||||
@ -190,9 +189,7 @@ public class CsrfWebFilterTests {
|
|||||||
@Test
|
@Test
|
||||||
// gh-8452
|
// gh-8452
|
||||||
public void matchesRequireCsrfProtectionWhenNonStandardHTTPMethodIsUsed() {
|
public void matchesRequireCsrfProtectionWhenNonStandardHTTPMethodIsUsed() {
|
||||||
ServerHttpRequest nonStandardHttpRequest = mock(ServerHttpRequest.class);
|
MockServerWebExchange nonStandardHttpExchange = from(MockServerHttpRequest.method("non-standard-http-method", "/"));
|
||||||
ServerWebExchange nonStandardHttpExchange = mock(ServerWebExchange.class);
|
|
||||||
when(nonStandardHttpExchange.getRequest()).thenReturn(nonStandardHttpRequest);
|
|
||||||
|
|
||||||
ServerWebExchangeMatcher serverWebExchangeMatcher = CsrfWebFilter.DEFAULT_CSRF_MATCHER;
|
ServerWebExchangeMatcher serverWebExchangeMatcher = CsrfWebFilter.DEFAULT_CSRF_MATCHER;
|
||||||
assertThat(serverWebExchangeMatcher.matches(nonStandardHttpExchange).map(MatchResult::isMatch).block()).isTrue();
|
assertThat(serverWebExchangeMatcher.matches(nonStandardHttpExchange).map(MatchResult::isMatch).block()).isTrue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user