Light, fluffy, and always free - The AWS Local Emulator alternative
fix(elbv2): hold an ACM certificate in use while a listener serves it (#6056)
Younes Beriane020015fd4e85
diff --git a/src/main/java/io/github/hectorvent/floci/services/acm/AcmService.java b/src/main/java/io/github/hectorvent/floci/services/acm/AcmService.javaindex 241ff0c930..292663a858 100644--- a/src/main/java/io/github/hectorvent/floci/services/acm/AcmService.java+++ b/src/main/java/io/github/hectorvent/floci/services/acm/AcmService.java@@ -354,7 +354,7 @@ public class AcmService implements ResourceProvider {List<String> consumers = certificateInUseBy(certificateArn, region);if (!consumers.isEmpty()) {throw new AwsException("ResourceInUseException",- "Certificate " + certificateArn + " is in use by: " + String.join(", ", consumers), 409);+ "Certificate " + certificateArn + " is in use by: " + String.join(", ", consumers), 400);}String storageKey = regionKey(region, cert.extractCertificateId());diff --git a/src/test/java/io/github/hectorvent/floci/services/acm/AcmInUseByTest.java b/src/test/java/io/github/hectorvent/floci/services/acm/AcmInUseByTest.javaindex b6ad0a507f..3faf1094bf 100644--- a/src/test/java/io/github/hectorvent/floci/services/acm/AcmInUseByTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/acm/AcmInUseByTest.java@@ -78,6 +78,7 @@ class AcmInUseByTest {AwsException failure = assertThrows(AwsException.class, () -> service.deleteCertificate(arn, REGION));assertEquals("ResourceInUseException", failure.getErrorCode());+ assertEquals(400, failure.getHttpStatus());assertEquals(List.of(CONSUMER), service.describeCertificate(arn, REGION).getInUseBy());}diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/AcmCfnProvisionerTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/AcmCfnProvisionerTest.javaindex e31716d9fb..2ebcfcadca 100644--- a/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/AcmCfnProvisionerTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/AcmCfnProvisionerTest.java@@ -422,7 +422,7 @@ class AcmCfnProvisionerTest {stored.setKeyAlgorithm(KeyAlgorithm.RSA_2048);when(acm.describeCertificate(ARN, REGION)).thenReturn(stored);stubRequestCertificate("new.example.com", certificate(NEW_ARN, "new.example.com"));- doThrow(new AwsException("ResourceInUseException", "in use", 409))+ doThrow(new AwsException("ResourceInUseException", "in use", 400)).when(acm).deleteCertificate(ARN, REGION);StackResource r = resource();@@ -491,7 +491,7 @@ class AcmCfnProvisionerTest {@Testvoid deletePropagatesACertificateStillInUse() {- doThrow(new AwsException("ResourceInUseException", "in use", 409))+ doThrow(new AwsException("ResourceInUseException", "in use", 400)).when(acm).deleteCertificate(ARN, REGION);assertThrows(AwsException.class,diff --git a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoUserPoolDomainIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoUserPoolDomainIntegrationTest.javaindex c6b9e33bb4..96c182f352 100644--- a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoUserPoolDomainIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoUserPoolDomainIntegrationTest.java@@ -224,7 +224,7 @@ class CognitoUserPoolDomainIntegrationTest {acm("DeleteCertificate", CERTIFICATE_ARN).then()- .statusCode(409)+ .statusCode(400).body("__type", equalTo("ResourceInUseException"));}diff --git a/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2HttpsDataPlaneIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2HttpsDataPlaneIntegrationTest.javaindex a28437eee9..827f35313d 100644--- a/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2HttpsDataPlaneIntegrationTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/elbv2/ElbV2HttpsDataPlaneIntegrationTest.java@@ -263,7 +263,7 @@ class ElbV2HttpsDataPlaneIntegrationTest {acmRequest().header("Authorization", accountAuthorization("test", "acm")).header("X-Amz-Target", "CertificateManager.DeleteCertificate")- .body(Map.of("CertificateArn", arn)).when().post("/").then().statusCode(409)+ .body(Map.of("CertificateArn", arn)).when().post("/").then().statusCode(400).body("__type", equalTo("ResourceInUseException"));}