OCT
REM: 1. 解决部分SOAP框架CheckStyle警告 2. 增加获取系统版本信息接口 3. 增加获取系统版本单元测试接口 4. 单元测试使用Token验证 4. 单元测试使用用户权限验证功能
This commit is contained in:
parent
31c5d0507b
commit
afee2acf8b
|
@ -2,10 +2,11 @@ server.port=9276
|
||||||
# 根据自身环境修改
|
# 根据自身环境修改
|
||||||
server.tomcat.basedir=./basedir
|
server.tomcat.basedir=./basedir
|
||||||
# 多个项目放在nginx下同个端口,通过该配置区分
|
# 多个项目放在nginx下同个端口,通过该配置区分
|
||||||
server.servlet.context-path=/phoenix
|
server.servlet.context-path=/dispose
|
||||||
|
|
||||||
# 配置数据源
|
# 配置数据源
|
||||||
spring.datasource.url=jdbc:mysql://172.28.72.118:33061/phoenix_local?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
spring.datasource.url=jdbc:mysql://172.28.72.118:33061/dispose_test?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\
|
||||||
|
=convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
spring.datasource.username=phoenix
|
spring.datasource.username=phoenix
|
||||||
spring.datasource.password=Hy@rfph32
|
spring.datasource.password=Hy@rfph32
|
||||||
|
@ -33,18 +34,22 @@ logging.config=file:config/logback.xml
|
||||||
#config tomcat
|
#config tomcat
|
||||||
server.tomcat.max-threads=128
|
server.tomcat.max-threads=128
|
||||||
|
|
||||||
|
#Json sort
|
||||||
|
spring.jackson.mapper.sort-properties-alphabetically=true
|
||||||
|
|
||||||
#====custom config,begin with phoenix====
|
#====custom config,begin with phoenix====
|
||||||
#test
|
#test
|
||||||
phoenix.system-name=phoenix framework
|
phoenix.system-name=phoenix framework
|
||||||
#config the swagger api switch true:可访问;false:不可访问
|
#config the swagger api switch true:可访问;false:不可访问
|
||||||
phoenix.swagger-switch=true
|
phoenix.swagger-switch=true
|
||||||
#config which client to use in redis,jedis or redisson
|
#config which client to use in redis,
|
||||||
phoenix.redis.type=redisson
|
#jedis or redisson-sentinel,redisson-single
|
||||||
|
phoenix.redis.type=redisson-single
|
||||||
#config redis info
|
#config redis info
|
||||||
#jedis config example>redis://:dfu56li_jdo8pd@172.28.72.111:7379/0,多个用逗号分隔
|
#jedis config example>redis://:dfu56li_jdo8pd@172.28.72.111:7379/0,多个用逗号分隔
|
||||||
#redisson sentinel config example>redis://172.28.72.104:28379,redis://172.28.72.124:28380,redis://172.28.72.124:28381
|
#redisson sentinel config example>redis://172.28.72.104:28379,redis://172.28.72.124:28380,redis://172.28.72.124:28381
|
||||||
phoenix.redis-server=redis://172.28.72.104:28379,redis://172.28.72.124:28380,redis://172.28.72.124:28381
|
#redisson single config example>redis://172.28.72.104:8380
|
||||||
#redis://172.28.72.113:7379/2
|
phoenix.redis-server=redis://172.28.72.104:8380
|
||||||
phoenix.redis-redisson-sentinel-master-name=mymaster
|
phoenix.redis-redisson-sentinel-master-name=mymaster
|
||||||
phoenix.redis-redisson-pwd=cmcc2019
|
phoenix.redis-redisson-pwd=cmcc2019
|
||||||
#config request dec switch,true=dec,false=plain do nothing
|
#config request dec switch,true=dec,false=plain do nothing
|
||||||
|
@ -56,3 +61,8 @@ phoenix.aes-key=Wt4EJu6Rrq5udd/42bNpCQ==
|
||||||
|
|
||||||
|
|
||||||
#====custom config,begin with phoenix====
|
#====custom config,begin with phoenix====
|
||||||
|
|
||||||
|
#调试配置
|
||||||
|
dispose.check-protocol-timeout=false
|
||||||
|
dispose.check-request-token=true
|
||||||
|
dispose.check-admin-permission=true
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.dispose.help;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@Builder
|
||||||
|
public class GetVersion {
|
||||||
|
private String commitId;
|
||||||
|
private String commitDescribe;
|
||||||
|
private String commitTime;
|
||||||
|
private String tagName;
|
||||||
|
private String tags;
|
||||||
|
}
|
|
@ -55,11 +55,4 @@ public interface DisposeDeviceMapper extends Mapper<DisposeDevice>,
|
||||||
* @param ipAddr the ip addr
|
* @param ipAddr the ip addr
|
||||||
*/
|
*/
|
||||||
void delDisposeDeviceByIp(String ipAddr);
|
void delDisposeDeviceByIp(String ipAddr);
|
||||||
|
|
||||||
/**
|
|
||||||
* Del dispose device by ip.
|
|
||||||
*
|
|
||||||
* @param id the id
|
|
||||||
*/
|
|
||||||
void delDisposeDeviceByIp(Long id);
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,18 +1,57 @@
|
||||||
package com.dispose.Global;
|
package com.dispose.Global;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.GlobalVar;
|
import com.dispose.common.GlobalVar;
|
||||||
|
import com.dispose.pojo.po.MReturnType;
|
||||||
|
import com.dispose.service.UserAccountService;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Init test environment.
|
* The type Init test environment.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Getter
|
@Getter
|
||||||
|
@ActiveProfiles("test")
|
||||||
public class InitTestEnvironment {
|
public class InitTestEnvironment {
|
||||||
private final String USER_NAME = "admin";
|
private final String USER_NAME = "admin";
|
||||||
private final String PASSWORD = "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58";
|
private final String PASSWORD = "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58";
|
||||||
|
private static String logToken = "45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User login.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Before
|
||||||
|
public void userLogin() throws Exception {
|
||||||
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||||
|
|
||||||
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||||
|
logToken = ret.getSecondParam();
|
||||||
|
|
||||||
|
Assert.assertNotNull(logToken);
|
||||||
|
Assert.assertNotEquals(logToken.length(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets log token.
|
||||||
|
*
|
||||||
|
* @return the log token
|
||||||
|
*/
|
||||||
|
public String getLogToken() {
|
||||||
|
return logToken;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init virtual device.
|
* Init virtual device.
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.dispose.TestSuit;
|
package com.dispose.TestSuit;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dispose.config.MyConfigTest;
|
||||||
import com.dispose.controller.AuthControllerTest;
|
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.controller.TaskControllerTest;
|
import com.dispose.controller.TaskControllerTest;
|
||||||
import com.dispose.dptech.DPTechInterfaceTestCase;
|
import com.dispose.dptech.DPTechInterfaceTestCase;
|
||||||
|
import com.dispose.help.GetVersionTest;
|
||||||
import com.dispose.manager.UserAccountManagerTest;
|
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;
|
||||||
|
@ -18,6 +20,8 @@ import org.junit.runners.Suite;
|
||||||
*/
|
*/
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({
|
@Suite.SuiteClasses({
|
||||||
|
MyConfigTest.class,
|
||||||
|
GetVersionTest.class,
|
||||||
DPTechInterfaceTestCase.class,
|
DPTechInterfaceTestCase.class,
|
||||||
UserAccountMapperTest.class,
|
UserAccountMapperTest.class,
|
||||||
UserAccountManagerTest.class,
|
UserAccountManagerTest.class,
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.dispose.config;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
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 MyConfigTest {
|
||||||
|
@Resource
|
||||||
|
private MyConfig myConfig;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t1_myConfigTest() {
|
||||||
|
Assert.assertNotNull(myConfig);
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,24 +36,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AuthControllerTest extends InitTestEnvironment {
|
public class AuthControllerTest extends InitTestEnvironment {
|
||||||
private static String logToken = "";
|
|
||||||
@Resource
|
@Resource
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
@Resource
|
@Resource
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
@Resource
|
|
||||||
private UserAccountService userAccountService;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void userLogin() throws Exception {
|
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
|
||||||
|
|
||||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
|
||||||
logToken = ret.getSecondParam();
|
|
||||||
|
|
||||||
Assert.assertNotNull(logToken);
|
|
||||||
Assert.assertNotEquals(logToken.length(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login 1.
|
* Login 1.
|
||||||
|
@ -63,8 +49,8 @@ public class AuthControllerTest extends InitTestEnvironment {
|
||||||
@Test
|
@Test
|
||||||
public void login1() throws Exception {
|
public void login1() throws Exception {
|
||||||
LoginReq logReq = LoginReq.builder()
|
LoginReq logReq = LoginReq.builder()
|
||||||
.userName("admin")
|
.userName(getUSER_NAME())
|
||||||
.password("c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58")
|
.password(getPASSWORD())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
@ -86,7 +72,7 @@ public class AuthControllerTest extends InitTestEnvironment {
|
||||||
ProtocolRespDTO rspInfo = objectMapper.readValue(ret, ProtocolRespDTO.class);
|
ProtocolRespDTO rspInfo = objectMapper.readValue(ret, ProtocolRespDTO.class);
|
||||||
LoginRsp logRsp = objectMapper.readValue(rspInfo.getMsgContent(), LoginRsp.class);
|
LoginRsp logRsp = objectMapper.readValue(rspInfo.getMsgContent(), LoginRsp.class);
|
||||||
|
|
||||||
Assert.assertEquals(logToken, logRsp.getToken());
|
Assert.assertEquals(getLogToken(), logRsp.getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +95,7 @@ public class AuthControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/auth/logout")
|
.post("/auth/logout")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer " + logToken)
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
|
|
@ -2,13 +2,18 @@ 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.mapper.DisposeDeviceMapper;
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||||
import com.dispose.pojo.entity.DisposeDevice;
|
import com.dispose.pojo.entity.DisposeDevice;
|
||||||
|
import com.dispose.pojo.po.MReturnType;
|
||||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
|
import com.dispose.service.UserAccountService;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -42,6 +47,9 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
@Resource
|
@Resource
|
||||||
private DisposeDeviceMapper disposeDeviceMapper;
|
private DisposeDeviceMapper disposeDeviceMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
|
|
||||||
private Long getExistsDeviceId() {
|
private Long getExistsDeviceId() {
|
||||||
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
|
List<DisposeDevice> dp = disposeDeviceMapper.selectAll();
|
||||||
|
@ -73,7 +81,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/version")
|
.post("/information/version")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -90,7 +98,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/version")
|
.post("/information/version")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -119,7 +127,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/version")
|
.post("/information/version")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -148,7 +156,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/deviceinfo")
|
.post("/information/deviceinfo")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -177,7 +185,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/deviceinfo")
|
.post("/information/deviceinfo")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -206,7 +214,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/capacity")
|
.post("/information/capacity")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -235,7 +243,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/capacity")
|
.post("/information/capacity")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -250,7 +258,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getDeviceProtectedIp() throws Exception {
|
public void t4_getDeviceProtectedIp() throws Exception {
|
||||||
IDArrayReq reqData = IDArrayReq.builder()
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||||
.build();
|
.build();
|
||||||
|
@ -264,7 +272,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/protected_ip")
|
.post("/information/protected_ip")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -279,7 +287,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getDeviceProtectedIpAll() throws Exception {
|
public void t4_getDeviceProtectedIpAll() throws Exception {
|
||||||
IDArrayReq reqData = IDArrayReq.builder()
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
.id(new String[]{})
|
.id(new String[]{})
|
||||||
.build();
|
.build();
|
||||||
|
@ -293,7 +301,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/protected_ip")
|
.post("/information/protected_ip")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -308,7 +316,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getDisposeNodeList() throws Exception {
|
public void t5_getDisposeNodeList() throws Exception {
|
||||||
IDArrayReq reqData = IDArrayReq.builder()
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||||
.build();
|
.build();
|
||||||
|
@ -322,7 +330,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/node_list")
|
.post("/information/node_list")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -337,7 +345,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getDisposeNodeListAll() throws Exception {
|
public void t5_getDisposeNodeListAll() throws Exception {
|
||||||
IDArrayReq reqData = IDArrayReq.builder()
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
.id(new String[]{})
|
.id(new String[]{})
|
||||||
.build();
|
.build();
|
||||||
|
@ -351,7 +359,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/node_list")
|
.post("/information/node_list")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -366,7 +374,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getDisposeNodeDetails() throws Exception {
|
public void t6_getDisposeNodeDetails() throws Exception {
|
||||||
IDArrayReq reqData = IDArrayReq.builder()
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||||
.build();
|
.build();
|
||||||
|
@ -380,7 +388,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/node_details")
|
.post("/information/node_details")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -395,7 +403,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getDisposeNodeDetailsAll() throws Exception {
|
public void t6_getDisposeNodeDetailsAll() throws Exception {
|
||||||
IDArrayReq reqData = IDArrayReq.builder()
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
.id(new String[]{})
|
.id(new String[]{})
|
||||||
.build();
|
.build();
|
||||||
|
@ -409,7 +417,55 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/node_details")
|
.post("/information/node_details")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t7_getLinkStatus() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{String.valueOf(getExistsDeviceId()), "123"})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/linkstatus")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t7_getLinkStatusAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/linkstatus")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
|
|
@ -61,18 +61,6 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
||||||
.readme("实验室测试设备")
|
.readme("实验室测试设备")
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
addReq.getItems().add(NewNodeInfo.builder()
|
|
||||||
.id("1")
|
|
||||||
.ipAddr("107.212.70.4")
|
|
||||||
.type(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode())
|
|
||||||
.areaCode(0)
|
|
||||||
.name("无效设备")
|
|
||||||
.manufacturer("浩瀚")
|
|
||||||
.model("清洗")
|
|
||||||
.version("3.1.1")
|
|
||||||
.readme("实验室测试设备")
|
|
||||||
.build());
|
|
||||||
|
|
||||||
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
@ -82,7 +70,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.put("/manager/device")
|
.put("/manager/device")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -113,7 +101,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.delete("/manager/device")
|
.delete("/manager/device")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -122,4 +110,30 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment {
|
||||||
.getContentAsString();
|
.getContentAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t3_delDeviceErr1() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{"0", "1", "2"})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.delete("/manager/device")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(525))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,19 @@ 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.po.MReturnType;
|
||||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
import com.dispose.pojo.vo.task.StartTaskReq;
|
import com.dispose.pojo.vo.task.StartTaskReq;
|
||||||
import com.dispose.pojo.vo.task.StopTaskData;
|
import com.dispose.pojo.vo.task.StopTaskData;
|
||||||
import com.dispose.pojo.vo.task.StopTaskReq;
|
import com.dispose.pojo.vo.task.StopTaskReq;
|
||||||
|
import com.dispose.service.UserAccountService;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
@ -37,6 +42,9 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
@Resource
|
@Resource
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* T 1 start task.
|
* T 1 start task.
|
||||||
*
|
*
|
||||||
|
@ -59,7 +67,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/start")
|
.post("/task/start")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -88,7 +96,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/stop")
|
.post("/task/stop")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -124,7 +132,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/stop_ip")
|
.post("/task/stop_ip")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -159,7 +167,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/stop_node")
|
.post("/task/stop_node")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -193,7 +201,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/stop_all")
|
.post("/task/stop_all")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -222,7 +230,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/get_node")
|
.post("/task/get_node")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
@ -251,7 +259,7 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/get")
|
.post("/task/get")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
.header("Authorization", "Bearer " + getLogToken())
|
||||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
.andDo(print()).andExpect(status().isOk())
|
.andDo(print()).andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.code").value(200))
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
|
|
@ -27,6 +27,10 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void userLogin() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* T 1 get all detection object from umc.
|
* T 1 get all detection object from umc.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.dispose.help;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
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.context.annotation.PropertySource;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@Slf4j
|
||||||
|
@SpringBootTest
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
@PropertySource("classpath:git.properties")
|
||||||
|
public class GetVersionTest {
|
||||||
|
@Resource
|
||||||
|
private GitInformation gitInformation;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t1_getVersionTest() throws JsonProcessingException {
|
||||||
|
GetVersion ver = GetVersion.builder().commitId(gitInformation.getCommit_id())
|
||||||
|
.commitDescribe(gitInformation.getCommit_describe())
|
||||||
|
.commitTime(gitInformation.getCommit_time())
|
||||||
|
.tagName(gitInformation.getTag_name())
|
||||||
|
.tags(gitInformation.getTags())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
log.info(new ObjectMapper().writeValueAsString(ver));
|
||||||
|
|
||||||
|
Assert.assertNotNull(ver);
|
||||||
|
}
|
||||||
|
}
|
|
@ -78,6 +78,8 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
@Test
|
@Test
|
||||||
public void t4_verifyUserLoginTest() {
|
public void t4_verifyUserLoginTest() {
|
||||||
Assert.assertEquals(userAccountCacheManager.verifyUserLogin(getUSER_NAME(), userToken), ErrorCode.ERR_OK);
|
Assert.assertEquals(userAccountCacheManager.verifyUserLogin(getUSER_NAME(), userToken), ErrorCode.ERR_OK);
|
||||||
|
Assert.assertEquals(userAccountCacheManager.verifyUserLogin(getUSER_NAME() + "3213", userToken),
|
||||||
|
ErrorCode.ERR_LOGOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,6 +133,7 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
@Test
|
@Test
|
||||||
public void t99_cleanUserTokenTest() {
|
public void t99_cleanUserTokenTest() {
|
||||||
userAccountCacheManager.cleanUserToken(getUSER_NAME());
|
userAccountCacheManager.cleanUserToken(getUSER_NAME());
|
||||||
|
userAccountCacheManager.cleanUserToken(getUSER_NAME() + "234");
|
||||||
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken), ErrorCode.ERR_LOGOUT);
|
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken), ErrorCode.ERR_LOGOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ public class UserAccountMapperTest extends InitTestEnvironment {
|
||||||
UserAccount user = userAccountMapper.getUserByName("admin");
|
UserAccount user = userAccountMapper.getUserByName("admin");
|
||||||
Assert.assertEquals(new Long(user.getStatus()), new Long(ConstValue.UserAccountStatus.LOCKED));
|
Assert.assertEquals(new Long(user.getStatus()), new Long(ConstValue.UserAccountStatus.LOCKED));
|
||||||
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
||||||
|
|
||||||
|
userAccountMapper.unlockUserAccount("admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ public class UserAccountServiceTest extends InitTestEnvironment {
|
||||||
private UserAccountService userAccountService;
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void userLogin() throws NoSuchAlgorithmException {
|
public void userLoginTest() throws NoSuchAlgorithmException {
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService("admin",
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(),
|
||||||
"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58");
|
getPASSWORD());
|
||||||
|
|
||||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||||
UserAccountServiceTest.token = ret.getSecondParam();
|
UserAccountServiceTest.token = ret.getSecondParam();
|
||||||
|
@ -36,25 +36,37 @@ public class UserAccountServiceTest extends InitTestEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t1_logService() throws NoSuchAlgorithmException {
|
public void t1_logServiceTest() throws NoSuchAlgorithmException {
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService("admin",
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(),
|
||||||
"c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58");
|
getPASSWORD());
|
||||||
|
|
||||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||||
Assert.assertNotNull(ret.getSecondParam());
|
Assert.assertNotNull(ret.getSecondParam());
|
||||||
Assert.assertEquals(ret.getSecondParam(), UserAccountServiceTest.token);
|
Assert.assertEquals(ret.getSecondParam(), UserAccountServiceTest.token);
|
||||||
|
|
||||||
|
ret = userAccountService.loginService(null, null);
|
||||||
|
|
||||||
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_USERNOTFOUND);
|
||||||
|
|
||||||
|
ret = userAccountService.loginService(getUSER_NAME(), "12345");
|
||||||
|
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t2_logoutService() {
|
public void t2_logoutServiceTest() {
|
||||||
ErrorCode err = userAccountService.logoutService("admin", token);
|
ErrorCode err = userAccountService.logoutService(getUSER_NAME(), token);
|
||||||
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
Assert.assertEquals(err, ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t3_getUserByToken() {
|
public void t3_getUserByTokenTest() {
|
||||||
UserAccount username = userAccountService.getUserByToken(UserAccountServiceTest.token);
|
UserAccount username = userAccountService.getUserByToken(UserAccountServiceTest.token);
|
||||||
|
|
||||||
Assert.assertEquals(username.getUsername(), "admin");
|
Assert.assertEquals(username.getUsername(), getUSER_NAME());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void t4_authTokenCheckTest() {
|
||||||
|
Assert.assertEquals(userAccountService.authTokenCheck(token), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue