diff --git a/moto/resourcegroupstaggingapi/models.py b/moto/resourcegroupstaggingapi/models.py index 850ab5c04..8c17864f3 100644 --- a/moto/resourcegroupstaggingapi/models.py +++ b/moto/resourcegroupstaggingapi/models.py @@ -318,7 +318,7 @@ class ResourceGroupsTaggingAPIBackend(BaseBackend): # KMS def get_kms_tags(kms_key_id): result = [] - for tag in self.kms_backend.list_resource_tags(kms_key_id): + for tag in self.kms_backend.list_resource_tags(kms_key_id).get("Tags",[]): result.append({"Key": tag["TagKey"], "Value": tag["TagValue"]}) return result diff --git a/tests/test_events/test_events.py b/tests/test_events/test_events.py index cf3743d34..80fadb449 100644 --- a/tests/test_events/test_events.py +++ b/tests/test_events/test_events.py @@ -10,9 +10,6 @@ from moto.core.exceptions import JsonRESTError from nose.tools import assert_raises from moto.core import ACCOUNT_ID -<< << << < HEAD -== == == = ->>>>>> > 100dbd529f174f18d579a1dcc066d55409f2e38f RULES = [ {"Name": "test1", "ScheduleExpression": "rate(5 minutes)"}, @@ -461,10 +458,6 @@ def test_delete_event_bus_errors(): ) -<< << << < HEAD -== == == = - ->>>>>> > 100dbd529f174f18d579a1dcc066d55409f2e38f @mock_events def test_rule_tagging_happy(): client = generate_environment() diff --git a/tests/test_kms/test_kms.py b/tests/test_kms/test_kms.py index d2dca6786..d00c885f2 100644 --- a/tests/test_kms/test_kms.py +++ b/tests/test_kms/test_kms.py @@ -682,7 +682,7 @@ def test__assert_default_policy(): ) -@mock_kms +@mock_kms_deprecated def test_key_tagging_happy(): client = boto3.client("kms", region_name="us-east-1") key = client.create_key(Description="test-key-tagging") @@ -702,7 +702,7 @@ def test_key_tagging_happy(): assert expected == actual -@mock_kms +@mock_kms_deprecated def test_key_tagging_sad(): b = KmsBackend() diff --git a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py index 3ee517ce8..dc75bb722 100644 --- a/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py +++ b/tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py @@ -248,3 +248,26 @@ def test_get_many_resources(): ) # TODO test pagenation + + +@mock_kms +def test_get_kms_tags(): + kms = boto3.client("kms", region_name="us-east-1") + key = kms.create_key( + KeyUsage="ENCRYPT_DECRYPT", + Tags=[ + {"TagKey": "key_name", "TagValue": "a_value"}, + {"TagKey": "key_2", "TagValue": "val2"}, + ], + ) + key_id = key["KeyMetadata"]["KeyId"] + + rtapi = boto3.client("resourcegroupstaggingapi", region_name="us-east-1") + resp = rtapi.get_resources( + ResourceTypeFilters=["kms"], + TagFilters=[{"Key": "key_name"}], + ) + resp["ResourceTagMappingList"].should.have.length_of(1) + resp["ResourceTagMappingList"][0]["Tags"].should.contain( + {"Key": "key_name", "Value": "a_value"} + )