fix(iam): word the service-linked duration refusal as AWS does (#8910)

The one refusal of the twelve that is recorded: UpdateRole changing a
service-linked role's MaxSessionDuration answers '<roleName> is an AWS
service linked role, max session duration cannot be changed.', where the
clause names the change refused rather than the service the role is linked
to. This package answered its own sentence there.

The other eleven keep it, and the IAM page says why: AWS words the clause
after the change, that clause cannot be inferred for eleven other changes,
and AWS may not refuse all of them this way at all.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-18 17:49:57 -04:00
1 parent 88a545a36f
commit c4d7499ca2
3 files changed
+79 -4

No files matched your search

@@ -644,6 +644,32 @@ class IamServiceLinkedRoleIntegrationTest {
.statusCode(404);
}
/**
* The sentence AWS was recorded answering for the one change this package guards on
* {@code UpdateRole}, with the role's own name and the rest fixed. The other actions guarded
* here carry no recording of their own and keep this emulator's sentence, which is why only
* this one is held to a message.
*/
@Test
@Order(35)
void theDurationRefusalCarriesTheRecordedSentence() {
createServiceLinkedRole("wordingprobe.amazonaws.com");
String roleName = "AWSServiceRoleForWordingprobe";
given()
.formParam("Action", "UpdateRole")
.formParam("RoleName", roleName)
.formParam("MaxSessionDuration", "7200")
.header("Authorization", AUTH_HEADER)
.when()
.post("/")
.then()
.statusCode(400)
.body("ErrorResponse.Error.Code", equalTo("UnmodifiableEntity"))
.body("ErrorResponse.Error.Message", equalTo(roleName
+ " is an AWS service linked role, max session duration cannot be changed."));
}
private static void refusedAsUnmodifiable(String action, String... formParams) {
RequestSpecification request = given().header("Authorization", AUTH_HEADER).formParam("Action", action);
for (int i = 0; i < formParams.length; i += 2) {