Skip to content

Commit

Permalink
feat: removed content length (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordenReuter authored May 6, 2024
1 parent 5da7d8b commit df3fc02
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,49 @@ h| Version

| https://quarkus.io/guides/rest[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-smallrye-openapi
| https://quarkus.io/guides/openapi-swaggerui[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-openapi.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-rest-jackson
| https://quarkus.io/guides/rest-json[Link]
|
| 3.9.3
| 3.9.4
| quarkus-smallrye-health
| https://quarkus.io/guides/smallrye-health[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-health.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-opentelemetry
| https://quarkus.io/guides/opentelemetry[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-micrometer-registry-prometheus
| https://quarkus.io/guides/telemetry-micrometer[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-openapi-generator
| https://docs.quarkiverse.io/quarkus-openapi-generator/dev/index.html[Link]
| https://github.com/quarkiverse/quarkus-openapi-generator/blob/2.4.1/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc[Link]
| 2.4.1
| https://github.com/quarkiverse/quarkus-openapi-generator/blob/2.4.2/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc[Link]
| 2.4.2
| quarkus-rest-client-reactive-jackson
| https://quarkus.io/guides/rest-client[Link]
|
| 3.9.3
| 3.9.4
| tkit-quarkus-log-cdi
Expand Down Expand Up @@ -96,25 +96,25 @@ h| Version
| https://quarkus.io/guides/validation[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-hibernate-validator.adoc[Link]
| 3.9.3
| 3.9.4
| onecx-permissions
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-permissions.html[Link]
| https://github.com/onecx/onecx-quarkus/blob/0.17.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link]
| 0.17.0
| https://github.com/onecx/onecx-quarkus/blob/0.18.0/docs/modules/onecx-quarkus/pages/includes/onecx-permissions.adoc[Link]
| 0.18.0
| quarkus-oidc
| https://quarkus.io/guides/security-oidc-bearer-token-authentication-tutorial[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-oidc.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-oidc-client-reactive-filter
| https://quarkus.io/guides/security-openid-connect-client-reference[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-oidc-client-reactive-filter.adoc[Link]
| 3.9.3
| 3.9.4
| tkit-quarkus-security
Expand All @@ -126,19 +126,19 @@ h| Version
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link]
|
| 0.17.0
| 0.18.0
| quarkus-arc
| https://quarkus.io/guides/cdi-reference[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link]
| 3.9.3
| 3.9.4
| quarkus-container-image-docker
| https://quarkus.io/guides/container-image[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link]
| 3.9.3
| 3.9.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.validation.ConstraintViolationException;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.Response;

import org.eclipse.microprofile.rest.client.inject.RestClient;
Expand Down Expand Up @@ -37,9 +38,12 @@ public class ImagesRestController implements ImagesInternalApiService {
@Inject
ExceptionMapper exceptionMapper;

@Inject
HttpHeaders headers;

@Override
public Response createImage(Integer contentLength, byte[] body) {
try (Response response = welcomeClient.createImage(contentLength, body)) {
public Response createImage(byte[] body) {
try (Response response = welcomeClient.createImage(headers.getLength(), body)) {
ImageDataResponseDTO responseDTO = mapper.map(response.readEntity(ImageDataResponse.class));
return Response.status(response.getStatus()).entity(responseDTO).build();
}
Expand Down Expand Up @@ -85,8 +89,8 @@ public Response getImageInfoById(String id) {
}

@Override
public Response updateImageById(String id, Integer contentLength, byte[] body) {
try (Response response = welcomeClient.updateImageById(id, contentLength, body)) {
public Response updateImageById(String id, byte[] body) {
try (Response response = welcomeClient.updateImageById(id, headers.getLength(), body)) {
ImageDataResponseDTO responseDTO = mapper.map(response.readEntity(ImageDataResponse.class));
return Response.status(response.getStatus()).entity(responseDTO).build();
}
Expand Down
15 changes: 0 additions & 15 deletions src/main/openapi/openapi-bff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,6 @@ paths:
- imagesInternal
description: create Image
operationId: createImage
parameters:
- in: header
name: Content-Length
required: true
schema:
minimum: 1
maximum: 1100000
type: integer
requestBody:
content:
image/*:
Expand Down Expand Up @@ -222,13 +214,6 @@ paths:
operationId: updateImageById
parameters:
- $ref: '#/components/parameters/id'
- in: header
name: Content-Length
required: true
schema:
minimum: 1
maximum: 1100000
type: integer
requestBody:
content:
image/*:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import gen.org.tkit.onecx.welcome.bff.rs.internal.model.ProblemDetailResponseDTO;
import gen.org.tkit.onecx.welcome.client.model.ImageDataResponse;
import gen.org.tkit.onecx.welcome.client.model.ImageInfo;
import gen.org.tkit.onecx.welcome.client.model.ProblemDetailResponse;
import io.quarkiverse.mockserver.test.InjectMockServerClient;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
Expand Down Expand Up @@ -376,16 +377,25 @@ void getAllImageInfosTest() {
}

@Test
void testMaxUploadSize() {
void testMaxUploadSize() throws IOException {

byte[] body = new byte[1100001];
new Random().nextBytes(body);
ProblemDetailResponse error = new ProblemDetailResponse();
error.setDetail("createImage.contentLength: must be less than or equal to 1100000");

// create mock rest endpoint
mockServerClient.when(request().withPath("/internal/images").withMethod(HttpMethod.POST)
.withContentType(MediaType.ANY_IMAGE_TYPE)
.withBody(FileUtils.readFileToByteArray(FILE)))
.withId(mockId)
.respond(httpRequest -> response().withStatusCode(BAD_REQUEST.getStatusCode())
.withContentType(MediaType.APPLICATION_JSON)
.withBody(JsonBody.json(error)));

var exception = given()
.when()
.auth().oauth2(keycloakClient.getAccessToken(ADMIN))
.header(APM_HEADER_PARAM, ADMIN)
.body(body)
.body(FILE)
.contentType(MEDIA_TYPE_IMAGE_PNG)
.post()
.then()
Expand Down

0 comments on commit df3fc02

Please sign in to comment.