mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(iam): change the calling user's console password (#5546)
ChangePassword was the last IAM operation held back for a reason that turned out not to hold. It was tracked as blocked on disambiguating a shared Query action name by Version, because Cognito publishes the name too. In fact IAM sits second in inferServiceFromAction's chain and Cognito ninth, and Cognito's form path answers UnsupportedOperation to every request, so adding the name to IAM_ACTIONS routes it to IAM and costs Cognito nothing. A request carrying a credential scope never reaches that chain at all. The operation takes no UserName. The API reference says it changes the password of the IAM user who is calling, and the CLI reference adds that it "can be called by IAM users only. If this command is called using AWS account (root) credentials, the command returns an InvalidUserType error", so a signing key with no stored user behind it, which is Floci's stand-in for that caller, answers InvalidUserType rather than reporting the key as missing. The resource the request is evaluated against needed nothing new: ResourceArnBuilder already resolves the signing user for an action whose UserName is absent, and the vendored action map already authorizes ChangePassword against a user. OldPassword is checked against the stored login profile before the new password is held to the account password policy, so a caller who cannot prove the current password learns nothing about what that policy requires. A mismatch is the one refusal the reference leaves unnamed: every error it publishes for this operation describes something else, so this answers InvalidParameterValue, the common error type AWS publishes for a parameter value a service cannot accept. A successful change clears PasswordResetRequired, which is what lets a user whose password an administrator reset restore their own console access programmatically, and it moves the password_last_changed the credential report reads. The passwordType shape check is now shared and names the member that failed, because this operation has two password members and a caller told that 'password' failed would have to guess which. An absent member and an empty one stay different answers. Two things the login profile needed before a self-service change could be trusted. The comparison and the write are one step under a new loginProfileLock, which every login-profile writer takes: read apart from the write, two requests presenting the same valid old password both pass the comparison and both are told they set the password, while only the later write survives, and a guard one writer skipped would leave a racing UpdateLoginProfile free to overwrite a password a ChangePassword had just promised. And PasswordReusePrevention is now enforced, on UpdateLoginProfile as well, the two sharing one bounded history per profile: the reference defines the value as "the number of previous passwords that IAM users are prevented from reusing" and makes no window mean no prevention. The password the profile holds is refused alongside the superseded ones, which the reference leaves open; read the other way the smallest window the policy accepts would allow setting a password to the value it already has, and would not refuse the change away and straight back that the setting is for. Twelve unit tests, one concurrency test and six integration tests, with each guard probed by reverting it alone: dropping the old-password comparison, the reset-flag clear, the policy check or the check order is caught by the test written for it, and dropping the routing entry leaves the unsigned request answered by Cognito, which is what the routing parity test says too. Dropping the lock leaves five of twenty-four racing requests all told they succeeded with one password stored, neutering the reuse check leaves both refusals silent, and widening the window by one lets it reach a password that has left it. 1668 tests across all 98 IAM and query-routing classes pass at this commit. docs/services/iam.md documents the operation, the judgements, and the one thing Floci still does not model. AllowUsersToChangePassword is accepted and reported but grants nothing: the user guide says the option gives all users in the account access to iam:ChangePassword for only their user and to iam:GetAccountPasswordPolicy, applied at the account level rather than by attaching a policy, while Floci authorizes both from identity policies alone, so under enforcement a caller needs a policy naming their own user however the flag is set. The matrix row moves 166 to 167.
This commit is contained in:
1 parent
6b0d0bc378
commit
5ea632cc13
9 files changed
+683
-39
No files matched your search
+174
@@ -0,0 +1,174 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsQueryController;
|
||||
import io.github.hectorvent.floci.testing.PartitionCleanup;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
/**
|
||||
* {@code ChangePassword} over the wire, which is the only IAM operation that acts on the caller
|
||||
* and gives no way to name anyone else.
|
||||
*
|
||||
* <p>Driven through the whole stack because two of the things worth checking live outside the
|
||||
* handler. The caller is read from the signing access key, so a request signed with a key that
|
||||
* belongs to a user has to reach that user and nobody else. And the action name is shared with
|
||||
* Cognito, so a request that arrives without a usable credential scope has to be routed to IAM by
|
||||
* {@link AwsQueryController}: Cognito is further down that chain and answers
|
||||
* {@code UnsupportedOperation} to every form request, so the routing is what decides whether the
|
||||
* operation exists at all on that path.
|
||||
*
|
||||
* <p>Runs in an account of its own, like the other IAM classes that set account-wide state: the
|
||||
* emulator is shared, and an account password policy left visible to another class changes what
|
||||
* that class's passwords are held to.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class IamChangePasswordIntegrationTest {
|
||||
|
||||
private static final String ACCOUNT = "000000000911";
|
||||
private static final String REGION = "us-east-1";
|
||||
private static final String PASSWORD = "Sup3r$ecret!";
|
||||
private static final String NEW_PASSWORD = "An0ther$ecret!";
|
||||
|
||||
@RegisterExtension
|
||||
final PartitionCleanup cleanup = new PartitionCleanup();
|
||||
|
||||
@Test
|
||||
void theSignerChangesItsOwnPassword() {
|
||||
String accessKeyId = userWithAConsolePassword("changes-own");
|
||||
|
||||
signedAs(accessKeyId, Map.of("OldPassword", PASSWORD, "NewPassword", NEW_PASSWORD))
|
||||
.statusCode(200)
|
||||
.body("ChangePasswordResponse.ResponseMetadata.RequestId", not(equalTo("")));
|
||||
|
||||
// Nothing echoes a password back, so the proof the write took is the next call: the old
|
||||
// password is no longer the current one and the new one is.
|
||||
signedAs(accessKeyId, Map.of("OldPassword", PASSWORD, "NewPassword", "Th1rd$ecret!"))
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidParameterValue"));
|
||||
signedAs(accessKeyId, Map.of("OldPassword", NEW_PASSWORD, "NewPassword", "Th1rd$ecret!"))
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSignerWithNoConsolePasswordIsNoSuchEntity() {
|
||||
String accessKeyId = userWithoutAConsolePassword("no-profile");
|
||||
|
||||
signedAs(accessKeyId, Map.of("OldPassword", PASSWORD, "NewPassword", NEW_PASSWORD))
|
||||
.statusCode(404)
|
||||
.body("ErrorResponse.Error.Code", equalTo("NoSuchEntity"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAccountCredentialIsInvalidUserType() {
|
||||
// The account's own credential stands in for the root user, which the CLI reference says
|
||||
// this operation answers InvalidUserType for.
|
||||
admin("ChangePassword", Map.of("OldPassword", PASSWORD, "NewPassword", NEW_PASSWORD))
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidUserType"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnsignedRequestIsAnsweredByIamRatherThanCognito() {
|
||||
// No credential scope, so the service comes from the action name alone. Cognito also
|
||||
// publishes ChangePassword; reaching it would answer UnsupportedOperation instead.
|
||||
given()
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "ChangePassword")
|
||||
.formParam("Version", "2010-05-08")
|
||||
.formParam("OldPassword", PASSWORD)
|
||||
.formParam("NewPassword", NEW_PASSWORD)
|
||||
.when().post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidUserType"))
|
||||
.body(not(containsString("UnsupportedOperation")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAbsentMemberNamesItself() {
|
||||
String accessKeyId = userWithAConsolePassword("absent-member");
|
||||
|
||||
signedAs(accessKeyId, Map.of("NewPassword", NEW_PASSWORD))
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("ValidationError"))
|
||||
.body("ErrorResponse.Error.Message", containsString("'oldPassword'"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theNewPasswordIsHeldToTheAccountPasswordPolicy() {
|
||||
String accessKeyId = userWithAConsolePassword("policy");
|
||||
admin("UpdateAccountPasswordPolicy", Map.of("MinimumPasswordLength", "20",
|
||||
"RequireSymbols", "true", "RequireNumbers", "true")).statusCode(200);
|
||||
cleanup.register(() -> admin("DeleteAccountPasswordPolicy", Map.of()).statusCode(200));
|
||||
|
||||
signedAs(accessKeyId, Map.of("OldPassword", PASSWORD, "NewPassword", "sh0rt!"))
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("PasswordPolicyViolation"));
|
||||
|
||||
signedAs(accessKeyId,
|
||||
Map.of("OldPassword", PASSWORD, "NewPassword", "L0ngEn0ugh$ecret!!!!"))
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
/** A user holding a console password, with an access key to sign its own requests with. */
|
||||
private String userWithAConsolePassword(String label) {
|
||||
String userName = user(label);
|
||||
admin("CreateLoginProfile", Map.of("UserName", userName, "Password", PASSWORD))
|
||||
.statusCode(200);
|
||||
cleanup.register(() -> admin("DeleteLoginProfile", Map.of("UserName", userName))
|
||||
.statusCode(200));
|
||||
return accessKeyFor(userName);
|
||||
}
|
||||
|
||||
/** The same, minus the console password: an IAM user with nothing to change. */
|
||||
private String userWithoutAConsolePassword(String label) {
|
||||
return accessKeyFor(user(label));
|
||||
}
|
||||
|
||||
private String user(String label) {
|
||||
String userName = "change-password-" + label;
|
||||
admin("CreateUser", Map.of("UserName", userName)).statusCode(200);
|
||||
cleanup.register(() -> admin("DeleteUser", Map.of("UserName", userName)).statusCode(200));
|
||||
return userName;
|
||||
}
|
||||
|
||||
private String accessKeyFor(String userName) {
|
||||
String accessKeyId = admin("CreateAccessKey", Map.of("UserName", userName)).statusCode(200)
|
||||
.extract().path("CreateAccessKeyResponse.CreateAccessKeyResult.AccessKey"
|
||||
+ ".AccessKeyId");
|
||||
cleanup.register(() -> admin("DeleteAccessKey",
|
||||
Map.of("UserName", userName, "AccessKeyId", accessKeyId)).statusCode(200));
|
||||
return accessKeyId;
|
||||
}
|
||||
|
||||
private ValidatableResponse signedAs(String accessKeyId, Map<String, String> params) {
|
||||
return iam(accessKeyId, "ChangePassword", params);
|
||||
}
|
||||
|
||||
private ValidatableResponse admin(String action, Map<String, String> params) {
|
||||
return iam(ACCOUNT, action, params);
|
||||
}
|
||||
|
||||
private static ValidatableResponse iam(String accessKeyId, String action,
|
||||
Map<String, String> params) {
|
||||
RequestSpecification spec = given()
|
||||
.header("Authorization", "AWS4-HMAC-SHA256 Credential=" + accessKeyId
|
||||
+ "/20261012/" + REGION + "/iam/aws4_request, SignedHeaders=host, "
|
||||
+ "Signature=abc")
|
||||
.contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", action)
|
||||
.formParam("Version", "2010-05-08");
|
||||
params.forEach(spec::formParam);
|
||||
return spec.when().post("/").then();
|
||||
}
|
||||
}
|
||||
@@ -346,6 +346,57 @@ class IamConcurrencyTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Every racing ChangePassword presents the same valid old password, so exactly one can be
|
||||
* right: once the first write lands, the old password the others hold is no longer the current
|
||||
* one. A request told it succeeded has to be the one whose password is in the store, since the
|
||||
* caller has no way to find out otherwise, the operation echoing nothing back.
|
||||
*/
|
||||
@Test
|
||||
void concurrentPasswordChangesLeaveExactlyOneWinner() throws Exception {
|
||||
ExecutorService pool = Executors.newFixedThreadPool(THREADS);
|
||||
try {
|
||||
for (int trial = 0; trial < TRIALS; trial++) {
|
||||
IamService iam = newIamService();
|
||||
iam.createUser("racer", "/");
|
||||
iam.createLoginProfile("racer", "Passw0rd$start", false);
|
||||
CountDownLatch start = new CountDownLatch(1);
|
||||
CountDownLatch done = new CountDownLatch(N);
|
||||
List<String> winners = new CopyOnWriteArrayList<>();
|
||||
List<String> unexpected = new CopyOnWriteArrayList<>();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
String candidate = "Passw0rd$" + i;
|
||||
pool.execute(() -> {
|
||||
try {
|
||||
start.await(10, TimeUnit.SECONDS);
|
||||
iam.changePassword("racer", "Passw0rd$start", candidate);
|
||||
winners.add(candidate);
|
||||
} catch (io.github.hectorvent.floci.core.common.AwsException e) {
|
||||
if (!"InvalidParameterValue".equals(e.getErrorCode())) {
|
||||
unexpected.add(e.getErrorCode());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
done.countDown();
|
||||
}
|
||||
});
|
||||
}
|
||||
start.countDown();
|
||||
assertTrue(done.await(30, TimeUnit.SECONDS), "password workers stalled");
|
||||
|
||||
String stored = iam.getLoginProfile("racer").getPassword();
|
||||
if (winners.size() != 1 || !winners.contains(stored) || !unexpected.isEmpty()) {
|
||||
fail("changePassword trial " + trial + ": winners=" + winners
|
||||
+ " stored=" + stored + " unexpectedErrors=" + unexpected);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] createPolicies(IamService iam, String prefix) {
|
||||
String[] arns = new String[N];
|
||||
for (int i = 0; i < N; i++) {
|
||||
|
||||
@@ -871,6 +871,194 @@ class IamServiceTest {
|
||||
assertEquals("alice", profile.getUserName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordReplacesThePasswordAndClearsTheResetFlag() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", true);
|
||||
|
||||
iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!");
|
||||
|
||||
LoginProfile profile = iamService.getLoginProfile("alice");
|
||||
assertFalse(profile.isPasswordResetRequired(),
|
||||
"a self-service change is what clears the reset an administrator required");
|
||||
assertNotNull(profile.getPasswordLastChanged());
|
||||
// The proof the write took is behavioural rather than a read of the stored field: the
|
||||
// new password is now the current one and the old one is not.
|
||||
iamService.changePassword("alice", "An0ther$ecret!", "Th1rd$ecret!");
|
||||
assertEquals("InvalidParameterValue", assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "An0ther$ecret!", "F0urth$ecret!"))
|
||||
.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordWithTheWrongOldPasswordChangesNothing() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "N0tTheOne!", "An0ther$ecret!"));
|
||||
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
// The refusal left the password alone, so the original still changes it.
|
||||
iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordChecksTheOldPasswordBeforeTheAccountPolicy() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
AccountPasswordPolicy policy = new AccountPasswordPolicy();
|
||||
policy.setMinimumPasswordLength(12);
|
||||
iamService.updateAccountPasswordPolicy(policy);
|
||||
|
||||
// Both halves of the request are wrong. A caller who cannot prove the current password is
|
||||
// told that and nothing about what the policy would have required.
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "N0tTheOne!", "short"));
|
||||
|
||||
assertEquals("InvalidParameterValue", ex.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordHoldsTheNewPasswordToTheAccountPolicy() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
AccountPasswordPolicy policy = new AccountPasswordPolicy();
|
||||
policy.setMinimumPasswordLength(12);
|
||||
policy.setRequireSymbols(true);
|
||||
policy.setRequireNumbers(true);
|
||||
iamService.updateAccountPasswordPolicy(policy);
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "Sup3r$ecret!", "short"));
|
||||
|
||||
assertEquals("PasswordPolicyViolation", ex.getErrorCode());
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordNamesTheMemberThatFailedItsConstraint() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
|
||||
AwsException missing = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", null, "An0ther$ecret!"));
|
||||
assertEquals("ValidationError", missing.getErrorCode());
|
||||
assertTrue(missing.getMessage().contains("Value null at 'oldPassword'"), missing.getMessage());
|
||||
|
||||
// An empty member is a value that fails the pattern rather than a member never supplied,
|
||||
// and the message names the one that failed, there being two password members here.
|
||||
AwsException empty = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "Sup3r$ecret!", ""));
|
||||
assertEquals("ValidationError", empty.getErrorCode());
|
||||
assertTrue(empty.getMessage().contains("Value at 'newPassword'"), empty.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordRefusesAPasswordTheReuseWindowStillHolds() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
AccountPasswordPolicy policy = new AccountPasswordPolicy();
|
||||
policy.setPasswordReusePrevention(1);
|
||||
iamService.updateAccountPasswordPolicy(policy);
|
||||
|
||||
iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!");
|
||||
|
||||
// The window is one superseded password, and the one in hand counts alongside it, so
|
||||
// neither going back nor standing still is allowed.
|
||||
assertEquals("PasswordPolicyViolation", assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "An0ther$ecret!", "Sup3r$ecret!"))
|
||||
.getErrorCode());
|
||||
assertEquals("PasswordPolicyViolation", assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "An0ther$ecret!", "An0ther$ecret!"))
|
||||
.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordAllowsAPasswordThatHasLeftTheReuseWindow() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
AccountPasswordPolicy policy = new AccountPasswordPolicy();
|
||||
policy.setPasswordReusePrevention(1);
|
||||
iamService.updateAccountPasswordPolicy(policy);
|
||||
|
||||
iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!");
|
||||
iamService.changePassword("alice", "An0ther$ecret!", "Th1rd$ecret!");
|
||||
|
||||
// A window of one reaches the current password and the one before it, and the first is
|
||||
// now two back, so it is reachable again.
|
||||
iamService.changePassword("alice", "Th1rd$ecret!", "Sup3r$ecret!");
|
||||
assertNotNull(iamService.getLoginProfile("alice").getPasswordLastChanged());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordWithNoReusePolicyTakesTheOldPasswordBack() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
AccountPasswordPolicy policy = new AccountPasswordPolicy();
|
||||
policy.setMinimumPasswordLength(8);
|
||||
iamService.updateAccountPasswordPolicy(policy);
|
||||
|
||||
// A policy that sets no window prevents nothing: the reference's default is that users
|
||||
// "are not prevented from reusing previous passwords".
|
||||
iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!");
|
||||
iamService.changePassword("alice", "An0ther$ecret!", "Sup3r$ecret!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateLoginProfileIsHeldToTheSameReuseWindow() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Sup3r$ecret!", false);
|
||||
AccountPasswordPolicy policy = new AccountPasswordPolicy();
|
||||
policy.setPasswordReusePrevention(2);
|
||||
iamService.updateAccountPasswordPolicy(policy);
|
||||
iamService.updateLoginProfile("alice", "An0ther$ecret!", null);
|
||||
|
||||
// An administrator reset is a password the policy applies to as much as a self-service
|
||||
// change, and the two share one history.
|
||||
assertEquals("PasswordPolicyViolation", assertThrows(AwsException.class,
|
||||
() -> iamService.updateLoginProfile("alice", "Sup3r$ecret!", null)).getErrorCode());
|
||||
assertEquals("PasswordPolicyViolation", assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "An0ther$ecret!", "Sup3r$ecret!"))
|
||||
.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void loginProfileHistoryStopsAtTheWidestWindowThePolicyAccepts() {
|
||||
iamService.createUser("alice", "/");
|
||||
iamService.createLoginProfile("alice", "Passw0rd$0", false);
|
||||
for (int i = 1; i <= 30; i++) {
|
||||
iamService.updateLoginProfile("alice", "Passw0rd$" + i, null);
|
||||
}
|
||||
|
||||
// Nothing can be asked about a password further back than the largest window, so the
|
||||
// history stops there rather than growing with every change.
|
||||
assertEquals(24, iamService.getLoginProfile("alice").getPreviousPasswords().size());
|
||||
assertEquals("Passw0rd$29",
|
||||
iamService.getLoginProfile("alice").getPreviousPasswords().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordForAUserWithoutAConsolePasswordIsNoSuchEntity() {
|
||||
iamService.createUser("alice", "/");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("alice", "Sup3r$ecret!", "An0ther$ecret!"));
|
||||
|
||||
assertEquals("NoSuchEntity", ex.getErrorCode());
|
||||
assertEquals(404, ex.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void changePasswordForAnUnknownUserIsNoSuchEntity() {
|
||||
AwsException ex = assertThrows(AwsException.class,
|
||||
() -> iamService.changePassword("nobody", "Sup3r$ecret!", "An0ther$ecret!"));
|
||||
|
||||
assertEquals("NoSuchEntity", ex.getErrorCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteUserWithLoginProfileIsDeleteConflict() {
|
||||
iamService.createUser("alice", "/");
|
||||
|
||||
Reference in new issue
Block a user