mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
#9743 read which queue each action of a message move task is checked on from two parameter sentences of the API reference picked one by one (SourceArn's "only ARNs of dead-letter queues (DLQs)", DestinationArn's "specify the destination queue"), a list of the three operations' pages, and a reading of its own for ListMessageMoveTasks: a queue no parameter named was the one the row named the operation's own action of. The developer guide's steps to configure a redrive's minimum permissions group the actions by queue instead: "Permissions for the DLQ (source queue): sqs:StartMessageMoveTask, ..., sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueAttributes" and "Permissions for destination queue: sqs:SendMessage". The fetcher now copies those groups, and group_permission_resources places each action the Service Reference lists an operation as authorized by on the queue its group names, the member of the request the group's words name as the generator's names go (the source queue is SourceArn, the destination queue DestinationArn), as CodeArtifact's destination repository is its destinationRepository. The parameter sentences, the list of operations and the own-queue reading are gone. The table is unchanged.
58 lines
2.8 KiB
Python
58 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for fetch_sqs_redrive_permissions.py, on a page in the Amazon SQS developer guide's markup."""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
import fetch_sqs_redrive_permissions as f
|
|
|
|
|
|
def group(heading: str, *items: str) -> str:
|
|
listed = "".join(f'<li class="listitem">\n<p>{item}</p>\n</li>' for item in items)
|
|
return (f'<li class="listitem">\n<p>{heading}</p>\n<div class="itemizedlist">\n'
|
|
f'<ul class="itemizedlist">{listed}</ul></div>\n</li>')
|
|
|
|
|
|
def code(action: str) -> str:
|
|
return f'<code class="code">{action}</code>'
|
|
|
|
|
|
SOURCE = group("Permissions for the DLQ (source queue):", code("sqs:StartMessageMoveTask"),
|
|
code("sqs:ReceiveMessage"), code("sqs:GetQueueAttributes"),
|
|
"Specify the <b>Resource ARN</b> of the DLQ (source queue).")
|
|
DESTINATION = group("Permissions for destination queue:", code("sqs:SendMessage"),
|
|
"Specify the <code class=\"code\">Resource ARN</code> of the destination queue.")
|
|
KEYS = group("Permissions for KMS keys:", code("kms:Decrypt") + " (Needed to decrypt messages in the DLQ.)")
|
|
STEPS = group("Create a new <b>policy</b> and add the following permissions.", "Open the IAM console.")
|
|
|
|
|
|
def page(*groups: str) -> str:
|
|
listed = groups or (SOURCE, DESTINATION, KEYS)
|
|
return ('<div id="main-col-body"><h1>Redrive</h1><h6>To configure permissions for an encrypted queue pair</h6>'
|
|
f'<ol><li><div class="itemizedlist"><ul class="itemizedlist">{STEPS}{"".join(listed)}</ul></div></li></ol>'
|
|
'</div><div class="prev-next"></div>')
|
|
|
|
|
|
def test_each_group_is_read_with_its_steps_the_resource_its_heading_names_and_its_actions():
|
|
built = f.build(page())
|
|
# A list item that is no "Permissions for ..." heading, as the console steps, is not a group.
|
|
assert [(found["resource"], found["actions"]) for found in built["groups"]] == [
|
|
("source queue", ["sqs:StartMessageMoveTask", "sqs:ReceiveMessage", "sqs:GetQueueAttributes"]),
|
|
("destination queue", ["sqs:SendMessage"]),
|
|
("KMS keys", ["kms:Decrypt"])]
|
|
assert {found["section"] for found in built["groups"]} == {"To configure permissions for an encrypted queue pair"}
|
|
assert built["groups"][0]["heading"] == "Permissions for the DLQ (source queue):"
|
|
|
|
|
|
def test_a_page_whose_layout_or_wording_changed_is_refused():
|
|
with pytest.raises(ValueError, match="no group of sqs: permissions for a queue"):
|
|
f.build(page(KEYS))
|
|
with pytest.raises(ValueError, match="with no action"):
|
|
f.build(page(group("Permissions for destination queue:", "Specify the destination queue.")))
|
|
|
|
|
|
def test_the_file_is_stale_when_the_page_says_something_else():
|
|
vendored = f.build(page())
|
|
assert not f.stale(vendored, page())
|
|
assert f.stale(vendored, page(SOURCE, DESTINATION.replace("sqs:SendMessage", "sqs:SendMessageBatch"), KEYS))
|