forked from fanruan/finekit
Browse Source
* commit '74400ef6b90294f76e827032cfb84b13f8da5ad7': test 改到loginkit里面了 KERNEL-1444 加几个接口remotes/1611766341912730171/master
superman
5 years ago
2 changed files with 99 additions and 0 deletions
@ -0,0 +1,69 @@
|
||||
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.Response; |
||||
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"); |
||||
Object responseData = new Object(); |
||||
String errorCode = ""; |
||||
String errorMsg = ""; |
||||
try { |
||||
Response response = (Response) LoginKit.refreshToken(jwtString, 1000 * 60, null, responseData, errorCode, errorMsg); |
||||
} catch (Exception e) { |
||||
Assert.assertTrue(e instanceof LoginInfoNotAvailableException); |
||||
} |
||||
LoginClientBean loginClientBean = new LoginClientBean(); |
||||
DecisionStatusService.loginStatusService().put(jwtString, loginClientBean); |
||||
try { |
||||
Response response = (Response) LoginKit.refreshToken(jwtString, 1000 * 60, null, responseData, errorCode, errorMsg); |
||||
} 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"); |
||||
} |
||||
} |
Loading…
Reference in new issue