refactor(core): move library usages to imports (#3873)

This commit is contained in:
Vũ Thế Huy authored and GitHub committed 2026-09-18 23:53:35 -05:00
1 parent bbaf3568c5
commit 11d04276a3
11 files changed
+90 -56

No files matched your search

@@ -43,6 +43,7 @@ import io.quarkus.vertx.http.HttpServerStart;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.event.ObservesAsync;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.jboss.logging.Logger;
@@ -99,7 +100,7 @@ public class EmulatorLifecycle {
private final InitLifecycleState initLifecycleState;
private final SchemaCreationWorker schemaCreationWorker;
private final StepFunctionsService stepFunctionsService;
private final jakarta.enterprise.inject.Instance<ContainerTeardown> containerTeardowns;
private final Instance<ContainerTeardown> containerTeardowns;
private final PersistentPathValidator persistentPathValidator;
@Inject
@@ -134,7 +135,7 @@ public class EmulatorLifecycle {
InitLifecycleState initLifecycleState,
SchemaCreationWorker schemaCreationWorker,
StepFunctionsService stepFunctionsService,
jakarta.enterprise.inject.Instance<ContainerTeardown> containerTeardowns,
Instance<ContainerTeardown> containerTeardowns,
PersistentPathValidator persistentPathValidator) {
this.storageFactory = storageFactory;
this.serviceRegistry = serviceRegistry;
@@ -2,20 +2,29 @@ package io.github.hectorvent.floci.config;
import io.github.hectorvent.floci.services.acm.CertificateGenerator;
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.openssl.jcajce.JcaPEMWriter;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Set;
import javax.security.auth.x500.X500Principal;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class FlociCertificateAuthorityTest {
@@ -95,8 +104,8 @@ class FlociCertificateAuthorityTest {
@Test
void expiredCaIsRegenerated() throws Exception {
CertificateGenerator gen = new CertificateGenerator();
java.security.KeyPair keyPair = java.security.KeyPairGenerator.getInstance("RSA").generateKeyPair();
var dn = new org.bouncycastle.asn1.x500.X500Name("CN=" + FlociCertificateAuthority.COMMON_NAME);
KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
X500Name dn = new X500Name("CN=" + FlociCertificateAuthority.COMMON_NAME);
X509Certificate expired = gen.signCertificate(dn, keyPair.getPublic(), dn, keyPair.getPrivate(), List.of(),
true, null, -1);
Files.writeString(tempDir.resolve("floci-root-ca.crt"), gen.toPem(expired));
@@ -231,8 +240,8 @@ class FlociCertificateAuthorityTest {
cert.verify(ca.certificate().getPublicKey());
assertEquals(deviceKey.getPublic(), cert.getPublicKey());
assertEquals(new javax.security.auth.x500.X500Principal(
new org.bouncycastle.asn1.x500.X500Name("CN=device-42,O=Example").getEncoded()), cert.getSubjectX500Principal());
assertEquals(new X500Principal(
new X500Name("CN=device-42,O=Example").getEncoded()), cert.getSubjectX500Principal());
assertEquals(List.of("1.3.6.1.5.5.7.3.2"), cert.getExtendedKeyUsage());
assertEquals(-1, cert.getBasicConstraints());
assertTrue(ca.isIssuedByUs(cert));
@@ -242,10 +251,10 @@ class FlociCertificateAuthorityTest {
void refusesWhatIsNotACsr() throws Exception {
FlociCertificateAuthority ca = FlociCertificateAuthority.loadOrCreate(tempDir);
var notPem = org.junit.jupiter.api.Assertions.assertThrows(IllegalArgumentException.class,
IllegalArgumentException notPem = assertThrows(IllegalArgumentException.class,
() -> ca.signClientCsr("hello"));
assertTrue(notPem.getMessage().contains("certificateSigningRequest"), notPem.getMessage());
var certificate = org.junit.jupiter.api.Assertions.assertThrows(IllegalArgumentException.class,
IllegalArgumentException certificate = assertThrows(IllegalArgumentException.class,
() -> ca.signClientCsr(ca.caPem()));
assertTrue(certificate.getMessage().contains("not a PEM CERTIFICATE REQUEST"), certificate.getMessage());
}
@@ -255,23 +264,23 @@ class FlociCertificateAuthorityTest {
FlociCertificateAuthority ca = FlociCertificateAuthority.loadOrCreate(tempDir);
String weak = csrPem("CN=weak", rsaKeyPair(1024));
var refused = org.junit.jupiter.api.Assertions.assertThrows(IllegalArgumentException.class,
IllegalArgumentException refused = assertThrows(IllegalArgumentException.class,
() -> ca.signClientCsr(weak));
assertTrue(refused.getMessage().contains("2048"), refused.getMessage());
}
private static java.security.KeyPair rsaKeyPair(int bits) throws Exception {
java.security.KeyPairGenerator kpg = java.security.KeyPairGenerator.getInstance("RSA");
private static KeyPair rsaKeyPair(int bits) throws Exception {
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
kpg.initialize(bits);
return kpg.generateKeyPair();
}
private static String csrPem(String subject, java.security.KeyPair keyPair) throws Exception {
var csr = new org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequestBuilder(
new org.bouncycastle.asn1.x500.X500Name(subject), keyPair.getPublic())
.build(new org.bouncycastle.operator.jcajce.JcaContentSignerBuilder("SHA256withRSA").build(keyPair.getPrivate()));
java.io.StringWriter out = new java.io.StringWriter();
try (var writer = new org.bouncycastle.openssl.jcajce.JcaPEMWriter(out)) {
private static String csrPem(String subject, KeyPair keyPair) throws Exception {
var csr = new JcaPKCS10CertificationRequestBuilder(
new X500Name(subject), keyPair.getPublic())
.build(new JcaContentSignerBuilder("SHA256withRSA").build(keyPair.getPrivate()));
StringWriter out = new StringWriter();
try (var writer = new JcaPEMWriter(out)) {
writer.writeObject(csr);
}
return out.toString();
@@ -1,7 +1,9 @@
package io.github.hectorvent.floci.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.hectorvent.floci.services.acm.CertificateGenerator;
import io.github.hectorvent.floci.services.acm.model.KeyAlgorithm;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.GeneralName;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.AfterEach;
@@ -14,6 +16,8 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermissions;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.Security;
import java.security.cert.X509Certificate;
import java.util.*;
@@ -409,7 +413,7 @@ class TlsCertificateHostnameTest {
Files.writeString(tlsDir.resolve("floci-server.crt"), legacy.certificatePem());
Files.writeString(tlsDir.resolve("floci-server.key"), legacy.privateKeyPem());
Files.writeString(tlsDir.resolve("floci-server.metadata.json"),
new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(
new ObjectMapper().writeValueAsString(
CertificateMetadata.create(sans, "dev")));
new TlsConfigSource();
@@ -429,16 +433,16 @@ class TlsCertificateHostnameTest {
FlociCertificateAuthority ca = FlociCertificateAuthority.loadOrCreate(tlsDir);
CertificateGenerator gen = new CertificateGenerator();
List<String> sans = TlsConfigSource.DEFAULT_SAN_HOSTNAMES;
java.security.KeyPair keyPair = java.security.KeyPairGenerator.getInstance("RSA").generateKeyPair();
KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
// Issued by the current CA with a validity that ended a day ago: only the expiry check can trigger.
X509Certificate expired = gen.signCertificate(new org.bouncycastle.asn1.x500.X500Name("CN=localhost"),
keyPair.getPublic(), org.bouncycastle.asn1.x500.X500Name.getInstance(
X509Certificate expired = gen.signCertificate(new X500Name("CN=localhost"),
keyPair.getPublic(), X500Name.getInstance(
ca.certificate().getSubjectX500Principal().getEncoded()), ca.key(), sans, false,
CertificateGenerator.LeafUsage.SERVER, -1);
Files.writeString(tlsDir.resolve("floci-server.crt"), gen.toPem(expired));
Files.writeString(tlsDir.resolve("floci-server.key"), gen.toPem(keyPair.getPrivate()));
Files.writeString(tlsDir.resolve("floci-server.metadata.json"),
new com.fasterxml.jackson.databind.ObjectMapper().writeValueAsString(CertificateMetadata.create(sans, "dev")));
new ObjectMapper().writeValueAsString(CertificateMetadata.create(sans, "dev")));
assertTrue(ca.isIssuedByUs(expired), "the expired leaf is ours, so only validity can reject it");
new TlsConfigSource();
@@ -15,15 +15,23 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.Security;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Integration test verifying TLS works with user-provided certificate and key files.
@@ -66,22 +74,22 @@ class TlsUserCertIntegrationTest {
.get("/_floci/ca.pem")
.then()
.statusCode(200)
.contentType(org.hamcrest.Matchers.startsWith("text/plain"))
.contentType(startsWith("text/plain"))
.extract().asString();
org.junit.jupiter.api.Assertions.assertFalse(pem.contains("PRIVATE KEY"),
assertFalse(pem.contains("PRIVATE KEY"),
"the key stored next to the certificate must never be served");
var bundle = java.security.cert.CertificateFactory.getInstance("X.509")
.generateCertificates(new java.io.ByteArrayInputStream(pem.getBytes(java.nio.charset.StandardCharsets.US_ASCII)))
.stream().map(java.security.cert.X509Certificate.class::cast).toList();
org.junit.jupiter.api.Assertions.assertEquals(2, bundle.size(), "user certificate plus the local CA");
org.junit.jupiter.api.Assertions.assertEquals(
List<X509Certificate> bundle = CertificateFactory.getInstance("X.509")
.generateCertificates(new ByteArrayInputStream(pem.getBytes(StandardCharsets.US_ASCII)))
.stream().map(X509Certificate.class::cast).toList();
assertEquals(2, bundle.size(), "user certificate plus the local CA");
assertEquals(
new CertificateGenerator().parseCertificate(Files.readString(UserCertProfile.CERT_FILE)), bundle.get(0),
"the user certificate, which signs the HTTPS endpoint, comes first");
java.security.cert.X509Certificate localCa = bundle.get(1);
org.junit.jupiter.api.Assertions.assertTrue(localCa.getBasicConstraints() >= 0, "the local CA is a CA");
org.junit.jupiter.api.Assertions.assertEquals("CN=Floci Local CA", localCa.getSubjectX500Principal().getName());
org.junit.jupiter.api.Assertions.assertTrue(pem.endsWith(Files.readString(
X509Certificate localCa = bundle.get(1);
assertTrue(localCa.getBasicConstraints() >= 0, "the local CA is a CA");
assertEquals("CN=Floci Local CA", localCa.getSubjectX500Principal().getName());
assertTrue(pem.endsWith(Files.readString(
Path.of("/tmp/floci-tls-usercert-test-data/tls/floci-root-ca.crt"))),
"the local CA served is the one on disk");
}
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.response.ValidatableResponse;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -89,7 +90,7 @@ class AssumedRoleAccountRoutingIntegrationTest {
listTables(ACCOUNT_A).body("TableNames", not(hasItem(tableName)));
}
private static io.restassured.response.ValidatableResponse listTables(String account) {
private static ValidatableResponse listTables(String account) {
return given()
.header("X-Amz-Target", "DynamoDB_20120810.ListTables")
.header("Authorization", auth(account, "dynamodb"))
@@ -19,8 +19,10 @@ import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.UriInfo;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
@@ -248,7 +250,7 @@ class IamConditionContextResolverTest {
resolver.resolve("s3", "s3:PutBucketTagging", containerRequest);
var restored = org.mockito.ArgumentCaptor.forClass(java.io.InputStream.class);
ArgumentCaptor<InputStream> restored = ArgumentCaptor.forClass(InputStream.class);
verify(containerRequest).setEntityStream(restored.capture());
assertArrayEquals(body.getBytes(StandardCharsets.UTF_8), restored.getValue().readAllBytes());
}
@@ -36,6 +36,7 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -90,8 +91,8 @@ class IamEnforcementFilterTest {
private IamEnforcementFilter newFilter() {
@SuppressWarnings("unchecked")
jakarta.enterprise.inject.Instance<io.github.hectorvent.floci.services.iam.ScpProvider> scpProvider =
mock(jakarta.enterprise.inject.Instance.class);
Instance<ScpProvider> scpProvider =
mock(Instance.class);
when(scpProvider.isResolvable()).thenReturn(false);
return new IamEnforcementFilter(
config, accountResolver, iamService, evaluator, actionRegistry, arnBuilder,
@@ -394,7 +395,7 @@ class IamEnforcementFilterTest {
newFilter().filter(containerRequest);
verify(evaluator, org.mockito.Mockito.times(2))
verify(evaluator, times(2))
.evaluateResolvedResourcePolicy(
any(),
eq(ResourcePolicyDecision.NEUTRAL),
@@ -1075,13 +1076,13 @@ class IamEnforcementFilterTest {
ResourcePolicyProvider provider = (scope, arn) ->
List.of(new ResourcePolicyProvider.ResourcePolicy(null, ownerAccountId));
@SuppressWarnings("unchecked")
jakarta.enterprise.inject.Instance<ResourcePolicyProvider> providers =
mock(jakarta.enterprise.inject.Instance.class);
Instance<ResourcePolicyProvider> providers =
mock(Instance.class);
when(providers.isUnsatisfied()).thenReturn(false);
when(providers.iterator()).thenReturn(List.of(provider).iterator());
@SuppressWarnings("unchecked")
jakarta.enterprise.inject.Instance<io.github.hectorvent.floci.services.iam.ScpProvider> scpProvider =
mock(jakarta.enterprise.inject.Instance.class);
Instance<ScpProvider> scpProvider =
mock(Instance.class);
when(scpProvider.isResolvable()).thenReturn(false);
return new IamEnforcementFilter(
config, accountResolver, iamService, evaluator, actionRegistry, arnBuilder,
@@ -5,6 +5,7 @@ import io.restassured.RestAssured;
import io.restassured.config.EncoderConfig;
import io.restassured.http.ContentType;
import io.restassured.parsing.Parser;
import io.restassured.specification.RequestSpecification;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -36,7 +37,7 @@ class JsonMalformedInputIntegrationTest {
RestAssured.registerParser(JSON_1_0, Parser.JSON);
}
private static io.restassured.specification.RequestSpecification req(String contentType, String target, String body) {
private static RequestSpecification req(String contentType, String target, String body) {
// RestAssured has no built-in serializer for the x-amz-json content types; send the raw body as text.
return given()
.config(RestAssured.config().encoderConfig(EncoderConfig.encoderConfig()
@@ -1,35 +1,40 @@
package io.github.hectorvent.floci.lifecycle;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.ContainerTeardown;
import io.github.hectorvent.floci.core.common.ServiceRegistry;
import io.github.hectorvent.floci.core.storage.PersistentPathValidator;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.lifecycle.InitLifecycleState;
import io.github.hectorvent.floci.lifecycle.inithook.InitializationHook;
import io.github.hectorvent.floci.lifecycle.inithook.InitializationHooksRunner;
import io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker;
import io.github.hectorvent.floci.services.docdb.container.DocDbContainerManager;
import io.github.hectorvent.floci.services.ec2.Ec2MetadataServer;
import io.github.hectorvent.floci.services.ecr.registry.EcrRegistryManager;
import io.github.hectorvent.floci.services.elasticache.ElastiCacheService;
import io.github.hectorvent.floci.services.elasticache.container.ElastiCacheContainerManager;
import io.github.hectorvent.floci.services.elasticache.container.ElastiCacheMemcachedContainerManager;
import io.github.hectorvent.floci.services.elasticache.proxy.ElastiCacheProxyManager;
import io.github.hectorvent.floci.services.docdb.container.DocDbContainerManager;
import io.github.hectorvent.floci.services.neptune.container.NeptuneContainerManager;
import io.github.hectorvent.floci.services.neptune.proxy.NeptuneProxyManager;
import io.github.hectorvent.floci.services.floci.ui.FlociUiManager;
import io.github.hectorvent.floci.services.iam.IamService;
import io.github.hectorvent.floci.services.lambda.DynamoDbStreamsEventSourcePoller;
import io.github.hectorvent.floci.services.lambda.KinesisEventSourcePoller;
import io.github.hectorvent.floci.services.lambda.SqsEventSourcePoller;
import io.github.hectorvent.floci.services.ec2.Ec2MetadataServer;
import io.github.hectorvent.floci.services.ecr.registry.EcrRegistryManager;
import io.github.hectorvent.floci.services.iam.IamService;
import io.github.hectorvent.floci.services.neptune.container.NeptuneContainerManager;
import io.github.hectorvent.floci.services.neptune.proxy.NeptuneProxyManager;
import io.github.hectorvent.floci.services.pipes.PipesService;
import io.github.hectorvent.floci.services.rds.RdsService;
import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;
import io.github.hectorvent.floci.services.rds.proxy.RdsProxyManager;
import io.github.hectorvent.floci.services.stepfunctions.StepFunctionsService;
import io.github.hectorvent.floci.services.timestreaminfluxdb.TimestreamInfluxDbService;
import io.quarkus.runtime.ShutdownDelayInitiatedEvent;
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.vertx.http.HttpServerStart;
import io.vertx.core.http.HttpServerOptions;
import jakarta.enterprise.inject.Instance;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -91,13 +96,13 @@ class EmulatorLifecycleTest {
@Mock private PipesService pipesService;
@Mock private Ec2MetadataServer ec2MetadataServer;
@Mock private EcrRegistryManager ecrRegistryManager;
@Mock private io.github.hectorvent.floci.services.floci.ui.FlociUiManager flociUiManager;
@Mock private FlociUiManager flociUiManager;
@Mock private InitLifecycleState initLifecycleState;
@Mock private PersistentPathValidator persistentPathValidator;
@Mock private EmulatorConfig.TlsConfig tlsConfig;
@Mock private io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker schemaCreationWorker;
@Mock private io.github.hectorvent.floci.services.stepfunctions.StepFunctionsService stepFunctionsService;
@Mock private jakarta.enterprise.inject.Instance<io.github.hectorvent.floci.core.common.ContainerTeardown> containerTeardowns;
@Mock private SchemaCreationWorker schemaCreationWorker;
@Mock private StepFunctionsService stepFunctionsService;
@Mock private Instance<ContainerTeardown> containerTeardowns;
private EmulatorLifecycle emulatorLifecycle;
@@ -413,7 +418,7 @@ class EmulatorLifecycleTest {
emulatorLifecycle.onPreShutdown(Mockito.mock(ShutdownDelayInitiatedEvent.class));
// The thread must NOT be left interrupted: ShutdownEvent cleanup runs next and
// interruptible I/O inside stopAll()/shutdownAll() would short-circuit otherwise.
org.junit.jupiter.api.Assertions.assertFalse(Thread.currentThread().isInterrupted(),
assertFalse(Thread.currentThread().isInterrupted(),
"Interrupt flag must not leak into ShutdownEvent cleanup");
} finally {
Thread.interrupted();
@@ -5,6 +5,7 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.Answers;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -21,7 +22,7 @@ import java.util.concurrent.TimeUnit;
@ExtendWith(MockitoExtension.class)
class HookScriptExecutorTest {
@org.junit.jupiter.api.io.TempDir
@TempDir
Path tempDirectory;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.testing;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.RestAssured;
import io.restassured.builder.ResponseBuilder;
import io.restassured.config.EncoderConfig;
import io.restassured.filter.Filter;
import io.restassured.filter.FilterContext;
@@ -84,7 +85,7 @@ class AwsContentTypeFilter implements Filter {
Response response = ctx.next(requestSpec, responseSpec);
String contentType = response.contentType();
if (contentType != null && contentType.contains("x-amz-json")) {
return new io.restassured.builder.ResponseBuilder()
return new ResponseBuilder()
.clone(response)
.setContentType(contentType.replaceFirst("application/x-amz-json-[0-9.]+", "application/json"))
.build();