From 1e45832d6b5167aceba598057a5433b1ecf7e307 Mon Sep 17 00:00:00 2001 From: Jimmy Liu Jia <91264074+JimmyLiuJia@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:22:53 +0800 Subject: [PATCH] fix(iam): derive tag-on-create verdicts from botocore (#8081) * fix(iam): derive tag-on-create verdicts from botocore * fix(iam): derive unreadable tag-on-create verdicts per model --- src/main/resources/aws/iam-tag-on-create.json | 6 +- tools/aws/regen_iam_tag_on_create.py | 70 +++++---- tools/aws/test_regen_iam_tag_on_create.py | 135 +++++++++++++++--- 3 files changed, 151 insertions(+), 60 deletions(-) diff --git a/src/main/resources/aws/iam-tag-on-create.json b/src/main/resources/aws/iam-tag-on-create.json index b789dc7213..a43739d848 100644 --- a/src/main/resources/aws/iam-tag-on-create.json +++ b/src/main/resources/aws/iam-tag-on-create.json @@ -239,7 +239,7 @@ "ecs:CreateCluster": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, "ecs:CreateDaemon": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, "ecs:CreateExpressGatewayService": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, - "ecs:CreateGateway": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "notRead": "no member of the request carries tags"}, + "ecs:CreateGateway": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, "ecs:CreateService": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, "ecs:CreateTaskSet": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, "ecs:RegisterContainerInstance": {"tagging": ["ecs:TagResource"], "createAction": true, "requestTags": true, "tags": [{"member": "tags[]", "key": "key", "value": "value"}]}, @@ -383,7 +383,7 @@ "network-firewall:CreateContainerAssociation": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}, "network-firewall:CreateFirewall": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}, "network-firewall:CreateFirewallPolicy": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}, - "network-firewall:CreateFirewallPolicyV2": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "notRead": "no member of the request carries tags"}, + "network-firewall:CreateFirewallPolicyV2": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "notRead": "the pinned botocore does not have the operation yet, so its request cannot be read"}, "network-firewall:CreateProxy": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}, "network-firewall:CreateProxyConfiguration": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}, "network-firewall:CreateProxyRuleGroup": {"tagging": ["network-firewall:TagResource"], "requestTags": true, "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]}, @@ -407,7 +407,7 @@ "rds:CopyOptionGroup": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, "rds:CreateBlueGreenDeployment": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, "rds:CreateCustomDBEngineVersion": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, - "rds:CreateDBCapacityReservation": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "notRead": "no member of the request carries tags"}, + "rds:CreateDBCapacityReservation": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, "rds:CreateDBCluster": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "TagSpecifications[item].Tags[Tag]", "key": "Key", "value": "Value", "resourceType": "ResourceType"}, {"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, "rds:CreateDBClusterEndpoint": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, "rds:CreateDBClusterParameterGroup": {"tagging": ["rds:AddTagsToResource"], "requestTags": true, "tags": [{"member": "Tags[Tag]", "key": "Key", "value": "Value"}]}, diff --git a/tools/aws/regen_iam_tag_on_create.py b/tools/aws/regen_iam_tag_on_create.py index 19656256d8..feeb2be82f 100644 --- a/tools/aws/regen_iam_tag_on_create.py +++ b/tools/aws/regen_iam_tag_on_create.py @@ -42,13 +42,14 @@ that need that action, and is marked `requestTags` when that action takes the re `CreateElasticsearchDomain` beside `es:AddTags`, as the OpenSearch Service developer guide's policy for creating a domain only with a tag grants `es:CreateDomain` and `es:AddTags`. One with no action of its name, or no tagging action going with that action, is left out. -Each of those operations ends up in exactly one of three places, and generation fails on an operation -that would end up in none: +Each of those operations ends up in exactly one of three places: - `tags`: the members it reads. - `byHand`: operations Floci checks itself, because they need one of several tagging actions. `TagOnCreateMembersTest` holds the two lists to each other. -- `notRead`: operations whose request carries no tags this table can read, each with its reason. +- `notRead`: the model has no tag member, the model lacks the operation, or the operation has an + explicit exception because its tags are nested deeper than this file reads. An unreadable protocol + or opaque payload gets its reason from the model as well. An operation whose tagging action takes the namespace's `CreateAction` condition key, as EC2's `ec2:CreateTags` does, is marked `createAction`, and Floci gives that key the operation's name. One @@ -69,8 +70,8 @@ The Service Reference is live rather than a pinned dependency, so a fresh genera byte-identical. The two gates split along the sources: - `--check` is offline and needs the pinned botocore. The file must be well-formed, and every - operation's members must be exactly what the rule and the corrections give from botocore for the - models the file names, so a hand-edited member fails. + operation's members and model-derived `notRead` verdict must be exactly what the rule and the + corrections give from botocore for the models the file names, so a stale verdict fails. - `--verify` is online and stdlib-only. Every operation the file carries must still list the same tagging actions, with the same `createAction` and `requestTags`, for the same SDK clients, and every resource type in `resourceArns` must still have its ARN. An operation AWS has added @@ -160,27 +161,14 @@ BY_HAND = { } NO_TAGS = "no member of the request carries tags" -# For an operation AWS has shipped since the botocore pin. It lasts until a bump brings the operation in, when -# entry_for refuses it, so that its tags are read. +# For an operation AWS has shipped since the botocore pin. A bump bringing the operation in +# replaces this verdict with its tag members (or NO_TAGS). NOT_IN_BOTOCORE = "the pinned botocore does not have the operation yet, so its request cannot be read" -# Operations the reference lists with a tagging action whose request carries no tags this file reads. +UNREADABLE_PROTOCOL = "the request uses a protocol this file does not read" +OPAQUE_PAYLOAD = "the request has an opaque payload this file does not read" +# Operations whose tags need an operation-specific reason instead of the model-derived verdict. NOT_READ = { - "athena:CreateSystemTableConfiguration": NOT_IN_BOTOCORE, - "cloudformation:ExecuteChangeSet": NO_TAGS, - "dynamodb:UpdateTable": NO_TAGS, "ec2:RequestSpotFleet": "its tags are in spotFleetRequestConfig, deeper than the members this file reads", - "ecr:BatchGetImage": NO_TAGS, - "ecs:CreateGateway": NO_TAGS, - "iam:AcquireRole": NO_TAGS, - "rds:CreateDBCapacityReservation": NO_TAGS, - "rds:DeleteDBCluster": NO_TAGS, - "rds:DeleteDBInstance": NO_TAGS, - "rds:DeleteTenantDatabase": NO_TAGS, - "network-firewall:CreateFirewallPolicyV2": NO_TAGS, - "events:StartReplay": NO_TAGS, - "rds:StopDBInstance": NO_TAGS, - "sagemaker:CreateClusterExtension": NOT_IN_BOTOCORE, - "ssm:StartExecutionPreview": NO_TAGS, } # Members the rule reads that carry no tags the operation attaches, each with why. @@ -397,14 +385,20 @@ def _collection(model: dict, shape_name: str) -> dict | None: return None -def tag_members(model: dict, operation: str) -> list[dict]: - """The members of the operation's request the rule reads, as vendored entries.""" - spec = model["operations"].get(operation) - if spec is None or "input" not in spec or not readable(model): - return [] +def tag_members(model: dict, operation: str) -> tuple[list[dict], str | None]: + """The request's tag members, or the model-derived reason none can be read.""" + if operation not in model["operations"]: + return [], NOT_IN_BOTOCORE + spec = model["operations"][operation] + if not isinstance(spec, dict): + raise ValueError(f"{operation}: botocore operation is not an object") + if "input" not in spec: + return [], NO_TAGS + if not readable(model): + return [], UNREADABLE_PROTOCOL root = model["shapes"][spec["input"]["shape"]] if root.get("payload") is not None: - return [] + return [], OPAQUE_PAYLOAD found = [] for name, member in root.get("members", {}).items(): if member.get("location") not in BODY_LOCATIONS or not TAG_MEMBER_RE.match(name): @@ -427,7 +421,7 @@ def tag_members(model: dict, operation: str) -> list[dict]: if len(kinds) == 1: inner_collection["resourceType"] = _serialized(kinds[0], element["members"][kinds[0]], model) found.append({"member": path, **inner_collection}) - return found + return found, None if found else NO_TAGS def resource_arns(documents: list[dict], namespaces: set[str]) -> dict[str, dict[str, str]]: @@ -458,14 +452,13 @@ def entry_for(operation: str, upstream: dict, models: dict[str, dict]) -> dict: return {**head, "byHand": BY_HAND[operation]} name = operation.split(":", 1)[1] if operation in NOT_READ: - if NOT_READ[operation] == NOT_IN_BOTOCORE and any(name in model["operations"] for model in models.values()): - raise ValueError(f"{operation}: the pinned botocore has it now, so take it out of NOT_READ") return {**head, "notRead": NOT_READ[operation]} if len(upstream["tagging"]) != 1: raise ValueError(f"{operation}: needs one of {upstream['tagging']}; check it by hand (BY_HAND)") + readings = [tag_members(model, name) for model in models.values()] members: dict[str, dict] = {} - for model in models.values(): - for member in tag_members(model, name): + for found, _reason in readings: + for member in found: members.setdefault(member["member"], member) for path in EXCLUDED_MEMBERS.get(operation, {}): members.pop(path, None) @@ -474,8 +467,11 @@ def entry_for(operation: str, upstream: dict, models: dict[str, dict]) -> dict: raise ValueError(f"{operation}: QUERY_MEMBERS names {path}, which its request does not have") members[path] = {**members[path], "query": query} if not members: - raise ValueError(f"{operation}: no request member carries tags; say why it is not read (NOT_READ) " - f"or check it by hand (BY_HAND)") + reasons = [reason for _found, reason in readings] + reason = next((item for item in reasons if item in (UNREADABLE_PROTOCOL, OPAQUE_PAYLOAD)), + NO_TAGS if NO_TAGS in reasons or any(found for found, _reason in readings) + else NOT_IN_BOTOCORE) + return {**head, "notRead": reason} return {**head, "tags": [members[path] for path in sorted(members)]} @@ -526,7 +522,7 @@ def _unmatched_exclusions(covered: dict[str, dict], namespaces: dict[str, list[s continue name = operation.split(":", 1)[1] found = {member["member"] for model in load_models(data, set(namespaces[namespace_of(operation)])).values() - for member in tag_members(model, name)} + for member in tag_members(model, name)[0]} problems += [f"EXCLUDED_MEMBERS names {path} for {operation}, which its request does not have" for path in paths if path not in found] return problems diff --git a/tools/aws/test_regen_iam_tag_on_create.py b/tools/aws/test_regen_iam_tag_on_create.py index ae8eac5f92..ea3d1c0a24 100644 --- a/tools/aws/test_regen_iam_tag_on_create.py +++ b/tools/aws/test_regen_iam_tag_on_create.py @@ -155,7 +155,7 @@ def test_a_tag_list_and_a_tag_map_are_read_with_their_key_and_value_names(): "KmsTag": structure(TagKey="String", TagValue="String"), **TAG_SHAPES, }) - assert r.tag_members(m, "Op") == [ + assert r.tag_members(m, "Op")[0] == [ {"member": "Tags[]", "key": "Key", "value": "Value"}, {"member": "ResourceTags[]", "key": "TagKey", "value": "TagValue"}, {"member": "UserPoolTags{}"}, @@ -171,14 +171,14 @@ def test_tag_specifications_are_read_through_their_list(): "Ec2Tag": structure(Key={"shape": "String", "locationName": "key"}, Value={"shape": "String", "locationName": "value"}), }, protocol="ec2") - assert r.tag_members(m, "Op") == [ + assert r.tag_members(m, "Op")[0] == [ {"member": "TagSpecification[item].Tag[item]", "key": "Key", "value": "Value", "resourceType": "ResourceType"}] def test_a_specification_naming_no_resource_type_gives_none(): m = model({"Op": "In"}, {"In": structure(TagSpecifications="Specs"), "Specs": {"type": "list", "member": {"shape": "Spec"}}, "Spec": structure(Tags="TagList"), **TAG_SHAPES}) - assert r.tag_members(m, "Op") == [{"member": "TagSpecifications[].Tags[]", "key": "Key", "value": "Value"}] + assert r.tag_members(m, "Op")[0] == [{"member": "TagSpecifications[].Tags[]", "key": "Key", "value": "Value"}] def test_each_resource_type_s_arn_keeps_the_partition_region_and_account_and_leaves_the_rest_open(): @@ -196,7 +196,7 @@ def test_each_resource_type_s_arn_keeps_the_partition_region_and_account_and_lea def test_an_ec2_query_name_wins_over_its_location_name(): m = model({"Op": "In"}, {"In": structure(Tags={"shape": "TagList", "locationName": "tags", "queryName": "Tag"}), **TAG_SHAPES}, protocol="ec2") - assert r.tag_members(m, "Op") == [{"member": "Tag[]", "key": "Key", "value": "Value"}] + assert r.tag_members(m, "Op")[0] == [{"member": "Tag[]", "key": "Key", "value": "Value"}] def test_members_named_otherwise_nested_deeper_or_holding_no_tags_are_not_read(): @@ -207,19 +207,19 @@ def test_members_named_otherwise_nested_deeper_or_holding_no_tags_are_not_read() "Keys": {"type": "list", "member": {"shape": "String"}}, **TAG_SHAPES, }) - assert r.tag_members(m, "Op") == [] + assert r.tag_members(m, "Op") == ([], r.NO_TAGS) def test_a_member_bound_to_the_uri_a_header_or_the_query_string_is_not_read(): m = model({"Op": "In"}, {"In": structure(Tags={"shape": "TagMap", "location": "header"}, tags="TagMap"), **TAG_SHAPES}, protocol="rest-json") - assert r.tag_members(m, "Op") == [{"member": "tags{}"}] + assert r.tag_members(m, "Op")[0] == [{"member": "tags{}"}] @pytest.mark.parametrize("protocol", ["rest-xml"]) def test_a_model_whose_requests_are_not_read_has_no_members(protocol): m = model({"Op": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}, protocol=protocol) - assert r.tag_members(m, "Op") == [] + assert r.tag_members(m, "Op") == ([], r.UNREADABLE_PROTOCOL) # --------------------------------------------------------------------------- # @@ -238,6 +238,89 @@ def test_an_operation_reads_its_members_for_its_one_tagging_action(corrections): "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]} +def test_a_modeled_operation_without_tag_members_derives_no_tags(corrections): + models = {"svc": model({"CreateThing": "In"}, {"In": structure(Name="String")})} + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "notRead": r.NO_TAGS} + + +def test_an_unreadable_client_does_not_derive_no_tags_from_another_client(corrections): + models = { + "svc": model({"CreateThing": "In"}, {"In": structure(Name="String")}), + "svc-xml": model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}, + protocol="rest-xml"), + } + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "notRead": r.UNREADABLE_PROTOCOL} + + +def test_an_unreadable_client_does_not_hide_another_client_s_tag_members(corrections): + models = { + "svc": model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}), + "svc-xml": model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}, + protocol="rest-xml"), + } + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]} + + +def test_an_opaque_client_does_not_hide_another_client_s_tag_members(corrections): + opaque = model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}) + opaque["shapes"]["In"]["payload"] = "Tags" + models = {"svc": opaque, "svcv2": SIMPLE["svc"]} + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]} + + +def test_an_unreadable_client_derives_its_reason_without_a_hand_entry(corrections): + models = {"svc-xml": model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}, + protocol="rest-xml")} + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "notRead": r.UNREADABLE_PROTOCOL} + + +def test_an_opaque_payload_does_not_derive_no_tags(corrections): + opaque = model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES}) + opaque["shapes"]["In"]["payload"] = "Tags" + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), {"svc": opaque}) == { + "tagging": ["svc:TagResource"], "notRead": r.OPAQUE_PAYLOAD} + tagless = model({"CreateThing": "In"}, {"In": structure(Name="String")}) + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), {"svc": tagless, "svcv2": opaque}) == { + "tagging": ["svc:TagResource"], "notRead": r.OPAQUE_PAYLOAD} + + +def test_an_operation_absent_from_the_pinned_models_derives_not_in_botocore(corrections): + models = {"svc": model({"CreateOther": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES})} + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "notRead": r.NOT_IN_BOTOCORE} + + +def test_a_modeled_operation_without_input_derives_no_tags(corrections): + no_input = model({}, {}) + no_input["operations"]["CreateThing"] = {} + assert r.tag_members(no_input, "CreateThing") == ([], r.NO_TAGS) + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), {"svc": no_input}) == { + "tagging": ["svc:TagResource"], "notRead": r.NO_TAGS} + + +def test_a_malformed_modeled_operation_is_not_reported_as_absent(corrections): + malformed = model({}, {}) + malformed["operations"]["CreateThing"] = None + with pytest.raises(ValueError, match="botocore operation is not an object"): + r.entry_for("svc:CreateThing", upstream("svc:TagResource"), {"svc": malformed}) + + +@pytest.mark.parametrize("operation, client, member", [ + ("ecs:CreateGateway", "ecs", {"member": "tags[]", "key": "key", "value": "value"}), + ("rds:CreateDBCapacityReservation", "rds", {"member": "Tags[Tag]", "key": "Key", "value": "Value"}), +]) +def test_a_stale_no_tags_verdict_cannot_hide_modeled_request_tags(operation, client, member): + data, _ = r.resolve_botocore_data(None) + models = r.load_models(data, {client}) + assert r.entry_for(operation, upstream(f"{client}:TagResource"), models) == { + "tagging": [f"{client}:TagResource"], "tags": [member]} + + def test_several_tagging_actions_must_be_checked_by_hand(corrections): with pytest.raises(ValueError, match="BY_HAND"): r.entry_for("svc:CreateThing", upstream("svc:TagResource", "svc:TagThing"), SIMPLE) @@ -246,23 +329,20 @@ def test_several_tagging_actions_must_be_checked_by_hand(corrections): "tagging": ["svc:TagResource", "svc:TagThing"], "byHand": "either action"} -def test_an_operation_carrying_no_tags_must_say_why(corrections): - models = {"svc": model({"CreateThing": "In"}, {"In": structure(Name="String")})} - with pytest.raises(ValueError, match="NOT_READ"): - r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) - corrections.setattr(r, "NOT_READ", {"svc:CreateThing": "no member of the request carries tags"}) - assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { - "tagging": ["svc:TagResource"], "notRead": "no member of the request carries tags"} - - -def test_an_operation_botocore_does_not_have_yet_is_not_read_until_a_bump_brings_it(corrections): - corrections.setattr(r, "NOT_READ", {"svc:CreateThing": r.NOT_IN_BOTOCORE}) +def test_an_operation_absent_from_botocore_is_read_after_a_model_bump(corrections): before = {"svc": model({"CreateOther": "In"}, {"In": structure(Name="String")})} assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), before) == { "tagging": ["svc:TagResource"], "notRead": r.NOT_IN_BOTOCORE} bumped = {"svc": model({"CreateThing": "In"}, {"In": structure(Tags="TagList"), **TAG_SHAPES})} - with pytest.raises(ValueError, match="take it out of NOT_READ"): - r.entry_for("svc:CreateThing", upstream("svc:TagResource"), bumped) + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), bumped) == { + "tagging": ["svc:TagResource"], "tags": [{"member": "Tags[]", "key": "Key", "value": "Value"}]} + + +def test_an_explicit_exception_keeps_its_reason(corrections): + corrections.setattr(r, "NOT_READ", {"svc:CreateThing": "tags nested deeper than this file reads"}) + models = {"svc": model({"CreateThing": "In"}, {"In": structure(Name="String")})} + assert r.entry_for("svc:CreateThing", upstream("svc:TagResource"), models) == { + "tagging": ["svc:TagResource"], "notRead": "tags nested deeper than this file reads"} def test_an_exclusion_drops_a_member_and_a_query_name_is_added(corrections): @@ -308,6 +388,15 @@ def test_a_hand_edited_member_does_not_match_botocore(corrections, tmp_path): assert len(r.derive(document, tmp_path)) == 1 +def test_a_stale_not_read_verdict_does_not_match_botocore(corrections, tmp_path): + write_models(tmp_path, SIMPLE) + document = r.build([reference("svc", {"CreateThing": ["svc:TagResource"]})], "test", tmp_path, "botocore test") + document["operations"]["svc:CreateThing"] = { + "tagging": ["svc:TagResource"], "notRead": r.NO_TAGS} + assert r.validate(document) == [] + assert len(r.derive(document, tmp_path)) == 1 + + def test_a_correction_naming_an_operation_the_reference_does_not_list_fails(corrections, tmp_path): write_models(tmp_path, SIMPLE) corrections.setattr(r, "NOT_READ", {"svc:Gone": "no member of the request carries tags"}) @@ -423,6 +512,12 @@ def test_the_vendored_file_is_well_formed(): assert document["resourceArns"]["ec2"]["instance"] == "arn:${Partition}:ec2:${Region}:${Account}:instance/*" assert document["resourceArns"]["ec2"]["image"] == "arn:${Partition}:ec2:${Region}::image/*" assert operations["budgets:CreateBudget"]["requestTags"] is True + assert operations["ecs:CreateGateway"]["tags"] == [ + {"member": "tags[]", "key": "key", "value": "value"}] + assert operations["rds:CreateDBCapacityReservation"]["tags"] == [ + {"member": "Tags[Tag]", "key": "Key", "value": "Value"}] + assert operations["network-firewall:CreateFirewallPolicyV2"]["notRead"] == r.NOT_IN_BOTOCORE + assert operations["ec2:RequestSpotFleet"]["notRead"] == r.NOT_READ["ec2:RequestSpotFleet"] # The opensearch client's CreateDomain, which the reference does not list, as es's CreateElasticsearchDomain. assert document["namespaces"]["es"] == ["es", "opensearch"] for operation in ("es:CreateDomain", "es:CreateElasticsearchDomain"):