File tree 2 files changed +4
-3
lines changed
main/java/org/springframework/security/web/server/csrf
test/java/org/springframework/security/web/server/csrf
2 files changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ public static void skipExchange(ServerWebExchange exchange) {
133
133
134
134
private Mono <Void > validateToken (ServerWebExchange exchange ) {
135
135
return this .csrfTokenRepository .loadToken (exchange )
136
- .switchIfEmpty (Mono .defer (() -> Mono .error (new CsrfException ("CSRF Token has been associated to this client " ))))
136
+ .switchIfEmpty (Mono .defer (() -> Mono .error (new CsrfException ("An expected CSRF token cannot be found " ))))
137
137
.filterWhen (expected -> containsValidCsrfToken (exchange , expected ))
138
138
.switchIfEmpty (Mono .defer (() -> Mono .error (new CsrfException ("Invalid CSRF Token" ))))
139
139
.then ();
Original file line number Diff line number Diff line change @@ -65,8 +65,7 @@ public class CsrfWebFilterTests {
65
65
private MockServerWebExchange get = from (
66
66
MockServerHttpRequest .get ("/" ));
67
67
68
- private ServerWebExchange post = from (
69
- MockServerHttpRequest .post ("/" ));
68
+ private MockServerWebExchange post = MockServerWebExchange .from (MockServerHttpRequest .post ("/" ));
70
69
71
70
@ Test
72
71
public void filterWhenGetThenSessionNotCreatedAndChainContinues () {
@@ -110,6 +109,8 @@ public void filterWhenPostAndEstablishedCsrfTokenAndRequestMissingTokenThenCsrfE
110
109
.verifyComplete ();
111
110
112
111
assertThat (this .post .getResponse ().getStatusCode ()).isEqualTo (HttpStatus .FORBIDDEN );
112
+ StepVerifier .create (this .post .getResponse ().getBodyAsString ())
113
+ .assertNext (b -> assertThat (b ).contains ("An expected CSRF token cannot be found" ));
113
114
}
114
115
115
116
@ Test
You can’t perform that action at this time.
0 commit comments