mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(acm): reject empty SAN arrays in certificate requests (#5688)
RequestCertificate answers an explicit empty SubjectAlternativeNames array with a 400 ValidationException, as ACM does: the API requires at least one name in the list. CloudFormation certificate resources keep accepting an empty list and request the certificate for the domain name alone, as before. Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
1 parent
190ed52249
commit
e15c081d33
5 files changed
+107
-1
No files matched your search
@@ -42,6 +42,22 @@ class AcmIntegrationTest {
|
||||
|
||||
// ==================== User Story 1: RequestCertificate ====================
|
||||
|
||||
@Test
|
||||
void requestCertificateRejectsEmptySans() {
|
||||
given()
|
||||
.header("X-Amz-Target", "CertificateManager.RequestCertificate")
|
||||
.contentType(ACM_CONTENT_TYPE)
|
||||
.body("""
|
||||
{"DomainName": "empty-sans.example.com", "SubjectAlternativeNames": []}
|
||||
""")
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("1 validation error detected: Value '[]' at 'subjectAlternativeNames' "
|
||||
+ "failed to satisfy constraint: Member must have length greater than or equal to 1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void requestCertificateBasic() {
|
||||
|
||||
+29
@@ -8,6 +8,7 @@ import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -114,6 +115,34 @@ class AcmCfnIntegrationTest {
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void certificateStackAcceptsEmptySans() {
|
||||
String stack = "acm-empty-sans";
|
||||
String template = """
|
||||
{
|
||||
"Resources": {"Cert": {
|
||||
"Type": "AWS::CertificateManager::Certificate",
|
||||
"Properties": {
|
||||
"DomainName": "empty-sans.example.com",
|
||||
"SubjectAlternativeNames": [],
|
||||
"ValidationMethod": "DNS"
|
||||
}
|
||||
}},
|
||||
"Outputs": {"CertArn": {"Value": {"Ref": "Cert"}}}
|
||||
}
|
||||
""";
|
||||
cloudFormation(stack, "CreateStack", template, Map.of());
|
||||
try {
|
||||
String arn = outputValue(describeStacks(stack, "CREATE_COMPLETE"), "CertArn");
|
||||
describeCertificate(arn).then()
|
||||
.statusCode(200)
|
||||
.body("Certificate.SubjectAlternativeNames", equalTo(List.of("empty-sans.example.com")));
|
||||
} finally {
|
||||
cloudFormation(stack, "DeleteStack", null, Map.of());
|
||||
CfnStackWaits.awaitStackDeleted(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void certificateOptionsFollowTheTemplateThroughCreateAndUpdate() {
|
||||
cloudFormation(OPTIONS_STACK, "CreateStack", OPTIONS_TEMPLATE, options("ENABLED", "DISABLED"));
|
||||
|
||||
Reference in new issue
Block a user