Skip to content

Commit e902be7

Browse files
committed
Use String to specify custom HTTP method in test
Closes gh-8592
1 parent fb936e2 commit e902be7

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

web/src/test/java/org/springframework/security/web/server/csrf/CsrfWebFilterTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.springframework.http.HttpStatus;
2525
import org.springframework.http.MediaType;
26-
import org.springframework.http.server.reactive.ServerHttpRequest;
2726
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
2827
import org.springframework.mock.web.server.MockServerWebExchange;
2928
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher;
@@ -190,9 +189,7 @@ public void filterWhenPostAndEstablishedCsrfTokenAndHeaderValidTokenThenContinue
190189
@Test
191190
// gh-8452
192191
public void matchesRequireCsrfProtectionWhenNonStandardHTTPMethodIsUsed() {
193-
ServerHttpRequest nonStandardHttpRequest = mock(ServerHttpRequest.class);
194-
ServerWebExchange nonStandardHttpExchange = mock(ServerWebExchange.class);
195-
when(nonStandardHttpExchange.getRequest()).thenReturn(nonStandardHttpRequest);
192+
MockServerWebExchange nonStandardHttpExchange = from(MockServerHttpRequest.method("non-standard-http-method", "/"));
196193

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

0 commit comments

Comments
 (0)