REM:
1. 增加异常单元测试
2. 增加用户缓存管理单元测试
3. 移除无用的lombok注解
This commit is contained in:
huangxin 2020-04-22 16:27:07 +08:00
parent cf5183d1e3
commit df193ea774
9 changed files with 208 additions and 46 deletions

View File

@ -15,7 +15,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -52,7 +51,6 @@ public class AuthController {
@PostMapping("/login") @PostMapping("/login")
@ResponseBody @ResponseBody
@ApiOperation("登录") @ApiOperation("登录")
@Builder
public ProtocolRespDTO userLogin(@RequestBody ProtocolReqDTO mr) public ProtocolRespDTO userLogin(@RequestBody ProtocolReqDTO mr)
throws JsonProcessingException, NoSuchAlgorithmException { throws JsonProcessingException, NoSuchAlgorithmException {
ErrorCode err = mr.verifyRequest(); ErrorCode err = mr.verifyRequest();
@ -91,7 +89,6 @@ public class AuthController {
@PostMapping("/logout") @PostMapping("/logout")
@ResponseBody @ResponseBody
@ApiOperation("注销") @ApiOperation("注销")
@Builder
public ProtocolRespDTO userLogout(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO userLogout(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {

View File

@ -23,7 +23,6 @@ import io.swagger.annotations.ApiOperation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -63,7 +62,6 @@ public class DisposeNodeInfoController {
@PostMapping("/linkstatus") @PostMapping("/linkstatus")
@ResponseBody @ResponseBody
@ApiOperation("链接状态") @ApiOperation("链接状态")
@Builder
public ProtocolRespDTO getLinkStatus(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getLinkStatus(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -123,7 +121,6 @@ public class DisposeNodeInfoController {
@PostMapping("/version") @PostMapping("/version")
@ResponseBody @ResponseBody
@ApiOperation("处置设备版本") @ApiOperation("处置设备版本")
@Builder
public ProtocolRespDTO getVersion(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getVersion(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -186,7 +183,6 @@ public class DisposeNodeInfoController {
@PostMapping("/deviceinfo") @PostMapping("/deviceinfo")
@ResponseBody @ResponseBody
@ApiOperation("处置设备信息") @ApiOperation("处置设备信息")
@Builder
public ProtocolRespDTO getDeviceInfo(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getDeviceInfo(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -261,7 +257,6 @@ public class DisposeNodeInfoController {
@PostMapping("/capacity") @PostMapping("/capacity")
@ResponseBody @ResponseBody
@ApiOperation("处置设备处置能力") @ApiOperation("处置设备处置能力")
@Builder
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getCapacity(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getCapacity(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
@ -324,7 +319,6 @@ public class DisposeNodeInfoController {
@PostMapping("/protected_ip") @PostMapping("/protected_ip")
@ResponseBody @ResponseBody
@ApiOperation("处置设备防护IP") @ApiOperation("处置设备防护IP")
@Builder
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getProtectedIp(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getProtectedIp(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
@ -387,7 +381,6 @@ public class DisposeNodeInfoController {
@PostMapping("/node_list") @PostMapping("/node_list")
@ResponseBody @ResponseBody
@ApiOperation("处置设备列表") @ApiOperation("处置设备列表")
@Builder
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getDisposeNodeList(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getDisposeNodeList(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
@ -456,7 +449,6 @@ public class DisposeNodeInfoController {
@PostMapping("/node_details") @PostMapping("/node_details")
@ResponseBody @ResponseBody
@ApiOperation("处置节点详细信息") @ApiOperation("处置节点详细信息")
@Builder
//@JsonView(DisposeCapacity.CapacityView.class) //@JsonView(DisposeCapacity.CapacityView.class)
public ProtocolRespDTO getDisposeNodeDetails(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getDisposeNodeDetails(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)

View File

@ -18,7 +18,6 @@ import io.swagger.annotations.ApiOperation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -56,7 +55,6 @@ public class DisposeNodeManagerController {
@PutMapping("/device") @PutMapping("/device")
@ResponseBody @ResponseBody
@ApiOperation("添加处置能力节点") @ApiOperation("添加处置能力节点")
@Builder
public ProtocolRespDTO addDisposeNode(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO addDisposeNode(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -117,7 +115,6 @@ public class DisposeNodeManagerController {
@DeleteMapping("/device") @DeleteMapping("/device")
@ResponseBody @ResponseBody
@ApiOperation("删除处置能力节点") @ApiOperation("删除处置能力节点")
@Builder
public ProtocolRespDTO removeDisposeNode(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO removeDisposeNode(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {

View File

@ -12,7 +12,6 @@ import com.dispose.pojo.vo.task.TaskInfoData;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -43,7 +42,6 @@ public class DisposeTaskController {
@PostMapping("/start") @PostMapping("/start")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO taskStart(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO taskStart(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -74,7 +72,6 @@ public class DisposeTaskController {
@PostMapping("/stop") @PostMapping("/stop")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO taskStop(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO taskStop(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -117,7 +114,6 @@ public class DisposeTaskController {
@PostMapping("/stop_ip") @PostMapping("/stop_ip")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO taskStopByIp(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO taskStopByIp(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -156,7 +152,6 @@ public class DisposeTaskController {
@PostMapping("/stop_node") @PostMapping("/stop_node")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO taskStopAllOfDisposeNode(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO taskStopAllOfDisposeNode(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -174,7 +169,6 @@ public class DisposeTaskController {
@PostMapping("/stop_all") @PostMapping("/stop_all")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO taskStopAll(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO taskStopAll(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {
@ -191,7 +185,6 @@ public class DisposeTaskController {
@PostMapping("/get_node") @PostMapping("/get_node")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO getNodeTask(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getNodeTask(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) throws JsonProcessingException { @RequestHeader HttpHeaders headers) throws JsonProcessingException {
return getAllTask(mr, headers); return getAllTask(mr, headers);
@ -208,7 +201,6 @@ public class DisposeTaskController {
@PostMapping("/get") @PostMapping("/get")
@ResponseBody @ResponseBody
@ApiOperation("启动处置任务") @ApiOperation("启动处置任务")
@Builder
public ProtocolRespDTO getAllTask(@RequestBody ProtocolReqDTO mr, public ProtocolRespDTO getAllTask(@RequestBody ProtocolReqDTO mr,
@RequestHeader HttpHeaders headers) @RequestHeader HttpHeaders headers)
throws JsonProcessingException { throws JsonProcessingException {

View File

@ -1,11 +1,16 @@
package com.dispose.Global; package com.dispose.Global;
import com.dispose.common.GlobalVar; import com.dispose.common.GlobalVar;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@Slf4j @Slf4j
@Getter
public class InitTestEnvironment { public class InitTestEnvironment {
private final String USER_NAME = "admin";
private final String PASSWORD = "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58";
@BeforeClass @BeforeClass
public static void initVirtualDevice(){ public static void initVirtualDevice(){
GlobalVar.USED_VIRTUAL_DISPOSE_MODE = true; GlobalVar.USED_VIRTUAL_DISPOSE_MODE = true;

View File

@ -5,6 +5,7 @@ import com.dispose.controller.AuthControllerTest;
import com.dispose.controller.DeviceNodeInfoControllerTest; import com.dispose.controller.DeviceNodeInfoControllerTest;
import com.dispose.controller.DeviceNodeManagerControllerTest; import com.dispose.controller.DeviceNodeManagerControllerTest;
import com.dispose.dptech.DPTechInterfaceTestCase; import com.dispose.dptech.DPTechInterfaceTestCase;
import com.dispose.manager.UserAccountManagerTest;
import com.dispose.mapper.DisposeDeviceMapperTest; import com.dispose.mapper.DisposeDeviceMapperTest;
import com.dispose.mapper.UserAccountMapperTest; import com.dispose.mapper.UserAccountMapperTest;
import com.dispose.service.UserAccountServiceTest; import com.dispose.service.UserAccountServiceTest;
@ -16,8 +17,9 @@ import org.junit.runners.Suite;
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ @Suite.SuiteClasses({
// DPTechInterfaceTestCase.class, DPTechInterfaceTestCase.class,
UserAccountMapperTest.class, UserAccountMapperTest.class,
UserAccountManagerTest.class,
DisposeDeviceMapperTest.class, DisposeDeviceMapperTest.class,
AuthControllerTest.class, AuthControllerTest.class,
DeviceNodeManagerControllerTest.class, DeviceNodeManagerControllerTest.class,

View File

@ -2,10 +2,13 @@ package com.dispose.controller;
import com.dispose.Global.InitTestEnvironment; import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ConstValue; import com.dispose.common.ConstValue;
import com.dispose.common.ErrorCode;
import com.dispose.pojo.dto.ProtocolReqDTO; import com.dispose.pojo.dto.ProtocolReqDTO;
import com.dispose.pojo.dto.ProtocolRespDTO; import com.dispose.pojo.dto.ProtocolRespDTO;
import com.dispose.pojo.po.MReturnType;
import com.dispose.pojo.vo.auth.LoginReq; import com.dispose.pojo.vo.auth.LoginReq;
import com.dispose.pojo.vo.auth.LoginRsp; import com.dispose.pojo.vo.auth.LoginRsp;
import com.dispose.service.UserAccountService;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -42,35 +45,20 @@ public class AuthControllerTest extends InitTestEnvironment {
@Resource @Resource
private ObjectMapper objectMapper; private ObjectMapper objectMapper;
@Resource
private UserAccountService userAccountService;
private static String logToken = ""; private static String logToken = "";
@Before @Before
public void userLogin() throws Exception { public void userLogin() throws Exception {
LoginReq logReq = LoginReq.builder() MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
.userName("admin")
.password("c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58")
.build();
ProtocolReqDTO reqInfo = new ProtocolReqDTO(); Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
reqInfo.setVer(ConstValue.Protocol.VERSION); logToken = ret.getSecondParam();
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
reqInfo.setTimeStamp(System.currentTimeMillis());
reqInfo.setMsgContent(objectMapper.writeValueAsString(logReq));
String ret = mockMvc.perform(MockMvcRequestBuilders Assert.assertNotNull(logToken);
.post("/auth/login") Assert.assertNotEquals(logToken.length(), 0);
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(200))
.andReturn()
.getResponse()
.getContentAsString();
ProtocolRespDTO rspInfo = objectMapper.readValue(ret, ProtocolRespDTO.class);
LoginRsp logRsp = objectMapper.readValue(rspInfo.getMsgContent(), LoginRsp.class);
logToken = logRsp.getToken();
} }
/** /**

View File

@ -0,0 +1,90 @@
package com.dispose.exception;
import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ConstValue;
import com.dispose.mapper.DisposeDeviceMapper;
import com.dispose.pojo.dto.ProtocolReqDTO;
import com.dispose.pojo.dto.ProtocolRespDTO;
import com.dispose.pojo.vo.auth.LoginReq;
import com.dispose.pojo.vo.auth.LoginRsp;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@AutoConfigureMockMvc
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@Slf4j
public class ExceptionTest{
@Resource
private MockMvc mockMvc;
@Resource
private ObjectMapper objectMapper;
@Rule
public ExpectedException expectedEx = ExpectedException.none();
@Test(expected = Throwable.class)
public void t1_inputException() throws Exception {
expectedEx.expect(Throwable.class);
expectedEx.expectMessage("Expected exception: java.lang.Throwable");
LoginReq logReq = null;
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
reqInfo.setVer(ConstValue.Protocol.VERSION);
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
reqInfo.setTimeStamp(System.currentTimeMillis());
reqInfo.setMsgContent(objectMapper.writeValueAsString(logReq));
String ret = mockMvc.perform(MockMvcRequestBuilders
.post("/auth/login")
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(reqInfo)))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(521))
.andReturn()
.getResponse()
.getContentAsString();
}
@Test(expected = Exception.class)
public void t2_globalException() throws Exception {
expectedEx.expect(Exception.class);
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
reqInfo.setVer(ConstValue.Protocol.VERSION);
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
reqInfo.setTimeStamp(System.currentTimeMillis());
reqInfo.setMsgContent("{}");
mockMvc.perform(MockMvcRequestBuilders
.post("/information/protected_ip")
.contentType(MediaType.APPLICATION_JSON)
.content("{}"))
.andDo(print()).andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(521))
.andReturn()
.getResponse()
.getContentAsString();
}
}

View File

@ -0,0 +1,99 @@
package com.dispose.manager;
import com.dispose.Global.InitTestEnvironment;
import com.dispose.common.ErrorCode;
import com.dispose.pojo.po.MReturnType;
import com.dispose.service.UserAccountService;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.security.NoSuchAlgorithmException;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@Slf4j
@SpringBootTest
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class UserAccountManagerTest extends InitTestEnvironment {
@Resource
private UserAccountCacheManager userAccountCacheManager;
@Resource
private UserAccountService userAccountService;
private static String userToken;
@Before
public void userLogin() throws NoSuchAlgorithmException {
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
userToken = ret.getSecondParam();
Assert.assertNotNull(userToken);
Assert.assertNotEquals(userToken.length(), 0);
}
@Test
public void t1_permissionTest() {
Assert.assertEquals(userAccountCacheManager.verifyPermission(userToken), ErrorCode.ERR_OK);
}
@Test
public void t2_getUsernameByTokenTest() {
Assert.assertEquals(userAccountCacheManager.getUsernameByToken(userToken), getUSER_NAME());
}
@Test
public void t3_verifyTokenTest() {
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken), ErrorCode.ERR_OK);
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken + "123"), ErrorCode.ERR_LOGOUT);
}
@Test
public void t4_verifyUserLoginTest() {
Assert.assertEquals(userAccountCacheManager.verifyUserLogin(getUSER_NAME(), userToken), ErrorCode.ERR_OK);
}
@Test
public void t5_getCacheUser() throws JsonProcessingException {
String userInfo = userAccountCacheManager.getCacheUser();
Assert.assertNotNull(userInfo);
Assert.assertNotEquals(userInfo.length(), 0);
}
@Test
public void t6_getUsrPwdErrTimesTest() {
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), 0);
}
@Test
public void t6_setUsrPwdErrTimesTest() {
for(int i = 0; i < 6; i++) {
userAccountCacheManager.setUserPwdErrTimes(getUSER_NAME(), i);
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), i);
}
userAccountCacheManager.setUserPwdErrTimes(getUSER_NAME(), 0);
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), 0);
}
@Test
public void t7_getUserTokenTest() throws NoSuchAlgorithmException {
Assert.assertEquals(userAccountCacheManager.getUserToken(getUSER_NAME()), userToken);
}
@Test
public void t99_cleanUserTokenTest() {
userAccountCacheManager.cleanUserToken(getUSER_NAME());
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken), ErrorCode.ERR_LOGOUT);
}
}