mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(elb): hold an ACM certificate in use while a Classic listener serves it (#6599)
* fix(elb): hold an ACM certificate in use while a Classic listener serves it * fix(elb): accept a blank certificate id on a plain listener Terraform's aws_elb sends an empty SSLCertificateId on every listener, so only an HTTPS or SSL listener refuses a blank one. Both certificate reference walks now share one listing that skips the blank id.
This commit is contained in:
1 parent
dfad9d6a19
commit
b4c4718c36
6 files changed
+168
-11
No files matched your search
+35
-1
@@ -42,7 +42,7 @@ class PartitionCrossServiceSmokeIntegrationTest {
|
||||
"aps", "autoscaling", "backup", "batch", "bcmdataexports", "bedrock", "bedrockagentcorecontrol", "ce",
|
||||
"cloudfront", "cloudmap", "cloudwatch", "codebuild", "codedeploy", "codepipeline", "cognito",
|
||||
"configservice", "connect", "controlcatalog", "controltower", "datasync", "dlm", "dms", "dsql", "dynamodb", "ec2",
|
||||
"ecr", "ecs", "efs", "eks", "elasticache", "elasticbeanstalk", "elbv2", "emr", "emrserverless",
|
||||
"ecr", "ecs", "efs", "eks", "elasticache", "elasticbeanstalk", "elb", "elbv2", "emr", "emrserverless",
|
||||
"eventbridge", "firehose", "fis", "glue", "guardduty", "iot", "kinesis", "kinesisanalytics", "lambda",
|
||||
"lambdamicrovms", "lambdaweb", "memorydb", "msk", "mwaa", "networkfirewall", "oam", "opensearch", "organizations",
|
||||
"pipes", "ram", "rds", "redshift", "redshiftserverless", "resourceexplorer2", "resourcegroups", "route53resolver",
|
||||
@@ -167,6 +167,40 @@ class PartitionCrossServiceSmokeIntegrationTest {
|
||||
PartitionMatrix.assertArnIn(partitionCase, arn);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource(PartitionMatrix.NON_COMMERCIAL_CASES)
|
||||
void elbClassicLoadBalancerArnInAcmInUseBy(PartitionCase partitionCase) {
|
||||
String region = offered(partitionCase, "acm");
|
||||
offered(partitionCase, "elasticloadbalancing");
|
||||
String certificateArn = json11(region, "acm", "CertificateManager.RequestCertificate",
|
||||
"{\"DomainName\":\"" + unique("smoke-elb", partitionCase) + ".example.com\"}")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().jsonPath().getString("CertificateArn");
|
||||
cleanup.register(() -> json11(region, "acm", "CertificateManager.DeleteCertificate",
|
||||
"{\"CertificateArn\":\"" + certificateArn + "\"}").when().post("/"));
|
||||
String name = unique("elb", partitionCase);
|
||||
signed(region, "elasticloadbalancing")
|
||||
.formParam("Action", "CreateLoadBalancer")
|
||||
.formParam("Version", "2012-06-01")
|
||||
.formParam("LoadBalancerName", name)
|
||||
.formParam("AvailabilityZones.member.1", region + "a")
|
||||
.formParam("Listeners.member.1.Protocol", "HTTPS")
|
||||
.formParam("Listeners.member.1.LoadBalancerPort", "443")
|
||||
.formParam("Listeners.member.1.InstancePort", "8080")
|
||||
.formParam("Listeners.member.1.SSLCertificateId", certificateArn)
|
||||
.when().post("/").then().statusCode(200);
|
||||
cleanup.register(() -> signed(region, "elasticloadbalancing")
|
||||
.formParam("Action", "DeleteLoadBalancer")
|
||||
.formParam("Version", "2012-06-01")
|
||||
.formParam("LoadBalancerName", name)
|
||||
.when().post("/"));
|
||||
String arn = json11(region, "acm", "CertificateManager.DescribeCertificate",
|
||||
"{\"CertificateArn\":\"" + certificateArn + "\"}")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().jsonPath().getString("Certificate.InUseBy[0]");
|
||||
PartitionMatrix.assertArnIn(partitionCase, arn);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource(PartitionMatrix.NON_COMMERCIAL_CASES)
|
||||
void glueSchemaRegistryArn(PartitionCase partitionCase) {
|
||||
|
||||
+56
@@ -7,12 +7,14 @@ import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.RestAssured;
|
||||
import io.restassured.config.EncoderConfig;
|
||||
import io.restassured.http.ContentType;
|
||||
import io.restassured.parsing.Parser;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@@ -58,6 +60,14 @@ class ElbClassicServerCertificateIntegrationTest {
|
||||
.extract().path("CertificateArn");
|
||||
}
|
||||
|
||||
private static ValidatableResponse acm(String target, String certificateArn) {
|
||||
return given().header("Authorization", ACM_AUTH)
|
||||
.header("X-Amz-Target", "CertificateManager." + target)
|
||||
.contentType("application/x-amz-json-1.1").config(RestAssured.config().encoderConfig(EncoderConfig.encoderConfig().encodeContentTypeAs("application/x-amz-json-1.1", ContentType.TEXT)))
|
||||
.body("{\"CertificateArn\": \"" + certificateArn + "\"}")
|
||||
.when().post("/").then().using().defaultParser(Parser.JSON);
|
||||
}
|
||||
|
||||
private static ValidatableResponse deleteCertificate(String name) {
|
||||
return given().header("Authorization", IAM_AUTH)
|
||||
.formParam("Action", "DeleteServerCertificate")
|
||||
@@ -145,6 +155,52 @@ class ElbClassicServerCertificateIntegrationTest {
|
||||
deleteCertificate(certName).statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createLoadBalancerRejectsABlankCertificateId() {
|
||||
createLoadBalancer("elb-cert-blank-" + suffix(), "")
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("CertificateNotFound"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createLoadBalancerAcceptsAnHttpListenerWithAnEmptyCertificateId() {
|
||||
given().header("Authorization", ELB_AUTH)
|
||||
.formParam("Action", "CreateLoadBalancer")
|
||||
.formParam("Version", CLASSIC_VERSION)
|
||||
.formParam("LoadBalancerName", "elb-cert-http-" + suffix())
|
||||
.formParam("Subnets.member.1", Ec2Service.defaultSubnetId("us-east-1", "a"))
|
||||
.formParam("Listeners.member.1.Protocol", "HTTP")
|
||||
.formParam("Listeners.member.1.LoadBalancerPort", "80")
|
||||
.formParam("Listeners.member.1.InstanceProtocol", "HTTP")
|
||||
.formParam("Listeners.member.1.InstancePort", "8080")
|
||||
.formParam("Listeners.member.1.SSLCertificateId", "")
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void acmCertificateInUseCannotBeDeletedUntilTheListenerIsGone() {
|
||||
String lb = "elb-acm-in-use-" + suffix();
|
||||
String arn = requestAcmCertificate();
|
||||
createLoadBalancer(lb, arn).statusCode(200);
|
||||
|
||||
acm("DescribeCertificate", arn)
|
||||
.statusCode(200)
|
||||
.body("Certificate.InUseBy",
|
||||
contains("arn:aws:elasticloadbalancing:us-east-1:000000000000:loadbalancer/" + lb));
|
||||
acm("DeleteCertificate", arn)
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ResourceInUseException"));
|
||||
|
||||
given().header("Authorization", ELB_AUTH)
|
||||
.formParam("Action", "DeleteLoadBalancerListeners")
|
||||
.formParam("Version", CLASSIC_VERSION)
|
||||
.formParam("LoadBalancerName", lb)
|
||||
.formParam("LoadBalancerPorts.member.1", "443")
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
acm("DeleteCertificate", arn).statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createLoadBalancerAcceptsAnAcmCertificateOfItsOwnRegionAndAccount() {
|
||||
createLoadBalancer("elb-acm-ok-" + suffix(), requestAcmCertificate()).statusCode(200);
|
||||
|
||||
Reference in new issue
Block a user