Fixes test to check rawquery values.

Since https://github.com/joel-costigliola/assertj-core/issues/1699 assertj uses the raw query instead of the encoded one.

fixes gh-1551
This commit is contained in:
Spencer Gibb
2020-02-03 17:46:33 -05:00
parent 16a1ce5ad8
commit 02b7411597
2 changed files with 8 additions and 3 deletions

View File

@@ -214,13 +214,16 @@ public final class ServerWebExchangeUtils {
boolean encoded = (uri.getRawQuery() != null && uri.getRawQuery().contains("%"))
|| (uri.getRawPath() != null && uri.getRawPath().contains("%"));
// Verify if it is really fully encoded. Treat partial encoded as uncoded.
// Verify if it is really fully encoded. Treat partial encoded as unencoded.
if (encoded) {
try {
UriComponentsBuilder.fromUri(uri).build(true);
return true;
}
catch (IllegalArgumentException ignore) {
if (log.isTraceEnabled()) {
log.trace("Error in containsEncodedParts", ignore);
}
}
return false;

View File

@@ -132,10 +132,12 @@ public class RouteToRequestUrlFilterTests {
ServerWebExchange webExchange = testFilter(request, "http://myhost");
URI uri = webExchange.getRequiredAttribute(GATEWAY_REQUEST_URL_ATTR);
assertThat(uri).hasScheme("http").hasHost("myhost")
.hasParameter("key[]", "test= key").hasParameter("start", "1533108081");
// since https://github.com/joel-costigliola/assertj-core/issues/1699
// assertj uses raw query
.hasParameter("key[]", "test=%20key").hasParameter("start", "1533108081");
// prove that it is double encoded since partial encoded uri is treated as
// uncoded.
// unencoded.
assertThat(uri.getRawQuery()).isEqualTo("key[]=test=%2520key&start=1533108081");
}