fix(系统设置): 用户通过邮箱邀请注册时增加名称长度的校验
--bug=1035151 --user=宋天阳 【系统设置】系统-用户-邮箱邀请用户,邮箱邀请链接页面校验姓名长度提示信息优化 https://www.tapd.cn/55049933/s/1459127
This commit is contained in:
parent
a8676365f6
commit
b7a3a7348c
|
@ -550,8 +550,8 @@ public class FileMetadataService {
|
||||||
fileMetadata.setProjectId(oldFile.getProjectId());
|
fileMetadata.setProjectId(oldFile.getProjectId());
|
||||||
fileMetadata.setModuleId(oldFile.getModuleId());
|
fileMetadata.setModuleId(oldFile.getModuleId());
|
||||||
fileMetadata.setName(oldFile.getName());
|
fileMetadata.setName(oldFile.getName());
|
||||||
fileMetadata.setCreateTime(oldFile.getCreateTime());
|
fileMetadata.setCreateTime(operationTime);
|
||||||
fileMetadata.setCreateUser(oldFile.getCreateUser());
|
fileMetadata.setCreateUser(operator);
|
||||||
fileMetadata.setUpdateTime(operationTime);
|
fileMetadata.setUpdateTime(operationTime);
|
||||||
fileMetadata.setPath(oldFile.getPath());
|
fileMetadata.setPath(oldFile.getPath());
|
||||||
fileMetadata.setUpdateUser(operator);
|
fileMetadata.setUpdateUser(operator);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.system.dto.request;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -12,6 +13,7 @@ public class UserRegisterRequest {
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "用户名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@Size(min = 1, max = 255, message = "{user.name.length_range}")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@NotBlank
|
@NotBlank
|
||||||
|
|
|
@ -319,7 +319,7 @@ public class UserLogService {
|
||||||
LogDTO log = LogDTOBuilder.builder()
|
LogDTO log = LogDTOBuilder.builder()
|
||||||
.projectId(OperationLogConstants.SYSTEM)
|
.projectId(OperationLogConstants.SYSTEM)
|
||||||
.module(OperationLogModule.SETTING_SYSTEM_USER_SINGLE)
|
.module(OperationLogModule.SETTING_SYSTEM_USER_SINGLE)
|
||||||
.createUser(user.getName())
|
.createUser(user.getId())
|
||||||
.organizationId(OperationLogConstants.SYSTEM)
|
.organizationId(OperationLogConstants.SYSTEM)
|
||||||
.sourceId(user.getId())
|
.sourceId(user.getId())
|
||||||
.type(OperationLogType.ADD.name())
|
.type(OperationLogType.ADD.name())
|
||||||
|
|
|
@ -1351,8 +1351,18 @@ public class UserControllerTests extends BaseTest {
|
||||||
String inviteId = INVITE_RECORD_ID_LIST.getFirst();
|
String inviteId = INVITE_RECORD_ID_LIST.getFirst();
|
||||||
UserRegisterRequest request = new UserRegisterRequest();
|
UserRegisterRequest request = new UserRegisterRequest();
|
||||||
request.setInviteId(inviteId);
|
request.setInviteId(inviteId);
|
||||||
request.setName("建国通过邮箱邀请");
|
|
||||||
request.setPassword(RsaUtils.publicEncrypt("Cao..12138", RsaUtils.getRsaKey().getPublicKey()));
|
request.setPassword(RsaUtils.publicEncrypt("Cao..12138", RsaUtils.getRsaKey().getPublicKey()));
|
||||||
|
|
||||||
|
//先测试反例:名称超过255
|
||||||
|
StringBuilder overSizeName = new StringBuilder();
|
||||||
|
while (overSizeName.length() < 256) {
|
||||||
|
overSizeName.append("i");
|
||||||
|
}
|
||||||
|
request.setName(overSizeName.toString());
|
||||||
|
this.requestPost(UserRequestUtils.URL_INVITE_REGISTER, request).andExpect(BAD_REQUEST_MATCHER);
|
||||||
|
|
||||||
|
//测试正常创建
|
||||||
|
request.setName("建国通过邮箱邀请");
|
||||||
MvcResult mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_INVITE_REGISTER, request);
|
MvcResult mvcResult = userRequestUtils.responsePost(UserRequestUtils.URL_INVITE_REGISTER, request);
|
||||||
String resultHolderStr = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
String resultHolderStr = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||||
ResultHolder resultHolder = JSON.parseObject(resultHolderStr, ResultHolder.class);
|
ResultHolder resultHolder = JSON.parseObject(resultHolderStr, ResultHolder.class);
|
||||||
|
@ -1361,6 +1371,8 @@ public class UserControllerTests extends BaseTest {
|
||||||
LOG_CHECK_LIST.add(
|
LOG_CHECK_LIST.add(
|
||||||
new CheckLogModel(resultHolder.getData().toString(), OperationLogType.ADD, UserRequestUtils.URL_INVITE_REGISTER)
|
new CheckLogModel(resultHolder.getData().toString(), OperationLogType.ADD, UserRequestUtils.URL_INVITE_REGISTER)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testUserRegisterError() throws Exception {
|
private void testUserRegisterError() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue