优化注释

This commit is contained in:
click33
2021-06-18 23:53:16 +08:00
parent c6d3cda4a4
commit a73adf6727
53 changed files with 801 additions and 568 deletions

View File

@@ -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);
//集成初始化

View File

@@ -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());
}
}