Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update createdby when replicating users [DHIS2-15595] #14752

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,29 @@ void testReplicateUser() {
.content());
}

@Test
void testReplicateUserCreatedByUpdated() throws JsonProcessingException {
User newUser = createUserWithAuth("test", "ALL");

switchToNewUser(newUser);

String replicatedUsername = "peter2";

assertWebMessage(
"Created",
201,
"OK",
"User replica created",
POST(
"/users/" + peter.getUid() + "/replica",
"{'username':'" + replicatedUsername + "','password':'Saf€sEcre1'}")
.content());

User replicatedUser = userService.getUserByUsername(replicatedUsername);

assertEquals(newUser.getUsername(), replicatedUser.getCreatedBy().getUsername());
}

@Test
void testReplicateUser_UserNameAlreadyTaken() {
assertWebMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ public WebMessage replicateUser(
userReplica.setUid(CodeGenerator.generateUid());
userReplica.setCode(null);
userReplica.setCreated(new Date());
userReplica.setCreatedBy(currentUser);
userReplica.setLdapId(null);
userReplica.setOpenId(null);
userReplica.setUsername(username);
Expand Down