mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(elbv2): omit HTTP-only fields from TCP target groups (#9030)
This commit is contained in:
1 parent
9f959a3f27
commit
f08cc57437
3 files changed
+61
-4
No files matched your search
+48
@@ -6,12 +6,15 @@ import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.function.Executable;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.acm.AcmClient;
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2Client;
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.model.Certificate;
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.model.Listener;
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetGroup;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -20,6 +23,7 @@ import static io.floci.aws.testing.QueryRequests.request;
|
||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@@ -34,6 +38,7 @@ class ElbV2OptionalResponseFieldsIntegrationTest {
|
||||
private String loadBalancer;
|
||||
private String targetGroup;
|
||||
private String certificate;
|
||||
private final List<String> createdTargetGroups = new ArrayList<>();
|
||||
|
||||
@BeforeEach
|
||||
void createResources() {
|
||||
@@ -64,6 +69,8 @@ class ElbV2OptionalResponseFieldsIntegrationTest {
|
||||
ownedElb.deleteTargetGroup(request -> request.targetGroupArn(targetGroup));
|
||||
}
|
||||
},
|
||||
() -> assertAll(createdTargetGroups.stream().map(arn -> (Executable) () ->
|
||||
ownedElb.deleteTargetGroup(request -> request.targetGroupArn(arn)))),
|
||||
() -> {
|
||||
if (certificate != null) {
|
||||
ownedAcm.deleteCertificate(request -> request.certificateArn(certificate));
|
||||
@@ -193,6 +200,47 @@ class ElbV2OptionalResponseFieldsIntegrationTest {
|
||||
() -> assertTerminalXml("DescribeListenerCertificates", Map.of("ListenerArn", listener)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void tcpTargetGroupsOmitFieldsOnlyHttpUses() {
|
||||
String tcp = createTargetGroup("optional-tcp", "TCP", "TCP");
|
||||
String tcpWithHttpCheck = createTargetGroup("optional-tcp-http", "TCP", "HTTP");
|
||||
String http = createTargetGroup("optional-http", "HTTP", null);
|
||||
TargetGroup tcpGroup = describeTargetGroup(tcp);
|
||||
TargetGroup tcpWithHttpCheckGroup = describeTargetGroup(tcpWithHttpCheck);
|
||||
TargetGroup httpGroup = describeTargetGroup(http);
|
||||
assertAll(
|
||||
() -> assertNull(tcpGroup.protocolVersion()),
|
||||
() -> assertNull(tcpGroup.healthCheckPath()),
|
||||
() -> assertNull(tcpGroup.matcher()),
|
||||
() -> assertNull(tcpWithHttpCheckGroup.protocolVersion()),
|
||||
() -> assertNotNull(tcpWithHttpCheckGroup.healthCheckPath()),
|
||||
() -> assertNotNull(tcpWithHttpCheckGroup.matcher()),
|
||||
() -> assertEquals("HTTP", httpGroup.healthCheckProtocolAsString()),
|
||||
() -> assertEquals("HTTP1", httpGroup.protocolVersion()),
|
||||
() -> assertEquals("/", httpGroup.healthCheckPath()),
|
||||
() -> assertEquals("200", httpGroup.matcher().httpCode()));
|
||||
|
||||
TargetGroup switchedToHttpCheck = elb.modifyTargetGroup(request -> request.targetGroupArn(tcp)
|
||||
.healthCheckProtocol("HTTP")).targetGroups().getFirst();
|
||||
assertAll("Switching to an HTTP check returns the stored path and matcher",
|
||||
() -> assertNotNull(switchedToHttpCheck.healthCheckPath()),
|
||||
() -> assertNotNull(switchedToHttpCheck.matcher()));
|
||||
}
|
||||
|
||||
private String createTargetGroup(String prefix, String protocol, String healthCheckProtocol) {
|
||||
String arn = elb.createTargetGroup(request -> request.name(uniqueName(prefix))
|
||||
.protocol(protocol).port(2022).targetType("ip")
|
||||
.vpcId(Ec2Service.defaultVpcId(REGION.id()))
|
||||
.healthCheckProtocol(healthCheckProtocol))
|
||||
.targetGroups().getFirst().targetGroupArn();
|
||||
createdTargetGroups.add(arn);
|
||||
return arn;
|
||||
}
|
||||
|
||||
private TargetGroup describeTargetGroup(String arn) {
|
||||
return elb.describeTargetGroups(request -> request.targetGroupArns(arn)).targetGroups().getFirst();
|
||||
}
|
||||
|
||||
private Listener createListener(String protocol, int port) {
|
||||
return createListener(protocol, port, SSL_POLICY);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user