Commit 95708b17 authored by Matija Obreza's avatar Matija Obreza

Merge branch 'ui-506-admin-can-make-changes-with-account-after-it-was-deleted' into 'master'

Fixed user archivation api endpoint

See merge request genesys-pgr/genesys-server!453
parents 1fa43194 92b99539
......@@ -163,7 +163,7 @@ public class UserManagementController {
@PostMapping(value = "/u/{uuid}/archive")
public User archiveAccount(@PathVariable("uuid") final UUID uuid) throws UserException {
User user = userService.getUser(uuid);
userService.archiveUser(user);
user = userService.archiveUser(user);
LOG.info("Archived user " + user.getEmail());
return user;
}
......
......@@ -81,9 +81,9 @@ public interface UserService extends BasicUserService<UserRole, User> {
* Disables the account and removes personally identifiable data.
*
* @param user
* @throws UserException
* @throws UserException
*/
void archiveUser(User user) throws UserException;
User archiveUser(User user) throws UserException;
/**
* Autocomplete user.
......
......@@ -432,7 +432,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
*/
@Override
@Transactional
public void archiveUser(User user) throws UserException {
public User archiveUser(User user) throws UserException {
user = userRepository.findOne(user.getId());
if (user.hasRole(UserRole.ADMINISTRATOR.getName())) {
......@@ -444,7 +444,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
user.setAccountExpires(now);
user.setActive(false);
user.setAccountType(AccountType.LOCAL);
// user.setAccountType(AccountType.DELETED);
// user.setAccountType(AccountType.DELETED);
user.setEmail("deleted@" + now.getTime());
user.setPassword(THIS_IS_NOT_A_PASSWORD);
user.setFtpPassword(null);
......@@ -457,6 +457,7 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
LOG.warn("Removing ACL entries for {}", user.getEmail());
aclEntryRepository.delete(user.getAclEntries());
return user;
}
/* (non-Javadoc)
......
......@@ -19,6 +19,7 @@ package org.genesys.test.server.api.v1;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
......@@ -202,8 +203,9 @@ public class UserManagementControllerTest extends AbstractApiTest {
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.uuid", is(user.getUuid())))
.andExpect(jsonPath("$.email", is(user.getEmail())))
.andExpect(jsonPath("$.fullName", is(user.getFullName())));
.andExpect(jsonPath("$.email", startsWith("deleted@")))
.andExpect(jsonPath("$.fullName", is("USER ACCOUNT DELETED")))
.andExpect(jsonPath("$.accountType", is(BasicUser.AccountType.LOCAL.name())));
/*@formatter:on*/
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment