File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
web/src/test/java/org/springframework/security/web/server/csrf Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 21
21
import org .mockito .Mock ;
22
22
import org .mockito .junit .MockitoJUnitRunner ;
23
23
24
- import org .springframework .http .HttpMethod ;
25
24
import org .springframework .http .HttpStatus ;
26
25
import org .springframework .http .MediaType ;
26
+ import org .springframework .http .server .reactive .ServerHttpRequest ;
27
27
import org .springframework .mock .http .server .reactive .MockServerHttpRequest ;
28
28
import org .springframework .mock .web .server .MockServerWebExchange ;
29
29
import org .springframework .security .web .server .util .matcher .ServerWebExchangeMatcher ;
@@ -190,11 +190,12 @@ public void filterWhenPostAndEstablishedCsrfTokenAndHeaderValidTokenThenContinue
190
190
@ Test
191
191
// gh-8452
192
192
public void matchesRequireCsrfProtectionWhenNonStandardHTTPMethodIsUsed () {
193
- HttpMethod customHttpMethod = HttpMethod .resolve ("non-standard-http-method" );
194
- MockServerWebExchange nonStandardHttpRequest = from (MockServerHttpRequest .method (customHttpMethod , "/" ));
193
+ ServerHttpRequest nonStandardHttpRequest = mock (ServerHttpRequest .class );
194
+ ServerWebExchange nonStandardHttpExchange = mock (ServerWebExchange .class );
195
+ when (nonStandardHttpExchange .getRequest ()).thenReturn (nonStandardHttpRequest );
195
196
196
197
ServerWebExchangeMatcher serverWebExchangeMatcher = CsrfWebFilter .DEFAULT_CSRF_MATCHER ;
197
- assertThat (serverWebExchangeMatcher .matches (nonStandardHttpRequest ).map (MatchResult ::isMatch ).block ()).isTrue ();
198
+ assertThat (serverWebExchangeMatcher .matches (nonStandardHttpExchange ).map (MatchResult ::isMatch ).block ()).isTrue ();
198
199
}
199
200
200
201
@ Test
You can’t perform that action at this time.
0 commit comments