mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(cognito): reject self-managed verification status (#2532)
This commit is contained in:
1 parent
2e8cbc13d7
commit
f8597bdef9
2 files changed
+42
-1
No files matched your search
@@ -1291,6 +1291,37 @@ class CognitoServiceTest {
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"email_verified", "phone_number_verified"})
|
||||
@SuppressWarnings("unchecked")
|
||||
void updateUserAttributesRejectsSelfManagedVerificationStatusWithoutPartialPersistence(
|
||||
String verificationStatusAttribute) {
|
||||
UserPool pool = createPoolAndUser();
|
||||
UserPoolClient client = service.createUserPoolClient(
|
||||
pool.getId(), "verification-status-client", false, false, List.of(), List.of());
|
||||
Map<String, Object> authResult = service.initiateAuth(
|
||||
client.getClientId(), "USER_PASSWORD_AUTH",
|
||||
Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!"));
|
||||
String accessToken = (String) ((Map<String, Object>) authResult.get("AuthenticationResult"))
|
||||
.get("AccessToken");
|
||||
|
||||
AwsException error = assertThrows(AwsException.class,
|
||||
() -> service.updateUserAttributes(accessToken, Map.of(
|
||||
verificationStatusAttribute, "true",
|
||||
"name", "must-not-be-persisted")));
|
||||
|
||||
assertEquals("InvalidParameterException", error.getErrorCode());
|
||||
assertEquals(400, error.getHttpStatus());
|
||||
CognitoUser unchanged = service.adminGetUser(pool.getId(), "alice");
|
||||
assertFalse(unchanged.getAttributes().containsKey(verificationStatusAttribute));
|
||||
assertFalse(unchanged.getAttributes().containsKey("name"));
|
||||
|
||||
service.adminUpdateUserAttributes(
|
||||
pool.getId(), "alice", Map.of(verificationStatusAttribute, "true"));
|
||||
assertEquals("true", service.adminGetUser(pool.getId(), "alice")
|
||||
.getAttributes().get(verificationStatusAttribute));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void jwtSubMatchesStoredSubAttribute() {
|
||||
|
||||
Reference in new issue
Block a user