mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(iam): preserve later policy writes during rollback (#5596)
* fix(iam): preserve later policy writes during rollback * fix(iam): explain rollback ownership conflicts
This commit is contained in:
1 parent
d5c6a36ac9
commit
9ab820d7f7
3 files changed
+102
-11
No files matched your search
+53
-1
@@ -232,9 +232,49 @@ class IamPolicyQuotaRollbackTest {
|
||||
assertEquals(policy(500), get(kind, "first", "shared"));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"User, false", "Group, false", "Role, false",
|
||||
"User, true", "Group, true", "Role, true"})
|
||||
void compensationRefusesAnotherWritersRoundTrip(String kind, boolean deletion) {
|
||||
create(kind, "first");
|
||||
put(kind, "first", "shared", policy(500));
|
||||
InlinePolicyChange change = deletion ? remove(kind, "first", "shared")
|
||||
: update(kind, "first", "shared", policy(200));
|
||||
put(kind, "first", "shared", policy(300));
|
||||
if (deletion) {
|
||||
delete(kind, "first", "shared");
|
||||
} else {
|
||||
put(kind, "first", "shared", policy(200));
|
||||
}
|
||||
AwsException error = assertThrows(AwsException.class, () -> change.rollback().run());
|
||||
assertEquals("ConcurrentModification", error.getErrorCode());
|
||||
assertEquals(409, error.getHttpStatus());
|
||||
if (deletion) {
|
||||
assertEquals("NoSuchEntity", assertThrows(AwsException.class,
|
||||
() -> get(kind, "first", "shared")).getErrorCode());
|
||||
} else {
|
||||
assertEquals(policy(200), get(kind, "first", "shared"));
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"User", "Group", "Role"})
|
||||
void nestedReverseCompensationRestoresTheOriginalDocuments(String kind) {
|
||||
void equalDocumentWriteStillTakesOwnership(String kind) {
|
||||
create(kind, "first");
|
||||
put(kind, "first", "shared", policy(500));
|
||||
InlinePolicyChange change = update(kind, "first", "shared", policy(200));
|
||||
put(kind, "first", "shared", policy(200));
|
||||
AwsException error = assertThrows(AwsException.class, () -> change.rollback().run());
|
||||
assertEquals("ConcurrentModification", error.getErrorCode());
|
||||
assertEquals(409, error.getHttpStatus());
|
||||
assertEquals("Cannot restore inline policy shared on first"
|
||||
+ " because its rollback ownership or state changed after the update.", error.getMessage());
|
||||
assertEquals(policy(200), get(kind, "first", "shared"));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"User", "Group", "Role"})
|
||||
void nestedReverseCompensationRestoresItsPredecessorOwnership(String kind) {
|
||||
create(kind, "first");
|
||||
put(kind, "first", "shared", policy(500));
|
||||
InlinePolicyChange removed = remove(kind, "first", "shared");
|
||||
@@ -250,6 +290,18 @@ class IamPolicyQuotaRollbackTest {
|
||||
() -> written.rollback().run()).getErrorCode());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"User", "Group", "Role"})
|
||||
void equalDocumentCompensationCannotRunTwice(String kind) {
|
||||
create(kind, "first");
|
||||
put(kind, "first", "shared", policy(200));
|
||||
InlinePolicyChange change = update(kind, "first", "shared", policy(200));
|
||||
change.rollback().run();
|
||||
assertEquals("ConcurrentModification", assertThrows(AwsException.class,
|
||||
() -> change.rollback().run()).getErrorCode());
|
||||
assertEquals(policy(200), get(kind, "first", "shared"));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"User, missing, false", "Group, missing, false", "Role, missing, false",
|
||||
"User, missing, true", "Group, missing, true", "Role, missing, true",
|
||||
|
||||
Reference in new issue
Block a user