Skip to content

Commit

Permalink
Merge pull request #657 from fedinskiy/fix/error_mapping
Browse files Browse the repository at this point in the history
Add check of passing HTTP status error through
  • Loading branch information
Pablo Gonzalez Granados authored May 24, 2022
2 parents 482077d + 726e3e1 commit 9d1ef81
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
Expand All @@ -22,7 +23,7 @@ public interface ProxyClient {
@GET
@Path("/example.txt")
@Produces(MediaType.TEXT_PLAIN)
Uni<String> getText();
Uni<Response> getText();

@GET
@Path("/auth")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.eclipse.microprofile.rest.client.inject.RestClient;

Expand All @@ -27,7 +28,7 @@ public Uni<String> getRoot() {
@GET
@Path("/banned")
@Produces(MediaType.TEXT_PLAIN)
public Uni<String> getBanned() {
public Uni<Response> getBanned() {
return client.getText();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".p
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".proxy-user=proxyuser
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.proxy.ProxyClient".proxy-password=proxypassword
quarkus.rest-client.logging.scope=request-response
quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG
quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=INFO
microprofile.rest.client.disable.default.mapper=true
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void getThrough() {
@Test
void banned() {
Response banned = proxyApp.given().with().get("/proxied/banned");
Assertions.assertEquals(HttpStatus.SC_OK, banned.statusCode());
Assertions.assertEquals(HttpStatus.SC_FORBIDDEN, banned.statusCode());
Assertions.assertEquals("Reading is prohibited by corporate policy!",
banned.body().asString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM nginx:1.21
EXPOSE 8090
COPY nginx.conf /etc/nginx/nginx.conf
3 changes: 3 additions & 0 deletions http/rest-client-reactive/src/test/resources/proxy/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
VERSION=1.0.1
docker build -t nginx-proxy .
docker tag nginx-proxy quay.io/quarkusqeteam/proxy:latest
docker tag nginx-proxy quay.io/quarkusqeteam/proxy:$VERSION
docker push quay.io/quarkusqeteam/proxy:latest
docker push quay.io/quarkusqeteam/proxy:$VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ http {
proxy_pass http://$host;
}
location ~ \.(txt)$ {
return 203 "Reading is prohibited by corporate policy!";
return 403 "Reading is prohibited by corporate policy!";
}
location /auth {
return 200 $http_proxy_authorization;
Expand Down

0 comments on commit 9d1ef81

Please sign in to comment.