From 6dfad9c907a51f07c86e0dd2a1933d207cfc7baf Mon Sep 17 00:00:00 2001 From: Joseph Torcasso Date: Wed, 9 Mar 2022 10:16:24 -0500 Subject: [PATCH] update unit tests and changelog --- .../696-elbv2-support-alb-attributes.yml | 2 +- tests/unit/module_utils/test_elbv2.py | 43 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/changelogs/fragments/696-elbv2-support-alb-attributes.yml b/changelogs/fragments/696-elbv2-support-alb-attributes.yml index a725959722b..7509ed61a5d 100644 --- a/changelogs/fragments/696-elbv2-support-alb-attributes.yml +++ b/changelogs/fragments/696-elbv2-support-alb-attributes.yml @@ -1,2 +1,2 @@ minor_changes: - - elbv2 - Add support for alb specific attributes (https://github.com/ansible-collections/amazon.aws/pull/696). + - module_utils.elbv2 - Add support for alb specific attributes in module_utils.elbv2 (https://github.com/ansible-collections/amazon.aws/pull/696). diff --git a/tests/unit/module_utils/test_elbv2.py b/tests/unit/module_utils/test_elbv2.py index 3ad6c5ebd1f..1b43b3f1ac1 100644 --- a/tests/unit/module_utils/test_elbv2.py +++ b/tests/unit/module_utils/test_elbv2.py @@ -114,7 +114,27 @@ def setUp(self): { "Value": "true", "Key": "routing.http2.enabled" - } + }, + { + "Value": "defensive", + "Key": "routing.http.desync_mitigation_mode" + }, + { + "Value": "true", + "Key": "routing.http.drop_invalid_header_fields.enabled" + }, + { + "Value": "true", + "Key": "routing.http.x_amzn_tls_version_and_cipher_suite.enabled" + }, + { + "Value": "true", + "Key": "routing.http.xff_client_port.enabled" + }, + { + "Value": "true", + "Key": "waf.fail_open.enabled" + }, ] } self.connection.describe_tags.return_value = { @@ -165,3 +185,24 @@ def test_modify_ip_address_type_update(self): self.connection.set_ip_address_type.assert_called_once() # assert we got the expected value self.assertEqual(self.elbv2obj.changed, True) + + # Test get_elb_attributes + def test_get_elb_attributes(self): + # Build expected result + expected_elb_attributes = { + "access_logs_s3_bucket": "", + "access_logs_s3_enabled": "false", + "access_logs_s3_prefix": "", + "deletion_protection_enabled": "false", + "idle_timeout_timeout_seconds": "60", + "routing_http2_enabled": "true", + "routing_http_desync_mitigation_mode": "defensive", + "routing_http_drop_invalid_header_fields_enabled": "true", + "routing_http_x_amzn_tls_version_and_cipher_suite_enabled": "true", + "routing_http_xff_client_port_enabled": "true", + "waf_fail_open_enabled": "true" + } + # Run module + actual_elb_attributes = self.elbv2obj.get_elb_attributes() + # Assert we got the expected result + self.assertEqual(actual_elb_attributes, expected_elb_attributes)