|
|
|
package com.fanruan.api.decision.login;
|
|
|
|
|
|
|
|
import com.fanruan.api.security.JwtKit;
|
|
|
|
import com.fr.config.dao.DaoContext;
|
|
|
|
import com.fr.config.dao.impl.LocalClassHelperDao;
|
|
|
|
import com.fr.config.dao.impl.LocalEntityDao;
|
|
|
|
import com.fr.config.dao.impl.LocalXmlEntityDao;
|
|
|
|
import com.fr.decision.config.AppearanceConfig;
|
|
|
|
import com.fr.decision.webservice.bean.authentication.LoginClientBean;
|
|
|
|
import com.fr.decision.webservice.exception.login.LoginInfoNotAvailableException;
|
|
|
|
import com.fr.decision.webservice.utils.DecisionStatusService;
|
|
|
|
import com.fr.runtime.FineRuntime;
|
|
|
|
import com.fr.store.StateHubManager;
|
|
|
|
import com.fr.store.impl.MemoryLock;
|
|
|
|
import com.fr.store.impl.MemoryStore;
|
|
|
|
import com.fr.transaction.Configurations;
|
|
|
|
import com.fr.transaction.LocalConfigurationHelper;
|
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author lidongy
|
|
|
|
* @version 10.0
|
|
|
|
* Created by lidongy on 2019/10/25
|
|
|
|
*/
|
|
|
|
public class LoginKitTest {
|
|
|
|
|
|
|
|
@Before
|
|
|
|
public void start() {
|
|
|
|
FineRuntime.start();
|
|
|
|
DaoContext.setEntityDao(new LocalEntityDao());
|
|
|
|
DaoContext.setClassHelperDao(new LocalClassHelperDao());
|
|
|
|
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
|
|
|
|
Configurations.setHelper(new LocalConfigurationHelper());
|
|
|
|
StateHubManager.setStorage(new MemoryStore());
|
|
|
|
StateHubManager.setLock(new MemoryLock());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRefreshToken() throws Exception{
|
|
|
|
String jwtString = JwtKit.createDefaultJWT("123");
|
|
|
|
try {
|
|
|
|
LoginKit.refreshToken(jwtString, 1000 * 60, null);
|
|
|
|
} catch (Exception e) {
|
|
|
|
Assert.assertTrue(e instanceof LoginInfoNotAvailableException);
|
|
|
|
}
|
|
|
|
LoginClientBean loginClientBean = new LoginClientBean();
|
|
|
|
DecisionStatusService.loginStatusService().put(jwtString, loginClientBean);
|
|
|
|
try {
|
|
|
|
LoginKit.refreshToken(jwtString, 1000 * 60, null);
|
|
|
|
} catch (Exception e) {
|
|
|
|
Assert.assertFalse(e instanceof LoginInfoNotAvailableException);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void TestGetLoginPageId() {
|
|
|
|
AppearanceConfig.getInstance().setLoginPageId("111");
|
|
|
|
Assert.assertEquals(LoginKit.getLoginPageId(), "111");
|
|
|
|
|
|
|
|
AppearanceConfig.getInstance().setLoginPageId("aaa");
|
|
|
|
Assert.assertEquals(LoginKit.getLoginPageId(), "aaa");
|
|
|
|
}
|
|
|
|
}
|