|
23 | 23 | import org.springframework.test.web.servlet.MockMvc;
|
24 | 24 | import org.springframework.test.web.servlet.RequestBuilder;
|
25 | 25 | import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
| 26 | +import org.springframework.web.util.UriComponentsBuilder; |
26 | 27 |
|
27 | 28 | import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
|
28 | 29 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
@@ -71,6 +72,8 @@ public static LogoutRequestBuilder logout() {
|
71 | 72 | * Creates a logout request (including any necessary {@link CsrfToken}) to the
|
72 | 73 | * specified {@code logoutUrl}
|
73 | 74 | *
|
| 75 | + * @param logoutUrl the logout request URL |
| 76 | + * |
74 | 77 | * @return the LogoutRequestBuilder for additional customizations
|
75 | 78 | */
|
76 | 79 | public static LogoutRequestBuilder logout(String logoutUrl) {
|
@@ -106,6 +109,19 @@ public LogoutRequestBuilder logoutUrl(String logoutUrl) {
|
106 | 109 | return this;
|
107 | 110 | }
|
108 | 111 |
|
| 112 | + /** |
| 113 | + * Specifies the logout URL to POST to. |
| 114 | + * |
| 115 | + * @param logoutUrl the logout URL to POST to. |
| 116 | + * @param uriVars the URI variables |
| 117 | + * @return the {@link LogoutRequestBuilder} for additional customizations |
| 118 | + */ |
| 119 | + public LogoutRequestBuilder logoutUrl(String logoutUrl, Object... uriVars) { |
| 120 | + this.logoutUrl = UriComponentsBuilder.fromPath(logoutUrl) |
| 121 | + .buildAndExpand(uriVars).encode().toString(); |
| 122 | + return this; |
| 123 | + } |
| 124 | + |
109 | 125 | private LogoutRequestBuilder() {
|
110 | 126 | }
|
111 | 127 | }
|
@@ -146,6 +162,19 @@ public FormLoginRequestBuilder loginProcessingUrl(String loginProcessingUrl) {
|
146 | 162 | return this;
|
147 | 163 | }
|
148 | 164 |
|
| 165 | + /** |
| 166 | + * Specifies the URL to POST to. |
| 167 | + * |
| 168 | + * @param loginProcessingUrl the URL to POST to |
| 169 | + * @param uriVars the URI variables |
| 170 | + * @return the {@link FormLoginRequestBuilder} for additional customizations |
| 171 | + */ |
| 172 | + public FormLoginRequestBuilder loginProcessingUrl(String loginProcessingUrl, Object... uriVars) { |
| 173 | + this.loginProcessingUrl = UriComponentsBuilder.fromPath(loginProcessingUrl) |
| 174 | + .buildAndExpand(uriVars).encode().toString(); |
| 175 | + return this; |
| 176 | + } |
| 177 | + |
149 | 178 | /**
|
150 | 179 | * The HTTP parameter to place the username. Default is "username".
|
151 | 180 | * @param usernameParameter the HTTP parameter to place the username. Default is
|
|
0 commit comments