feat: use AWS-specific content type within the response of all JSON-based controllers (#240)

This commit is contained in:
Christian Franzen authored and GitHub committed 2026-04-06 11:05:24 -05:00
1 parent eeefb729c4
commit b4afdbb842
29 files changed
+478 -420

No files matched your search

@@ -2,13 +2,11 @@ package io.github.hectorvent.floci.core.common;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.notNullValue;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
/**
@@ -28,10 +26,7 @@ class AwsRequestIdFilterIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SSM_CONTENT_TYPE, ContentType.TEXT)
.encodeContentTypeAs(DYNAMODB_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
// --- REST XML protocol (S3) ---
@@ -99,7 +94,7 @@ class AwsRequestIdFilterIntegrationTest {
void dynamoDbSuccessResponseContainsRequestIdHeaders() {
given()
.header("X-Amz-Target", "DynamoDB_20120810.ListTables")
.contentType("application/x-amz-json-1.0")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("{}")
.when()
.post("/")
@@ -113,7 +108,7 @@ class AwsRequestIdFilterIntegrationTest {
void dynamoDbErrorResponseContainsRequestIdHeaders() {
given()
.header("X-Amz-Target", "DynamoDB_20120810.GetItem")
.contentType("application/x-amz-json-1.0")
.contentType(DYNAMODB_CONTENT_TYPE)
.body("{\"TableName\": \"NonExistentTable\", \"Key\": {\"id\": {\"S\": \"1\"}}}")
.when()
.post("/")
@@ -144,7 +139,7 @@ class AwsRequestIdFilterIntegrationTest {
void ssmSuccessResponseContainsRequestIdHeaders() {
given()
.header("X-Amz-Target", "AmazonSSM.DescribeParameters")
.contentType("application/x-amz-json-1.1")
.contentType(SSM_CONTENT_TYPE)
.body("{}")
.when()
.post("/")
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -29,10 +27,7 @@ class RegionIsolationIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SSM_CONTENT_TYPE, ContentType.TEXT)
.encodeContentTypeAs(DYNAMODB_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,6 +1,5 @@
package io.github.hectorvent.floci.lifecycle;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.acm;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -25,9 +23,7 @@ class AcmEdgeCaseTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(ACM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
// ==================== Wildcard Domain Tests ====================
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.acm;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -28,9 +26,7 @@ class AcmIdempotencyTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(ACM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,10 +1,8 @@
package io.github.hectorvent.floci.services.acm;
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import jakarta.inject.Inject;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
@@ -38,9 +36,7 @@ class AcmImportExportTest {
@BeforeAll
void setupTestCertificates() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(ACM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
// Generate a valid test certificate using CertificateGenerator
CertificateGenerator.GeneratedCertificate generated = certificateGenerator.generateCertificate(
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.acm;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -24,9 +22,7 @@ class AcmIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(ACM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
// ==================== User Story 1: RequestCertificate ====================
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.acm;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
@@ -18,7 +16,6 @@ import java.util.List;
import java.util.Set;
import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;
@@ -36,9 +33,7 @@ class AcmPaginationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(ACM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -2,9 +2,8 @@ package io.github.hectorvent.floci.services.apigateway;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.*;
@@ -37,9 +36,7 @@ class ApiGatewayAwsIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SFN_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
// ──────────────── Setup: DynamoDB table + SFN state machine ────────────────
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.cloudformation;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -19,7 +17,6 @@ import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.matchesRegex;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
@@ -35,11 +32,7 @@ class CloudFormationIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(DYNAMODB_CONTENT_TYPE, ContentType.TEXT)
.encodeContentTypeAs(SSM_CONTENT_TYPE, ContentType.TEXT)
.encodeContentTypeAs(SM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
private static byte[] buildHandlerZip() {
@@ -2,10 +2,8 @@ package io.github.hectorvent.floci.services.cognito;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
@@ -41,9 +39,7 @@ class CognitoIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(COGNITO_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -2,10 +2,8 @@ package io.github.hectorvent.floci.services.cognito;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
@@ -42,9 +40,7 @@ class CognitoOAuthTokenIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(COGNITO_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.dynamodb;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -21,9 +19,7 @@ class DynamoDbIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(DYNAMODB_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.ecs;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -44,9 +42,7 @@ class EcsIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
// ── Helpers ───────────────────────────────────────────────────────────────
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.eventbridge;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.*;
import static io.restassured.RestAssured.given;
@@ -21,11 +19,7 @@ class EventBridgeIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SQS_CONTENT_TYPE, ContentType.TEXT)
.encodeContentTypeAs(EVENT_BRIDGE_CONTENT_TYPE, ContentType.TEXT)
);
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.kinesis;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -21,9 +19,7 @@ class KinesisIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(KINESIS_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.sns;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -26,9 +24,7 @@ class SnsIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SNS_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
private static String topicArn;
@@ -1,13 +1,8 @@
package io.github.hectorvent.floci.services.sqs;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.*;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
@@ -18,6 +13,11 @@ class SqsIntegrationTest {
private static String queueUrl;
@BeforeAll
static void configureRestAssured() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@Order(1)
void createQueue() {
@@ -336,9 +336,6 @@ class SqsIntegrationTest {
@Test
void jsonProtocol_nonExistentQueue_returnsQueueDoesNotExist() {
given()
.config(RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs("application/x-amz-json-1.0", ContentType.TEXT)))
.contentType("application/x-amz-json-1.0")
.header("X-Amz-Target", "AmazonSQS.GetQueueUrl")
.body("{\"QueueName\": \"no-such-queue-xyz\"}")
@@ -346,6 +343,7 @@ class SqsIntegrationTest {
.post("/")
.then()
.statusCode(400)
.header("x-amzn-query-error", "AWS.SimpleQueueService.NonExistentQueue;Sender")
.body(containsString("QueueDoesNotExist"))
.body(not(containsString("AWS.SimpleQueueService.NonExistentQueue")));
}
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.sqs;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -34,10 +32,7 @@ class SqsJsonProtocolTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(CONTENT_TYPE, ContentType.TEXT)
);
RestAssuredJsonUtils.configureAwsContentTypes();
}
// --- Root-path JSON 1.0 (POST /) ---
@@ -1,9 +1,7 @@
package io.github.hectorvent.floci.services.ssm;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
@@ -21,9 +19,7 @@ class SsmIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SSM_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -2,10 +2,8 @@ package io.github.hectorvent.floci.services.stepfunctions;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.*;
@@ -29,9 +27,7 @@ class StepFunctionsDynamoDbIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SFN_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -1,15 +1,12 @@
package io.github.hectorvent.floci.services.stepfunctions;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;
@QuarkusTest
@@ -20,9 +17,7 @@ class StepFunctionsJsonataIntegrationTest {
@BeforeAll
static void configureRestAssured() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(SFN_CONTENT_TYPE, ContentType.TEXT));
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
@@ -0,0 +1,70 @@
package io.github.hectorvent.floci.testing;
import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.filter.Filter;
import io.restassured.filter.FilterContext;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.specification.FilterableRequestSpecification;
import io.restassured.specification.FilterableResponseSpecification;
/**
* Registers a global RestAssured filter that rewrites AWS-specific JSON content types
* to standard application/json before response parsing.
* <p>
* Changes EncoderConfig to allow AWS-specific content types to be treated as JSON for request encoding.
* <p>
* Note: RestAssured.registerParser() and RestAssured.defaultParser do not work reliably
* under Quarkus @QuarkusTest because the ResponseParserRegistrar state does not propagate
* correctly to RestAssured's internal Groovy-based response parsing. The filter approach
* modifies the response content type directly, bypassing this issue.
*/
public class RestAssuredJsonUtils {
private static final String AWS_CONTENT_TYPE_1_0 = "application/x-amz-json-1.0";
private static final String AWS_CONTENT_TYPE_1_1 = "application/x-amz-json-1.1";
private static final AwsContentTypeFilter AWS_CONTENT_TYPE_FILTER = new AwsContentTypeFilter();
private RestAssuredJsonUtils() {
// Utility class, prevent instantiation
}
public static void configureAwsContentTypes() {
RestAssured.config = RestAssured.config().encoderConfig(
EncoderConfig.encoderConfig()
.encodeContentTypeAs(AWS_CONTENT_TYPE_1_0, ContentType.JSON)
.encodeContentTypeAs(AWS_CONTENT_TYPE_1_1, ContentType.JSON));
if (!RestAssured.filters().contains(AWS_CONTENT_TYPE_FILTER)) {
RestAssured.filters(AWS_CONTENT_TYPE_FILTER);
}
}
}
/**
* RestAssured filter that rewrites AWS-specific JSON content types
* (e.g. application/x-amz-json-1.0) to standard application/json.
* <p>
* This is necessary because RestAssured.registerParser() does not work
* reliably under Quarkus @QuarkusTest due to classloader isolation between
* the test class and RestAssured's internal Groovy-based response parsing.
*/
class AwsContentTypeFilter implements Filter {
@Override
public Response filter(FilterableRequestSpecification requestSpec,
FilterableResponseSpecification responseSpec,
FilterContext ctx) {
Response response = ctx.next(requestSpec, responseSpec);
String contentType = response.contentType();
if (contentType != null && contentType.contains("x-amz-json")) {
return new io.restassured.builder.ResponseBuilder()
.clone(response)
.setContentType(contentType.replaceFirst("application/x-amz-json-[0-9.]+", "application/json"))
.build();
}
return response;
}
}