mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(iam): read a Query list's constraints from the model (#6625)
The Query walk the managed-policy family reads its constraints through read scalars only, and refused an operation whose input carries a list when the vendored file loaded. It reads a list now, and a structure, which is what the rest of this track is gated on: 34 of IAM's 180 operations carry a list or a map, and 6 of STS's 11 do. A list arrives numbered under its own name, Audience.member.1 or the bare Audience.1, and a member of a list of structures carries its fields under that prefix, as Tags.member.1.Key does. Each is named in a message the way this package already names one, filter.1.member and tags.1.member.key, under the index the request spelled rather than the position the member sits at, which is what #6478 settled. The count is held to the list's own bounds with the value left out of the message, which is the form checkListLength and the audience check both already answer: quoting it would echo every member of the list back. A list of no members is how an absent list arrives on this protocol, so a required one reads as null rather than as a list breaking a minimum of 1, and only a minimum above 1 is reachable at all. A structure member arrives as TaskPolicyArn.Arn and is named taskPolicyArn.arn, and a request naming none of its fields is a request without the member. GetAccountAuthorizationDetails is the operation this wave opts in, and the one where the model adds refusals rather than rewording an answer already given: the handler reads none of its three declared members, so a Filter outside the model's enum, a MaxItems outside 1 to 1000 and a Marker breaking its length or its pattern are all answered with a 200 today. They are a 400 ValidationError now, which is the ordering #6402 settled for this package. A map is still refused when the file loads, and so is anything nested deeper than a list of structures. The refusal is the point rather than a gap: this package answers a map against the whole map today, Map keys must satisfy constraint on PutAccountProperties, where the protocol numbers a map's entries as Properties.entry.N.key, and no source here says which of the two AWS answers. Reading one would reword a merged answer on the strength of a guess. The reader the walk needs went into AwsQueryLists rather than into a third copy. That file already reads a list's values, and StsQueryHandler holds a private copy that captures the prefix and the index for the same reason this one does; the STS wave is where that copy goes. A number too large for a long is a number all the same, which the range check reads as one now. It compared through a long before, so a MaxItems of 9223372036854775808 failed to parse, read as no number at all and reached the operation past a maximum of 1000. The bound it breaks is one that fits in a long either way, so the comparison carries no width of its own, and the value is written as the number reads rather than as the request spelled it, a leading plus or zero gone, which is what a parsed value already answered. Seven unit tests cover the new forms, two of them on the reader, which is where one of them found that a key naming its own member read as a member numbered after it: the index is a number or the key is not a member's. Four wire tests cover the operation. Removing the list branch fails four of the six list and structure tests and two of the four wire tests: the two that stay green are MaxItems and Marker, scalars the walk already read, so they prove the operation was opted in rather than the walk.
This commit is contained in:
1 parent
7c0ee92480
commit
0ec28aee68
10 files changed
+604
-64
No files matched your search
@@ -50,6 +50,38 @@ class AwsQueryListsTest {
|
||||
assertEquals(List.of(), AwsQueryLists.values(params, "TagKeys", "TagKey"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void membersCarryThePrefixTheirFieldsArriveUnderAndTheIndexAsSpelled() {
|
||||
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
|
||||
params.putSingle("Tags.member.7.Key", "team");
|
||||
params.putSingle("Tags.member.7.Value", "platform");
|
||||
params.putSingle("Tags.member.2.Key", "owner");
|
||||
params.putSingle("Audience.1", "");
|
||||
params.putSingle("Audience.member.3", "second");
|
||||
params.putSingle("OtherTags.member.1.Key", "another list");
|
||||
|
||||
assertEquals(List.of(new AwsQueryLists.IndexedMember("Tags.member.2", "2"),
|
||||
new AwsQueryLists.IndexedMember("Tags.member.7", "7")),
|
||||
AwsQueryLists.members(params, "Tags", null),
|
||||
"one member per index, in the order the indexes read");
|
||||
assertEquals(List.of(new AwsQueryLists.IndexedMember("Audience.1", "1"),
|
||||
new AwsQueryLists.IndexedMember("Audience.member.3", "3")),
|
||||
AwsQueryLists.members(params, "Audience", null),
|
||||
"the bare numbered form is a member too, empty value and all");
|
||||
assertEquals(List.of(), AwsQueryLists.members(params, "Filter", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMemberIsReadUnderTheNameItsShapeGivesItToo() {
|
||||
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
|
||||
params.putSingle("SubnetIds.SubnetIdentifier.4", "fourth");
|
||||
|
||||
assertEquals(List.of(new AwsQueryLists.IndexedMember("SubnetIds.SubnetIdentifier.4", "4")),
|
||||
AwsQueryLists.members(params, "SubnetIds", "SubnetIdentifier"));
|
||||
assertEquals(List.of(), AwsQueryLists.members(params, "SubnetIds", null),
|
||||
"without the name, the generic and bare forms only");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aMemberIndexIsTheNumberTheKeyEndsIn() {
|
||||
assertEquals(12, AwsQueryLists.memberIndex("Filters.Filter.3.Values.Value.12"));
|
||||
|
||||
+200
-21
@@ -33,10 +33,38 @@ class QueryConstraintCheckTest {
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String LIST_MODEL = """
|
||||
{
|
||||
"operations": {"Vend": "VendRequest"},
|
||||
"shapes": {
|
||||
"VendRequest": {"type": "structure", "required": ["Audience", "Target"], "members": {
|
||||
"Audience": "audienceList", "Names": "nameList", "Tags": "tagList",
|
||||
"Target": "targetType"}},
|
||||
"audienceList": {"type": "list", "member": "audienceType", "min": 1, "max": 2},
|
||||
"audienceType": {"type": "string", "min": 1, "max": 6},
|
||||
"nameList": {"type": "list", "member": "nameType", "min": 2},
|
||||
"tagList": {"type": "list", "member": "tagType", "max": 2},
|
||||
"tagType": {"type": "structure", "required": ["Key", "Value"], "members": {
|
||||
"Key": "nameType", "Value": "valueType"}},
|
||||
"targetType": {"type": "structure", "required": ["Arn"], "members": {
|
||||
"Arn": "arnType", "Note": "valueType"}},
|
||||
"nameType": {"type": "string", "min": 1, "max": 8, "pattern": "[\\\\w+=,.@-]+"},
|
||||
"valueType": {"type": "string", "max": 4},
|
||||
"arnType": {"type": "string", "min": 20, "max": 2048}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
private static final String ARN = "arn:aws:iam::000000000000:role/r";
|
||||
|
||||
private static QueryConstraintCheck check() throws Exception {
|
||||
return QueryConstraintCheck.of(MAPPER.readTree(MODEL));
|
||||
}
|
||||
|
||||
private static QueryConstraintCheck lists() throws Exception {
|
||||
return QueryConstraintCheck.of(MAPPER.readTree(LIST_MODEL));
|
||||
}
|
||||
|
||||
private static MultivaluedMap<String, String> params(String... pairs) {
|
||||
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
|
||||
for (int pair = 0; pair < pairs.length; pair += 2) {
|
||||
@@ -114,6 +142,32 @@ class QueryConstraintCheckTest {
|
||||
assertEquals(List.of(), check().violations("Put", words));
|
||||
}
|
||||
|
||||
/**
|
||||
* A number too large for a {@code long} is a number all the same, and the bound it breaks is
|
||||
* one that fits in one. Reading it as no number at all would have let it past the maximum.
|
||||
*/
|
||||
@Test
|
||||
void aNumberTooLargeForALongIsStillHeldToItsRange() throws Exception {
|
||||
assertEquals(List.of("Value '9223372036854775808' at 'age' failed to satisfy constraint: "
|
||||
+ "Member must have value less than or equal to 30"),
|
||||
check().violations("Put", params("Name", "ok", "Arn", "a".repeat(20),
|
||||
"Age", "9223372036854775808")));
|
||||
|
||||
assertEquals(List.of("Value '-9223372036854775809' at 'age' failed to satisfy constraint: "
|
||||
+ "Member must have value greater than or equal to 1"),
|
||||
check().violations("Put", params("Name", "ok", "Arn", "a".repeat(20),
|
||||
"Age", "-9223372036854775809")));
|
||||
|
||||
assertEquals(List.of("Value '31' at 'age' failed to satisfy constraint: "
|
||||
+ "Member must have value less than or equal to 30"),
|
||||
check().violations("Put", params("Name", "ok", "Arn", "a".repeat(20), "Age", "+31")),
|
||||
"a value is written as the number reads, the plus gone, as a parsed one already was");
|
||||
|
||||
assertEquals(List.of(), check().violations("Put",
|
||||
params("Name", "ok", "Arn", "a".repeat(20), "Age", "+2")),
|
||||
"and a signed value inside the range is still inside it");
|
||||
}
|
||||
|
||||
/** A boolean declares nothing a request can break, so nothing is checked for one. */
|
||||
@Test
|
||||
void aBooleanIsNotChecked() throws Exception {
|
||||
@@ -142,46 +196,163 @@ class QueryConstraintCheckTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* A list or a map is read from numbered parameters rather than from one, so an operation
|
||||
* carrying either is refused when the file loads rather than passed over without its
|
||||
* constraints.
|
||||
* A map is read from numbered entries whose key is a value of its own, and this package answers
|
||||
* one today against the whole map rather than against an entry, so an operation carrying one is
|
||||
* refused when the file loads rather than passed over without its constraints. So is anything
|
||||
* nested deeper than a list of structures or a structure of scalars.
|
||||
*/
|
||||
@Test
|
||||
void anOperationCarryingAListIsRefusedWhenTheFileLoads() throws Exception {
|
||||
JsonNode model = MAPPER.readTree("""
|
||||
void anOperationCarryingAMapOrDeeperNestingIsRefusedWhenTheFileLoads() throws Exception {
|
||||
JsonNode map = MAPPER.readTree("""
|
||||
{
|
||||
"operations": {"Tag": "TagRequest"},
|
||||
"operations": {"Put": "PutRequest"},
|
||||
"shapes": {
|
||||
"TagRequest": {"type": "structure", "members": {"Tags": "tagList"}},
|
||||
"tagList": {"type": "list", "member": "nameType", "max": 50},
|
||||
"PutRequest": {"type": "structure", "members": {"Properties": "propertyMap"}},
|
||||
"propertyMap": {"type": "map", "key": "nameType", "value": "nameType"},
|
||||
"nameType": {"type": "string", "min": 1}
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
IllegalStateException thrown =
|
||||
assertThrows(IllegalStateException.class, () -> QueryConstraintCheck.of(model));
|
||||
IllegalStateException refused =
|
||||
assertThrows(IllegalStateException.class, () -> QueryConstraintCheck.of(map));
|
||||
assertTrue(refused.getMessage().contains("Put's Properties is a map"), refused.getMessage());
|
||||
|
||||
assertTrue(thrown.getMessage().contains("Tag's Tags is a list"), thrown.getMessage());
|
||||
JsonNode listOfLists = MAPPER.readTree("""
|
||||
{
|
||||
"operations": {"Put": "PutRequest"},
|
||||
"shapes": {
|
||||
"PutRequest": {"type": "structure", "members": {"Rows": "rowList"}},
|
||||
"rowList": {"type": "list", "member": "nameList"},
|
||||
"nameList": {"type": "list", "member": "nameType"},
|
||||
"nameType": {"type": "string", "min": 1}
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
IllegalStateException nested =
|
||||
assertThrows(IllegalStateException.class, () -> QueryConstraintCheck.of(listOfLists));
|
||||
assertTrue(nested.getMessage().contains("Put's Rows is a list of list"), nested.getMessage());
|
||||
|
||||
JsonNode structureInStructure = MAPPER.readTree("""
|
||||
{
|
||||
"operations": {"Put": "PutRequest"},
|
||||
"shapes": {
|
||||
"PutRequest": {"type": "structure", "members": {"Target": "targetType"}},
|
||||
"targetType": {"type": "structure", "members": {"Inner": "innerType"}},
|
||||
"innerType": {"type": "structure", "members": {"Name": "nameType"}},
|
||||
"nameType": {"type": "string", "min": 1}
|
||||
}
|
||||
}
|
||||
""");
|
||||
|
||||
IllegalStateException deeper = assertThrows(IllegalStateException.class,
|
||||
() -> QueryConstraintCheck.of(structureInStructure));
|
||||
assertTrue(deeper.getMessage().contains("Put's Target.Inner is a structure"),
|
||||
deeper.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* A list's members are held to the element's own constraints, each named under the index the
|
||||
* request spelled rather than the position it sits at, which is what #6478 settled for a member
|
||||
* of a Query list. A member present and empty is still a member.
|
||||
*/
|
||||
@Test
|
||||
void aListsMembersAreNamedUnderTheIndexTheRequestSpelled() throws Exception {
|
||||
List<String> violations = lists().violations("Vend", params(
|
||||
"Audience.member.1", "", "Audience.member.7", "overlong", "Target.Arn", ARN));
|
||||
|
||||
assertEquals(List.of(
|
||||
"Value '' at 'audience.1.member' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 1",
|
||||
"Value 'overlong' at 'audience.7.member' failed to satisfy constraint: "
|
||||
+ "Member must have length less than or equal to 6"),
|
||||
violations);
|
||||
|
||||
assertEquals(List.of("Value '' at 'audience.1.member' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 1"),
|
||||
lists().violations("Vend", params("Audience.1", "", "Target.Arn", ARN)),
|
||||
"the bare numbered form is a member too");
|
||||
}
|
||||
|
||||
/**
|
||||
* The count is held to the list's own bounds, with the value left out of the message: quoting it
|
||||
* would echo every member of the list back. A list of no members is how an absent list arrives
|
||||
* on this protocol, so a required one reads as null and a minimum of 1 is unreachable.
|
||||
*/
|
||||
@Test
|
||||
void aListIsHeldToItsOwnBoundsAndOneOfNoMembersReadsAsAbsent() throws Exception {
|
||||
assertEquals(List.of("Value at 'audience' failed to satisfy constraint: "
|
||||
+ "Member must have length less than or equal to 2"),
|
||||
lists().violations("Vend", params("Audience.member.1", "a", "Audience.member.2", "b",
|
||||
"Audience.member.3", "c", "Target.Arn", ARN)));
|
||||
|
||||
assertEquals(List.of("Value null at 'audience' failed to satisfy constraint: "
|
||||
+ "Member must not be null"),
|
||||
lists().violations("Vend", params("Target.Arn", ARN)),
|
||||
"a required list of no members is the member reading as null");
|
||||
|
||||
assertEquals(List.of("Value at 'names' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 2"),
|
||||
lists().violations("Vend", params("Audience.member.1", "a", "Target.Arn", ARN,
|
||||
"Names.member.1", "one")),
|
||||
"a minimum above one is reachable, where a minimum of one is not");
|
||||
}
|
||||
|
||||
/** A member of a list of structures carries its fields under its own prefix. */
|
||||
@Test
|
||||
void aListOfStructuresNamesEachFieldUnderItsMember() throws Exception {
|
||||
List<String> violations = lists().violations("Vend", params(
|
||||
"Audience.member.1", "a", "Target.Arn", ARN,
|
||||
"Tags.member.1.Key", "", "Tags.member.1.Value", "toolong",
|
||||
"Tags.member.2.Key", "ok"));
|
||||
|
||||
assertEquals(List.of(
|
||||
"Value '' at 'tags.1.member.key' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 1",
|
||||
"Value '' at 'tags.1.member.key' failed to satisfy constraint: "
|
||||
+ "Member must satisfy regular expression pattern: [\\w+=,.@-]+",
|
||||
"Value 'toolong' at 'tags.1.member.value' failed to satisfy constraint: "
|
||||
+ "Member must have length less than or equal to 4",
|
||||
"Value null at 'tags.2.member.value' failed to satisfy constraint: "
|
||||
+ "Member must not be null"),
|
||||
violations);
|
||||
}
|
||||
|
||||
/**
|
||||
* A structure member arrives under its own name, and a request naming none of its fields is a
|
||||
* request without the member at all.
|
||||
*/
|
||||
@Test
|
||||
void aStructureMemberNamesItsFieldsUnderItAndReadsAsAbsentWithNone() throws Exception {
|
||||
assertEquals(List.of(
|
||||
"Value null at 'target.arn' failed to satisfy constraint: Member must not be null",
|
||||
"Value 'toolong' at 'target.note' failed to satisfy constraint: "
|
||||
+ "Member must have length less than or equal to 4"),
|
||||
lists().violations("Vend", params("Audience.member.1", "a", "Target.Note", "toolong")));
|
||||
|
||||
assertEquals(List.of("Value null at 'target' failed to satisfy constraint: "
|
||||
+ "Member must not be null"),
|
||||
lists().violations("Vend", params("Audience.member.1", "a")));
|
||||
}
|
||||
|
||||
/**
|
||||
* The vendored IAM file itself, read the way the handler reads it. Loading it is the check on
|
||||
* it: every operation's members have to be scalars and every pattern has to be one Java's
|
||||
* engine compiles, and a wave that breaks either would otherwise surface as a failure on the
|
||||
* first IAM request rather than here. Naming the twelve operations keeps the wave's own
|
||||
* contract, so an operation renamed or dropped in the model is a failure with a name on it.
|
||||
* it: every operation's members have to be ones this walk reads and every pattern has to be one
|
||||
* Java's engine compiles, and a wave that breaks either would otherwise surface as a failure on
|
||||
* the first IAM request rather than here. Naming the operations keeps each wave's own contract,
|
||||
* so one renamed or dropped in the model is a failure with a name on it.
|
||||
*/
|
||||
@Test
|
||||
void theVendoredIamFileLoadsAndCarriesTheOperationsThisWaveClaims() {
|
||||
void theVendoredIamFileLoadsAndCarriesTheOperationsTheseWavesClaim() {
|
||||
QueryConstraintCheck iam =
|
||||
QueryConstraintCheck.load("aws/iam-request-shapes.json", "IAM request shapes");
|
||||
|
||||
List<String> wave = List.of("AttachGroupPolicy", "AttachRolePolicy", "AttachUserPolicy",
|
||||
"DetachGroupPolicy", "DetachRolePolicy", "DetachUserPolicy", "GetPolicy",
|
||||
"DeletePolicy", "CreatePolicyVersion", "GetPolicyVersion", "DeletePolicyVersion",
|
||||
"SetDefaultPolicyVersion");
|
||||
for (String operation : wave) {
|
||||
List<String> managedPolicyFamily = List.of("AttachGroupPolicy", "AttachRolePolicy",
|
||||
"AttachUserPolicy", "DetachGroupPolicy", "DetachRolePolicy", "DetachUserPolicy",
|
||||
"GetPolicy", "DeletePolicy", "CreatePolicyVersion", "GetPolicyVersion",
|
||||
"DeletePolicyVersion", "SetDefaultPolicyVersion");
|
||||
for (String operation : managedPolicyFamily) {
|
||||
assertTrue(iam.violations(operation, params()).stream()
|
||||
.allMatch(violation -> violation.contains("must not be null")),
|
||||
operation + " reported something other than its absent required members");
|
||||
@@ -192,5 +363,13 @@ class QueryConstraintCheckTest {
|
||||
assertEquals(List.of("Value 'v1' 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:"
|
||||
+ " Member must satisfy enum value set:"
|
||||
+ " [User, Role, Group, LocalManagedPolicy, AWSManagedPolicy]"),
|
||||
iam.violations("GetAccountAuthorizationDetails", params("Filter.member.1", "Users")),
|
||||
"the one list this wave opts in resolves to its member's enum");
|
||||
}
|
||||
}
|
||||
+81
-5
@@ -10,11 +10,12 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
/**
|
||||
* The declared constraints the managed-policy family is now read against, from the model rather
|
||||
* than from a hand-written check. What they change is the status: a value that breaks a declared
|
||||
* constraint used to reach the store and answer {@code NoSuchEntity}, where AWS's validation layer
|
||||
* runs ahead of the operation and answers {@code ValidationError}, which is the ordering #6402
|
||||
* settled for this package.
|
||||
* The declared constraints the managed-policy family and {@code GetAccountAuthorizationDetails} are
|
||||
* now read against, from the model rather than from a hand-written check. What they change is the
|
||||
* status: a value that breaks a declared constraint used to reach the store and answer
|
||||
* {@code NoSuchEntity}, or on the second of those to be answered with a 200, where AWS's validation
|
||||
* layer runs ahead of the operation and answers {@code ValidationError}, which is the ordering
|
||||
* #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
|
||||
@@ -230,4 +231,79 @@ class IamRequestConstraintsIntegrationTest {
|
||||
.when().post("/").then().statusCode(404)
|
||||
.body(CODE, equalTo("NoSuchEntity"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code GetAccountAuthorizationDetails} is the first operation read through the list walk, and
|
||||
* none of its three members was read at all before: a {@code Filter} outside the model's enum,
|
||||
* a {@code MaxItems} outside its range and a {@code Marker} breaking its length all reached the
|
||||
* operation and were answered with a 200.
|
||||
*/
|
||||
@Test
|
||||
void aFilterMemberOutsideItsEnumIsRefusedWhereItUsedToBeIgnored() {
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.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]"));
|
||||
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.formParam("Filter.member.1", "User")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(containsString("GetAccountAuthorizationDetailsResult"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Each member of a list is named under the index the request spelled rather than the position
|
||||
* it sits at, and the two are reported together in one message.
|
||||
*/
|
||||
@Test
|
||||
void twoBrokenListMembersAreReportedTogetherUnderTheIndexesTheRequestSpelled() {
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.formParam("Filter.member.2", "Users")
|
||||
.formParam("Filter.member.9", "Policies")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.body(MESSAGE, containsString("2 validation errors detected: Value 'Users' at"
|
||||
+ " 'filter.2.member'"))
|
||||
.body(MESSAGE, containsString("Value 'Policies' at 'filter.9.member'"));
|
||||
}
|
||||
|
||||
/** {@code maxItemsType} is 1 to 1000, which this operation reads nothing of today. */
|
||||
@Test
|
||||
void aMaxItemsOutsideItsRangeIsRefused() {
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.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"));
|
||||
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.formParam("MaxItems", "1000")
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
// A number too large for a long is a number all the same, and 1000 is still the bound.
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.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"));
|
||||
}
|
||||
|
||||
/** A marker sent empty breaks its minimum and its pattern, and both are reported. */
|
||||
@Test
|
||||
void anEmptyMarkerBreaksItsLengthAndItsPattern() {
|
||||
iam("GetAccountAuthorizationDetails")
|
||||
.formParam("Marker", "")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(CODE, equalTo("ValidationError"))
|
||||
.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:"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user