1、系统登录改造:首页移除机构、新用户用手机号登录(机构新增组织管理员移除账号密码、新增用户移除账号密码)、需要验证码的部分(首页忘记密码、修改密保手机);2、组织权限菜单树增加visiable属性过滤;3、支持钉钉、阿里云短信配置加密、对接系统发送短信;

This commit is contained in:
gaoqr
2024-08-28 09:28:52 +08:00
parent 2248f89e70
commit 156ff82411
67 changed files with 973 additions and 316 deletions
@@ -5,20 +5,14 @@ import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.enums.UserTypeEnum;
import com.cf.imes.framework.test.core.ut.BaseDbUnitTest;
import com.cf.imes.module.system.api.sms.SmsCodeApi;
import com.cf.imes.module.system.api.social.dto.SocialUserBindReqDTO;
import com.cf.imes.module.system.api.social.dto.SocialUserRespDTO;
import com.cf.imes.module.system.controller.admin.auth.vo.*;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthLoginReqVO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthLoginRespVO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthSmsLoginReqVO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthSmsSendReqVO;
import com.cf.imes.module.system.controller.admin.auth.vo.AuthSocialLoginReqVO;
import com.cf.imes.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import com.cf.imes.module.system.dal.dataobject.user.AdminUserDO;
import com.cf.imes.module.system.enums.logger.LoginLogTypeEnum;
import com.cf.imes.module.system.enums.logger.LoginResultEnum;
import com.cf.imes.module.system.enums.sms.SmsSceneEnum;
import com.cf.imes.module.system.enums.social.SocialTypeEnum;
import com.cf.imes.module.system.service.logger.LoginLogService;
import com.cf.imes.module.system.service.member.MemberService;
import com.cf.imes.module.system.service.oauth2.OAuth2TokenService;
@@ -91,7 +85,7 @@ public class AdminAuthServiceImplTest extends BaseDbUnitTest {
when(userService.isPasswordMatch(eq(password), eq(user.getPassword()))).thenReturn(true);
// 调用
AdminUserDO loginUser = authService.authenticate(username, password, null);
AdminUserDO loginUser = authService.authenticate(AuthLoginReqVO.builder().username(username).password(password).build());
// 校验
assertPojoEquals(user, loginUser);
}
@@ -103,7 +97,7 @@ public class AdminAuthServiceImplTest extends BaseDbUnitTest {
String password = randomString();
// 调用, 并断言异常
assertServiceException(() -> authService.authenticate(username, password, null),
assertServiceException(() -> authService.authenticate(AuthLoginReqVO.builder().username(username).password(password).build()),
AUTH_LOGIN_BAD_CREDENTIALS);
verify(loginLogService).createLoginLog(
argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType())
@@ -123,7 +117,7 @@ public class AdminAuthServiceImplTest extends BaseDbUnitTest {
when(userService.getUserByUsername(eq(username), null)).thenReturn(user);
// 调用, 并断言异常
assertServiceException(() -> authService.authenticate(username, password, null),
assertServiceException(() -> authService.authenticate(AuthLoginReqVO.builder().username(username).password(password).build()),
AUTH_LOGIN_BAD_CREDENTIALS);
verify(loginLogService).createLoginLog(
argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType())
@@ -145,7 +139,7 @@ public class AdminAuthServiceImplTest extends BaseDbUnitTest {
when(userService.isPasswordMatch(eq(password), eq(user.getPassword()))).thenReturn(true);
// 调用, 并断言异常
assertServiceException(() -> authService.authenticate(username, password, null),
assertServiceException(() -> authService.authenticate(AuthLoginReqVO.builder().username(username).password(password).build()),
AUTH_LOGIN_USER_DISABLED);
verify(loginLogService).createLoginLog(
argThat(o -> o.getLogType().equals(LoginLogTypeEnum.LOGIN_USERNAME.getType())
@@ -5,6 +5,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.sms.core.client.SmsClient;
import com.cf.imes.framework.sms.core.client.SmsClientFactory;
import com.cf.imes.framework.sms.core.enums.SmsChannelEnum;
import com.cf.imes.framework.sms.core.property.SmsChannelProperties;
import com.cf.imes.framework.test.core.ut.BaseDbUnitTest;
import com.cf.imes.module.system.controller.admin.sms.vo.channel.SmsChannelPageReqVO;
@@ -200,16 +201,12 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
Long id = channel.getId();
// mock 方法
SmsClient mockClient = mock(SmsClient.class);
when(smsClientFactory.getSmsClient(eq(id))).thenReturn(mockClient);
when(smsClientFactory.getSmsClient(eq(SmsChannelEnum.ALIYUN.getCode()))).thenReturn(mockClient);
// 调用
SmsClient client = smsChannelService.getSmsClient(id);
// 断言
assertSame(client, mockClient);
verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> {
SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class);
return properties.equals(arg);
}));
}
@Test
@@ -227,10 +224,6 @@ public class SmsChannelServiceTest extends BaseDbUnitTest {
SmsClient client = smsChannelService.getSmsClient(code);
// 断言
assertSame(client, mockClient);
verify(smsClientFactory).createOrUpdateSmsClient(argThat(arg -> {
SmsChannelProperties properties = BeanUtils.toBean(channel, SmsChannelProperties.class);
return properties.equals(arg);
}));
}
}
@@ -130,10 +130,11 @@ public class SmsLogServiceImplTest extends BaseDbUnitTest {
String apiSendMsg = randomString();
String apiRequestId = randomString();
String apiSerialNo = randomString();
String channelCode = randomString();
// 调用
smsLogService.updateSmsSendResult(id, success,
apiSendCode, apiSendMsg, apiRequestId, apiSerialNo);
apiSendCode, apiSendMsg, apiRequestId, apiSerialNo, channelCode);
// 断言
dbSmsLog = smsLogMapper.selectById(id);
assertEquals(success ? SmsSendStatusEnum.SUCCESS.getStatus() : SmsSendStatusEnum.FAILURE.getStatus(),
@@ -85,8 +85,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest {
// 断言
assertEquals(smsLogId, resultSmsLogId);
// 断言调用
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(user.getMobile()),
eq(template.getChannelId()), eq(template.getApiTemplateId()),
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(user.getMobile()), eq(template),
eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login"))));
}
@@ -124,8 +123,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest {
// 断言
assertEquals(smsLogId, resultSmsLogId);
// 断言调用
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile),
eq(template.getChannelId()), eq(template.getApiTemplateId()),
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), eq(template),
eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login"))));
}
@@ -164,8 +162,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest {
// 断言
assertEquals(smsLogId, resultSmsLogId);
// 断言调用
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile),
eq(template.getChannelId()), eq(template.getApiTemplateId()),
verify(smsProducer).sendSmsSendMessage(eq(smsLogId), eq(mobile), eq(template),
eq(Lists.newArrayList(new KeyValue<>("code", "1234"), new KeyValue<>("op", "login"))));
}
@@ -204,8 +201,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest {
// 断言
assertEquals(smsLogId, resultSmsLogId);
// 断言调用
verify(smsProducer, times(0)).sendSmsSendMessage(anyLong(), anyString(),
anyLong(), any(), anyList());
verify(smsProducer, times(0)).sendSmsSendMessage(anyLong(), any(), any(), anyList());
}
@Test
@@ -274,7 +270,7 @@ public class SmsSendServiceImplTest extends BaseMockitoUnitTest {
// 断言
verify(smsLogService).updateSmsSendResult(eq(message.getLogId()),
eq(sendResult.getSuccess()), eq(sendResult.getApiCode()),
eq(sendResult.getApiMsg()), eq(sendResult.getApiRequestId()), eq(sendResult.getSerialNo()));
eq(sendResult.getApiMsg()), eq(sendResult.getApiRequestId()), eq(sendResult.getSerialNo()), eq(sendResult.getChannelCode()));
}
@Test
@@ -588,7 +588,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile)));
// 调用,校验异常
assertServiceException(() -> userService.validateMobileUnique(null, mobile, 1L),
assertServiceException(() -> userService.validateMobileUnique(null, mobile),
USER_MOBILE_EXISTS);
}
@@ -601,7 +601,7 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
userMapper.insert(randomAdminUserDO(o -> o.setMobile(mobile)));
// 调用,校验异常
assertServiceException(() -> userService.validateMobileUnique(id, mobile, 1L),
assertServiceException(() -> userService.validateMobileUnique(id, mobile),
USER_MOBILE_EXISTS);
}