fix: 修复单元测试中不通过的代码

This commit is contained in:
click33 2025-03-19 04:10:31 +08:00
parent 5b5c031bdd
commit eaef278426
3 changed files with 16 additions and 28 deletions

View File

@ -23,10 +23,11 @@ import cn.dev33.satoken.exception.SaTokenException;
import cn.dev33.satoken.jwt.error.SaJwtErrorCode;
import cn.dev33.satoken.jwt.exception.SaJwtException;
import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
import cn.dev33.satoken.stp.parameter.SaLogoutParameter;
import cn.dev33.satoken.util.SaFoxUtil;
import cn.dev33.satoken.util.SaTokenConsts;
@ -136,34 +137,20 @@ public class StpLogicJwtForMixin extends StpLogic {
}
/**
* [禁用] 会话注销根据账号id 设备类型
* [work] 注销下线
*
* @param tokenValue 指定 token
* @param logoutParameter 注销参数
*/
@Override
public void logout(Object loginId, String deviceType) {
public void _logoutByTokenValue(String tokenValue, SaLogoutParameter logoutParameter) {
throw new ApiDisabledException();
}
/**
* [禁用] 会话注销根据指定 Token
* [禁用] 会话注销
*/
@Override
public void logoutByTokenValue(String tokenValue) {
throw new ApiDisabledException();
}
/**
* [禁用] 踢人下线根据账号id 设备类型
*/
@Override
public void kickout(Object loginId, String deviceType) {
throw new ApiDisabledException();
}
/**
* [禁用] 踢人下线根据指定 Token
*/
@Override
public void kickoutByTokenValue(String tokenValue) {
public void _logout(Object loginId, SaLogoutParameter logoutParameter) {
throw new ApiDisabledException();
}

View File

@ -26,9 +26,9 @@ import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.spring.SpringMVCUtil;
import cn.dev33.satoken.spring.pathmatch.SaPathMatcherHolder;
import cn.dev33.satoken.stp.SaLoginConfig;
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
import cn.dev33.satoken.util.SaTokenConsts;
import cn.dev33.satoken.util.SoMap;
import org.junit.jupiter.api.AfterAll;
@ -253,9 +253,10 @@ public class BasicsTest {
// 测试根据token强制注销
@Test
public void testLogoutByToken() {
StpUtil.logout(10001);
// 先登录上
StpUtil.login(10001);
StpUtil.login(10001);
Assertions.assertTrue(StpUtil.isLogin());
String token = StpUtil.getTokenValue();

View File

@ -57,7 +57,7 @@ public class ManyLoginTest {
// 测试并发登录共享token同端
@Test
public void login() {
SaManager.setConfig(new SaTokenConfig());
SaManager.setConfig(new SaTokenConfig().setIsShare(true));
StpUtil.login(10001);
String token1 = StpUtil.getTokenValue();