mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-09-19 10:08:07 +08:00
优化注释
This commit is contained in:
@@ -10,6 +10,7 @@ import cn.dev33.satoken.action.SaTokenAction;
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.annotation.SaCheckSafe;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.dao.SaTokenDao;
|
||||
import cn.dev33.satoken.listener.SaTokenListener;
|
||||
@@ -29,6 +30,7 @@ public class XPluginImp implements Plugin {
|
||||
Aop.context().beanAroundAdd(SaCheckPermission.class, SaTokenMethodInterceptor.INSTANCE);
|
||||
Aop.context().beanAroundAdd(SaCheckRole.class, SaTokenMethodInterceptor.INSTANCE);
|
||||
Aop.context().beanAroundAdd(SaCheckLogin.class, SaTokenMethodInterceptor.INSTANCE);
|
||||
Aop.context().beanAroundAdd(SaCheckSafe.class, SaTokenMethodInterceptor.INSTANCE);
|
||||
|
||||
//集成初始化
|
||||
|
||||
|
@@ -183,5 +183,27 @@ public class SaTokenSpringBootStarterTest {
|
||||
long timeout = SaTempUtil.getTimeout(token);
|
||||
Assert.assertTrue(timeout > 195);
|
||||
}
|
||||
|
||||
// 测试:二级认证
|
||||
@Test
|
||||
public void testSafe() throws InterruptedException {
|
||||
// 登录
|
||||
StpUtil.login(10001);
|
||||
Assert.assertFalse(StpUtil.isSafe());
|
||||
|
||||
// 开启二级认证
|
||||
StpUtil.openSafe(2);
|
||||
Assert.assertTrue(StpUtil.isSafe());
|
||||
Assert.assertTrue(StpUtil.getSafeTime() > 0);
|
||||
|
||||
// 自然结束
|
||||
Thread.sleep(2500);
|
||||
Assert.assertFalse(StpUtil.isSafe());
|
||||
|
||||
// 手动结束
|
||||
StpUtil.openSafe(2);
|
||||
StpUtil.closeSafe();
|
||||
Assert.assertFalse(StpUtil.isSafe());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user