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:
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user