feat(aws): add tags to Global Accelerator (#5233)

This commit is contained in:
Rubén De la Torre Vico
2024-09-27 18:37:19 +02:00
committed by GitHub
parent b402ced402
commit 13e40eb03e
4 changed files with 43 additions and 1 deletions
@@ -42,6 +42,8 @@ def mock_make_api_call(self, operation_name, kwarg):
}
if operation_name == "GetSubscriptionState":
return {"SubscriptionState": "ACTIVE"}
if operation_name == "ListTagsForResource":
return {"Tags": [{"Key": "Name", "Value": "TestAccelerator"}]}
return make_api_call(self, operation_name, kwarg)
@@ -94,3 +96,18 @@ class Test_GlobalAccelerator_Service:
== AWS_REGION_US_WEST_2
)
assert globalaccelerator.accelerators[TEST_ACCELERATOR_ARN].enabled
def test_list_tags(self):
# GlobalAccelerator client for this test class
aws_provider = set_mocked_aws_provider()
globalaccelerator = GlobalAccelerator(aws_provider)
assert len(globalaccelerator.accelerators) == 1
assert (
globalaccelerator.accelerators[TEST_ACCELERATOR_ARN].tags[0]["Key"]
== "Name"
)
assert (
globalaccelerator.accelerators[TEST_ACCELERATOR_ARN].tags[0]["Value"]
== "TestAccelerator"
)
@@ -43,6 +43,7 @@ class Test_shield_advanced_protection_in_global_accelerators:
name=accelerator_name,
region=AWS_REGION_EU_WEST_1,
enabled=True,
tags=[{"Key": "Name", "Value": "TestAccelerator"}],
)
}
@@ -85,6 +86,9 @@ class Test_shield_advanced_protection_in_global_accelerators:
result[0].status_extended
== f"Global Accelerator {accelerator_id} is protected by AWS Shield Advanced."
)
assert result[0].resource_tags == [
{"Key": "Name", "Value": "TestAccelerator"}
]
def test_shield_enabled_globalaccelerator_not_protected(self):
# GlobalAccelerator Client
@@ -98,6 +102,7 @@ class Test_shield_advanced_protection_in_global_accelerators:
name=accelerator_name,
region=AWS_REGION_EU_WEST_1,
enabled=True,
tags=[{"Key": "Name", "Value": "TestAccelerator"}],
)
}
@@ -131,6 +136,9 @@ class Test_shield_advanced_protection_in_global_accelerators:
result[0].status_extended
== f"Global Accelerator {accelerator_id} is not protected by AWS Shield Advanced."
)
assert result[0].resource_tags == [
{"Key": "Name", "Value": "TestAccelerator"}
]
def test_shield_disabled_globalaccelerator_not_protected(self):
# GlobalAccelerator Client