mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(elbv2): reject gateway listener protocols (#6465)
* fix: reject explicit protocols on gateway load balancer listeners Validate gateway listener Protocol before create publication or modify mutation. Preserve omitted-field updates and cover Query rejection and state preservation. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * test(elbv2): omit protocol in gateway listener fixture Keep the successful gateway listener lifecycle fixture aligned with the accepted Protocol prohibition. Assert protocol preservation after an action-only update without introducing a default-protocol contract. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> * fix(elbv2): preserve gateway listener defaults Default gateway listener responses to GENEVE and keep omitted protocol and port unset through CloudFormation create and update. Preserve application and network listener defaults. Cover direct Query and stack lifecycle behavior. Signed-off-by: Andre Kurait <AndreKurait@gmail.com> --------- Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
This commit is contained in:
1 parent
87cd8ead73
commit
3d2e17bbbd
7 files changed
+182
-24
No files matched your search
@@ -47,7 +47,7 @@ Floci supports Application Load Balancers (ALB) and Network Load Balancers (NLB)
|
||||
|
||||
HTTPS listeners require a default certificate. Supply one when creating a listener or changing an HTTP listener to HTTPS; an omitted certificate list on an existing HTTPS listener keeps its default.
|
||||
|
||||
Gateway Load Balancer listeners require an omitted `Port` on both create and modify requests. Their portless control-plane configuration does not provide GENEVE packet forwarding.
|
||||
Gateway Load Balancer listeners require omitted `Port` and `Protocol` fields on both create and modify requests. Their portless control-plane configuration does not provide GENEVE packet forwarding.
|
||||
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
@@ -98,6 +98,7 @@ Gateway Load Balancer listeners require an omitted `Port` on both create and mod
|
||||
- `SetSubnets`, like `CreateLoadBalancer`, takes `Subnets` or `SubnetMappings`, and both together are refused with `ValidationError`. With neither it returns the same `ValidationError` as `CreateLoadBalancer` for the balancer's type, `At least two subnets in two different Availability Zones must be specified` for an Application Load Balancer and `At least one subnet must be specified` for a Network or Gateway Load Balancer, and leaves the balancer on its subnets. A `SetSubnets` that names subnets is counted as `CreateLoadBalancer` counts them, following the two-zone rule its API reference states: one subnet for an Application Load Balancer, in `Subnets` or `SubnetMappings`, returns `ValidationError` `At least two subnets in two different Availability Zones must be specified` before any subnet is looked up, and leaves the balancer on its subnets. AWS does not document the error for this case, so Floci gives `CreateLoadBalancer`'s error, in the same order. A CloudFormation update that keeps an Application Load Balancer and names one subnet fails with that error and rolls back. A Network Load Balancer can be set onto one subnet. The `SetSubnets` API reference requires a Gateway Load Balancer's `Subnets` to include every subnet it is already on; Floci does not enforce that.
|
||||
- EC2 refuses deletion of subnets and VPCs still referenced by load balancers with `DependencyViolation`. These account- and region-scoped dependencies follow persisted load balancer state; changing subnets or deleting the load balancer releases its old references. A CloudFormation update that names other subnets in `Subnets` or `SubnetMappings` moves the load balancer the way `SetSubnets` does, and a rolled-back update moves it back. An independent target group does not prevent subnet or VPC deletion.
|
||||
- HTTP listener sockets are preserved when listener actions change and are restarted only when socket-level settings such as port change.
|
||||
- Gateway listeners require `Protocol` and `Port` to be omitted on create and modify. Their control-plane response reports `GENEVE` without a port. CloudFormation preserves omitted gateway listener settings on create and update; other load balancer types retain their existing `HTTP` and port 80 defaults.
|
||||
- Instance targets are resolved through EC2 instance private addresses so local load balancer traffic can reach containers.
|
||||
- Target health starts in `initial` state with reason `Elb.RegistrationInProgress` and is updated by Floci's health checker when monitoring is active.
|
||||
- Health checks probe the target group's `HealthCheckPort` when it is a port number, and each target's own port when it is `traffic-port` (the default).
|
||||
|
||||
+10
-3
@@ -305,14 +305,21 @@ public class ElbV2CfnProvisioner implements CfnResourceProvisioner {
|
||||
*/
|
||||
private void provisionListener(StackResource r, JsonNode props, ProvisionContext ctx) {
|
||||
String lbArn = ctx.resolveOptional(props, "LoadBalancerArn");
|
||||
String protocol = ctx.resolveOrDefault(props, "Protocol", "HTTP");
|
||||
int port = parseInt(ctx.resolveOptional(props, "Port"), "Port", 80);
|
||||
Listener prior = ctx.isUpdate() ? priorListener(ctx) : null;
|
||||
String effectiveLbArn = lbArn != null ? lbArn : prior != null ? prior.getLoadBalancerArn() : null;
|
||||
LoadBalancer lb = effectiveLbArn == null ? null
|
||||
: elbV2Service.describeLoadBalancers(ctx.region(), List.of(effectiveLbArn),
|
||||
null, null, null).getFirst();
|
||||
boolean gateway = lb != null && "gateway".equals(lb.getType());
|
||||
String protocol = gateway ? ctx.resolveOptional(props, "Protocol")
|
||||
: ctx.resolveOrDefault(props, "Protocol", "HTTP");
|
||||
Integer port = gateway ? optionalInt(props, ctx, "Port")
|
||||
: Integer.valueOf(parseInt(ctx.resolveOptional(props, "Port"), "Port", 80));
|
||||
String sslPolicy = ctx.resolveOptional(props, "SslPolicy");
|
||||
List<String> certificates = parseCertificates(props, ctx);
|
||||
List<Action> defaultActions = parseActions(props != null ? props.get("DefaultActions") : null, ctx);
|
||||
|
||||
Listener listener;
|
||||
Listener prior = ctx.isUpdate() ? priorListener(ctx) : null;
|
||||
if (prior != null && (lbArn == null || lbArn.equals(prior.getLoadBalancerArn()))) {
|
||||
listener = elbV2Service.modifyListener(ctx.region(), ctx.priorPhysicalId(), protocol, port, sslPolicy,
|
||||
certificates, defaultActions, null);
|
||||
|
||||
@@ -604,7 +604,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
List<Action> defaultActions, List<String> alpnPolicy,
|
||||
Map<String, String> initialTags) {
|
||||
validatePort(port, "port");
|
||||
requireGatewayListenerPort(requireLoadBalancer(region, lbArn), port);
|
||||
requireGatewayListenerSettings(requireLoadBalancer(region, lbArn), protocol, port);
|
||||
|
||||
Map<String, Listener> regionListeners = listeners.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
|
||||
|
||||
@@ -632,7 +632,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
listener.setListenerArn(listenerArn);
|
||||
listener.setLoadBalancerArn(lbArn);
|
||||
listener.setPort(port);
|
||||
listener.setProtocol(protocol != null ? protocol : "HTTP");
|
||||
listener.setProtocol(protocol != null ? protocol : ("gateway".equals(lbType) ? "GENEVE" : "HTTP"));
|
||||
listener.setSslPolicy(sslPolicy);
|
||||
listener.setCertificates(certificates != null ? new ArrayList<>(certificates) : new ArrayList<>());
|
||||
listener.setDefaultActions(defaultActions != null ? new ArrayList<>(defaultActions) : new ArrayList<>());
|
||||
@@ -747,7 +747,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
while (true) {
|
||||
Listener initial = requireListener(region, listenerArn);
|
||||
LoadBalancer initialLb = requireLoadBalancer(region, initial.getLoadBalancerArn());
|
||||
requireGatewayListenerPort(initialLb, port);
|
||||
requireGatewayListenerSettings(initialLb, protocol, port);
|
||||
ListenerState initialState = listenerState(initial, initialLb);
|
||||
requireAvailableListenerPort(listeners.getOrDefault(region, Map.of()), initial.getLoadBalancerArn(),
|
||||
listenerArn, port != null ? port : initialState.port());
|
||||
@@ -1230,11 +1230,15 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
}
|
||||
}
|
||||
|
||||
private static void requireGatewayListenerPort(LoadBalancer loadBalancer, Integer port) {
|
||||
private static void requireGatewayListenerSettings(LoadBalancer loadBalancer, String protocol, Integer port) {
|
||||
if (port != null && "gateway".equals(loadBalancer.getType())) {
|
||||
throw new AwsException("InvalidConfigurationRequest",
|
||||
"You can't specify a port for a Gateway Load Balancer.", 400);
|
||||
}
|
||||
if (protocol != null && "gateway".equals(loadBalancer.getType())) {
|
||||
throw new AwsException("InvalidConfigurationRequest",
|
||||
"You can't specify a protocol for a Gateway Load Balancer.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private void requireCompatibleListenerProtocol(String listenerArn, Integer port, String protocol) {
|
||||
|
||||
+56
@@ -15,6 +15,7 @@ import io.github.hectorvent.floci.services.elbv2.model.LoadBalancer;
|
||||
import io.github.hectorvent.floci.services.elbv2.model.Rule;
|
||||
import io.github.hectorvent.floci.services.elbv2.model.RuleCondition;
|
||||
import io.github.hectorvent.floci.services.elbv2.model.TargetGroup;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
@@ -68,6 +69,61 @@ class ElbV2CfnProvisionerTest {
|
||||
private final ElbV2CfnProvisioner provisioner = new ElbV2CfnProvisioner(elb);
|
||||
private final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@BeforeEach
|
||||
void defaultListenerLoadBalancer() {
|
||||
LoadBalancer lb = new LoadBalancer();
|
||||
lb.setType("application");
|
||||
when(elb.describeLoadBalancers(eq(REGION), anyList(), isNull(), isNull(), isNull()))
|
||||
.thenReturn(List.of(lb));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {false, true})
|
||||
void gatewayListenerLeavesProtocolAndPortUnset(boolean update) {
|
||||
LoadBalancer lb = new LoadBalancer();
|
||||
lb.setType("gateway");
|
||||
when(elb.describeLoadBalancers(REGION, List.of(LB_ARN), null, null, null)).thenReturn(List.of(lb));
|
||||
if (update) {
|
||||
when(elb.describeListeners(REGION, null, List.of(LISTENER_ARN))).thenReturn(List.of(listener(LB_ARN)));
|
||||
when(elb.modifyListener(eq(REGION), eq(LISTENER_ARN), isNull(), isNull(), isNull(),
|
||||
anyList(), anyList(), isNull())).thenReturn(listener(LB_ARN));
|
||||
} else {
|
||||
when(elb.createListener(eq(REGION), eq(LB_ARN), isNull(), isNull(), isNull(),
|
||||
anyList(), anyList(), isNull(), eq(Map.of()))).thenReturn(listener(LB_ARN));
|
||||
}
|
||||
StackResource resource = resource("AWS::ElasticLoadBalancingV2::Listener", "Listener");
|
||||
|
||||
provisioner.provision(resource, mapper.createObjectNode().put("LoadBalancerArn", LB_ARN),
|
||||
ctx(update ? LISTENER_ARN : null));
|
||||
|
||||
assertEquals(LISTENER_ARN, resource.getPhysicalId());
|
||||
assertEquals(LISTENER_ARN, resource.getAttributes().get("ListenerArn"));
|
||||
if (update) {
|
||||
verify(elb).modifyListener(eq(REGION), eq(LISTENER_ARN), isNull(), isNull(), isNull(),
|
||||
anyList(), anyList(), isNull());
|
||||
} else {
|
||||
verify(elb).createListener(eq(REGION), eq(LB_ARN), isNull(), isNull(), isNull(),
|
||||
anyList(), anyList(), isNull(), eq(Map.of()));
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"HTTP", ""})
|
||||
void gatewayListenerPassesExplicitProtocolToService(String protocol) {
|
||||
LoadBalancer lb = new LoadBalancer();
|
||||
lb.setType("gateway");
|
||||
when(elb.describeLoadBalancers(REGION, List.of(LB_ARN), null, null, null)).thenReturn(List.of(lb));
|
||||
when(elb.createListener(eq(REGION), eq(LB_ARN), eq(protocol), isNull(), isNull(),
|
||||
anyList(), anyList(), isNull(), eq(Map.of()))).thenReturn(listener(LB_ARN));
|
||||
StackResource resource = resource("AWS::ElasticLoadBalancingV2::Listener", "Listener");
|
||||
|
||||
provisioner.provision(resource, mapper.createObjectNode().put("LoadBalancerArn", LB_ARN)
|
||||
.put("Protocol", protocol), ctx());
|
||||
|
||||
verify(elb).createListener(eq(REGION), eq(LB_ARN), eq(protocol), isNull(), isNull(),
|
||||
anyList(), anyList(), isNull(), eq(Map.of()));
|
||||
}
|
||||
|
||||
private ProvisionContext ctx() {
|
||||
return ctx(null);
|
||||
}
|
||||
|
||||
+55
-3
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.elbv2;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -161,12 +162,14 @@ class ElbV2DefaultAttributesIntegrationTest {
|
||||
void aGatewayListenerRetainsItsControlPlaneWithoutAPort() {
|
||||
String arn = createLoadBalancer("attrs-gwlb-listener", "gateway", "10.120.");
|
||||
try {
|
||||
String listener = given().header("Authorization", AUTH).formParam("Action", "CreateListener")
|
||||
.formParam("LoadBalancerArn", arn).formParam("Protocol", "GENEVE")
|
||||
Response created = given().header("Authorization", AUTH).formParam("Action", "CreateListener")
|
||||
.formParam("LoadBalancerArn", arn)
|
||||
.formParam("DefaultActions.member.1.Type", "fixed-response")
|
||||
.formParam("DefaultActions.member.1.FixedResponseConfig.StatusCode", "200")
|
||||
.when().post("/").then().statusCode(200).extract()
|
||||
.path("CreateListenerResponse.CreateListenerResult.Listeners.member.ListenerArn");
|
||||
.response();
|
||||
String listener = created.path("CreateListenerResponse.CreateListenerResult.Listeners.member.ListenerArn");
|
||||
assertEquals("GENEVE", created.path("CreateListenerResponse.CreateListenerResult.Listeners.member.Protocol"));
|
||||
given().header("Authorization", AUTH).formParam("Action", "ModifyListener")
|
||||
.formParam("ListenerArn", listener)
|
||||
.formParam("DefaultActions.member.1.Type", "fixed-response")
|
||||
@@ -186,6 +189,55 @@ class ElbV2DefaultAttributesIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aGatewayListenerStackPreservesOmittedSettingsOnUpdate() {
|
||||
String arn = createLoadBalancer("attrs-gwlb-stack", "gateway", "10.121.");
|
||||
String stack = "gateway-listener-settings";
|
||||
String template = """
|
||||
{"Resources":{"Listener":{"Type":"AWS::ElasticLoadBalancingV2::Listener",
|
||||
"Properties":{"LoadBalancerArn":"%s","DefaultActions":[{"Type":"fixed-response",
|
||||
"FixedResponseConfig":{"StatusCode":"%s"}}]}}}}
|
||||
""";
|
||||
try {
|
||||
given().formParam("Action", "CreateStack").formParam("StackName", stack)
|
||||
.formParam("TemplateBody", template.formatted(arn, "200"))
|
||||
.when().post("/").then().statusCode(200);
|
||||
given().formParam("Action", "DescribeStacks").formParam("StackName", stack)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body("DescribeStacksResponse.DescribeStacksResult.Stacks.member.StackStatus", equalTo("CREATE_COMPLETE"));
|
||||
String listener = given().header("Authorization", AUTH).formParam("Action", "DescribeListeners")
|
||||
.formParam("LoadBalancerArn", arn).when().post("/").then().statusCode(200)
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Protocol", equalTo("GENEVE"))
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Port.text()", equalTo(""))
|
||||
.extract().path("DescribeListenersResponse.DescribeListenersResult.Listeners.member.ListenerArn");
|
||||
|
||||
given().formParam("Action", "UpdateStack").formParam("StackName", stack)
|
||||
.formParam("TemplateBody", template.formatted(arn, "201"))
|
||||
.when().post("/").then().statusCode(200);
|
||||
given().formParam("Action", "DescribeStacks").formParam("StackName", stack)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body("DescribeStacksResponse.DescribeStacksResult.Stacks.member.StackStatus", equalTo("UPDATE_COMPLETE"));
|
||||
given().header("Authorization", AUTH).formParam("Action", "DescribeListeners")
|
||||
.formParam("LoadBalancerArn", arn).when().post("/").then().statusCode(200)
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.ListenerArn", equalTo(listener))
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Protocol", equalTo("GENEVE"))
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Port.text()", equalTo(""))
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.DefaultActions.member.FixedResponseConfig.StatusCode",
|
||||
equalTo("201"));
|
||||
} finally {
|
||||
try {
|
||||
given().formParam("Action", "DeleteStack").formParam("StackName", stack)
|
||||
.when().post("/").then().statusCode(200);
|
||||
given().header("Authorization", AUTH).formParam("Action", "DescribeListeners")
|
||||
.formParam("LoadBalancerArn", arn).when().post("/").then().statusCode(200)
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.size()", equalTo(0));
|
||||
} finally {
|
||||
given().header("Authorization", AUTH).formParam("Action", "DeleteLoadBalancer")
|
||||
.formParam("LoadBalancerArn", arn).when().post("/").then().statusCode(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aModifiedAttributeWinsOverItsDefaultAndTheRestStillReport() {
|
||||
String arn = createLoadBalancer("attrs-modified", "application", "10.99.");
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.elbv2;
|
||||
|
||||
import io.github.hectorvent.floci.services.ec2.Ec2Service;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
@@ -71,8 +72,9 @@ class ElbV2IntegrationTest {
|
||||
+ "' at 'port' failed to satisfy constraint: Member must have value " + constraint));
|
||||
}
|
||||
|
||||
@Test
|
||||
void gatewayListenerPortRejectionsPreservePortlessListener() {
|
||||
@ParameterizedTest
|
||||
@CsvSource({"Port,6081", "Protocol,GENEVE", "Protocol,TCP"})
|
||||
void gatewayListenerRejectionsPreservePortlessListener(String field, String value) {
|
||||
String gatewayArn = given().header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateLoadBalancer")
|
||||
.formParam("Name", "gateway-listener-port")
|
||||
@@ -83,32 +85,32 @@ class ElbV2IntegrationTest {
|
||||
try {
|
||||
given().header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateListener").formParam("LoadBalancerArn", gatewayArn)
|
||||
.formParam("Protocol", "GENEVE").formParam("Port", 6081)
|
||||
.formParam(field, value)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidConfigurationRequest"));
|
||||
given().header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeListeners").formParam("LoadBalancerArn", gatewayArn)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.size()", equalTo(0));
|
||||
String gatewayListener = given().header("Authorization", AUTH)
|
||||
Response created = given().header("Authorization", AUTH)
|
||||
.formParam("Action", "CreateListener").formParam("LoadBalancerArn", gatewayArn)
|
||||
.formParam("Protocol", "GENEVE")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().path("CreateListenerResponse.CreateListenerResult.Listeners.member.ListenerArn");
|
||||
.when().post("/").then().statusCode(200).extract().response();
|
||||
String gatewayListener = created.path("CreateListenerResponse.CreateListenerResult.Listeners.member.ListenerArn");
|
||||
String originalProtocol = created.path("CreateListenerResponse.CreateListenerResult.Listeners.member.Protocol");
|
||||
given().header("Authorization", AUTH)
|
||||
.formParam("Action", "ModifyListener").formParam("ListenerArn", gatewayListener)
|
||||
.formParam("Protocol", "TCP").formParam("Port", 6081)
|
||||
.formParam(field, value)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidConfigurationRequest"));
|
||||
given().header("Authorization", AUTH)
|
||||
.formParam("Action", "DescribeListeners").formParam("ListenerArns.member.1", gatewayListener)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Protocol", equalTo("GENEVE"))
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Protocol", equalTo(originalProtocol))
|
||||
.body("DescribeListenersResponse.DescribeListenersResult.Listeners.member.Port.size()", equalTo(0));
|
||||
given().header("Authorization", AUTH)
|
||||
.formParam("Action", "ModifyListener").formParam("ListenerArn", gatewayListener)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body("ModifyListenerResponse.ModifyListenerResult.Listeners.member.Protocol", equalTo("GENEVE"))
|
||||
.body("ModifyListenerResponse.ModifyListenerResult.Listeners.member.Protocol", equalTo(originalProtocol))
|
||||
.body("ModifyListenerResponse.ModifyListenerResult.Listeners.member.Port.size()", equalTo(0));
|
||||
} finally {
|
||||
given().header("Authorization", AUTH)
|
||||
|
||||
@@ -606,14 +606,49 @@ class ElbV2ServiceTest {
|
||||
assertTrue(service.describeListeners(REGION, lbArn, null).isEmpty());
|
||||
verifyNoInteractions(dataPlane);
|
||||
|
||||
Listener listener = service.createListener(REGION, lbArn, "GENEVE", null, null,
|
||||
Listener listener = service.createListener(REGION, lbArn, null, null, null,
|
||||
List.of(), List.of(), List.of(), Map.of());
|
||||
String originalProtocol = listener.getProtocol();
|
||||
clearInvocations(dataPlane);
|
||||
AwsException modifyError = assertThrows(AwsException.class, () -> service.modifyListener(
|
||||
REGION, listener.getListenerArn(), "TCP", port, null, null, null, null));
|
||||
assertEquals("InvalidConfigurationRequest", modifyError.getErrorCode());
|
||||
assertNull(listener.getPort());
|
||||
assertEquals("GENEVE", listener.getProtocol());
|
||||
assertEquals(originalProtocol, listener.getProtocol());
|
||||
verifyNoInteractions(dataPlane);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"GENEVE", "TCP", ""})
|
||||
void gatewayListenerRejectsExplicitProtocolWithoutPublication(String protocol) {
|
||||
String lbArn = service.createLoadBalancer(REGION, "gateway-protocol", "internal", "gateway", "ipv4",
|
||||
ALB_SUBNETS, List.of(), Map.of()).getLoadBalancerArn();
|
||||
clearInvocations(dataPlane);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createListener(
|
||||
REGION, lbArn, protocol, null, null, List.of(), List.of(), List.of(), Map.of()));
|
||||
|
||||
assertEquals("InvalidConfigurationRequest", error.getErrorCode());
|
||||
assertTrue(service.describeListeners(REGION, lbArn, null).isEmpty());
|
||||
verifyNoInteractions(dataPlane);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"GENEVE", "TCP", ""})
|
||||
void gatewayListenerRejectsProtocolUpdateWithoutMutation(String protocol) {
|
||||
String lbArn = service.createLoadBalancer(REGION, "gateway-protocol", "internal", "gateway", "ipv4",
|
||||
ALB_SUBNETS, List.of(), Map.of()).getLoadBalancerArn();
|
||||
Listener listener = service.createListener(REGION, lbArn, null, null, null,
|
||||
List.of(), List.of(), List.of(), Map.of());
|
||||
String originalProtocol = listener.getProtocol();
|
||||
clearInvocations(dataPlane);
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.modifyListener(
|
||||
REGION, listener.getListenerArn(), protocol, null, null, null, null, null));
|
||||
|
||||
assertEquals("InvalidConfigurationRequest", error.getErrorCode());
|
||||
assertEquals(originalProtocol, listener.getProtocol());
|
||||
assertNull(listener.getPort());
|
||||
verifyNoInteractions(dataPlane);
|
||||
}
|
||||
|
||||
@@ -623,8 +658,9 @@ class ElbV2ServiceTest {
|
||||
ALB_SUBNETS, List.of(), Map.of()).getLoadBalancerArn();
|
||||
String oldTarget = createTargetGroup("gateway-old");
|
||||
String newTarget = createTargetGroup("gateway-new");
|
||||
Listener listener = service.createListener(REGION, lbArn, "GENEVE", null, null,
|
||||
Listener listener = service.createListener(REGION, lbArn, null, null, null,
|
||||
List.of(), List.of(forwardAction(oldTarget)), List.of(), Map.of());
|
||||
assertEquals("GENEVE", listener.getProtocol());
|
||||
|
||||
service.modifyListener(REGION, listener.getListenerArn(), null, null, null, null,
|
||||
List.of(forwardAction(newTarget)), null);
|
||||
|
||||
Reference in new issue
Block a user