mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 07:11:11 -05:00
feat(iam): read every modelled operation's constraints from the model (#6965)
The vendored file carried 52 of IAM's operations and carries 162 now, which is every one of the 164 that declares a required member, a length, a pattern, an enum or a range, bar the two account alias operations: those answer their single member in AWS's own wording, so there is nothing left for the walk to read on them. What takes the last of them in is a walk that reads a Query map and anything nested under one. A map arrives as entries numbered under its own name, `ReplacementValues.entry.1.key` and `.entry.1.value`, and an entry's value is named under the key that entry carried, `replacementValues.Department.values`, which is how both maps this service answered by hand already named one and how the JSON protocols name a map's value here. An entry is read off its key, so one numbered with a value and no key is not an entry the map could hold. A structure's field may be a list, a list's member may hold a list of its own and a map's value may be a structure, so `AcquireRole`, `PutAccountProperties`, `CreateDelegationRequest` and both simulators are read with the rest, and the file refuses to load only for a shape of a type the walk would pass over unread. The two hand-written map checks come off with that. `AcquireRole`'s answers do not move at all: the count of 30, each entry's required `Values` and the 20 values one entry admits read exactly as its own check read them, named by the key the entry was sent under, which is what the tests it already had pin. `PutAccountProperties` keeps the set it answered for a key, `Map keys must satisfy constraint: [...]`, with the minimum length of 1 the model declares now inside it where the hand-written set listed the maximum and the pattern alone, and a value outside its bounds is answered in the words every other member carries rather than the `must have length between 1 and 1024` that check wrote. The `Namespace/PropertyName` rule stays exactly where it was, being a rule the service applies after the format is good rather than a constraint the model declares. Two reductions keep an answer that is AWS's own rather than rewording it, both through the hook the shared driver already takes. Eight operations answer a member the request leaves out with "The request must contain the parameter CertificateBody.", the wording this emulator answers for a missing Query parameter in several services, so their shapes are vendored without the model's required list and keep that refusal while their lengths and patterns are read. Seventeen more are vendored without a member they answer in a wording of their own: a service-linked role's principal and suffix, an empty `ServiceNamespaces`, `statusType` on all four operations that take it, `Encoding` on `GetSSHPublicKey`, the simulators' empty `ActionNames`, `PolicyInputList` and `PolicySourceArn`, and `TagKeys` on the eight untag operations. Nine wordings this service wrote for itself go with the checks that wrote them: the three password-policy ranges, the name refusal that spelled out its own bounds and the group, server certificate and instance profile names beside it, the path refusal, the authentication code, the virtual MFA device name and the serial number. Each is answered by the model's own violation now, through the one writer this package already had. A member whose shape fixes one length is answered for that length rather than for a bound it sits under, `Member must have length equal to 6`. That is the wording a report's 36-character job id already answered by hand, which is why the three report readers can be read from the model at all, and it reaches STS through the same writer, whose `TokenCode` and `SigningAlgorithm` each fix one length too. Two test fixtures carried values AWS refuses and now carry values it takes. `SignedIamUsers` named a user with a prefix plus a whole UUID, which reaches 66 characters where `userNameType` declares 64, and the two sibling fixtures that named one the same way follow it onto the shorter suffix. The SDK suite registered a SAML provider with a 375-character metadata document where AWS declares 1000, so each of its two documents is padded to that bound on its own. `docs/services/iam.md` carries each reading, the maps among them.
This commit is contained in:
1 parent
361b3177b8
commit
98a3d2a346
27 files changed
+2638
-482
No files matched your search
@@ -150,18 +150,38 @@ class IamTest {
|
||||
* contends with the one the Organizations suite builds for the default account.
|
||||
*/
|
||||
private static final String REPORT_MANAGEMENT_ACCOUNT = "555555555557";
|
||||
private static final String SAML_METADATA_DOCUMENT = "<md:EntityDescriptor "
|
||||
/** The minimum AWS declares for {@code SAMLMetadataDocument}. */
|
||||
private static final int SAML_METADATA_MINIMUM = 1000;
|
||||
private static final String SAML_METADATA_BODY = "<md:EntityDescriptor "
|
||||
+ "xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"https://idp.example.test/sdk-test\">"
|
||||
+ "<md:IDPSSODescriptor><md:KeyDescriptor use=\"signing\"><ds:KeyInfo "
|
||||
+ "xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"><ds:X509Data><ds:X509Certificate>"
|
||||
+ "c2RrLXRlc3QtY2VydGlmaWNhdGU=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor>"
|
||||
+ "</md:IDPSSODescriptor></md:EntityDescriptor>";
|
||||
private static final String SAML_METADATA_DOCUMENT_UPDATED = SAML_METADATA_DOCUMENT
|
||||
.replace("sdk-test", "sdk-test-updated").replace("c2RrLXRlc3QtY2VydGlmaWNhdGU=", "dXBkYXRlZC1jZXJ0");
|
||||
+ "</md:IDPSSODescriptor>";
|
||||
private static final String SAML_METADATA_DOCUMENT = samlMetadata(SAML_METADATA_BODY);
|
||||
/** The same document under another entity id and certificate, padded on its own: the
|
||||
* replacements are shorter than what they replace, so padding the first document and editing
|
||||
* it would leave the second under the minimum. */
|
||||
private static final String SAML_METADATA_DOCUMENT_UPDATED = samlMetadata(SAML_METADATA_BODY
|
||||
.replace("sdk-test", "sdk-test-updated").replace("c2RrLXRlc3QtY2VydGlmaWNhdGU=", "dXBkYXRlZC1jZXJ0"));
|
||||
private static String policyArn;
|
||||
private static String accessKeyId;
|
||||
private static String samlProviderArn;
|
||||
|
||||
/**
|
||||
* The document closed off and padded to the minimum AWS declares for it. A document carrying
|
||||
* nothing but an entity id and one signing key is about a third of that, and the service holds
|
||||
* the member to its published bound, so the filler comment brings it up: it parses as nothing,
|
||||
* the entity id and the certificate being what the provider is read from.
|
||||
*/
|
||||
private static String samlMetadata(String body) {
|
||||
String end = "</md:EntityDescriptor>";
|
||||
String open = "<!-- ";
|
||||
String close = " -->";
|
||||
int filler = SAML_METADATA_MINIMUM - body.length() - end.length() - open.length() - close.length();
|
||||
return body + open + "x".repeat(Math.max(1, filler)) + close + end;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
iam = TestFixtures.iamClient();
|
||||
|
||||
Reference in new issue
Block a user