Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(iam): name the member without the offending value in a validation error (#6811)

Priamo Germosen66066574342b
diff --git a/docs/services/iam.md b/docs/services/iam.md
index e7926161e2..501e70bd78 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -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 |
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/QueryConstraintCheck.java b/src/main/java/io/github/hectorvent/floci/core/common/QueryConstraintCheck.java
index 1ed3855737..82cba9772a 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/QueryConstraintCheck.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/QueryConstraintCheck.java
@@ -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);
}
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/SmithyValidationErrors.java b/src/main/java/io/github/hectorvent/floci/core/common/SmithyValidationErrors.java
index de34c23514..2cd32af967 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/SmithyValidationErrors.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/SmithyValidationErrors.java
@@ -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);
+ }
+ }
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/DelegationRequestService.java b/src/main/java/io/github/hectorvent/floci/services/iam/DelegationRequestService.java
index ca46c55cbe..ab2d23f38e 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/DelegationRequestService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/DelegationRequestService.java
@@ -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) {
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java
index f7710ed652..2ff9d33747 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamQueryHandler.java
@@ -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) {
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamRequestShapes.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamRequestShapes.java
index 27d12a98c9..5b235dadec 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/IamRequestShapes.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamRequestShapes.java
@@ -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() {
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java
index ebb5d63f96..7b28349c39 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamService.java
@@ -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) {
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamValidationErrors.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamValidationErrors.java
new file mode 100644
index 0000000000..4f7028c20a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamValidationErrors.java
@@ -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));
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportService.java b/src/main/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportService.java
index 72494e9dca..65bbe7381e 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportService.java
@@ -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,
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedService.java b/src/main/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedService.java
index 8e970c4a01..ade7b9cc88 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedService.java
@@ -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]");
}
}
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/QueryConstraintCheckTest.java b/src/test/java/io/github/hectorvent/floci/core/common/QueryConstraintCheckTest.java
index 8960c37fb7..221c0e7d32 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/QueryConstraintCheckTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/QueryConstraintCheckTest.java
@@ -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")),
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/SmithyValidationErrorsTest.java b/src/test/java/io/github/hectorvent/floci/core/common/SmithyValidationErrorsTest.java
index 7cf3660f09..ceb857c6d4 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/SmithyValidationErrorsTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/SmithyValidationErrorsTest.java
@@ -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));
+ }
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/DelegationRequestIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/DelegationRequestIntegrationTest.java
index a950e8b89f..fbad8ef629 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/DelegationRequestIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/DelegationRequestIntegrationTest.java
@@ -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
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java
index 96ace60dba..c0bb1ab70c 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamIntegrationTest.java
@@ -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());
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamListPaginationIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamListPaginationIntegrationTest.java
index 55514862dd..834e00c352 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamListPaginationIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamListPaginationIntegrationTest.java
@@ -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);
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestConstraintsIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestConstraintsIntegrationTest.java
index 9775d27125..3681422639 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestConstraintsIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestConstraintsIntegrationTest.java
@@ -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:"));
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportIntegrationTest.java
index d343926d21..66deef050f 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/OrganizationsAccessReportIntegrationTest.java
@@ -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"));
}
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedIntegrationTest.java
index cc0841bace..3769077bc0 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/ServiceLastAccessedIntegrationTest.java
@@ -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 &apos;.
.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"));
}