Operation
Does a thing.
{"".join(paragraphs)}' f'#!/usr/bin/env python3 """Tests for fetch_secretsmanager_required_permissions.py, on the Service Reference and pages in the AWS Secrets Manager API reference's markup.""" from __future__ import annotations import pytest import fetch_secretsmanager_required_permissions as f def operation(name: str, *actions: str) -> dict: return {"Name": name, "AuthorizedActions": [{"Service": action.split(":")[0], "Name": action.split(":")[1]} for action in (f"secretsmanager:{name}", *actions)]} REFERENCE = {"Operations": [ operation("BatchGetSecretValue", "secretsmanager:GetSecretValue", "secretsmanager:ListSecrets"), operation("CreateSecret", "secretsmanager:ReplicateSecretToRegions"), # An operation authorized by its own action, or by another namespace's beside it, has no page read. operation("DescribeSecret"), operation("RotateSecret", "iam:PassRole"), ]} BATCH = ("
Required permissions: secretsmanager:BatchGetSecretValue, and you must have\n"
"secretsmanager:GetSecretValue for each secret. If you use filters, you must also have\n"
"secretsmanager:ListSecrets. If the secrets are encrypted using customer-managed keys, then you also "
"need kms:Decrypt permissions for the keys.
Required permissions: secretsmanager:CreateSecret. If you include tags in the secret, you "
"also need secretsmanager:TagResource. To add replica Regions, you must also have "
"secretsmanager:ReplicateSecretToRegions.
Does a thing.
{"".join(paragraphs)}' f'Permissions: secretsmanager:BatchGetSecretValue.
")) with pytest.raises(ValueError, match="which names no action as they did"): f.build(REFERENCE, pages(batch="Required permissions: secretsmanager:BatchGetSecretValue, or a key.
")) # A conditional sentence AWS rewords is refused rather than dropping its action. with pytest.raises(ValueError, match="gives a secretsmanager: action in no wording they used"): f.build(REFERENCE, pages(batch=BATCH.replace("If you use filters, you must also have", "With filters, you need"))) def test_the_file_is_stale_when_the_reference_or_a_page_says_something_else(): vendored = f.build(REFERENCE, pages()) assert not f.stale(vendored, REFERENCE, pages()) assert f.stale(vendored, REFERENCE, pages(create=CREATE.replace("To add replica Regions", "To add Regions"))) fewer = {"Operations": REFERENCE["Operations"][1:]} assert f.stale(vendored, fewer, pages())