✅ test: 添加对企业账号状态的登录测试用例
This commit is contained in:
@@ -156,12 +156,16 @@ public class BackDoorLoginService
|
||||
{
|
||||
throw new ServiceException("企业账号不存在");
|
||||
}
|
||||
if (!UserStatus.OK.getCode().equals(appUser.getDelFlag()))
|
||||
// HighGo 中 app_user.status 是 CHAR(2),JDBC 会保留定长字段的尾部空格。
|
||||
// SQL 比较会将 "0 " 视为 "0",Java 字符串比较则不会;统一 trim,确保
|
||||
// 列表筛选与登录时的状态判断使用完全相同的语义。
|
||||
String delFlag = StringUtils.trimToEmpty(appUser.getDelFlag());
|
||||
String status = StringUtils.trimToEmpty(appUser.getStatus());
|
||||
if (!UserStatus.OK.getCode().equals(delFlag))
|
||||
{
|
||||
throw new ServiceException("企业账号已删除,不能登录");
|
||||
}
|
||||
if (StringUtils.isNotBlank(appUser.getStatus())
|
||||
&& !UserStatus.OK.getCode().equals(appUser.getStatus()))
|
||||
if (StringUtils.isNotEmpty(status) && !UserStatus.OK.getCode().equals(status))
|
||||
{
|
||||
throw new ServiceException("企业账号已停用,不能登录");
|
||||
}
|
||||
|
||||
@@ -200,6 +200,20 @@ class BackDoorLoginServiceTest
|
||||
verify(tokenService, never()).createTokenHourTwo(org.mockito.ArgumentMatchers.any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void loginCompanyAcceptsPaddedHighGoActiveStatus()
|
||||
{
|
||||
AppUser company = activeCompany(66L);
|
||||
company.setStatus("0 ");
|
||||
when(sysUserService.selectAppUserById(66L)).thenReturn(company);
|
||||
when(sysLoginService.loginUserIdApp(company)).thenReturn("company-site-token");
|
||||
|
||||
CompanyLoginSession session = service.loginCompany(66L);
|
||||
|
||||
assertEquals("company-site-token", session.getToken());
|
||||
verify(sysLoginService).loginUserIdApp(company);
|
||||
}
|
||||
|
||||
@Test
|
||||
void loginCompanyRejectsNonCompanyAccount()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user