mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 08:31:53 -05:00
Under enforcement a CreateAccessEntry scoped by eks:principalArn or eks:accessEntryType was refused for every entry, and an AssociateAccessPolicy scoped by eks:policyArn or eks:namespaces for every association, as #8311 reports: the request condition key table read none of these keys, so a condition on them never saw a value. Neither botocore nor the Service Reference says which request member carries them. The Service Authorization Reference's table of the keys EKS defines says it: eks:principalArn, eks:kubernetesGroups, eks:policyArn and eks:namespaces filter on "the <member> present in the access entry requests" or in "the associate / disassociate access policy requests", and eks:accessEntryType and eks:username on "the access entry type" and "the Kubernetes username" present in them, the access entry requests' type and username. A vendored source, tools/aws/sources/eks-condition-keys.json, written by tools/aws/fetch_eks_conditions.py from that page, gives each key its member, and the generator reads it for eks (CONDITION_SOURCES) beside the cluster keys it already reads. The page gives what a request carries, so a vendored key is read from an action's request only where the reference lists it on the action itself; one the reference gives a resource type alone is the stored resource's value. A list's values are each read (kubernetesGroups, accessScope.namespaces). A vendored member the request carries outside its body, as DisassociateAccessPolicy carries policyArn in its path, or as a structure, as accessScope is, the page not saying which of its values the key holds, is not read. The keys the reference gives the access entry itself, its stored principal, type, groups and username on the operations acting on one, are not read yet: those requests are checked on an access entry ARN whose identity and id are left open, which names no one entry to read them from. Closes #8311.
53 lines
2.5 KiB
Python
53 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Tests for fetch_eks_conditions.py, on a page in the Service Authorization Reference's markup."""
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
import fetch_eks_conditions as f
|
|
|
|
SERVICE = " the user makes to the EKS service"
|
|
|
|
|
|
def row(key: str, description: str) -> str:
|
|
return f'<tr><td><a id="key-{key}">{key}</a></td><td>{description}</td><td>String</td></tr>'
|
|
|
|
|
|
ROWS = (row("eks:principalArn", "Filters access by the principalArn present in the access entry requests requests"
|
|
+ SERVICE)
|
|
+ row("eks:accessEntryType", "Filters access by the access entry type present in the access entry requests"
|
|
+ SERVICE)
|
|
+ row("eks:namespaces", "Filters access by the namespaces present in the associate / disassociate access "
|
|
"policy requests" + SERVICE)
|
|
+ row("eks:authenticationMode", "Filters access by the authenticationMode present in the create / update "
|
|
"cluster request"))
|
|
|
|
|
|
def page(rows: str = ROWS) -> str:
|
|
return f"<table><tr><th>Condition keys</th><th>Description</th><th>Type</th></tr>{rows}</table>"
|
|
|
|
|
|
def test_each_access_entry_key_is_read_from_the_member_its_row_names():
|
|
keys = {entry["key"]: entry for entry in f.build(lambda url: page())["keys"]}
|
|
assert keys["eks:principalArn"]["member"] == "principalArn"
|
|
# A member named in words is the one those words name.
|
|
assert keys["eks:accessEntryType"]["member"] == "type"
|
|
assert keys["eks:namespaces"]["requests"] == "associate / disassociate access policy requests"
|
|
# A key of another request is not read here.
|
|
assert "eks:authenticationMode" not in keys
|
|
assert keys["eks:principalArn"]["row"].endswith("requests requests the user makes to the EKS service")
|
|
|
|
|
|
def test_a_page_whose_layout_changed_is_refused():
|
|
with pytest.raises(ValueError, match="no table"):
|
|
f.build(lambda url: "<table></table>")
|
|
with pytest.raises(ValueError, match="no member's name"):
|
|
f.build(lambda url: page(row("eks:principalArn", "Filters access by the principal ARN of the entry present "
|
|
"in the access entry requests" + SERVICE)))
|
|
|
|
|
|
def test_the_file_is_stale_when_the_page_says_something_else():
|
|
vendored = f.build(lambda url: page())
|
|
assert not f.stale(vendored, page())
|
|
assert f.stale(vendored, page(ROWS.replace("the principalArn present", "the principal present")))
|