Skip to content

Commit

Permalink
Use String to specify custom HTTP method in test
Browse files Browse the repository at this point in the history
Closes gh-8592
  • Loading branch information
eleftherias committed Jul 21, 2020
1 parent fb936e2 commit e902be7
Showing 1 changed file with 1 addition and 4 deletions.
Expand Up @@ -23,7 +23,6 @@

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.web.server.MockServerWebExchange;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
Expand Down Expand Up @@ -190,9 +189,7 @@ public void filterWhenPostAndEstablishedCsrfTokenAndHeaderValidTokenThenContinue
@Test
// gh-8452
public void matchesRequireCsrfProtectionWhenNonStandardHTTPMethodIsUsed() {
ServerHttpRequest nonStandardHttpRequest = mock(ServerHttpRequest.class);
ServerWebExchange nonStandardHttpExchange = mock(ServerWebExchange.class);
when(nonStandardHttpExchange.getRequest()).thenReturn(nonStandardHttpRequest);
MockServerWebExchange nonStandardHttpExchange = from(MockServerHttpRequest.method("non-standard-http-method", "/"));

ServerWebExchangeMatcher serverWebExchangeMatcher = CsrfWebFilter.DEFAULT_CSRF_MATCHER;
assertThat(serverWebExchangeMatcher.matches(nonStandardHttpExchange).map(MatchResult::isMatch).block()).isTrue();
Expand Down

0 comments on commit e902be7

Please sign in to comment.