|
|
@ -24,9 +24,9 @@ import io.metersphere.system.request.user.UserRoleBatchRelationRequest;
|
|
|
|
import io.metersphere.system.response.user.UserImportResponse;
|
|
|
|
import io.metersphere.system.response.user.UserImportResponse;
|
|
|
|
import io.metersphere.system.response.user.UserSelectOption;
|
|
|
|
import io.metersphere.system.response.user.UserSelectOption;
|
|
|
|
import io.metersphere.system.response.user.UserTableResponse;
|
|
|
|
import io.metersphere.system.response.user.UserTableResponse;
|
|
|
|
import io.metersphere.system.response.user.UserTreeSelectOption;
|
|
|
|
|
|
|
|
import io.metersphere.system.service.GlobalUserRoleRelationService;
|
|
|
|
import io.metersphere.system.service.GlobalUserRoleRelationService;
|
|
|
|
import io.metersphere.system.service.UserService;
|
|
|
|
import io.metersphere.system.service.UserService;
|
|
|
|
|
|
|
|
import io.metersphere.system.service.UserToolService;
|
|
|
|
import io.metersphere.system.utils.user.UserParamUtils;
|
|
|
|
import io.metersphere.system.utils.user.UserParamUtils;
|
|
|
|
import io.metersphere.system.utils.user.UserRequestUtils;
|
|
|
|
import io.metersphere.system.utils.user.UserRequestUtils;
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
@ -58,6 +58,8 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private UserService userService;
|
|
|
|
private UserService userService;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private UserToolService userToolService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private UserMapper userMapper;
|
|
|
|
private UserMapper userMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private GlobalUserRoleRelationService globalUserRoleRelationService;
|
|
|
|
private GlobalUserRoleRelationService globalUserRoleRelationService;
|
|
|
@ -73,7 +75,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
private static final List<UserCreateInfo> USER_LIST = new ArrayList<>();
|
|
|
|
private static final List<UserCreateInfo> USER_LIST = new ArrayList<>();
|
|
|
|
private static final List<UserSelectOption> USER_ROLE_LIST = new ArrayList<>();
|
|
|
|
private static final List<UserSelectOption> USER_ROLE_LIST = new ArrayList<>();
|
|
|
|
private static final List<UserSelectOption> ORG_LIST = new ArrayList<>();
|
|
|
|
private static final List<UserSelectOption> ORG_LIST = new ArrayList<>();
|
|
|
|
private static final List<UserTreeSelectOption> PROJECT_LIST = new ArrayList<>();
|
|
|
|
private static final List<BaseTreeNode> PROJECT_LIST = new ArrayList<>();
|
|
|
|
//默认数据
|
|
|
|
//默认数据
|
|
|
|
public static final String USER_DEFAULT_NAME = "tianyang.no.1";
|
|
|
|
public static final String USER_DEFAULT_NAME = "tianyang.no.1";
|
|
|
|
public static final String USER_DEFAULT_EMAIL = "tianyang.no.1@126.com";
|
|
|
|
public static final String USER_DEFAULT_EMAIL = "tianyang.no.1@126.com";
|
|
|
@ -95,7 +97,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@Order(0)
|
|
|
|
@Order(0)
|
|
|
|
public void testGetGlobalSystemUserRoleSuccess() throws Exception {
|
|
|
|
public void testGetGlobalSystemUserRoleSuccess() throws Exception {
|
|
|
|
MvcResult mvcResult = userRequestUtils.responseGet(userRequestUtils.URL_GET_GLOBAL_SYSTEM);
|
|
|
|
MvcResult mvcResult = userRequestUtils.responseGet(UserRequestUtils.URL_GET_GLOBAL_SYSTEM);
|
|
|
|
this.setDefaultUserRoleList(mvcResult);
|
|
|
|
this.setDefaultUserRoleList(mvcResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -119,7 +121,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
MvcResult mvcResult = userRequestUtils.responsePost(userRequestUtils.URL_USER_CREATE, userMaintainRequest);
|
|
|
|
MvcResult mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest);
|
|
|
|
this.addUser2List(mvcResult);
|
|
|
|
this.addUser2List(mvcResult);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,7 +138,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
Collections.singletonList(USER_ROLE_LIST.get(0)),
|
|
|
|
Collections.singletonList(USER_ROLE_LIST.get(0)),
|
|
|
|
userCreateInfoList
|
|
|
|
userCreateInfoList
|
|
|
|
);
|
|
|
|
);
|
|
|
|
mvcResult = userRequestUtils.responsePost(userRequestUtils.URL_USER_CREATE, userMaintainRequest);
|
|
|
|
mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest);
|
|
|
|
this.addUser2List(mvcResult);
|
|
|
|
this.addUser2List(mvcResult);
|
|
|
|
|
|
|
|
|
|
|
|
//含有重复的用户名称
|
|
|
|
//含有重复的用户名称
|
|
|
@ -154,12 +156,10 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
mvcResult = userRequestUtils.responsePost(userRequestUtils.URL_USER_CREATE, userMaintainRequest);
|
|
|
|
mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest);
|
|
|
|
this.addUser2List(mvcResult);
|
|
|
|
this.addUser2List(mvcResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public final String URL_GET_ORGANIZATION = "/system/user/get/organization";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@Order(2)
|
|
|
|
@Order(2)
|
|
|
|
@Sql(scripts = {"/dml/init_user_controller_test.sql"},
|
|
|
|
@Sql(scripts = {"/dml/init_user_controller_test.sql"},
|
|
|
@ -184,7 +184,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private UserDTO getUserByEmail(String email) throws Exception {
|
|
|
|
private UserDTO getUserByEmail(String email) throws Exception {
|
|
|
|
String url = String.format(userRequestUtils.URL_USER_GET, email);
|
|
|
|
String url = String.format(UserRequestUtils.URL_USER_GET, email);
|
|
|
|
return userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseGet(url), UserDTO.class);
|
|
|
|
return userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseGet(url), UserDTO.class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -193,7 +193,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
public void testGetByEmailError() throws Exception {
|
|
|
|
public void testGetByEmailError() throws Exception {
|
|
|
|
//测试使用任意参数,不能获取到任何用户信息
|
|
|
|
//测试使用任意参数,不能获取到任何用户信息
|
|
|
|
this.checkUserList();
|
|
|
|
this.checkUserList();
|
|
|
|
String url = userRequestUtils.URL_USER_GET + UUID.randomUUID();
|
|
|
|
String url = UserRequestUtils.URL_USER_GET + UUID.randomUUID();
|
|
|
|
MvcResult mvcResult = userRequestUtils.responseGet(url);
|
|
|
|
MvcResult mvcResult = userRequestUtils.responseGet(url);
|
|
|
|
|
|
|
|
|
|
|
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
|
|
|
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
|
|
@ -207,7 +207,11 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@Order(3)
|
|
|
|
@Order(3)
|
|
|
|
public void testPageSuccess() throws Exception {
|
|
|
|
public void testPageSuccess() throws Exception {
|
|
|
|
List<String> userRoleIdList = USER_ROLE_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList());
|
|
|
|
if (CollectionUtils.isEmpty(USER_ROLE_LIST)) {
|
|
|
|
|
|
|
|
this.testGetGlobalSystemUserRoleSuccess();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> userRoleIdList = USER_ROLE_LIST.stream().map(UserSelectOption::getId).toList();
|
|
|
|
this.checkUserList();
|
|
|
|
this.checkUserList();
|
|
|
|
BasePageRequest basePageRequest = UserParamUtils.getDefaultPageRequest();
|
|
|
|
BasePageRequest basePageRequest = UserParamUtils.getDefaultPageRequest();
|
|
|
|
|
|
|
|
|
|
|
@ -222,9 +226,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//用户组不存在非全局用户组
|
|
|
|
//用户组不存在非全局用户组
|
|
|
|
for (UserTableResponse response : userList) {
|
|
|
|
for (UserTableResponse response : userList) {
|
|
|
|
if (CollectionUtils.isNotEmpty(response.getUserRoleList())) {
|
|
|
|
if (CollectionUtils.isNotEmpty(response.getUserRoleList())) {
|
|
|
|
response.getUserRoleList().forEach(role -> {
|
|
|
|
response.getUserRoleList().forEach(role -> Assertions.assertTrue(userRoleIdList.contains(role.getId())));
|
|
|
|
Assertions.assertTrue(userRoleIdList.contains(role.getId()));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -242,9 +244,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
userList = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserTableResponse.class);
|
|
|
|
userList = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserTableResponse.class);
|
|
|
|
for (UserTableResponse response : userList) {
|
|
|
|
for (UserTableResponse response : userList) {
|
|
|
|
if (CollectionUtils.isNotEmpty(response.getUserRoleList())) {
|
|
|
|
if (CollectionUtils.isNotEmpty(response.getUserRoleList())) {
|
|
|
|
response.getUserRoleList().forEach(role -> {
|
|
|
|
response.getUserRoleList().forEach(role -> Assertions.assertTrue(userRoleIdList.contains(role.getId())));
|
|
|
|
Assertions.assertTrue(userRoleIdList.contains(role.getId()));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -264,12 +264,20 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
userList = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserTableResponse.class);
|
|
|
|
userList = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserTableResponse.class);
|
|
|
|
for (UserTableResponse response : userList) {
|
|
|
|
for (UserTableResponse response : userList) {
|
|
|
|
if (CollectionUtils.isNotEmpty(response.getUserRoleList())) {
|
|
|
|
if (CollectionUtils.isNotEmpty(response.getUserRoleList())) {
|
|
|
|
response.getUserRoleList().forEach(role -> {
|
|
|
|
response.getUserRoleList().forEach(role -> Assertions.assertTrue(userRoleIdList.contains(role.getId())));
|
|
|
|
Assertions.assertTrue(userRoleIdList.contains(role.getId()));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查找不存在的用户
|
|
|
|
|
|
|
|
basePageRequest = UserParamUtils.getDefaultPageRequest();
|
|
|
|
|
|
|
|
basePageRequest.setKeyword(UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
returnPager = userRequestUtils.selectUserPage(basePageRequest);
|
|
|
|
|
|
|
|
//返回值不为空
|
|
|
|
|
|
|
|
Assertions.assertNotNull(returnPager);
|
|
|
|
|
|
|
|
//返回值的页码和当前页码相同
|
|
|
|
|
|
|
|
Assertions.assertEquals(returnPager.getTotal(), 0);
|
|
|
|
|
|
|
|
//返回的数据量不超过规定要返回的数据量相同
|
|
|
|
|
|
|
|
Assertions.assertEquals(0, JSON.parseArray(JSON.toJSONString(returnPager.getList())).size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -278,15 +286,15 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//当前页码不大于0
|
|
|
|
//当前页码不大于0
|
|
|
|
BasePageRequest basePageRequest = new BasePageRequest();
|
|
|
|
BasePageRequest basePageRequest = new BasePageRequest();
|
|
|
|
basePageRequest.setPageSize(5);
|
|
|
|
basePageRequest.setPageSize(5);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//pageSize超过100
|
|
|
|
//pageSize超过100
|
|
|
|
basePageRequest = UserParamUtils.getDefaultPageRequest();
|
|
|
|
basePageRequest = UserParamUtils.getDefaultPageRequest();
|
|
|
|
basePageRequest.setPageSize(250);
|
|
|
|
basePageRequest.setPageSize(250);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//当前页数不大于5
|
|
|
|
//当前页数不大于5
|
|
|
|
basePageRequest = new BasePageRequest();
|
|
|
|
basePageRequest = new BasePageRequest();
|
|
|
|
basePageRequest.setCurrent(1);
|
|
|
|
basePageRequest.setCurrent(1);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//排序字段不合法
|
|
|
|
//排序字段不合法
|
|
|
|
basePageRequest = new BasePageRequest();
|
|
|
|
basePageRequest = new BasePageRequest();
|
|
|
|
basePageRequest.setCurrent(1);
|
|
|
|
basePageRequest.setCurrent(1);
|
|
|
@ -294,7 +302,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
basePageRequest.setSort(new HashMap<>() {{
|
|
|
|
basePageRequest.setSort(new HashMap<>() {{
|
|
|
|
put("SELECT * FROM user", "asc");
|
|
|
|
put("SELECT * FROM user", "asc");
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_PAGE, basePageRequest, BAD_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -309,21 +317,21 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//更改名字
|
|
|
|
//更改名字
|
|
|
|
user.setName("TEST-UPDATE");
|
|
|
|
user.setName("TEST-UPDATE");
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
//更改邮箱
|
|
|
|
//更改邮箱
|
|
|
|
user.setEmail("songtianyang-test-email@12138.com");
|
|
|
|
user.setEmail("songtianyang-test-email@12138.com");
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
//更改手机号
|
|
|
|
//更改手机号
|
|
|
|
user.setPhone("18511112222");
|
|
|
|
user.setPhone("18511112222");
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
@ -331,13 +339,13 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user,
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user,
|
|
|
|
USER_ROLE_LIST.stream().filter(item -> StringUtils.equals(item.getId(), "member")).toList()
|
|
|
|
USER_ROLE_LIST.stream().filter(item -> StringUtils.equals(item.getId(), "member")).toList()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
//更改用户组(把上面的情况添加别的权限)
|
|
|
|
//更改用户组(把上面的情况添加别的权限)
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
@ -345,7 +353,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
user = new UserCreateInfo();
|
|
|
|
user = new UserCreateInfo();
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responsePost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest), UserEditRequest.class);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkLog(response.getId(), OperationLogType.UPDATE);
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
checkDTO = this.getUserByEmail(user.getEmail());
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
|
UserParamUtils.compareUserDTO(response, checkDTO);
|
|
|
@ -361,22 +369,22 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
user.setName("");
|
|
|
|
user.setName("");
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//email为空
|
|
|
|
//email为空
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
user.setEmail("");
|
|
|
|
user.setEmail("");
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//手机号为空
|
|
|
|
//手机号为空
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
user.setEmail("");
|
|
|
|
user.setEmail("");
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//用户组为空
|
|
|
|
//用户组为空
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, new ArrayList<>());
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, new ArrayList<>());
|
|
|
|
userMaintainRequest.setUserRoleIdList(new ArrayList<>());
|
|
|
|
userMaintainRequest.setUserRoleIdList(new ArrayList<>());
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
|
|
|
|
|
|
|
|
// 500验证
|
|
|
|
// 500验证
|
|
|
|
//邮箱重复
|
|
|
|
//邮箱重复
|
|
|
@ -384,13 +392,13 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
user.setEmail(USER_LIST.get(USER_LIST.size() - 1).getEmail());
|
|
|
|
user.setEmail(USER_LIST.get(USER_LIST.size() - 1).getEmail());
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user, USER_ROLE_LIST);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
//用户组不包含系统成员
|
|
|
|
//用户组不包含系统成员
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
BeanUtils.copyBean(user, USER_LIST.get(0));
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user,
|
|
|
|
userMaintainRequest = UserParamUtils.getUserUpdateDTO(user,
|
|
|
|
USER_ROLE_LIST.stream().filter(item -> !StringUtils.equals(item.getId(), "member")).toList()
|
|
|
|
USER_ROLE_LIST.stream().filter(item -> !StringUtils.equals(item.getId(), "member")).toList()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -404,7 +412,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
this.add(userInfo.getId());
|
|
|
|
this.add(userInfo.getId());
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
userChangeEnableRequest.setEnable(false);
|
|
|
|
userChangeEnableRequest.setEnable(false);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE_ENABLE, userChangeEnableRequest, status().isOk());
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE_ENABLE, userChangeEnableRequest, status().isOk());
|
|
|
|
for (String item : userChangeEnableRequest.getSelectIds()) {
|
|
|
|
for (String item : userChangeEnableRequest.getSelectIds()) {
|
|
|
|
checkLog(item, OperationLogType.UPDATE);
|
|
|
|
checkLog(item, OperationLogType.UPDATE);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -420,12 +428,12 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//用户不存在
|
|
|
|
//用户不存在
|
|
|
|
UserChangeEnableRequest userChangeEnableRequest = new UserChangeEnableRequest();
|
|
|
|
UserChangeEnableRequest userChangeEnableRequest = new UserChangeEnableRequest();
|
|
|
|
userChangeEnableRequest.setEnable(false);
|
|
|
|
userChangeEnableRequest.setEnable(false);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE_ENABLE, userChangeEnableRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE_ENABLE, userChangeEnableRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//含有非法用户
|
|
|
|
//含有非法用户
|
|
|
|
userChangeEnableRequest.setSelectIds(new ArrayList<>() {{
|
|
|
|
userChangeEnableRequest.setSelectIds(new ArrayList<>() {{
|
|
|
|
this.add("BCDEDIT");
|
|
|
|
this.add("BCDEDIT");
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_UPDATE_ENABLE, userChangeEnableRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_UPDATE_ENABLE, userChangeEnableRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -441,7 +449,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_success.xlsx")).getPath();
|
|
|
|
String filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_success.xlsx")).getPath();
|
|
|
|
MockMultipartFile file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
MockMultipartFile file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
ExcelParseDTO<UserExcelRowDTO> userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
ExcelParseDTO<UserExcelRowDTO> userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);//检查返回值
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);//检查返回值
|
|
|
|
List<UserDTO> userDTOList = this.checkImportUserInDb(userImportReportDTOByFile);//检查数据已入库
|
|
|
|
List<UserDTO> userDTOList = this.checkImportUserInDb(userImportReportDTOByFile);//检查数据已入库
|
|
|
|
for (UserDTO item : userDTOList) {
|
|
|
|
for (UserDTO item : userDTOList) {
|
|
|
@ -451,7 +459,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//导入空文件. 应当导入成功的数据为0
|
|
|
|
//导入空文件. 应当导入成功的数据为0
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_success_empty.xlsx")).getPath();
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_success_empty.xlsx")).getPath();
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
importSuccessData = 0;
|
|
|
|
importSuccessData = 0;
|
|
|
|
errorDataIndex = new int[]{};
|
|
|
|
errorDataIndex = new int[]{};
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
@ -459,7 +467,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//文件内没有一条合格数据 应当导入成功的数据为0
|
|
|
|
//文件内没有一条合格数据 应当导入成功的数据为0
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_all.xlsx")).getPath();
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_all.xlsx")).getPath();
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
errorDataIndex = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
|
|
errorDataIndex = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
|
|
|
|
|
|
|
@ -467,7 +475,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_email_repeat_db.xlsx")).getPath();
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_email_repeat_db.xlsx")).getPath();
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
importSuccessData = 8;
|
|
|
|
importSuccessData = 8;
|
|
|
|
errorDataIndex = new int[]{1, 7};
|
|
|
|
errorDataIndex = new int[]{1, 7};
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
@ -480,7 +488,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_email_repeat_in_file.xlsx")).getPath();
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_error_email_repeat_in_file.xlsx")).getPath();
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
errorDataIndex = new int[]{9, 10};
|
|
|
|
errorDataIndex = new int[]{9, 10};
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
userDTOList = this.checkImportUserInDb(userImportReportDTOByFile);//检查数据已入库
|
|
|
|
userDTOList = this.checkImportUserInDb(userImportReportDTOByFile);//检查数据已入库
|
|
|
@ -491,7 +499,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
//文件不符合规范 应当导入成功的数据为0
|
|
|
|
//文件不符合规范 应当导入成功的数据为0
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/abcde.gif")).getPath();
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/abcde.gif")).getPath();
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
importSuccessData = 0;
|
|
|
|
importSuccessData = 0;
|
|
|
|
errorDataIndex = new int[]{};
|
|
|
|
errorDataIndex = new int[]{};
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);
|
|
|
@ -500,7 +508,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_success_03.xls")).getPath();
|
|
|
|
filePath = Objects.requireNonNull(this.getClass().getClassLoader().getResource("file/user_import_success_03.xls")).getPath();
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
file = new MockMultipartFile("file", "userImport.xlsx", MediaType.APPLICATION_OCTET_STREAM_VALUE, UserParamUtils.getFileBytes(filePath));
|
|
|
|
userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
userImportReportDTOByFile = userService.getUserExcelParseDTO(file);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(userRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
response = userRequestUtils.parseObjectFromMvcResult(userRequestUtils.responseFile(UserRequestUtils.URL_USER_IMPORT, file), UserImportResponse.class);
|
|
|
|
importSuccessData = 10;//应该导入成功的数据数量
|
|
|
|
importSuccessData = 10;//应该导入成功的数据数量
|
|
|
|
errorDataIndex = new int[]{};//出错数据的行数
|
|
|
|
errorDataIndex = new int[]{};//出错数据的行数
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);//检查返回值
|
|
|
|
UserParamUtils.checkImportResponse(response, importSuccessData, errorDataIndex);//检查返回值
|
|
|
@ -517,7 +525,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
request.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
request.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
this.requestPostAndReturn(userRequestUtils.URL_USER_RESET_PASSWORD, request, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPostAndReturn(UserRequestUtils.URL_USER_RESET_PASSWORD, request, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -545,24 +553,24 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
//所有参数都为空
|
|
|
|
//所有参数都为空
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(null, null);
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(null, null);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//用户组ID为空
|
|
|
|
//用户组ID为空
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
errorUserList);
|
|
|
|
errorUserList);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//没有用户
|
|
|
|
//没有用户
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
null);
|
|
|
|
null);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//用户组含有null
|
|
|
|
//用户组含有null
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
errorUserList);
|
|
|
|
errorUserList);
|
|
|
|
userMaintainRequest.getUserRoleIdList().add(null);
|
|
|
|
userMaintainRequest.getUserRoleIdList().add(null);
|
|
|
|
userMaintainRequest.getUserRoleIdList().add("");
|
|
|
|
userMaintainRequest.getUserRoleIdList().add("");
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//含有用户名称为空的数据
|
|
|
|
//含有用户名称为空的数据
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
@ -571,7 +579,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
userMaintainRequest.getUserInfoList().add(new UserCreateInfo() {{
|
|
|
|
userMaintainRequest.getUserInfoList().add(new UserCreateInfo() {{
|
|
|
|
setEmail("tianyang.name.empty@126.com");
|
|
|
|
setEmail("tianyang.name.empty@126.com");
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//含有用户邮箱为空的数据
|
|
|
|
//含有用户邮箱为空的数据
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
@ -580,7 +588,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
userMaintainRequest.getUserInfoList().add(new UserCreateInfo() {{
|
|
|
|
userMaintainRequest.getUserInfoList().add(new UserCreateInfo() {{
|
|
|
|
setName("tianyang.email.empty");
|
|
|
|
setName("tianyang.email.empty");
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
//用户邮箱不符合标准
|
|
|
|
//用户邮箱不符合标准
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
@ -590,7 +598,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
setName("用户邮箱放飞自我");
|
|
|
|
setName("用户邮箱放飞自我");
|
|
|
|
setEmail("用户邮箱放飞自我");
|
|
|
|
setEmail("用户邮箱放飞自我");
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, BAD_REQUEST_MATCHER);
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* 校验业务判断出错的反例 (500 error)
|
|
|
|
* 校验业务判断出错的反例 (500 error)
|
|
|
|
* 需要保证数据库有正常数据
|
|
|
|
* 需要保证数据库有正常数据
|
|
|
@ -604,7 +612,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
errorUserList);
|
|
|
|
errorUserList);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
//含有重复的用户邮箱
|
|
|
|
//含有重复的用户邮箱
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
@ -615,7 +623,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
setName("tianyang.no.error4");
|
|
|
|
setName("tianyang.no.error4");
|
|
|
|
setEmail(firstUserEmail);
|
|
|
|
setEmail(firstUserEmail);
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
//测试请求参数中含有数据库中已存在的邮箱情况
|
|
|
|
//测试请求参数中含有数据库中已存在的邮箱情况
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
userMaintainRequest = UserParamUtils.getUserCreateDTO(
|
|
|
|
USER_ROLE_LIST,
|
|
|
|
USER_ROLE_LIST,
|
|
|
@ -629,7 +637,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
}});
|
|
|
|
}});
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_CREATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_CREATE, userMaintainRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -640,7 +648,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
request.setSelectIds(Collections.singletonList("admin"));
|
|
|
|
request.setSelectIds(Collections.singletonList("admin"));
|
|
|
|
this.requestPostAndReturn(userRequestUtils.URL_USER_RESET_PASSWORD, request);
|
|
|
|
this.requestPostAndReturn(UserRequestUtils.URL_USER_RESET_PASSWORD, request);
|
|
|
|
//检查数据库
|
|
|
|
//检查数据库
|
|
|
|
UserExample userExample = new UserExample();
|
|
|
|
UserExample userExample = new UserExample();
|
|
|
|
userExample.createCriteria().andIdEqualTo("admin").andPasswordEqualTo(CodingUtil.md5("metersphere"));
|
|
|
|
userExample.createCriteria().andIdEqualTo("admin").andPasswordEqualTo(CodingUtil.md5("metersphere"));
|
|
|
@ -657,11 +665,11 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
request.setSelectIds(Collections.singletonList(userId));
|
|
|
|
request.setSelectIds(Collections.singletonList(userId));
|
|
|
|
TableBatchProcessResponse response = userRequestUtils.parseObjectFromMvcResult(
|
|
|
|
TableBatchProcessResponse response = userRequestUtils.parseObjectFromMvcResult(
|
|
|
|
this.requestPostAndReturn(userRequestUtils.URL_USER_RESET_PASSWORD, request),
|
|
|
|
this.requestPostAndReturn(UserRequestUtils.URL_USER_RESET_PASSWORD, request),
|
|
|
|
TableBatchProcessResponse.class
|
|
|
|
TableBatchProcessResponse.class
|
|
|
|
);
|
|
|
|
);
|
|
|
|
Assertions.assertEquals(response.getTotalCount(), response.getSuccessCount(), 1);
|
|
|
|
Assertions.assertEquals(response.getTotalCount(), response.getSuccessCount(), 1);
|
|
|
|
List<User> userList = userService.selectByIdList(Collections.singletonList(userId));
|
|
|
|
List<User> userList = userToolService.selectByIdList(Collections.singletonList(userId));
|
|
|
|
for (User checkUser : userList) {
|
|
|
|
for (User checkUser : userList) {
|
|
|
|
UserExample userExample = new UserExample();
|
|
|
|
UserExample userExample = new UserExample();
|
|
|
|
userExample.createCriteria().andIdEqualTo(checkUser.getId()).andPasswordEqualTo(CodingUtil.md5(checkUser.getEmail()));
|
|
|
|
userExample.createCriteria().andIdEqualTo(checkUser.getId()).andPasswordEqualTo(CodingUtil.md5(checkUser.getEmail()));
|
|
|
@ -675,7 +683,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
request.setExcludeIds(Collections.singletonList("admin"));
|
|
|
|
request.setExcludeIds(Collections.singletonList("admin"));
|
|
|
|
request.setSelectAll(true);
|
|
|
|
request.setSelectAll(true);
|
|
|
|
TableBatchProcessResponse response = userRequestUtils.parseObjectFromMvcResult(
|
|
|
|
TableBatchProcessResponse response = userRequestUtils.parseObjectFromMvcResult(
|
|
|
|
this.requestPostAndReturn(userRequestUtils.URL_USER_RESET_PASSWORD, request),
|
|
|
|
this.requestPostAndReturn(UserRequestUtils.URL_USER_RESET_PASSWORD, request),
|
|
|
|
TableBatchProcessResponse.class
|
|
|
|
TableBatchProcessResponse.class
|
|
|
|
);
|
|
|
|
);
|
|
|
|
UserExample example = new UserExample();
|
|
|
|
UserExample example = new UserExample();
|
|
|
@ -705,9 +713,9 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
List<UserCreateInfo> last50Users = USER_LIST.subList(USER_LIST.size() - 50, USER_LIST.size());
|
|
|
|
List<UserCreateInfo> last50Users = USER_LIST.subList(USER_LIST.size() - 50, USER_LIST.size());
|
|
|
|
//测试添加角色权限。 预期数据:每个用户都会增加对应的权限
|
|
|
|
//测试添加角色权限。 预期数据:每个用户都会增加对应的权限
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).toList());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_USER_ROLE_RELATION, request, null);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_USER_ROLE_RELATION, request, null);
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
Assertions.assertEquals(
|
|
|
|
Assertions.assertEquals(
|
|
|
|
globalUserRoleRelationService.selectByUserIdAndRuleId(request.getSelectIds(), request.getRoleIds()).size(),
|
|
|
|
globalUserRoleRelationService.selectByUserIdAndRuleId(request.getSelectIds(), request.getRoleIds()).size(),
|
|
|
@ -719,7 +727,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//测试重复添加用户权限。预期结果:不会额外增加数据
|
|
|
|
//测试重复添加用户权限。预期结果:不会额外增加数据
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_USER_ROLE_RELATION, request, null);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_USER_ROLE_RELATION, request, null);
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
Assertions.assertEquals(
|
|
|
|
Assertions.assertEquals(
|
|
|
|
globalUserRoleRelationService.selectByUserIdAndRuleId(request.getSelectIds(), request.getRoleIds()).size(),
|
|
|
|
globalUserRoleRelationService.selectByUserIdAndRuleId(request.getSelectIds(), request.getRoleIds()).size(),
|
|
|
@ -742,25 +750,25 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
// 用户ID为空
|
|
|
|
// 用户ID为空
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(new ArrayList<>());
|
|
|
|
request.setSelectIds(new ArrayList<>());
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).toList());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
// 角色id为空
|
|
|
|
// 角色id为空
|
|
|
|
request = new UserRoleBatchRelationRequest();
|
|
|
|
request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
request.setRoleIds(new ArrayList<>());
|
|
|
|
request.setRoleIds(new ArrayList<>());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
// 用户ID含有不存在的
|
|
|
|
// 用户ID含有不存在的
|
|
|
|
request = new UserRoleBatchRelationRequest();
|
|
|
|
request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
request.getSelectIds().add("none user");
|
|
|
|
request.getSelectIds().add("none user");
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).toList());
|
|
|
|
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
// 角色ID含有不存在的
|
|
|
|
// 角色ID含有不存在的
|
|
|
|
request = new UserRoleBatchRelationRequest();
|
|
|
|
request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
request.setSelectIds(last50Users.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
request.setRoleIds(USER_ROLE_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
request.getRoleIds().add("none role");
|
|
|
|
request.getRoleIds().add("none role");
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_USER_ROLE_RELATION, request, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
@ -769,20 +777,20 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED),
|
|
|
|
config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED),
|
|
|
|
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
|
|
|
|
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
|
|
|
|
public void testGetProjectAndOrganization() throws Exception {
|
|
|
|
public void testGetProjectAndOrganization() throws Exception {
|
|
|
|
String str = userRequestUtils.responseGet(userRequestUtils.URL_GET_PROJECT).getResponse().getContentAsString(StandardCharsets.UTF_8);
|
|
|
|
String str = userRequestUtils.responseGet(UserRequestUtils.URL_GET_PROJECT).getResponse().getContentAsString(StandardCharsets.UTF_8);
|
|
|
|
ResultHolder rh = JSON.parseObject(str, ResultHolder.class);
|
|
|
|
ResultHolder rh = JSON.parseObject(str, ResultHolder.class);
|
|
|
|
List<UserTreeSelectOption> userTreeSelectOptions = JSON.parseArray(
|
|
|
|
List<BaseTreeNode> userTreeSelectOptions = JSON.parseArray(
|
|
|
|
JSON.toJSONString(rh.getData()),
|
|
|
|
JSON.toJSONString(rh.getData()),
|
|
|
|
UserTreeSelectOption.class);
|
|
|
|
BaseTreeNode.class);
|
|
|
|
//返回值不为空
|
|
|
|
//返回值不为空
|
|
|
|
Assertions.assertTrue(CollectionUtils.isNotEmpty(userTreeSelectOptions));
|
|
|
|
Assertions.assertTrue(CollectionUtils.isNotEmpty(userTreeSelectOptions));
|
|
|
|
PROJECT_LIST.addAll(userTreeSelectOptions);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userTreeSelectOptions.forEach(item -> PROJECT_LIST.addAll(item.getChildren()));
|
|
|
|
|
|
|
|
|
|
|
|
List<UserSelectOption> userSelectOptions = JSON.parseArray(
|
|
|
|
List<UserSelectOption> userSelectOptions = JSON.parseArray(
|
|
|
|
JSON.toJSONString(
|
|
|
|
JSON.toJSONString(
|
|
|
|
JSON.parseObject(
|
|
|
|
JSON.parseObject(
|
|
|
|
userRequestUtils.responseGet(userRequestUtils.URL_GET_ORGANIZATION).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
|
|
|
userRequestUtils.responseGet(UserRequestUtils.URL_GET_ORGANIZATION).getResponse().getContentAsString(StandardCharsets.UTF_8),
|
|
|
|
ResultHolder.class).getData()),
|
|
|
|
ResultHolder.class).getData()),
|
|
|
|
UserSelectOption.class);
|
|
|
|
UserSelectOption.class);
|
|
|
|
ORG_LIST.addAll(userSelectOptions);
|
|
|
|
ORG_LIST.addAll(userSelectOptions);
|
|
|
@ -799,14 +807,12 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
this.testGetProjectAndOrganization();
|
|
|
|
this.testGetProjectAndOrganization();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<String> userIds = this.selectUserTableIds(50);
|
|
|
|
List<String> userIds = this.selectUserTableIds(100);
|
|
|
|
|
|
|
|
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(userIds);
|
|
|
|
request.setSelectIds(userIds);
|
|
|
|
request.setRoleIds(PROJECT_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
request.setRoleIds(PROJECT_LIST.stream().map(BaseTreeNode::getId).toList());
|
|
|
|
//排除树结构中的组织ID
|
|
|
|
this.requestPostWithOk(UserRequestUtils.URL_ADD_PROJECT_MEMBER, request);
|
|
|
|
request.getRoleIds().removeAll(ORG_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
this.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, request);
|
|
|
|
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
UserRoleRelationExample checkExample = new UserRoleRelationExample();
|
|
|
|
UserRoleRelationExample checkExample = new UserRoleRelationExample();
|
|
|
|
|
|
|
|
|
|
|
@ -850,8 +856,8 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
|
|
|
|
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
UserRoleBatchRelationRequest request = new UserRoleBatchRelationRequest();
|
|
|
|
request.setSelectIds(userIds);
|
|
|
|
request.setSelectIds(userIds);
|
|
|
|
request.setRoleIds(ORG_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
request.setRoleIds(ORG_LIST.stream().map(UserSelectOption::getId).toList());
|
|
|
|
this.requestPostWithOk(userRequestUtils.URL_ADD_ORGANIZATION_MEMBER, request);
|
|
|
|
this.requestPostWithOk(UserRequestUtils.URL_ADD_ORGANIZATION_MEMBER, request);
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
//检查有权限的数据量是否一致
|
|
|
|
UserRoleRelationExample checkExample = new UserRoleRelationExample();
|
|
|
|
UserRoleRelationExample checkExample = new UserRoleRelationExample();
|
|
|
|
for (String orgId : request.getRoleIds()) {
|
|
|
|
for (String orgId : request.getRoleIds()) {
|
|
|
@ -881,45 +887,45 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
// 用户ID为空
|
|
|
|
// 用户ID为空
|
|
|
|
UserRoleBatchRelationRequest addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
UserRoleBatchRelationRequest addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest.setSelectIds(new ArrayList<>());
|
|
|
|
addToProjectRequest.setSelectIds(new ArrayList<>());
|
|
|
|
addToProjectRequest.setRoleIds(PROJECT_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
addToProjectRequest.setRoleIds(PROJECT_LIST.stream().map(BaseTreeNode::getId).toList());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
// 项目为空
|
|
|
|
// 项目为空
|
|
|
|
addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
addToProjectRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
addToProjectRequest.setRoleIds(new ArrayList<>());
|
|
|
|
addToProjectRequest.setRoleIds(new ArrayList<>());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, BAD_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, BAD_REQUEST_MATCHER);
|
|
|
|
// 用户ID含有不存在的
|
|
|
|
// 用户ID含有不存在的
|
|
|
|
addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
addToProjectRequest.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
addToProjectRequest.setRoleIds(PROJECT_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
addToProjectRequest.setRoleIds(PROJECT_LIST.stream().map(BaseTreeNode::getId).toList());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
// 项目ID含有不存在的
|
|
|
|
// 项目ID含有不存在的
|
|
|
|
addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest = new UserRoleBatchRelationRequest();
|
|
|
|
addToProjectRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
addToProjectRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
addToProjectRequest.setRoleIds(Collections.singletonList("none role"));
|
|
|
|
addToProjectRequest.setRoleIds(Collections.singletonList("none role"));
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, addToProjectRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用户ID为空
|
|
|
|
// 用户ID为空
|
|
|
|
UserRoleBatchRelationRequest orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
UserRoleBatchRelationRequest orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest.setSelectIds(new ArrayList<>());
|
|
|
|
orgRequest.setSelectIds(new ArrayList<>());
|
|
|
|
orgRequest.setRoleIds(ORG_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
orgRequest.setRoleIds(ORG_LIST.stream().map(UserSelectOption::getId).toList());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
// 项目为空
|
|
|
|
// 项目为空
|
|
|
|
orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
orgRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
orgRequest.setRoleIds(new ArrayList<>());
|
|
|
|
orgRequest.setRoleIds(new ArrayList<>());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, BAD_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, BAD_REQUEST_MATCHER);
|
|
|
|
// 用户ID含有不存在的
|
|
|
|
// 用户ID含有不存在的
|
|
|
|
orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
orgRequest.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
orgRequest.setRoleIds(ORG_LIST.stream().map(UserSelectOption::getId).collect(Collectors.toList()));
|
|
|
|
orgRequest.setRoleIds(ORG_LIST.stream().map(UserSelectOption::getId).toList());
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
// 项目ID含有不存在的
|
|
|
|
// 项目ID含有不存在的
|
|
|
|
orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest = new UserRoleBatchRelationRequest();
|
|
|
|
orgRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
orgRequest.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
orgRequest.setRoleIds(Collections.singletonList("none role"));
|
|
|
|
orgRequest.setRoleIds(Collections.singletonList("none role"));
|
|
|
|
userRequestUtils.requestPost(userRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
userRequestUtils.requestPost(UserRequestUtils.URL_ADD_PROJECT_MEMBER, orgRequest, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//本测试类中会用到很多次用户数据。所以测试删除的方法放于最后
|
|
|
|
//本测试类中会用到很多次用户数据。所以测试删除的方法放于最后
|
|
|
@ -929,9 +935,9 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
this.checkUserList();
|
|
|
|
this.checkUserList();
|
|
|
|
//删除USER_LIST用户
|
|
|
|
//删除USER_LIST用户
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
request.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).collect(Collectors.toList()));
|
|
|
|
request.setSelectIds(USER_LIST.stream().map(UserCreateInfo::getId).toList());
|
|
|
|
TableBatchProcessResponse response = userRequestUtils.parseObjectFromMvcResult(
|
|
|
|
TableBatchProcessResponse response = userRequestUtils.parseObjectFromMvcResult(
|
|
|
|
userRequestUtils.responsePost(userRequestUtils.URL_USER_DELETE, request), TableBatchProcessResponse.class);
|
|
|
|
userRequestUtils.responsePost(UserRequestUtils.URL_USER_DELETE, request), TableBatchProcessResponse.class);
|
|
|
|
Assertions.assertEquals(request.getSelectIds().size(), response.getTotalCount());
|
|
|
|
Assertions.assertEquals(request.getSelectIds().size(), response.getTotalCount());
|
|
|
|
Assertions.assertEquals(request.getSelectIds().size(), response.getSuccessCount());
|
|
|
|
Assertions.assertEquals(request.getSelectIds().size(), response.getSuccessCount());
|
|
|
|
//检查数据库
|
|
|
|
//检查数据库
|
|
|
@ -950,21 +956,21 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
public void testUserDeleteError() throws Exception {
|
|
|
|
public void testUserDeleteError() throws Exception {
|
|
|
|
//参数为空
|
|
|
|
//参数为空
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
TableBatchProcessDTO request = new TableBatchProcessDTO();
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
//用户不存在
|
|
|
|
//用户不存在
|
|
|
|
request.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
request.setSelectIds(Collections.singletonList("none user"));
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
//测试用户已经被删除的
|
|
|
|
//测试用户已经被删除的
|
|
|
|
if (CollectionUtils.isEmpty(DELETED_USER_ID_LIST)) {
|
|
|
|
if (CollectionUtils.isEmpty(DELETED_USER_ID_LIST)) {
|
|
|
|
this.testUserDeleteSuccess();
|
|
|
|
this.testUserDeleteSuccess();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
request.setSelectIds(DELETED_USER_ID_LIST);
|
|
|
|
request.setSelectIds(DELETED_USER_ID_LIST);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
|
|
|
|
|
|
|
|
//测试包含Admin用户
|
|
|
|
//测试包含Admin用户
|
|
|
|
request = new TableBatchProcessDTO();
|
|
|
|
request = new TableBatchProcessDTO();
|
|
|
|
request.setSelectAll(true);
|
|
|
|
request.setSelectAll(true);
|
|
|
|
this.requestPost(userRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
this.requestPost(UserRequestUtils.URL_USER_DELETE, request, ERROR_REQUEST_MATCHER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -987,7 +993,7 @@ public class UserControllerTests extends BaseTest {
|
|
|
|
Pager<?> returnPager = userRequestUtils.selectUserPage(basePageRequest);
|
|
|
|
Pager<?> returnPager = userRequestUtils.selectUserPage(basePageRequest);
|
|
|
|
//用户组不存在非全局用户组
|
|
|
|
//用户组不存在非全局用户组
|
|
|
|
List<UserTableResponse> userList = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserTableResponse.class);
|
|
|
|
List<UserTableResponse> userList = JSON.parseArray(JSON.toJSONString(returnPager.getList()), UserTableResponse.class);
|
|
|
|
return userList.stream().map(User::getId).collect(Collectors.toList());
|
|
|
|
return userList.stream().map(User::getId).toList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//成功入库的用户保存内存中,其他用例会使用到
|
|
|
|
//成功入库的用户保存内存中,其他用例会使用到
|
|
|
|