|
|
@@ -100,6 +100,7 @@ class InfoUserControllerTest {
|
|
|
messageSource.addMessage("no.user.jcaptcha.error", Locale.getDefault(), "验证码错误");
|
|
|
messageSource.addMessage("no.oauth.tempkey.expired", Locale.getDefault(), "登录凭证已过期");
|
|
|
messageSource.addMessage("no.oauth.phone.duplicate", Locale.getDefault(), "该手机号关联多个账号,请联系平台");
|
|
|
+ messageSource.addMessage("no.user.phone.duplicate", Locale.getDefault(), "该手机号关联多个账号,请联系平台");
|
|
|
beanFactory.registerSingleton("messageSource", messageSource);
|
|
|
beanFactory.registerSingleton("redisCache", mock(RedisCache.class));
|
|
|
new SpringUtils().postProcessBeanFactory(beanFactory);
|
|
|
@@ -325,7 +326,7 @@ class InfoUserControllerTest {
|
|
|
created.setUserId(42L);
|
|
|
created.setPhone(request.getPhone());
|
|
|
when(infoUserService.saveOrUpdate(any(InfoUser.class))).thenReturn(true);
|
|
|
- when(infoUserService.getuser(request.getPhone())).thenReturn(created);
|
|
|
+ when(infoUserService.list(any(Wrapper.class))).thenReturn(java.util.List.of(created));
|
|
|
|
|
|
AjaxResult result = controller.createUser(request);
|
|
|
|
|
|
@@ -333,6 +334,43 @@ class InfoUserControllerTest {
|
|
|
assertEquals("phone", JWT.decode(token).getClaim("provider").asString());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void phoneLoginRejectsPhoneLinkedToMultipleAccounts() {
|
|
|
+ UserDTO request = new UserDTO();
|
|
|
+ request.setPhone("0912345678");
|
|
|
+ request.setCode("8888");
|
|
|
+ when(redisCache.getCacheObject("0912345678")).thenReturn(null);
|
|
|
+ when(infoUserService.list(any(Wrapper.class))).thenReturn(java.util.List.of(
|
|
|
+ activeUser(71L, "0"), activeUser(72L, "0")));
|
|
|
+
|
|
|
+ ServiceException exception = assertThrows(ServiceException.class,
|
|
|
+ () -> controller.lodeing(request));
|
|
|
+
|
|
|
+ assertEquals("该手机号关联多个账号,请联系平台", exception.getMessage());
|
|
|
+ verify(infoUserService, never()).saveOrUpdate(any(InfoUser.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void phoneLoginOnlyMatchesMemberAccounts() {
|
|
|
+ UserDTO request = new UserDTO();
|
|
|
+ request.setPhone("0912345678");
|
|
|
+ request.setCode("8888");
|
|
|
+ when(redisCache.getCacheObject("0912345678")).thenReturn(null);
|
|
|
+ InfoUser created = activeUser(42L, "0");
|
|
|
+ created.setPhone("0912345678");
|
|
|
+ // 查询限定 user_type=0:同号商家行不命中,未注册则新建会员(首查空 + 新建回查)
|
|
|
+ when(infoUserService.list(any(Wrapper.class)))
|
|
|
+ .thenReturn(java.util.List.of(), java.util.List.of(created));
|
|
|
+ when(infoUserService.saveOrUpdate(any(InfoUser.class))).thenReturn(true);
|
|
|
+
|
|
|
+ AjaxResult result = controller.lodeing(request);
|
|
|
+
|
|
|
+ assertEquals(HttpStatus.SUCCESS, result.get(AjaxResult.CODE_TAG));
|
|
|
+ ArgumentCaptor<InfoUser> createdCaptor = ArgumentCaptor.forClass(InfoUser.class);
|
|
|
+ verify(infoUserService).saveOrUpdate(createdCaptor.capture());
|
|
|
+ assertEquals("0", createdCaptor.getValue().getUserType());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void riderRegistrationRejectsDuplicateBusinessPhone() {
|
|
|
com.ruoyi.system.domain.vo.UserDTO request = new com.ruoyi.system.domain.vo.UserDTO();
|