mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(ses): implement v1 ReorderReceiptRuleSet and CloneReceiptRuleSet (#3176)
* feat(ses): implement v1 ReorderReceiptRuleSet and CloneReceiptRuleSet Completes the SES v1 receipt management surface with the two remaining rule-set actions, both reproducing wire behavior probed against real AWS (us-east-1, 2026-09). ReorderReceiptRuleSet demands an exact permutation of the set's rules, with the probed error precedence: rule-set existence first, then a duplicate request name (InvalidParameterValue "Multiple positions found for rule", even when the duplicated name is not in the set), then set rules absent from the request (listed in set order), then request names not in the set (RuleDoesNotExist, first in request order). RuleNames members validate at the Smithy layer under the bare 'ruleNames' path with a nested list-member constraint whose length cap is 100; there is no service-level "Not a valid ruleName" stage, so a 65-char name lands on RuleDoesNotExist. A failed reorder leaves the order unchanged. CloneReceiptRuleSet deep-copies the source's rules under a new creation timestamp; the active flag stays behind. Name validation is two-layer for both members: the Smithy pattern combines violations with originalRuleSetName listed first, and the service-level 64-char check reports the target before the source. An existing target wins over a missing source (AlreadyExists before RuleSetDoesNotExist). Covered by unit tests, Query-protocol integration tests, and AWS SDK compatibility tests run against a live local instance. * fix(ses): parse ReorderReceiptRuleSet RuleNames with the probed AWS index grammar Review flagged that a sparse Query list (RuleNames.member.1 plus member.3) was silently truncated at the first missing index. Probing real SES with raw signed Query requests showed the string-list grammar differs from the receipt-action struct-list grammar: a gap is padded with empty members (which then fail the ruleNames Smithy constraint, so nothing is ever truncated) up to a skip of 10, counted from the previous index or from 1 for a leading gap; a larger gap is MalformedInput "Excessively sparse input would skip N list elements" with a comma-grouped count; an index above 214748369 (exact boundary, found by bisection) is MalformedInput "Index N is illegal"; index 0, a leading-zero spelling, and a non-numeric token are each their own probed MalformedInput; and a repeated index keeps its first value. The same probing showed the ruleNames Smithy violation carries no member index and appears at most once however many members are malformed, so the service now emits it once instead of per member. Covered by wire-level integration tests for each grammar case and a unit test for the single-violation behavior.
This commit is contained in:
1 parent
438ae619fd
commit
f485122ffc
10 files changed
+692
-10
No files matched your search
@@ -585,6 +585,209 @@ class SesReceiptRuleServiceTest {
|
||||
assertEquals("RuleSetDoesNotExist", e.getErrorCode());
|
||||
}
|
||||
|
||||
// ---- reorder / clone ----
|
||||
|
||||
private void createThreeRuleSet(String name) {
|
||||
service.createReceiptRuleSet(name, REGION);
|
||||
service.createReceiptRule(name, rule("r1"), null, REGION, ANY_SENDER_VERIFIED);
|
||||
service.createReceiptRule(name, rule("r2"), "r1", REGION, ANY_SENDER_VERIFIED);
|
||||
service.createReceiptRule(name, rule("r3"), "r2", REGION, ANY_SENDER_VERIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_appliesFullPermutation() {
|
||||
createThreeRuleSet("rules-a");
|
||||
service.reorderReceiptRuleSet("rules-a", List.of("r3", "r1", "r2"), REGION);
|
||||
assertEquals(List.of("r3", "r1", "r2"), ruleNames("rules-a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_identityOrder_isNoOp() {
|
||||
createThreeRuleSet("rules-a");
|
||||
service.reorderReceiptRuleSet("rules-a", List.of("r1", "r2", "r3"), REGION);
|
||||
assertEquals(List.of("r1", "r2", "r3"), ruleNames("rules-a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_unknownSet_throwsBeforeRuleNameProblems() {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("ghost", List.of("rX", "rX"), REGION));
|
||||
assertEquals("RuleSetDoesNotExist", e.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_duplicateName_winsOverMissingAndUnknown() {
|
||||
createThreeRuleSet("rules-a");
|
||||
|
||||
// Duplicate of an existing name, with the set only partially covered.
|
||||
AwsException dup = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a", List.of("r1", "r1"), REGION));
|
||||
assertEquals("InvalidParameterValue", dup.getErrorCode());
|
||||
assertEquals("Multiple positions found for rule: r1", dup.getMessage());
|
||||
|
||||
// Duplicate of a name that is not in the set at all still takes the duplicate error.
|
||||
AwsException dupUnknown = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a",
|
||||
List.of("r1", "r2", "r3", "rX", "rX"), REGION));
|
||||
assertEquals("Multiple positions found for rule: rX", dupUnknown.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_missingRules_listedInSetOrder_beforeUnknownNames() {
|
||||
createThreeRuleSet("rules-a");
|
||||
service.reorderReceiptRuleSet("rules-a", List.of("r3", "r1", "r2"), REGION);
|
||||
|
||||
// Unknown rX does not surface while set rules are missing; the list follows set order.
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a", List.of("r2", "rX"), REGION));
|
||||
assertEquals("InvalidParameterValue", e.getErrorCode());
|
||||
assertEquals("Positions for rules not found: r3, r1", e.getMessage());
|
||||
|
||||
// An empty RuleNames list is the same error naming every rule.
|
||||
AwsException empty = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a", List.of(), REGION));
|
||||
assertEquals("Positions for rules not found: r3, r1, r2", empty.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_unknownName_reportsFirstInRequestOrder_andLeavesOrderUnchanged() {
|
||||
createThreeRuleSet("rules-a");
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a",
|
||||
List.of("r1", "r2", "r3", "rX", "rY"), REGION));
|
||||
assertEquals("RuleDoesNotExist", e.getErrorCode());
|
||||
assertEquals("Rule does not exist: rX", e.getMessage());
|
||||
assertEquals(List.of("r1", "r2", "r3"), ruleNames("rules-a"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_ruleNamesMembers_getNestedSmithyViolation_beforeSetExistence() {
|
||||
AwsException badChar = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("ghost", List.of("bad name!"), REGION));
|
||||
assertEquals("ValidationError", badChar.getErrorCode());
|
||||
assertEquals("1 validation error detected: Value at 'ruleNames' failed to satisfy "
|
||||
+ "constraint: Member must satisfy constraint: "
|
||||
+ "[Member must have length less than or equal to 100, "
|
||||
+ "Member must have length greater than or equal to 1, "
|
||||
+ "Member must satisfy regular expression pattern: ^[a-zA-Z0-9_.-]+$]",
|
||||
badChar.getMessage());
|
||||
|
||||
// Empty and >100 take the same violation; a 65-char name passes (the cap here is 100,
|
||||
// not the 64 of the service-level name checks) and lands on RuleDoesNotExist instead.
|
||||
createThreeRuleSet("rules-a");
|
||||
AwsException empty = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a", List.of(""), REGION));
|
||||
assertEquals("ValidationError", empty.getErrorCode());
|
||||
AwsException tooLong = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a", List.of("a".repeat(101)), REGION));
|
||||
assertEquals("ValidationError", tooLong.getErrorCode());
|
||||
AwsException longButLegal = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a",
|
||||
List.of("r1", "r2", "r3", "a".repeat(65)), REGION));
|
||||
assertEquals("RuleDoesNotExist", longButLegal.getErrorCode());
|
||||
|
||||
// Several malformed members still produce the single index-less violation (probed).
|
||||
AwsException manyBad = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("rules-a",
|
||||
List.of("bad name!", "", "a".repeat(101)), REGION));
|
||||
assertTrue(manyBad.getMessage().startsWith("1 validation error detected: "));
|
||||
}
|
||||
|
||||
@Test
|
||||
void reorder_ruleSetName_getsSmithyThenServiceValidation() {
|
||||
AwsException empty = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("", List.of("r1"), REGION));
|
||||
assertEquals("ValidationError", empty.getErrorCode());
|
||||
assertTrue(empty.getMessage().startsWith("2 validation errors detected: "));
|
||||
assertTrue(empty.getMessage().contains("'ruleSetName'"));
|
||||
|
||||
AwsException tooLong = assertThrows(AwsException.class,
|
||||
() -> service.reorderReceiptRuleSet("a".repeat(65), List.of("r1"), REGION));
|
||||
assertEquals("InvalidParameterValue", tooLong.getErrorCode());
|
||||
assertEquals("Not a valid ruleSetName: " + "a".repeat(65), tooLong.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clone_deepCopiesRulesWithNewTimestampAndInactive() {
|
||||
createThreeRuleSet("rules-src");
|
||||
service.createReceiptRule("rules-src",
|
||||
rule("r0", action("S3Action", "BucketName", "inbox", "ObjectKeyPrefix", "mail/")),
|
||||
null, REGION, ANY_SENDER_VERIFIED);
|
||||
service.setActiveReceiptRuleSet("rules-src", REGION);
|
||||
ReceiptRuleSet original = service.describeReceiptRuleSet("rules-src", REGION);
|
||||
|
||||
ReceiptRuleSet clone = service.cloneReceiptRuleSet("rules-copy", "rules-src", REGION);
|
||||
|
||||
assertEquals("rules-copy", clone.getName());
|
||||
assertEquals(List.of("r0", "r1", "r2", "r3"), ruleNames("rules-copy"));
|
||||
assertEquals("inbox", service.describeReceiptRule("rules-copy", "r0", REGION)
|
||||
.getActions().get(0).property("BucketName"));
|
||||
assertNotNull(clone.getCreatedTimestamp());
|
||||
assertFalse(clone.getCreatedTimestamp().isBefore(original.getCreatedTimestamp()));
|
||||
// The active flag stays with the original.
|
||||
assertFalse(clone.isActive());
|
||||
assertEquals("rules-src", service.describeActiveReceiptRuleSet(REGION).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clone_isIndependentOfLaterSourceMutations() {
|
||||
createThreeRuleSet("rules-src");
|
||||
service.cloneReceiptRuleSet("rules-copy", "rules-src", REGION);
|
||||
|
||||
service.deleteReceiptRule("rules-src", "r1", REGION);
|
||||
service.describeReceiptRule("rules-src", "r2", REGION)
|
||||
.getActions().add(action("StopAction", "Scope", "RuleSet"));
|
||||
|
||||
assertEquals(List.of("r1", "r2", "r3"), ruleNames("rules-copy"));
|
||||
assertTrue(service.describeReceiptRule("rules-copy", "r2", REGION).getActions().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clone_emptySet_succeeds() {
|
||||
service.createReceiptRuleSet("rules-empty", REGION);
|
||||
service.cloneReceiptRuleSet("rules-copy", "rules-empty", REGION);
|
||||
assertEquals(List.of(), ruleNames("rules-copy"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void clone_missingSource_throwsRuleSetDoesNotExist() {
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.cloneReceiptRuleSet("rules-copy", "ghost", REGION));
|
||||
assertEquals("RuleSetDoesNotExist", e.getErrorCode());
|
||||
assertEquals("Rule set does not exist: ghost", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clone_existingTarget_winsOverMissingSource() {
|
||||
service.createReceiptRuleSet("rules-a", REGION);
|
||||
AwsException e = assertThrows(AwsException.class,
|
||||
() -> service.cloneReceiptRuleSet("rules-a", "ghost", REGION));
|
||||
assertEquals("AlreadyExists", e.getErrorCode());
|
||||
assertEquals("Rule set already exists: rules-a", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clone_nameValidation_isTwoLayer_targetBeforeSource() {
|
||||
// Smithy pattern layer combines both members, original first.
|
||||
AwsException bothBad = assertThrows(AwsException.class,
|
||||
() -> service.cloneReceiptRuleSet("bad target!", "bad source!", REGION));
|
||||
assertEquals("ValidationError", bothBad.getErrorCode());
|
||||
assertTrue(bothBad.getMessage().startsWith("2 validation errors detected: "));
|
||||
assertTrue(bothBad.getMessage().indexOf("'originalRuleSetName'")
|
||||
< bothBad.getMessage().indexOf("'ruleSetName'"));
|
||||
|
||||
// The service-level length check reports the target before the source and does not
|
||||
// name the member.
|
||||
AwsException bothLong = assertThrows(AwsException.class,
|
||||
() -> service.cloneReceiptRuleSet("a".repeat(65), "b".repeat(65), REGION));
|
||||
assertEquals("InvalidParameterValue", bothLong.getErrorCode());
|
||||
assertEquals("Not a valid ruleSetName: " + "a".repeat(65), bothLong.getMessage());
|
||||
|
||||
AwsException sourceLong = assertThrows(AwsException.class,
|
||||
() -> service.cloneReceiptRuleSet("rules-copy", "b".repeat(65), REGION));
|
||||
assertEquals("Not a valid ruleSetName: " + "b".repeat(65), sourceLong.getMessage());
|
||||
}
|
||||
|
||||
// ---- receipt filters ----
|
||||
|
||||
@Test
|
||||
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
package io.github.hectorvent.floci.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for the SES V1 Query-protocol ReorderReceiptRuleSet and CloneReceiptRuleSet
|
||||
* actions. Wire behavior follows real AWS as probed (2026-09): reorder demands an exact
|
||||
* permutation of the set with a duplicate-then-missing-then-unknown error precedence, and clone
|
||||
* deep-copies the rules under a new creation timestamp while the active flag stays behind.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesReceiptRuleSetReorderCloneV1IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-west-2/email/aws4_request";
|
||||
private static final String RS = "floci-v1-reorder";
|
||||
private static final String CLONE = "floci-v1-reorder-copy";
|
||||
|
||||
private static io.restassured.specification.RequestSpecification req(String action) {
|
||||
return given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.header("Authorization", AUTH)
|
||||
.formParam("Action", action);
|
||||
}
|
||||
|
||||
private static String describeRuleNames(String ruleSetName) {
|
||||
return req("DescribeReceiptRuleSet").formParam("RuleSetName", ruleSetName)
|
||||
.when().post("/").then().statusCode(200).extract().asString();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void reorder_appliesPermutation_andAnswersEmptyResult() {
|
||||
req("CreateReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.when().post("/").then().statusCode(200);
|
||||
for (String name : new String[] {"r3", "r2", "r1"}) {
|
||||
// Without After each create lands at the front, so the set reads r1, r2, r3.
|
||||
req("CreateReceiptRule").formParam("RuleSetName", RS)
|
||||
.formParam("Rule.Name", name)
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r2")
|
||||
.formParam("RuleNames.member.2", "r3")
|
||||
.formParam("RuleNames.member.3", "r1")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(containsString("ReorderReceiptRuleSetResponse"));
|
||||
|
||||
String body = describeRuleNames(RS);
|
||||
assertTrue(body.indexOf("<Name>r2</Name>") < body.indexOf("<Name>r3</Name>"));
|
||||
assertTrue(body.indexOf("<Name>r3</Name>") < body.indexOf("<Name>r1</Name>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void reorder_errorPrecedence_onTheWire() {
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", "floci-v1-ghost")
|
||||
.formParam("RuleNames.member.1", "r1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>RuleSetDoesNotExist</Code>"))
|
||||
.body(containsString("Rule set does not exist: floci-v1-ghost"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r1")
|
||||
.formParam("RuleNames.member.2", "r1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>InvalidParameterValue</Code>"))
|
||||
.body(containsString("Multiple positions found for rule: r1"));
|
||||
|
||||
// Missing set rules (listed in set order) win over the unknown name.
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r3")
|
||||
.formParam("RuleNames.member.2", "rX")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("Positions for rules not found: r2, r1"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r1")
|
||||
.formParam("RuleNames.member.2", "r2")
|
||||
.formParam("RuleNames.member.3", "r3")
|
||||
.formParam("RuleNames.member.4", "rX")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>RuleDoesNotExist</Code>"))
|
||||
.body(containsString("Rule does not exist: rX"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "bad name!")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>ValidationError</Code>"))
|
||||
.body(containsString("Value at 'ruleNames' failed to satisfy constraint: "
|
||||
+ "Member must satisfy constraint: "
|
||||
+ "[Member must have length less than or equal to 100"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void clone_deepCopies_andActiveStaysBehind() {
|
||||
req("SetActiveReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.when().post("/").then().statusCode(200);
|
||||
|
||||
req("CloneReceiptRuleSet").formParam("RuleSetName", CLONE)
|
||||
.formParam("OriginalRuleSetName", RS)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(containsString("CloneReceiptRuleSetResponse"));
|
||||
|
||||
String body = describeRuleNames(CLONE);
|
||||
assertTrue(body.contains("<Name>" + CLONE + "</Name>"));
|
||||
assertTrue(body.indexOf("<Name>r2</Name>") < body.indexOf("<Name>r3</Name>"));
|
||||
|
||||
req("DescribeActiveReceiptRuleSet")
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(containsString("<Name>" + RS + "</Name>"));
|
||||
|
||||
// Clear the active flag so the shared-state teardown delete succeeds.
|
||||
req("SetActiveReceiptRuleSet")
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(4)
|
||||
void clone_targetConflictAndMissingSource_errors() {
|
||||
req("CloneReceiptRuleSet").formParam("RuleSetName", CLONE)
|
||||
.formParam("OriginalRuleSetName", "floci-v1-ghost")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>AlreadyExists</Code>"))
|
||||
.body(containsString("Rule set already exists: " + CLONE));
|
||||
|
||||
req("CloneReceiptRuleSet").formParam("RuleSetName", "floci-v1-fresh")
|
||||
.formParam("OriginalRuleSetName", "floci-v1-ghost")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>RuleSetDoesNotExist</Code>"))
|
||||
.body(containsString("Rule set does not exist: floci-v1-ghost"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(5)
|
||||
void reorder_ruleNamesIndexGrammar_matchesProbedWire() {
|
||||
// A gap of up to 10 is padded with empty members, which then fail the ruleNames
|
||||
// Smithy constraint; nothing is truncated.
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r1")
|
||||
.formParam("RuleNames.member.3", "r3")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>ValidationError</Code>"))
|
||||
.body(containsString("Value at 'ruleNames' failed to satisfy constraint"));
|
||||
|
||||
// A larger gap is its own MalformedInput; the skip counts from the previous index.
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r1")
|
||||
.formParam("RuleNames.member.2", "r2")
|
||||
.formParam("RuleNames.member.3", "r3")
|
||||
.formParam("RuleNames.member.14", "rX")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>MalformedInput</Code>"))
|
||||
.body(containsString("Excessively sparse input would skip 11 list elements"));
|
||||
|
||||
// The skip count is comma-grouped like AWS renders it.
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r1")
|
||||
.formParam("RuleNames.member.1500", "rX")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("Excessively sparse input would skip 1,499 list elements"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.0", "r1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("<Code>MalformedInput</Code>"))
|
||||
.body(containsString("0 is not a valid index"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.01", "r1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("Value found where not expected"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.x", "r1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("Start of list found where not expected"));
|
||||
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.999999999", "r1")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("Index 999999999 is illegal"));
|
||||
|
||||
// A repeated index keeps its first value: the list reads r1, r1, r3 and trips the
|
||||
// duplicate-name check, proving the second value never displaced the first.
|
||||
req("ReorderReceiptRuleSet").formParam("RuleSetName", RS)
|
||||
.formParam("RuleNames.member.1", "r1", "r2")
|
||||
.formParam("RuleNames.member.2", "r1")
|
||||
.formParam("RuleNames.member.3", "r3")
|
||||
.when().post("/").then().statusCode(400)
|
||||
.body(containsString("Multiple positions found for rule: r1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
void cleanup_deletesBothSets() {
|
||||
for (String name : new String[] {RS, CLONE}) {
|
||||
req("DeleteReceiptRuleSet").formParam("RuleSetName", name)
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user