mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(iam): word the account property key refusal as AWS does (#9161)
A key that satisfies the published shape and is not Namespace/PropertyName answers 'Property key must be in format Namespace/PropertyName: <key>', recorded for a key carrying no separator, with the key as the request sent it. This package described the rule in a sentence of its own instead. The rule itself is unchanged, and the layer AWS applies after it is left out on purpose rather than guessed: an unrecognised namespace is refused there, and building that check needs the set of namespaces AWS recognises, which the recordings do not give. The IAM page says so.
This commit is contained in:
1 parent
1cad7b2b62
commit
6fe1da3219
3 files changed
+33
-5
No files matched your search
@@ -1709,6 +1709,29 @@ it is STS itself: Floci does not vary its token format by account preference, so
|
||||
observable in the summary rather than in a token. `v1Token` is reported as the default for an account
|
||||
that has never set one.
|
||||
|
||||
### What a bad account property key answers
|
||||
|
||||
A property key is read in three layers and two of them are settled by recordings.
|
||||
|
||||
A key breaking the published shape, `accountPropertyKeyType` at 1 to 50 characters matching
|
||||
`^[A-Za-z][A-Za-z0-9/_-]*$`, is the declared constraint violation, a `ValidationError` naming the
|
||||
map's keys, which is what AWS answers and what this package already gave.
|
||||
|
||||
A key that satisfies the shape and is not `Namespace/PropertyName` is `InvalidInput` 400 with
|
||||
`Property key must be in format Namespace/PropertyName: <key>`, recorded 2026-11-06 for a key
|
||||
carrying no separator at all, the key echoed as the request sent it. This package answered a
|
||||
sentence of its own describing the rule; the rule itself is unchanged, and the two other spellings
|
||||
it refuses, a trailing slash and several slashes, carry the same sentence without a recording of
|
||||
their own.
|
||||
|
||||
The third layer is not implemented and is tracked rather than guessed. AWS also refuses a key whose
|
||||
namespace it does not recognise, `InvalidInput` 400 with `Unsupported namespace: <namespace>`,
|
||||
recorded 2026-10-25, where this emulator stores the property under whatever namespace the key
|
||||
names. Doing it needs the set of namespaces AWS recognises, and the recordings name exactly one
|
||||
real namespace and one invented one, so a check built from them would refuse namespaces AWS
|
||||
accepts. That is the wrong direction to be wrong in, so the set has to come from a source that
|
||||
publishes it.
|
||||
|
||||
### Organizations Root Access
|
||||
|
||||
| Action | Description |
|
||||
|
||||
@@ -3483,10 +3483,12 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
private String accountPropertyNamespace(String key) {
|
||||
int separator = key == null ? -1 : key.indexOf('/');
|
||||
if (separator <= 0 || separator != key.lastIndexOf('/') || separator == key.length() - 1) {
|
||||
// AWS's own fixed text for this refusal, carrying the key exactly as the request
|
||||
// sent it, so nothing here may reword it or trim the key. Which spellings reach it is
|
||||
// this package's reading: no slash, several, and a trailing one share the sentence.
|
||||
// The IAM page carries the recording behind it and what it does and does not cover.
|
||||
throw new AwsException("InvalidInput",
|
||||
"The property key '" + key + "' is not Namespace/PropertyName: a key has "
|
||||
+ "exactly one forward slash, and neither a leading nor a trailing "
|
||||
+ "one.", 400);
|
||||
"Property key must be in format Namespace/PropertyName: " + key, 400);
|
||||
}
|
||||
return key.substring(0, separator);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,10 @@ class AccountPropertiesIntegrationTest {
|
||||
/**
|
||||
* These three satisfy the published pattern, which admits no slash, several, and a trailing
|
||||
* one, and fail only the Namespace/PropertyName rule. The service applies that after the
|
||||
* format is already good, so it is {@code InvalidInput} rather than a constraint failure.
|
||||
* format is already good, so it is {@code InvalidInput} rather than a constraint failure, and
|
||||
* the sentence is the one AWS was recorded answering for the key that carries no separator,
|
||||
* with the key as the request sent it. The other two spellings are this package's own rule
|
||||
* under the same sentence, nothing recording what AWS answers for them.
|
||||
*/
|
||||
@Test
|
||||
void aKeyThatIsNotNamespaceSlashPropertyIsInvalidInput() {
|
||||
@@ -115,7 +118,7 @@ class AccountPropertiesIntegrationTest {
|
||||
.body(not(containsString("ValidationError")))
|
||||
// The wording matters as much as the code here: carrying the constraint phrasing
|
||||
// on an InvalidInput is the mismatch this split exists to remove.
|
||||
.body(containsString("is not Namespace/PropertyName"))
|
||||
.body(containsString("Property key must be in format Namespace/PropertyName: " + key))
|
||||
.body(not(containsString("failed to satisfy constraint")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user