mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(iam): read members clients locate apart, S3's key shape and unread bodies (#9151)
Four rules of the request-resources generator that S3 needs to be read from the table, which leave the
table as it is while S3 is still built by hand.
A member the clients of an operation carry in different places, a body the reader reads among them, is
recorded under each client locating it (locatedApart: S3's CreateBucket carries its Bucket as {Bucket},
S3 Control's as {name}), and the reader takes the members of the client whose vendored route the request
matched; a split by a client with no vendored routes is refused. A member whose botocore shape is named
as the type and Key fills the type's name (S3's Key, an ObjectKey, the object's ${ObjectName}). A type
named exactly as what an operation makes rules out one only ending with that name (PutObject makes an
object, not an accesspointobject). An operation of a REST-XML model naming what it acts on in its body
by such a key shape, which the reader does not read, is recorded unread (DeleteObjects'
Delete.Objects[].Key), and RequestResources.reads, of and ofBody leave it to its service.
This commit is contained in:
1 parent
27de6fd46e
commit
1a107f8f46
6 files changed
+360
-33
No files matched your search
@@ -758,6 +758,51 @@ class RequestResourceMembersTest {
|
||||
return new ArnFormat(format, RequestResourceMembers.pattern(format), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* A member the clients of an operation locate apart is read for the client whose route a request matched, and an
|
||||
* operation naming what it acts on in a body the reader does not read is recorded unread; a malformed entry of
|
||||
* either is refused.
|
||||
*/
|
||||
@Test
|
||||
void membersLocatedApartAreReadForTheRequestsClientAndUnreadOperationsAreRecorded() throws Exception {
|
||||
String formats = "\"arnFormats\":{\"a\":{\"thing\":\"arn:${Partition}:a:::${ThingName}\"}}";
|
||||
String operation = "{\"resources\":[{\"type\":\"thing\",\"fill\":{\"ThingName\":\"Bucket\"}}],"
|
||||
+ "\"located\":{\"Marker\":\"?marker\"},"
|
||||
+ "\"locatedApart\":{\"one\":{\"Bucket\":\"{Bucket}\"},\"two\":{\"Bucket\":\"{name}\"}},"
|
||||
+ "\"unread\":[\"Delete.Objects[].Key\"]}";
|
||||
RequestResourceMembers.Table table = parse("{\"namespaces\":{\"a\":[]}," + formats
|
||||
+ ",\"operations\":{\"a:Op\":" + operation + "}}");
|
||||
assertEquals(Map.of("one", Map.of("Bucket", "{Bucket}"), "two", Map.of("Bucket", "{name}")),
|
||||
table.locatedApart().get("a:Op"));
|
||||
assertEquals(Set.of("a:Op"), table.unread());
|
||||
// An unread operation is one the table does not read: RequestResources.of names nothing from it.
|
||||
assertFalse(RequestResources.readable(table, "a:Op"));
|
||||
RequestResourceMembers.Table read = parse("{\"namespaces\":{\"a\":[]}," + formats
|
||||
+ ",\"operations\":{\"a:Op\":{\"resources\":[]}}}");
|
||||
assertTrue(RequestResources.readable(read, "a:Op"));
|
||||
assertFalse(RequestResources.readable(read, "a:Other"));
|
||||
assertEquals(Map.of("Marker", "?marker", "Bucket", "{Bucket}"),
|
||||
RequestResources.locatedMembers(table, "a:Op", "one", Map.of()));
|
||||
assertEquals(Map.of("Marker", "?marker", "Bucket", "{name}"),
|
||||
RequestResources.locatedMembers(table, "a:Op", "two", Map.of()));
|
||||
// A request no route of the operation matched, or one of a client locating nothing apart, reads only what every
|
||||
// client locates alike.
|
||||
assertEquals(Map.of("Marker", "?marker"), RequestResources.locatedMembers(table, "a:Op", null, Map.of()));
|
||||
assertEquals(Map.of("Marker", "?marker"), RequestResources.locatedMembers(table, "a:Op", "three", Map.of()));
|
||||
// A generated alternative route still says where its members are.
|
||||
assertEquals(Map.of("Bucket", "{name}"),
|
||||
RequestResources.locatedMembers(table, "a:Op", "two", Map.of("Marker", "body")));
|
||||
for (String bad : List.of("\"locatedApart\":{\"One\":{\"Bucket\":\"{Bucket}\"}}",
|
||||
"\"locatedApart\":{\"one\":{\"Bucket\":\"Bucket\"}}", "\"locatedApart\":{\"one\":{}}",
|
||||
"\"locatedApart\":{}", "\"locatedApart\":[]", "\"locatedApart\":\"one\"",
|
||||
"\"locatedApart\":{\"one\":\"{Bucket}\"}", "\"locatedApart\":{\"one\":[\"{Bucket}\"]}",
|
||||
"\"unread\":[\"Delete..Key\"]", "\"unread\":[1]", "\"unread\":[]", "\"unread\":\"Delete.Key\"",
|
||||
"\"unread\":{\"a\":\"Delete.Key\"}")) {
|
||||
assertThrows(IllegalStateException.class, () -> parse("{\"namespaces\":{\"a\":[]}," + formats
|
||||
+ ",\"operations\":{\"a:Op\":{\"resources\":[]," + bad + "}}}"), bad);
|
||||
}
|
||||
}
|
||||
|
||||
private static String document(String formats, String resource) {
|
||||
return "{\"namespaces\":{\"a\":[]}," + formats + ",\"operations\":{\"a:Op\":{\"resources\":[" + resource + "]}}}";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user