Add createTimestamp to REST service (#23293)

Closes #14009
This commit is contained in:
Lucas Hedding 2023-09-27 05:38:16 -06:00 committed by GitHub
parent 10c1e3ba6d
commit de5aa2e74d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -268,6 +268,7 @@ public class UserResource {
if (rep.isEnabled() != null) user.setEnabled(rep.isEnabled());
if (rep.isEmailVerified() != null) user.setEmailVerified(rep.isEmailVerified());
if (rep.getCreatedTimestamp() != null && !isUpdateExistingUser) user.setCreatedTimestamp(rep.getCreatedTimestamp());
if (rep.getFederationLink() != null) user.setFederationLink(rep.getFederationLink());

View file

@ -645,6 +645,22 @@ public class UserTest extends AbstractAdminTest {
}
}
@Test
public void createUserWithCreateTimestamp() {
UserRepresentation user = new UserRepresentation();
user.setUsername("user1");
user.setEmail("user1@localhost");
Long createdTimestamp = 1695238476L;
user.setCreatedTimestamp(createdTimestamp);
String userId = createUser(user);
// fetch user again and see created timestamp filled in
UserRepresentation createdUser = realm.users().get(userId).toRepresentation();
assertNotNull(createdUser);
assertEquals(user.getCreatedTimestamp(), createdUser.getCreatedTimestamp());
}
private List<String> createUsers() {
List<String> ids = new ArrayList<>();