mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
fix(iam): name the member without the offending value in a validation error (#6811)
IAM's constraint violations read `Value at 'roleName' failed to satisfy constraint: Member must have length greater than or equal to 1`, with no value beside the member, which is where the recorded messages point: the two IAM messages in LocalStack's AWS-validated snapshot from 2025-03-06, a 2026 capture of a `UserName` over 64 characters, and the messages the Identity Center guide lists as the ones that commonly appear in CloudTrail events. The two captures that carry the value are from 2019 and 2024, so they read as stale rather than as wrong when written. STS keeps the value, which its own 2024 capture carries and which is the same split this package already records for pattern and enum messages. It is a reading rather than a published rule, so `docs/services/iam.md` says so and names the captures behind it. A direct capture that shows IAM carrying the value again moves it back in one edit. The form is chosen in one place. `SmithyValidationErrors.Violations` writes each sentence once and carries both forms; the statics stay the quoting one, so every other service answers exactly what it answered before. `IamValidationErrors` names IAM's side of the split for the handler, the service and the service-last-accessed check, and the shared Query walk is loaded with the form of the service reading it, IAM without the value and STS with it. Two messages are left alone, neither being this question: a list checked as a whole carries the list as its value, which is what AWS does elsewhere, and a required member the request leaves out keeps `Value null at '<member>'`, which no capture covers in either form. Two checks built the message by hand rather than through a helper and so are swept here too: `GenerateOrganizationsAccessReport` and the delegation request operations each composed the quoted value inline, which is why neither shows up in a search for the literal form. Their entity path and request id now assert the whole message rather than only the error code, since asserting the code alone is what let that drift sit unnoticed. The vendored shapes file carries 52 operations now rather than 13, so the members the paging wave opted in answer in the shorter form as well, and the table sweep over every paged operation asserts it that way.
This commit is contained in:
1 parent
42b4bf4245
commit
6606657434
18 files changed
+332
-137
No files matched your search
@@ -236,6 +236,29 @@ whose `SortKey` is held to its enum by hand, `ListPoliciesGrantingServiceAccess`
|
||||
`SimulatePrincipalPolicy`, whose `ContextEntries` nest a list inside a list of structures, which the
|
||||
walk does not read.
|
||||
|
||||
Every constraint violation IAM answers names the member and leaves the offending value out,
|
||||
`Value at 'roleName' failed to satisfy constraint: Member must have length greater than or equal to
|
||||
1`, where most services write `Value 'x' at 'roleName'` and STS still does. That is a reading rather
|
||||
than a published rule, and it is where the recorded messages point. Without the value: the two IAM
|
||||
messages in LocalStack's AWS-validated IAM snapshot, recorded 2025-03-06, a 2026 capture of a
|
||||
`UserName` over 64 characters, and the messages the Identity Center guide lists as the ones that
|
||||
"commonly appear in CloudTrail events", which read `Value at 'name.familyName'`. With it: two older
|
||||
issue reports, from 2019 and 2024. So the reading is that IAM stopped carrying the value between
|
||||
them and the older captures are stale, and this service answers the newer form everywhere, from a
|
||||
check written by hand to a constraint read off the model. STS keeps the value, which its own 2024
|
||||
capture carries and which is the same split recorded here for pattern and enum messages.
|
||||
|
||||
A list is named the same way, with its members left out: a tag list over its limit, or one holding a
|
||||
key that breaks its own shape, reads `Value at 'tagKeys'` rather than echoing every key back. That
|
||||
was already this service's choice for a list over its limit, and it is now what a list says
|
||||
whatever it breaks. Other services do quote a list, Lambda's `Value '[x86_64, arm64]' at
|
||||
'architectures'` being a captured one, which is why this is IAM's reading and not a rule.
|
||||
|
||||
The one message that still carries a word where the value would go is the required member a request
|
||||
leaves out, `Value null at '<member>'`, which no capture covers in either form. The form is chosen
|
||||
in one place, so a direct capture that ever shows IAM carrying its values again moves it back in one
|
||||
edit rather than across the service.
|
||||
|
||||
### Permission Boundaries
|
||||
|
||||
| Action | Description |
|
||||
|
||||
@@ -27,10 +27,11 @@ import java.util.regex.Pattern;
|
||||
* merged for a `ServiceSpecificCredentialId` breaking both its length and its pattern, and
|
||||
* `docs/services/iam.md` carries it.
|
||||
*
|
||||
* <p>The offending value is quoted, which is what {@link SmithyValidationErrors#lengthOutOfRange}
|
||||
* and this package's `validateRoleName` already answer. Whether current IAM quotes it at all is
|
||||
* what DRIFT-13 asks, and the point of reading the constraints here is that one capture would
|
||||
* change one helper rather than every message in the package.
|
||||
* <p>Whether the offending value is quoted beside the member is the service's own, so the check is
|
||||
* loaded with the form that service answers: IAM names the member and leaves the value out, STS
|
||||
* quotes it. That is DRIFT-13's reading, taken from the captures in hand and recorded in
|
||||
* {@code docs/services/iam.md}, and reading the constraints here is what makes it one object to
|
||||
* change rather than every message in a package.
|
||||
*
|
||||
* <p>A member the request leaves out is absent, and only a required member is reported for one. A
|
||||
* member present and empty is a value: the protocol carries it, so it breaks its minimum length
|
||||
@@ -62,11 +63,13 @@ public final class QueryConstraintCheck {
|
||||
|
||||
private final JsonNode operations;
|
||||
private final JsonNode shapes;
|
||||
private final SmithyValidationErrors.Violations messages;
|
||||
private final Map<String, Pattern> patterns = new HashMap<>();
|
||||
|
||||
private QueryConstraintCheck(JsonNode model) {
|
||||
private QueryConstraintCheck(JsonNode model, SmithyValidationErrors.Violations messages) {
|
||||
this.operations = model.path("operations");
|
||||
this.shapes = model.path("shapes");
|
||||
this.messages = messages;
|
||||
for (Map.Entry<String, JsonNode> shape : shapes.properties()) {
|
||||
if (shape.getValue().has("pattern")) {
|
||||
patterns.put(shape.getKey(), Pattern.compile(shape.getValue().get("pattern").asText()));
|
||||
@@ -77,14 +80,27 @@ public final class QueryConstraintCheck {
|
||||
}
|
||||
}
|
||||
|
||||
/** The vendored resource {@code name}; {@code description} names it in a failure. */
|
||||
/**
|
||||
* The vendored resource {@code name}, answering in the form most services do, with the
|
||||
* offending value quoted; {@code description} names it in a failure.
|
||||
*/
|
||||
public static QueryConstraintCheck load(String name, String description) {
|
||||
return load(name, description, SmithyValidationErrors.Violations.QUOTED);
|
||||
}
|
||||
|
||||
/** The same, in the message form {@code messages} writes, which is the service's own. */
|
||||
public static QueryConstraintCheck load(String name, String description,
|
||||
SmithyValidationErrors.Violations messages) {
|
||||
return VendoredResources.read(name, description,
|
||||
input -> new QueryConstraintCheck(MAPPER.readTree(input)));
|
||||
input -> new QueryConstraintCheck(MAPPER.readTree(input), messages));
|
||||
}
|
||||
|
||||
public static QueryConstraintCheck of(JsonNode model) {
|
||||
return new QueryConstraintCheck(model);
|
||||
return of(model, SmithyValidationErrors.Violations.QUOTED);
|
||||
}
|
||||
|
||||
public static QueryConstraintCheck of(JsonNode model, SmithyValidationErrors.Violations messages) {
|
||||
return new QueryConstraintCheck(model, messages);
|
||||
}
|
||||
|
||||
private void requireReadableMembers(String operation, String inputShape) {
|
||||
@@ -250,14 +266,14 @@ public final class QueryConstraintCheck {
|
||||
return List.of();
|
||||
}
|
||||
List<String> violations = new ArrayList<>();
|
||||
String length = SmithyValidationErrors.lengthOutOfRange(path, value,
|
||||
String length = messages.lengthOutOfRange(path, value,
|
||||
shape.path("min").asInt(0), shape.path("max").asInt(Integer.MAX_VALUE));
|
||||
if (length != null) {
|
||||
violations.add(length);
|
||||
}
|
||||
Pattern pattern = patterns.get(shapeName);
|
||||
if (pattern != null && !pattern.matcher(value).matches()) {
|
||||
violations.add(SmithyValidationErrors.pattern(path, value, pattern.pattern()));
|
||||
violations.add(messages.pattern(path, value, pattern.pattern()));
|
||||
}
|
||||
violations.addAll(single(enumViolation(shape, value, path)));
|
||||
return violations;
|
||||
@@ -277,7 +293,7 @@ public final class QueryConstraintCheck {
|
||||
* written as the number reads rather than as the request spelled it, a leading zero or plus
|
||||
* gone, which is what a parsed value already answered.
|
||||
*/
|
||||
private static String numberViolation(JsonNode shape, String value, String path) {
|
||||
private String numberViolation(JsonNode shape, String value, String path) {
|
||||
String text = value.trim();
|
||||
if (!INTEGER.matcher(text).matches()) {
|
||||
// Not a number at all, so no range of the model's is what it breaks.
|
||||
@@ -287,20 +303,20 @@ public final class QueryConstraintCheck {
|
||||
long min = shape.path("min").asLong(Long.MIN_VALUE);
|
||||
long max = shape.path("max").asLong(Long.MAX_VALUE);
|
||||
if (number.compareTo(BigInteger.valueOf(min)) < 0) {
|
||||
return SmithyValidationErrors.valueTooSmall(path, number.toString(), min);
|
||||
return messages.valueTooSmall(path, number.toString(), min);
|
||||
}
|
||||
if (number.compareTo(BigInteger.valueOf(max)) > 0) {
|
||||
return SmithyValidationErrors.valueTooLarge(path, number.toString(), max);
|
||||
return messages.valueTooLarge(path, number.toString(), max);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String enumViolation(JsonNode shape, String value, String path) {
|
||||
private String enumViolation(JsonNode shape, String value, String path) {
|
||||
if (!shape.has("enum")) {
|
||||
return null;
|
||||
}
|
||||
List<String> allowed = new ArrayList<>();
|
||||
shape.path("enum").forEach(choice -> allowed.add(choice.asText()));
|
||||
return allowed.contains(value) ? null : SmithyValidationErrors.notInEnum(value, path, allowed);
|
||||
return allowed.contains(value) ? null : messages.notInEnum(value, path, allowed);
|
||||
}
|
||||
}
|
||||
@@ -74,13 +74,7 @@ public final class SmithyValidationErrors {
|
||||
|
||||
/** The violation for a number outside {@code min} to {@code max}, or {@code null} for one inside. */
|
||||
public static String outOfRange(String path, long value, long min, long max) {
|
||||
if (value < min) {
|
||||
return valueTooSmall(path, Long.toString(value), min);
|
||||
}
|
||||
if (value > max) {
|
||||
return valueTooLarge(path, Long.toString(value), max);
|
||||
}
|
||||
return null;
|
||||
return Violations.QUOTED.outOfRange(path, value, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,27 +82,17 @@ public final class SmithyValidationErrors {
|
||||
* large for a {@code long} is still a number, and the bound it breaks is one that fits in one.
|
||||
*/
|
||||
public static String valueTooSmall(String path, String value, long min) {
|
||||
return "Value '" + value + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must have value greater than or equal to " + min;
|
||||
return Violations.QUOTED.valueTooSmall(path, value, min);
|
||||
}
|
||||
|
||||
/** The violation for a number above {@code max}, with the value already written. */
|
||||
public static String valueTooLarge(String path, String value, long max) {
|
||||
return "Value '" + value + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must have value less than or equal to " + max;
|
||||
return Violations.QUOTED.valueTooLarge(path, value, max);
|
||||
}
|
||||
|
||||
/** The violation for a string outside its length bounds, or {@code null} for one inside. */
|
||||
public static String lengthOutOfRange(String path, String value, int min, int max) {
|
||||
int length = value.codePointCount(0, value.length());
|
||||
if (length < min) {
|
||||
return lengthTooShort(path, value, min);
|
||||
}
|
||||
if (length > max) {
|
||||
return "Value '" + value + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must have length less than or equal to " + max;
|
||||
}
|
||||
return null;
|
||||
return Violations.QUOTED.lengthOutOfRange(path, value, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,20 +115,17 @@ public final class SmithyValidationErrors {
|
||||
|
||||
/** Also used by services that reject whitespace-only input as an empty member. */
|
||||
public static String lengthTooShort(String path, String value, int min) {
|
||||
return "Value '" + value + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to " + min;
|
||||
return Violations.QUOTED.lengthTooShort(path, value, min);
|
||||
}
|
||||
|
||||
/** The violation for a string that does not match the pattern its shape declares. */
|
||||
public static String pattern(String path, String value, String pattern) {
|
||||
return "Value '" + value + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must satisfy regular expression pattern: " + pattern;
|
||||
return Violations.QUOTED.pattern(path, value, pattern);
|
||||
}
|
||||
|
||||
/** The violation for a value outside its enum, listing the allowed values in the model's order. */
|
||||
public static String notInEnum(String value, String path, List<String> allowed) {
|
||||
return "Value '" + value + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: " + allowed;
|
||||
return Violations.QUOTED.notInEnum(value, path, allowed);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,4 +136,84 @@ public final class SmithyValidationErrors {
|
||||
return "Value '" + values + "' at '" + path + "' failed to satisfy constraint: "
|
||||
+ "Member must satisfy constraint: [Member must satisfy enum value set: " + allowed + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* The same violations in the form one service writes them, which is not the same everywhere.
|
||||
* Most services, STS among them, quote the offending value beside the member; IAM names the
|
||||
* member and leaves the value out, which is what every capture of it since 2025-03 reads and
|
||||
* what {@code docs/services/iam.md} records as the reading. Choosing a form here rather than at
|
||||
* each message means a later capture changes one object instead of a package.
|
||||
*
|
||||
* <p>Only the violations that carry a value differ. A required member the request leaves out
|
||||
* ({@link #notNull}), a list held to its member count ({@link #sizeOutOfRange}) and a list
|
||||
* checked as a whole ({@link #notAllInEnum}) read the same either way.
|
||||
*/
|
||||
public static final class Violations {
|
||||
|
||||
/** The offending value quoted beside the member, which is what most services answer. */
|
||||
public static final Violations QUOTED = new Violations(true);
|
||||
|
||||
/** The member named with no value beside it, which is what IAM answers. */
|
||||
public static final Violations WITHOUT_VALUES = new Violations(false);
|
||||
|
||||
private final boolean quoted;
|
||||
|
||||
private Violations(boolean quoted) {
|
||||
this.quoted = quoted;
|
||||
}
|
||||
|
||||
/** One violation naming {@code constraint}, carrying {@code value} where this form does. */
|
||||
public String constraint(String path, String value, String constraint) {
|
||||
String member = quoted ? "Value '" + value + "' at '" : "Value at '";
|
||||
return member + path + "' failed to satisfy constraint: " + constraint;
|
||||
}
|
||||
|
||||
/** The violation for a number outside {@code min} to {@code max}, or null for one inside. */
|
||||
public String outOfRange(String path, long value, long min, long max) {
|
||||
if (value < min) {
|
||||
return valueTooSmall(path, Long.toString(value), min);
|
||||
}
|
||||
if (value > max) {
|
||||
return valueTooLarge(path, Long.toString(value), max);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The violation for a number below {@code min}, with the value already written. */
|
||||
public String valueTooSmall(String path, String value, long min) {
|
||||
return constraint(path, value, "Member must have value greater than or equal to " + min);
|
||||
}
|
||||
|
||||
/** The violation for a number above {@code max}, with the value already written. */
|
||||
public String valueTooLarge(String path, String value, long max) {
|
||||
return constraint(path, value, "Member must have value less than or equal to " + max);
|
||||
}
|
||||
|
||||
/** The violation for a string outside its length bounds, or null for one inside. */
|
||||
public String lengthOutOfRange(String path, String value, int min, int max) {
|
||||
int length = value.codePointCount(0, value.length());
|
||||
if (length < min) {
|
||||
return lengthTooShort(path, value, min);
|
||||
}
|
||||
if (length > max) {
|
||||
return constraint(path, value, "Member must have length less than or equal to " + max);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The violation for a string under {@code min} characters, an empty one included. */
|
||||
public String lengthTooShort(String path, String value, int min) {
|
||||
return constraint(path, value, "Member must have length greater than or equal to " + min);
|
||||
}
|
||||
|
||||
/** The violation for a string that does not match the pattern its shape declares. */
|
||||
public String pattern(String path, String value, String pattern) {
|
||||
return constraint(path, value, "Member must satisfy regular expression pattern: " + pattern);
|
||||
}
|
||||
|
||||
/** The violation for a value outside its enum, the values in the model's order. */
|
||||
public String notInEnum(String value, String path, List<String> allowed) {
|
||||
return constraint(path, value, "Member must satisfy enum value set: " + allowed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -747,12 +747,15 @@ public class DelegationRequestService {
|
||||
* A member that does not meet the format or the constraints it declares. The reference's
|
||||
* common errors publish {@code ValidationError} for exactly that, "the input doesn't meet the
|
||||
* required format or constraints", for every IAM operation and without listing it on any of
|
||||
* them, which is why it appears in no operation's error table and in none of these.
|
||||
* them, which is why it appears in no operation's error table and in none of these. The member
|
||||
* is named without the value, as {@link IamValidationErrors} reads it, and a member the request
|
||||
* never sent keeps the one word that still stands where a value would.
|
||||
*/
|
||||
private static AwsException constraintViolation(String value, String member, String constraint) {
|
||||
return SmithyValidationErrors.validationError("Value "
|
||||
+ (value == null ? "null" : "'" + value + "'") + " at '" + member
|
||||
+ "' failed to satisfy constraint: " + constraint);
|
||||
if (value == null) {
|
||||
return SmithyValidationErrors.validationError(SmithyValidationErrors.notNull(member));
|
||||
}
|
||||
return IamValidationErrors.validationError(member, value, constraint);
|
||||
}
|
||||
|
||||
private static AwsException noSuchRequest(String id) {
|
||||
|
||||
@@ -1004,10 +1004,8 @@ public class IamQueryHandler {
|
||||
try {
|
||||
return Integer.valueOf(raw.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + raw + "' at '"
|
||||
+ Character.toLowerCase(name.charAt(0)) + name.substring(1)
|
||||
+ "' failed to satisfy constraint: Member must be an integer");
|
||||
throw validationError(raw, Character.toLowerCase(name.charAt(0)) + name.substring(1),
|
||||
"Member must be an integer");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3608,13 +3606,12 @@ public class IamQueryHandler {
|
||||
|
||||
/**
|
||||
* IAM's constraint-violation shape for a scalar member, which leads with the error count and
|
||||
* quotes the offending value. Only the bound actually broken is named, as AWS does: a value
|
||||
* outside a range reports the side it fell outside, not the whole range.
|
||||
* names the member without the offending value, as {@link IamValidationErrors} reads it. Only
|
||||
* the bound actually broken is named, as AWS does: a value outside a range reports the side it
|
||||
* fell outside, not the whole range.
|
||||
*/
|
||||
private static AwsException validationError(String value, String at, String constraint) {
|
||||
return SmithyValidationErrors.validationError(
|
||||
"Value '" + value + "' at '" + at + "' failed to satisfy constraint: "
|
||||
+ constraint);
|
||||
return IamValidationErrors.validationError(at, value, constraint);
|
||||
}
|
||||
|
||||
private List<String> getMemberList(MultivaluedMap<String, String> params, String name) {
|
||||
|
||||
@@ -11,6 +11,9 @@ import jakarta.ws.rs.core.MultivaluedMap;
|
||||
* ValidationError} whether or not the thing it names exists, the ordering #6402 settled for this
|
||||
* package.
|
||||
*
|
||||
* <p>The violations read as IAM writes them, naming the member with no value beside it, which is
|
||||
* {@link IamValidationErrors}' reading of the captures rather than the walk's own default.
|
||||
*
|
||||
* <p>The vendored file carries a wave of operations rather than all 180, and grows a wave at a
|
||||
* time, each one chosen where no operation checks a declared constraint by hand, so the model adds
|
||||
* the refusals AWS answers without rewording an answer already given. The managed-policy family
|
||||
@@ -24,8 +27,8 @@ import jakarta.ws.rs.core.MultivaluedMap;
|
||||
*/
|
||||
final class IamRequestShapes {
|
||||
|
||||
private static final QueryConstraintCheck CHECK =
|
||||
QueryConstraintCheck.load("aws/iam-request-shapes.json", "IAM request shapes");
|
||||
private static final QueryConstraintCheck CHECK = QueryConstraintCheck.load(
|
||||
"aws/iam-request-shapes.json", "IAM request shapes", IamValidationErrors.MESSAGES);
|
||||
|
||||
private IamRequestShapes() {
|
||||
}
|
||||
|
||||
@@ -1311,9 +1311,10 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
String value = roleName == null ? "null" : "'" + roleName + "'";
|
||||
throw SmithyValidationErrors.validationError("Value " + value
|
||||
+ " at 'roleName' failed to satisfy constraint: " + constraint);
|
||||
if (roleName == null) {
|
||||
throw SmithyValidationErrors.validationError(SmithyValidationErrors.notNull("roleName"));
|
||||
}
|
||||
throw IamValidationErrors.validationError("roleName", roleName, constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1778,10 +1779,8 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
&& !"All".equalsIgnoreCase(scope)
|
||||
&& !"AWS".equalsIgnoreCase(scope)
|
||||
&& !"Local".equalsIgnoreCase(scope)) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + scope + "' at 'scope' failed to "
|
||||
+ "satisfy constraint: Member must satisfy enum value set: "
|
||||
+ "[All, AWS, Local]");
|
||||
throw IamValidationErrors.validationError("scope", scope,
|
||||
"Member must satisfy enum value set: [All, AWS, Local]");
|
||||
}
|
||||
String prefix = pathPrefix != null ? pathPrefix : "/";
|
||||
boolean blankScope = scope == null || scope.isBlank();
|
||||
@@ -3045,10 +3044,8 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
private String validateAccountPropertyKey(String key) {
|
||||
if (key == null || key.isEmpty() || key.length() > MAX_ACCOUNT_PROPERTY_KEY_LENGTH
|
||||
|| !ACCOUNT_PROPERTY_KEY_PATTERN.matcher(key).matches()) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + key + "' at 'properties' failed "
|
||||
+ "to satisfy constraint: Map keys "
|
||||
+ "must satisfy constraint: [Member must have length less than or "
|
||||
throw IamValidationErrors.validationError("properties", key,
|
||||
"Map keys must satisfy constraint: [Member must have length less than or "
|
||||
+ "equal to " + MAX_ACCOUNT_PROPERTY_KEY_LENGTH + ", Member must "
|
||||
+ "satisfy regular expression pattern: "
|
||||
+ ACCOUNT_PROPERTY_KEY_PATTERN.pattern() + "]");
|
||||
@@ -3077,10 +3074,8 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
public void setSecurityTokenServicePreferences(String globalEndpointTokenVersion) {
|
||||
if (globalEndpointTokenVersion == null
|
||||
|| !GLOBAL_ENDPOINT_TOKEN_VERSIONS.contains(globalEndpointTokenVersion)) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + globalEndpointTokenVersion
|
||||
+ "' at 'globalEndpointTokenVersion' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: ["
|
||||
throw IamValidationErrors.validationError("globalEndpointTokenVersion",
|
||||
globalEndpointTokenVersion, "Member must satisfy enum value set: ["
|
||||
+ String.join(", ", GLOBAL_ENDPOINT_TOKEN_VERSIONS) + "]");
|
||||
}
|
||||
stsPreferences.put(STS_PREFERENCES_KEY, globalEndpointTokenVersion);
|
||||
@@ -3815,11 +3810,9 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
}
|
||||
if (credentialAgeDays < MIN_CREDENTIAL_AGE_DAYS
|
||||
|| credentialAgeDays > MAX_CREDENTIAL_AGE_DAYS) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + credentialAgeDays
|
||||
+ "' at 'credentialAgeDays' failed to satisfy constraint: "
|
||||
+ "Member must be between " + MIN_CREDENTIAL_AGE_DAYS + " and "
|
||||
+ MAX_CREDENTIAL_AGE_DAYS);
|
||||
throw IamValidationErrors.validationError("credentialAgeDays",
|
||||
String.valueOf(credentialAgeDays), "Member must be between "
|
||||
+ MIN_CREDENTIAL_AGE_DAYS + " and " + MAX_CREDENTIAL_AGE_DAYS);
|
||||
}
|
||||
}
|
||||
synchronized (serviceCredentialLock) {
|
||||
@@ -4140,10 +4133,8 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
public List<VirtualMfaDevice> listVirtualMfaDevices(String assignmentStatus) {
|
||||
String status = assignmentStatus == null || assignmentStatus.isBlank() ? "Any" : assignmentStatus;
|
||||
if (!status.equals("Any") && !status.equals("Assigned") && !status.equals("Unassigned")) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + assignmentStatus
|
||||
+ "' at 'assignmentStatus' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: [Any, Unassigned, Assigned]");
|
||||
throw IamValidationErrors.validationError("assignmentStatus", assignmentStatus,
|
||||
"Member must satisfy enum value set: [Any, Unassigned, Assigned]");
|
||||
}
|
||||
return virtualMfaDevices.scan(k -> true).stream()
|
||||
.filter(d -> switch (status) {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
|
||||
/**
|
||||
* The form IAM's constraint violations take, which is Smithy's wording with the offending value
|
||||
* left out: {@code Value at 'userName' failed to satisfy constraint: Member must have length less
|
||||
* than or equal to 64}. Every capture of an IAM validation message since 2025-03 reads that way,
|
||||
* where the older ones quoted the value, and STS still quotes it, so this names IAM's side of that
|
||||
* split in one place. {@code docs/services/iam.md} records the reading and the captures behind it.
|
||||
*
|
||||
* <p>A message AWS itself writes with the value is not forced through here: a list checked as a
|
||||
* whole carries the list, and a required member the request leaves out reads
|
||||
* {@code Value null at '<member>'}, which no capture here covers either way.
|
||||
*/
|
||||
final class IamValidationErrors {
|
||||
|
||||
/** IAM's form, for a check that builds its own violations rather than throwing one. */
|
||||
static final SmithyValidationErrors.Violations MESSAGES =
|
||||
SmithyValidationErrors.Violations.WITHOUT_VALUES;
|
||||
|
||||
private IamValidationErrors() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The 400 {@code ValidationError} for one violation of {@code constraint} by {@code value} at
|
||||
* {@code path}. The value is taken even though IAM's form leaves it out, so that the one place
|
||||
* that decides the form is the only place that changes if a capture ever moves it back.
|
||||
*/
|
||||
static AwsException validationError(String path, String value, String constraint) {
|
||||
return SmithyValidationErrors.validationError(MESSAGES.constraint(path, value, constraint));
|
||||
}
|
||||
}
|
||||
+9
-4
@@ -275,11 +275,16 @@ public class OrganizationsAccessReportService {
|
||||
}
|
||||
}
|
||||
|
||||
/** AWS's shape-violation message: an unquoted null, a quoted value, and what it failed. */
|
||||
/**
|
||||
* IAM's shape-violation message, which names the member and leaves the value out, as
|
||||
* {@link IamValidationErrors} reads it. A member the request never sent is the one place a
|
||||
* word still stands where the value would, {@code Value null at '<member>'}.
|
||||
*/
|
||||
private static AwsException validationError(String value, String at, String constraint) {
|
||||
return SmithyValidationErrors.validationError("Value "
|
||||
+ (value == null ? "null" : "'" + value + "'") + " at '" + at
|
||||
+ "' failed to satisfy constraint: " + constraint);
|
||||
if (value == null) {
|
||||
return SmithyValidationErrors.validationError(SmithyValidationErrors.notNull(at));
|
||||
}
|
||||
return IamValidationErrors.validationError(at, value, constraint);
|
||||
}
|
||||
|
||||
private OrganizationsAccessReportJob completed(String callerAccountId, String entityPath,
|
||||
|
||||
+2
-5
@@ -1,7 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.iam.model.ServiceLastAccessedEntity;
|
||||
@@ -54,10 +53,8 @@ public class ServiceLastAccessedService {
|
||||
*/
|
||||
public static void validateGranularity(String granularity) {
|
||||
if (granularity != null && !GRANULARITIES.contains(granularity)) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value '" + granularity + "' at 'granularity' "
|
||||
+ "failed to satisfy constraint: Member must satisfy enum value set: "
|
||||
+ "[SERVICE_LEVEL, ACTION_LEVEL]");
|
||||
throw IamValidationErrors.validationError("granularity", granularity,
|
||||
"Member must satisfy enum value set: [SERVICE_LEVEL, ACTION_LEVEL]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -345,8 +345,10 @@ class QueryConstraintCheckTest {
|
||||
*/
|
||||
@Test
|
||||
void theVendoredIamFileLoadsAndCarriesTheOperationsTheseWavesClaim() {
|
||||
QueryConstraintCheck iam =
|
||||
QueryConstraintCheck.load("aws/iam-request-shapes.json", "IAM request shapes");
|
||||
// Loaded in IAM's own form, naming the member with no value beside it, which is what
|
||||
// IamRequestShapes passes and what DRIFT-13 settles.
|
||||
QueryConstraintCheck iam = QueryConstraintCheck.load("aws/iam-request-shapes.json",
|
||||
"IAM request shapes", SmithyValidationErrors.Violations.WITHOUT_VALUES);
|
||||
|
||||
List<String> managedPolicyFamily = List.of("AttachGroupPolicy", "AttachRolePolicy",
|
||||
"AttachUserPolicy", "DetachGroupPolicy", "DetachRolePolicy", "DetachUserPolicy",
|
||||
@@ -360,13 +362,13 @@ class QueryConstraintCheckTest {
|
||||
operation + " resolved to no required members, so its shape did not resolve");
|
||||
}
|
||||
|
||||
assertEquals(List.of("Value 'v1' at 'policyArn' failed to satisfy constraint: Member must"
|
||||
assertEquals(List.of("Value at 'policyArn' failed to satisfy constraint: Member must"
|
||||
+ " have length greater than or equal to 20"),
|
||||
iam.violations("GetPolicy", params("PolicyArn", "v1")));
|
||||
|
||||
assertEquals(List.of(), iam.violations("GetAccountAuthorizationDetails", params()),
|
||||
"every member of it is optional, so a request naming none of them breaks nothing");
|
||||
assertEquals(List.of("Value 'Users' at 'filter.1.member' failed to satisfy constraint:"
|
||||
assertEquals(List.of("Value at 'filter.1.member' failed to satisfy constraint:"
|
||||
+ " Member must satisfy enum value set:"
|
||||
+ " [User, Role, Group, LocalManagedPolicy, AWSManagedPolicy]"),
|
||||
iam.violations("GetAccountAuthorizationDetails", params("Filter.member.1", "Users")),
|
||||
|
||||
@@ -85,4 +85,41 @@ class SmithyValidationErrorsTest {
|
||||
SmithyValidationErrors.lengthOutOfRange("name", value.repeat(2), 0, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* A service's own form decides whether the offending value is quoted beside the member, which
|
||||
* is the only thing the two differ in. The statics are the quoting form, so every service that
|
||||
* calls them keeps the message it answered.
|
||||
*/
|
||||
@Test
|
||||
void aServicesFormDecidesWhetherTheValueIsQuoted() {
|
||||
SmithyValidationErrors.Violations quoted = SmithyValidationErrors.Violations.QUOTED;
|
||||
SmithyValidationErrors.Violations without = SmithyValidationErrors.Violations.WITHOUT_VALUES;
|
||||
|
||||
assertEquals("Value 'ab' at 'userName' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 3",
|
||||
quoted.lengthOutOfRange("userName", "ab", 3, 10));
|
||||
assertEquals("Value at 'userName' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 3",
|
||||
without.lengthOutOfRange("userName", "ab", 3, 10));
|
||||
|
||||
assertEquals(SmithyValidationErrors.lengthOutOfRange("userName", "ab", 3, 10),
|
||||
quoted.lengthOutOfRange("userName", "ab", 3, 10));
|
||||
assertEquals(SmithyValidationErrors.pattern("userName", "a b", "[a-z]+"),
|
||||
quoted.pattern("userName", "a b", "[a-z]+"));
|
||||
assertEquals(SmithyValidationErrors.notInEnum("Users", "filter", List.of("User")),
|
||||
quoted.notInEnum("Users", "filter", List.of("User")));
|
||||
assertEquals(SmithyValidationErrors.outOfRange("maxItems", 1001, 1, 1000),
|
||||
quoted.outOfRange("maxItems", 1001, 1, 1000));
|
||||
|
||||
assertEquals("Value at 'filter' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: [User]",
|
||||
without.notInEnum("Users", "filter", List.of("User")));
|
||||
assertEquals("Value at 'maxItems' failed to satisfy constraint: "
|
||||
+ "Member must have value less than or equal to 1000",
|
||||
without.outOfRange("maxItems", 1001, 1, 1000));
|
||||
|
||||
// A value inside its bounds is no violation in either form.
|
||||
assertNull(without.lengthOutOfRange("userName", "abc", 3, 10));
|
||||
assertNull(without.outOfRange("maxItems", 1000, 1, 1000));
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -276,7 +276,12 @@ class DelegationRequestIntegrationTest {
|
||||
// here too rather than with the InvalidInput these operations happen to model.
|
||||
byId(PARTNER_AUTH, "GetDelegationRequest", "dr-short")
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"));
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
// The whole message, since these operations name the member with no value beside
|
||||
// it, as every other IAM check does.
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
|
||||
+ " 'delegationRequestId' failed to satisfy constraint: Member must have"
|
||||
+ " length greater than or equal to 16"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1691,8 +1691,8 @@ class IamIntegrationTest {
|
||||
.when().post("/").then()
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value '" + name
|
||||
+ "' at 'roleName' failed to satisfy constraint: " + entry.getValue()));
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
|
||||
+ " 'roleName' failed to satisfy constraint: " + entry.getValue()));
|
||||
|
||||
given()
|
||||
.formParam("Action", "GetRole")
|
||||
@@ -1728,8 +1728,8 @@ class IamIntegrationTest {
|
||||
.when().post("/").then()
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value ''"
|
||||
+ " at 'roleName' failed to satisfy constraint: Member must have length greater than or equal to 1"));
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
|
||||
+ " 'roleName' failed to satisfy constraint: Member must have length greater than or equal to 1"));
|
||||
|
||||
given()
|
||||
.formParam("Action", "CreateRole")
|
||||
@@ -1744,7 +1744,7 @@ class IamIntegrationTest {
|
||||
@Order(87)
|
||||
void roleActionsRejectANameOutsideTheRoleNamePattern() {
|
||||
String name = "aws:ec2-instance";
|
||||
String message = "1 validation error detected: Value '" + name + "' at 'roleName' failed to satisfy"
|
||||
String message = "1 validation error detected: Value at 'roleName' failed to satisfy"
|
||||
+ " constraint: Member must satisfy regular expression pattern: [\\w+=,.@-]+";
|
||||
Map<String, Map<String, String>> actions = new LinkedHashMap<>();
|
||||
actions.put("GetRole", Map.of());
|
||||
|
||||
+4
-4
@@ -888,14 +888,14 @@ class IamListPaginationIntegrationTest {
|
||||
listRequest(action, fixture, Integer.toString(min - 1), null).when().post("/").then()
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value '"
|
||||
+ (min - 1) + "' at 'maxItems' failed to satisfy constraint: "
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: "
|
||||
+ "Value at 'maxItems' failed to satisfy constraint: "
|
||||
+ "Member must have value greater than or equal to " + min));
|
||||
listRequest(action, fixture, Integer.toString(max + 1), null).when().post("/").then()
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value '"
|
||||
+ (max + 1) + "' at 'maxItems' failed to satisfy constraint: "
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: "
|
||||
+ "Value at 'maxItems' failed to satisfy constraint: "
|
||||
+ "Member must have value less than or equal to " + max));
|
||||
|
||||
List<String> all = walkFrom(action, paginator, fixture, Integer.toString(max), null);
|
||||
|
||||
+29
-30
@@ -18,8 +18,9 @@ import static org.hamcrest.Matchers.not;
|
||||
* #6402 settled for this package.
|
||||
*
|
||||
* <p>{@code AttachRolePolicy}'s {@code RoleName} is the parity case rather than a change:
|
||||
* {@code IamService.validateRoleName} already answered it in this form, from the same bounds and
|
||||
* the same pattern, and the message is unchanged by the model taking it over.
|
||||
* {@code IamService.validateRoleName} answers it from the same bounds and the same pattern, and
|
||||
* both write the message IAM writes, which names the member with no value beside it: that is
|
||||
* DRIFT-13's reading, and `docs/services/iam.md` carries it.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class IamRequestConstraintsIntegrationTest {
|
||||
@@ -48,9 +49,8 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("PolicyArn", "arn:aws:iam::1:p/ab")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value 'arn:aws:iam::1:p/ab' at"
|
||||
+ " 'policyArn' failed to satisfy constraint: Member must have length greater"
|
||||
+ " than or equal to 20"))
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'policyArn' failed to"
|
||||
+ " satisfy constraint: Member must have length greater than or equal to 20"))
|
||||
.body(not(containsString("NoSuchEntity")));
|
||||
|
||||
// The same ARN one character longer clears the constraint and reaches the lookup.
|
||||
@@ -76,7 +76,7 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("PolicyArn", SHORTEST_ARN)
|
||||
.formParam("VersionId", "1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value '1' at 'versionId' failed to"
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'versionId' failed to"
|
||||
+ " satisfy constraint: Member must satisfy regular expression pattern:"
|
||||
+ " v[1-9][0-9]*(\\.[A-Za-z0-9-]*)?"));
|
||||
|
||||
@@ -98,10 +98,10 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("PolicyArn", SHORTEST_ARN)
|
||||
.formParam("PolicyDocument", "")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value '' at"
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value at"
|
||||
+ " 'policyDocument' failed to satisfy constraint: Member must have length"
|
||||
+ " greater than or equal to 1"))
|
||||
.body(MESSAGE, containsString("Value '' at 'policyDocument' failed to satisfy"
|
||||
.body(MESSAGE, containsString("Value at 'policyDocument' failed to satisfy"
|
||||
+ " constraint: Member must satisfy regular expression pattern:"));
|
||||
}
|
||||
|
||||
@@ -114,10 +114,10 @@ class IamRequestConstraintsIntegrationTest {
|
||||
*/
|
||||
@Test
|
||||
void twoBrokenMembersAreReportedTogetherInTheModelsOrder() {
|
||||
String expected = "2 validation errors detected: Value '" + "a".repeat(65) + "' at"
|
||||
+ " 'userName' failed to satisfy constraint: Member must have length less than"
|
||||
+ " or equal to 64; Value 'short' at 'policyArn' failed to satisfy constraint:"
|
||||
+ " Member must have length greater than or equal to 20";
|
||||
String expected = "2 validation errors detected: Value at 'userName' failed to satisfy"
|
||||
+ " constraint: Member must have length less than or equal to 64; Value at"
|
||||
+ " 'policyArn' failed to satisfy constraint: Member must have length greater"
|
||||
+ " than or equal to 20";
|
||||
|
||||
iam("AttachUserPolicy")
|
||||
.formParam("UserName", "a".repeat(65))
|
||||
@@ -144,9 +144,9 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("PolicyArn", SHORTEST_ARN)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value 'two words' at 'roleName'"
|
||||
+ " failed to satisfy constraint: Member must satisfy regular expression"
|
||||
+ " pattern: [\\w+=,.@-]+"));
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'roleName' failed to"
|
||||
+ " satisfy constraint: Member must satisfy regular expression pattern:"
|
||||
+ " [\\w+=,.@-]+"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,9 +170,9 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("PolicyArn", SHORTEST_ARN)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, equalTo("2 validation errors detected: Value '' at 'roleName' failed to"
|
||||
.body(MESSAGE, equalTo("2 validation errors detected: Value at 'roleName' failed to"
|
||||
+ " satisfy constraint: Member must have length greater than or equal to 1;"
|
||||
+ " Value '' at 'roleName' failed to satisfy constraint: Member must satisfy"
|
||||
+ " Value at 'roleName' failed to satisfy constraint: Member must satisfy"
|
||||
+ " regular expression pattern: [\\w+=,.@-]+"));
|
||||
|
||||
// The same empty name on an operation this wave leaves alone, reported the older way.
|
||||
@@ -180,7 +180,7 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("RoleName", "")
|
||||
.formParam("AssumeRolePolicyDocument", TRUST_POLICY)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value '' at 'roleName' failed to"
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'roleName' failed to"
|
||||
+ " satisfy constraint: Member must have length greater than or equal to 1"));
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("RoleName", " ")
|
||||
.formParam("PolicyArn", SHORTEST_ARN)
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value ' ' at 'roleName' failed to"
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'roleName' failed to"
|
||||
+ " satisfy constraint: Member must satisfy regular expression pattern:"
|
||||
+ " [\\w+=,.@-]+"));
|
||||
}
|
||||
@@ -244,9 +244,9 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("Filter.member.1", "Users")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value 'Users' at"
|
||||
+ " 'filter.1.member' failed to satisfy constraint: Member must satisfy enum"
|
||||
+ " value set: [User, Role, Group, LocalManagedPolicy, AWSManagedPolicy]"));
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'filter.1.member'"
|
||||
+ " failed to satisfy constraint: Member must satisfy enum value set:"
|
||||
+ " [User, Role, Group, LocalManagedPolicy, AWSManagedPolicy]"));
|
||||
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.formParam("Filter.member.1", "User")
|
||||
@@ -265,9 +265,9 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("Filter.member.9", "Policies")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value 'Users' at"
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value at"
|
||||
+ " 'filter.2.member'"))
|
||||
.body(MESSAGE, containsString("Value 'Policies' at 'filter.9.member'"));
|
||||
.body(MESSAGE, containsString("Value at 'filter.9.member'"));
|
||||
}
|
||||
|
||||
/** {@code maxItemsType} is 1 to 1000, which this operation reads nothing of today. */
|
||||
@@ -277,8 +277,8 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("MaxItems", "1001")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value '1001' at 'maxItems' failed"
|
||||
+ " to satisfy constraint: Member must have value less than or equal to 1000"));
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'maxItems' failed to"
|
||||
+ " satisfy constraint: Member must have value less than or equal to 1000"));
|
||||
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.formParam("MaxItems", "1000")
|
||||
@@ -289,9 +289,8 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("MaxItems", "9223372036854775808")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value '9223372036854775808' at"
|
||||
+ " 'maxItems' failed to satisfy constraint: Member must have value less than"
|
||||
+ " or equal to 1000"));
|
||||
.body(MESSAGE, equalTo("1 validation error detected: Value at 'maxItems' failed to"
|
||||
+ " satisfy constraint: Member must have value less than or equal to 1000"));
|
||||
}
|
||||
|
||||
/** A marker sent empty breaks its minimum and its pattern, and both are reported. */
|
||||
@@ -301,7 +300,7 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.formParam("Marker", "")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value '' at 'marker'"
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value at 'marker'"
|
||||
+ " failed to satisfy constraint: Member must have length greater than or"
|
||||
+ " equal to 1"))
|
||||
.body(MESSAGE, containsString("Member must satisfy regular expression pattern:"));
|
||||
|
||||
+24
-2
@@ -286,6 +286,12 @@ class OrganizationsAccessReportIntegrationTest {
|
||||
.body("ErrorResponse.Error.Code", equalTo("AccessDenied"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The whole message rather than the code alone, because the form it takes is the thing worth
|
||||
* pinning: this operation names the member with no value beside it, as every other IAM check
|
||||
* does, and the member that never arrived is the one place a word still stands where a value
|
||||
* would.
|
||||
*/
|
||||
@Test
|
||||
void anEntityPathTheModelRejectsIsAValidationError() {
|
||||
organizationWithScpsEnabled();
|
||||
@@ -293,7 +299,23 @@ class OrganizationsAccessReportIntegrationTest {
|
||||
iam(MANAGEMENT_ACCOUNT, "GenerateOrganizationsAccessReport")
|
||||
.formParam("EntityPath", "o-a1b2c3d4e5")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"));
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
|
||||
+ " 'entityPath' failed to satisfy constraint: Member must have length"
|
||||
+ " greater than or equal to 19"));
|
||||
|
||||
iam(MANAGEMENT_ACCOUNT, "GenerateOrganizationsAccessReport")
|
||||
.formParam("EntityPath", "o-a1b2c3d4e5/x-0000/not a path")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value at"
|
||||
+ " 'entityPath' failed to satisfy constraint: Member must satisfy regular"
|
||||
+ " expression pattern: ^o-[0-9a-z]{10,32}\\/r-[0-9a-z]{4,32}[0-9a-z-\\/]*"));
|
||||
|
||||
iam(MANAGEMENT_ACCOUNT, "GenerateOrganizationsAccessReport")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body("ErrorResponse.Error.Message", equalTo("1 validation error detected: Value"
|
||||
+ " null at 'entityPath' failed to satisfy constraint: Member must not be"
|
||||
+ " null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -491,7 +513,7 @@ class OrganizationsAccessReportIntegrationTest {
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo(
|
||||
"1 validation error detected: Value '1001' at 'maxItems' failed to satisfy "
|
||||
"1 validation error detected: Value at 'maxItems' failed to satisfy "
|
||||
+ "constraint: Member must have value less than or equal to 1000"));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -806,7 +806,7 @@ class ServiceLastAccessedIntegrationTest {
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", equalTo(
|
||||
"1 validation error detected: Value '0' at 'maxItems' failed to satisfy "
|
||||
"1 validation error detected: Value at 'maxItems' failed to satisfy "
|
||||
+ "constraint: Member must have value greater than or equal to 1"));
|
||||
}
|
||||
|
||||
@@ -1035,7 +1035,7 @@ class ServiceLastAccessedIntegrationTest {
|
||||
// broke: an over-large MaxItems says nothing about the minimum. Asserted on the parsed
|
||||
// element because the raw body escapes the quotes as '.
|
||||
.body("ErrorResponse.Error.Message", equalTo(
|
||||
"1 validation error detected: Value '1001' at 'maxItems' failed to satisfy "
|
||||
"1 validation error detected: Value at 'maxItems' failed to satisfy "
|
||||
+ "constraint: Member must have value less than or equal to 1000"));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user