Skip to content

Commit

Permalink
fix: use raw path and avoid double encoding, adapt tests accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
aureamunoz committed Jan 8, 2024
1 parent 3280cc3 commit 4c52fbb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void shouldSayHelloNameWithSlash() {
.then()
.statusCode(200)
// The response contains an encoded `/`
.body(equalTo("Hello, stork%2Fstork"));
.body(equalTo("Hello, stork/stork"));

}

Expand All @@ -86,6 +86,6 @@ void shouldSayHelloNameWithBlank() {
.then()
.statusCode(200)
// The response contains an encoded blank espace
.body(equalTo("Hello, smallrye%20stork"));
.body(equalTo("Hello, smallrye stork"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void shouldDetermineUrlViaStork() {
greeting = RestClientBuilder.newBuilder().baseUri(URI.create("stork://hello-service/hello"))
.build(HelloClient.class)
.helloWithPathParam("black and white bird");
assertThat(greeting).isEqualTo("Hello, black%20and%20white%20bird");
assertThat(greeting).isEqualTo("Hello, black and white bird");
}

@Test
Expand All @@ -56,7 +56,7 @@ void shouldDetermineUrlViaStorkWhenUsingTarget() throws URISyntaxException {

greeting = ClientBuilder.newClient().target("stork://hello-service/hello").path("big bird").request()
.get(String.class);
assertThat(greeting).isEqualTo("Hello, big%20bird");
assertThat(greeting).isEqualTo("Hello, big bird");
}

@Test
Expand All @@ -65,7 +65,7 @@ void shouldDetermineUrlViaStorkCDI() {
assertThat(greeting).isEqualTo("hello, big bird");

greeting = client.helloWithPathParam("big bird");
assertThat(greeting).isEqualTo("Hello, big%20bird");
assertThat(greeting).isEqualTo("Hello, big bird");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void shouldDetermineUrlViaStork() {
greeting = RestClientBuilder.newBuilder().baseUri(URI.create("stork://hello-service"))
.build(HelloClient.class)
.helloWithPathParam("black and white bird");
assertThat(greeting).isEqualTo("Hello, black%20and%20white%20bird");
assertThat(greeting).isEqualTo("Hello, black and white bird");
}

@Test
Expand All @@ -55,7 +55,7 @@ void shouldDetermineUrlViaStorkWhenUsingTarget() throws URISyntaxException {

greeting = ClientBuilder.newClient().target("stork://hello-service/").path("big bird").request()
.get(String.class);
assertThat(greeting).isEqualTo("Hello, big%20bird");
assertThat(greeting).isEqualTo("Hello, big bird");
}

@Test
Expand All @@ -64,7 +64,7 @@ void shouldDetermineUrlViaStorkCDI() {
assertThat(greeting).isEqualTo("hello, big bird");

greeting = client.helloWithPathParam("big bird");
assertThat(greeting).isEqualTo("Hello, big%20bird");
assertThat(greeting).isEqualTo("Hello, big bird");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.annotation.Priority;
import jakarta.ws.rs.Priorities;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.UriBuilder;
import jakarta.ws.rs.ext.Provider;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -79,11 +80,12 @@ public void filter(ResteasyReactiveClientRequestContext requestContext) {
}
}
}

//To avoid the path double encoding we create uri with path=null and set the path after
URI newUri = new URI(scheme,
uri.getUserInfo(), host, port,
actualPath, uri.getQuery(), uri.getFragment());
requestContext.setUri(newUri);
null, uri.getQuery(), uri.getFragment());
URI build = UriBuilder.fromUri(newUri).path(actualPath).build();
requestContext.setUri(build);
if (measureTime && instance.gatherStatistics()) {
requestContext.setCallStatsCollector(instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ void shouldUseQuarkusVertxInstance() {
}

@Test
// @Disabled
void shouldUseFasterService() {
Set<String> responses = new HashSet<>();

Expand Down

0 comments on commit 4c52fbb

Please sign in to comment.