mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
chore(iam): regenerate the request resources table for OAM's link and sink types (#9108)
The Service Reference now lists both the Link and the Sink resource types for OAM's CreateLink and UpdateLink, so iam-request-resources-verify fails on every change touching the table. make iam-request-resources-sync, with no change to the generator, brings them in: CreateLink is checked on the sink it names and now on the link it makes too, link/* in the caller's account and Region, and UpdateLink, whose Identifier holds a link's ARN, on the same link as before. The same run brings in Textract's blueprint, job and project types for its tag actions, which Floci does not serve. RequestResourcesTest expects the made link, the REST route enforcement test grants it with the sink and refuses a grant on the sink alone, and the table-wide member test gives an ARN member that also fills a resource of one of its types an ARN of that type.
This commit is contained in:
1 parent
6b420b166f
commit
751f84079f
4 files changed
+40
-19
No files matched your search
@@ -492,7 +492,8 @@ class RequestResourceMembersTest {
|
||||
.map(resource -> DynamicTest.dynamicTest(operation.getKey() + " " + resource, () -> {
|
||||
String namespace = operation.getKey().substring(0, operation.getKey().indexOf(':'));
|
||||
String name = operation.getKey().substring(namespace.length() + 1);
|
||||
ArnFormat format = table.formats().get(namespace).get(resource.types().getFirst());
|
||||
String type = exampleType(resource, operation.getValue());
|
||||
ArnFormat format = table.formats().get(namespace).get(type);
|
||||
String arn = example(format.format());
|
||||
String account = resource.account() != null ? "111122223333" : "000000000000";
|
||||
String expected = resource.arn() != null || resource.through() != null || resource.byDefault() ? arn
|
||||
@@ -536,7 +537,7 @@ class RequestResourceMembersTest {
|
||||
});
|
||||
List<String> named = operation.getValue().stream()
|
||||
.filter(other -> (other == resource || named(other) || sharesAMember(other, given)
|
||||
|| fillsFromTheArn(other, resource)
|
||||
|| fillsFromTheArn(other, resource, type)
|
||||
|| !other.find().isEmpty() && other.find().equals(resource.find())
|
||||
&& other.when().equals(resource.when()) && other.unless().equals(resource.unless()))
|
||||
&& (other.endpoint() == null || resource.endpoint() == null
|
||||
@@ -629,12 +630,25 @@ class RequestResourceMembersTest {
|
||||
/**
|
||||
* Whether a resource fills its variables from the ARN the other's member holds, as that ARN's type's variable alone
|
||||
* (a permission set made in the instance an {@code InstanceArn} names), so a request naming the other by an ARN of
|
||||
* its first type, which the test gives, names it too.
|
||||
* the type the test gives names it too.
|
||||
*/
|
||||
private static boolean fillsFromTheArn(Resource resource, Resource other) {
|
||||
private static boolean fillsFromTheArn(Resource resource, Resource other, String type) {
|
||||
return other.arn() != null && !resource.fill().isEmpty()
|
||||
&& resource.fill().values().stream().allMatch(other.arn()::equals)
|
||||
&& other.types().getFirst().equals(resource.arnOf().get(other.arn().path()));
|
||||
&& type.equals(resource.arnOf().get(other.arn().path()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the ARN the test gives a resource's member: for an ARN member that also fills a resource of one of
|
||||
* the types it is read as, that resource's type, as the member holds one of those (OAM's {@code CreateLink} reads
|
||||
* its {@code SinkIdentifier} as a link or a sink and fills the sink from it); else its first type.
|
||||
*/
|
||||
private static String exampleType(Resource resource, List<Resource> resources) {
|
||||
return resource.arn() == null ? resource.types().getFirst() : resources.stream()
|
||||
.filter(other -> other.arn() == null && other.fill().containsValue(resource.arn())
|
||||
&& !other.arnOf().containsKey(resource.arn().path())
|
||||
&& resource.types().contains(other.types().getFirst()))
|
||||
.map(other -> other.types().getFirst()).findFirst().orElse(resource.types().getFirst());
|
||||
}
|
||||
|
||||
/** Whether every request of its operation names the resource: no member names it and no member's value selects it. */
|
||||
|
||||
@@ -336,7 +336,8 @@ class RequestResourcesTest {
|
||||
/**
|
||||
* An ARN naming another account whose service acts on that account's resource for the caller (the sink an OAM
|
||||
* link is made to, a RAM invitation sent to it) is that resource alone, never the caller's of that name too; one
|
||||
* the service holds no such resource under is still checked as the caller's own too.
|
||||
* the service holds no such resource under is still checked as the caller's own too. The link {@code CreateLink}
|
||||
* makes is the caller's.
|
||||
*/
|
||||
@Test
|
||||
void anArnOfAnotherAccountItsServiceActsOnThereIsCheckedAsGivenAlone() {
|
||||
@@ -345,13 +346,15 @@ class RequestResourcesTest {
|
||||
String link = "{\"SinkIdentifier\":\"" + sink + "\",\"LabelTemplate\":\"$AccountName\"}";
|
||||
String accept = "{\"resourceShareInvitationArn\":\"" + invitation + "\"}";
|
||||
|
||||
assertEquals(List.of(sink), RequestResources.of("oam:CreateLink", json(link), "aws", "us-east-1",
|
||||
String made = "arn:aws:oam:us-east-1:000000000000:link/*";
|
||||
assertEquals(List.of(sink, made), RequestResources.of("oam:CreateLink", json(link), "aws", "us-east-1",
|
||||
"000000000000", reaching("oam", sink)));
|
||||
assertEquals(List.of(invitation), RequestResources.of("ram:AcceptResourceShareInvitation", json(accept), "aws",
|
||||
"us-east-1", "000000000000", reaching("ram", invitation)));
|
||||
assertEquals(List.of(sink, "arn:aws:oam:us-east-1:000000000000:sink/abc"), RequestResources.of("oam:CreateLink",
|
||||
json(link), "aws", "us-east-1", "000000000000", reaching("oam", "arn:aws:oam:us-east-1:111122223333:sink/x")));
|
||||
assertEquals(List.of(sink, "arn:aws:oam:us-east-1:000000000000:sink/abc"), of("oam:CreateLink", json(link)));
|
||||
String own = "arn:aws:oam:us-east-1:000000000000:sink/abc";
|
||||
assertEquals(List.of(sink, own, made), RequestResources.of("oam:CreateLink", json(link), "aws", "us-east-1",
|
||||
"000000000000", reaching("oam", "arn:aws:oam:us-east-1:111122223333:sink/x")));
|
||||
assertEquals(List.of(sink, own, made), of("oam:CreateLink", json(link)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1590,13 +1590,17 @@ class IamRestRouteEnforcementIntegrationTest {
|
||||
String body = "{\"SinkIdentifier\":\"" + sink + "\",\"LabelTemplate\":\"$AccountName\","
|
||||
+ "\"ResourceTypes\":[\"AWS::CloudWatch::Metric\"]}";
|
||||
|
||||
String links = "arn:aws:oam:us-east-1:" + ACCOUNT + ":link/*";
|
||||
|
||||
// The sink is the other account's, which the link is made to: a grant on a sink of that name of the caller's
|
||||
// own is no grant on it.
|
||||
policy(user, allow(action, sink.replace(PEER, ACCOUNT)));
|
||||
// own is no grant on it. The link it makes is the caller's, and is checked too.
|
||||
policy(user, allow(action, sink.replace(PEER, ACCOUNT)) + "," + allow(action, links));
|
||||
refused(request(user, "oam", "POST", "/CreateLink", body), action);
|
||||
policy(user, allow(action, "*") + "," + deny(action, sink));
|
||||
refused(request(user, "oam", "POST", "/CreateLink", body), action);
|
||||
policy(user, allow(action, sink));
|
||||
refused(request(user, "oam", "POST", "/CreateLink", body), action);
|
||||
policy(user, allow(action, sink) + "," + allow(action, links));
|
||||
String link = request(user, "oam", "POST", "/CreateLink", body).statusCode(200).extract().path("Arn");
|
||||
cleanup.register(() -> adminOf("oam").body("{\"Identifier\":\"" + link + "\"}").post("/DeleteLink"));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user