From 1e85e16f0ffdc43fc919c6c28dd16756a9e93e32 Mon Sep 17 00:00:00 2001 From: Julio Cesar Date: Sat, 6 Nov 2021 09:37:19 -0300 Subject: [PATCH] Fix missing valid_attrs (issue 4529) (#4530) --- moto/elbv2/models.py | 2 ++ tests/test_elbv2/test_elbv2.py | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/moto/elbv2/models.py b/moto/elbv2/models.py index 64ee30047..137c1642e 100644 --- a/moto/elbv2/models.py +++ b/moto/elbv2/models.py @@ -425,6 +425,8 @@ class FakeLoadBalancer(CloudFormationModel): "access_logs.s3.prefix", "deletion_protection.enabled", "idle_timeout.timeout_seconds", + "routing.http2.enabled", + "routing.http.drop_invalid_header_fields.enabled", } def __init__( diff --git a/tests/test_elbv2/test_elbv2.py b/tests/test_elbv2/test_elbv2.py index 8fd0bf5d2..63ecf9b69 100644 --- a/tests/test_elbv2/test_elbv2.py +++ b/tests/test_elbv2/test_elbv2.py @@ -1146,6 +1146,50 @@ def test_modify_load_balancer_attributes_idle_timeout(): idle_timeout["Value"].should.equal("600") +@mock_elbv2 +@mock_ec2 +def test_modify_load_balancer_attributes_routing_http2_enabled(): + response, _, _, _, _, client = create_load_balancer() + arn = response["LoadBalancers"][0]["LoadBalancerArn"] + + client.modify_load_balancer_attributes( + LoadBalancerArn=arn, + Attributes=[{"Key": "routing.http2.enabled", "Value": "false"}], + ) + + response = client.describe_load_balancer_attributes(LoadBalancerArn=arn) + routing_http2_enabled = list( + filter( + lambda item: item["Key"] == "routing.http2.enabled", response["Attributes"], + ) + )[0] + routing_http2_enabled["Value"].should.equal("false") + + +@mock_elbv2 +@mock_ec2 +def test_modify_load_balancer_attributes_routing_http_drop_invalid_header_fields_enabled(): + response, _, _, _, _, client = create_load_balancer() + arn = response["LoadBalancers"][0]["LoadBalancerArn"] + + client.modify_load_balancer_attributes( + LoadBalancerArn=arn, + Attributes=[ + {"Key": "routing.http.drop_invalid_header_fields.enabled", "Value": "false"} + ], + ) + + response = client.describe_load_balancer_attributes(LoadBalancerArn=arn) + routing_http_drop_invalid_header_fields_enabled = list( + filter( + lambda item: item["Key"] + == "routing.http.drop_invalid_header_fields.enabled", + response["Attributes"], + ) + )[0] + routing_http_drop_invalid_header_fields_enabled["Value"].should.equal("false") + + @mock_elbv2 @mock_ec2 @mock_acm