-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take into account quarkus.resteasy.gzip.max-input in REST Client
Fix #12941
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...yment/src/test/java/io/quarkus/restclient/compression/ClientUsingGzipCompressionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.quarkus.restclient.compression; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.WebApplicationException; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
import org.eclipse.microprofile.rest.client.inject.RestClient; | ||
import org.jboss.resteasy.annotations.GZIP; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ClientUsingGzipCompressionTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(MyResource.class, MyClient.class)) | ||
.withConfigurationResource("client-using-gzip-application.properties"); | ||
|
||
@RestClient | ||
MyClient client; | ||
|
||
/** | ||
* Test that covers the property `quarkus.resteasy.gzip.max-input`. | ||
* Larger payloads than 10 bytes should return HTTP Request Too Large. | ||
*/ | ||
@Test | ||
public void testGzipMaxInput() { | ||
WebApplicationException ex = Assertions.assertThrows(WebApplicationException.class, () -> client.gzip(new byte[11])); | ||
assertEquals(HttpStatus.SC_REQUEST_TOO_LONG, ex.getResponse().getStatus()); | ||
|
||
// verify shorter message works fine | ||
Assertions.assertEquals("Worked!", client.gzip(new byte[10])); | ||
} | ||
|
||
@Path("/client") | ||
@RegisterRestClient(configKey = "my-client") | ||
public interface MyClient { | ||
|
||
@POST | ||
@Path("/gzip") | ||
String gzip(@GZIP byte[] message); | ||
|
||
} | ||
|
||
@Path("/client") | ||
public class MyResource { | ||
|
||
@POST | ||
@Path("/gzip") | ||
public String gzip(@GZIP String message) { | ||
return "Worked!"; | ||
} | ||
|
||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...lassic/rest-client/deployment/src/test/resources/client-using-gzip-application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
quarkus.resteasy.gzip.enabled=true | ||
quarkus.resteasy.gzip.max-input=10 | ||
|
||
quarkus.rest-client.my-client.url=http://localhost:${quarkus.http.test-port:8081} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters