OCT
REM: 1. 增加获取任务列表QA测试用例单测代码 2. 增加启动处置任务QA测试用例单测代码 3. 增加启动多个IP处置任务QA测试用例单测代码 4. 增加停止处置任务QA测试用例单测代码 5. 增加P3QA测试用例单测代码
This commit is contained in:
parent
28f7af5789
commit
6914611a2a
|
@ -4,15 +4,15 @@ server.tomcat.basedir=./basedir
|
||||||
# 多个项目放在nginx下同个端口,通过该配置区分
|
# 多个项目放在nginx下同个端口,通过该配置区分
|
||||||
server.servlet.context-path=/dispose
|
server.servlet.context-path=/dispose
|
||||||
# 配置数据源
|
# 配置数据源
|
||||||
#spring.datasource.url=jdbc:mysql://10.88.77.65:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\
|
spring.datasource.url=jdbc:mysql://10.88.77.65:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior\
|
||||||
# =convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
|
=convertToNull&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
|
||||||
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
#spring.datasource.username=root
|
|
||||||
#spring.datasource.password=h0K0_8u
|
|
||||||
spring.datasource.url=jdbc:mysql://172.28.72.118:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=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=root
|
||||||
spring.datasource.password=Hy@rfph32
|
spring.datasource.password=h0K0_8u
|
||||||
|
#spring.datasource.url=jdbc:mysql://172.28.72.118:33061/ci_dispose_v2?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true
|
||||||
|
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
#spring.datasource.username=phoenix
|
||||||
|
#spring.datasource.password=Hy@rfph32
|
||||||
|
|
||||||
# 配置连接池
|
# 配置连接池
|
||||||
spring.datasource.schema=classpath:test_db/unit_test.sql
|
spring.datasource.schema=classpath:test_db/unit_test.sql
|
||||||
|
|
|
@ -132,7 +132,8 @@ CREATE TABLE `dispose_task` (
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of dispose_task
|
-- Records of dispose_task
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `dispose_task` VALUES (1, -1, 1, 0, '192.168.10.1', CURRENT_TIMESTAMP, date_add(now(), interval 10 MINUTE), null, 2, 8796093022207, 1024, 0);
|
INSERT INTO `dispose_task` VALUES (1, -1, 1, 0, '192.168.10.1', CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
|
||||||
|
INSERT INTO `dispose_task` VALUES (2, -1, 1, 0, '192.168.10.2', CURRENT_TIMESTAMP, date_add(now(), interval 60 MINUTE), null, 2, 8796093022207, 1024, 0);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for user_account
|
-- Table structure for user_account
|
||||||
|
|
|
@ -12,6 +12,11 @@ import com.dispose.test.qa.testcase.v20.P2DeviceUpgrade;
|
||||||
import com.dispose.test.qa.testcase.v20.P2Info;
|
import com.dispose.test.qa.testcase.v20.P2Info;
|
||||||
import com.dispose.test.qa.testcase.v20.P2Login;
|
import com.dispose.test.qa.testcase.v20.P2Login;
|
||||||
import com.dispose.test.qa.testcase.v20.P2Logout;
|
import com.dispose.test.qa.testcase.v20.P2Logout;
|
||||||
|
import com.dispose.test.qa.testcase.v20.P2TaskList;
|
||||||
|
import com.dispose.test.qa.testcase.v20.P2TaskStart;
|
||||||
|
import com.dispose.test.qa.testcase.v20.P2TaskStartMulIp;
|
||||||
|
import com.dispose.test.qa.testcase.v20.P2TaskStop;
|
||||||
|
import com.dispose.test.qa.testcase.v20.P3All;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -52,6 +57,7 @@ public interface TestCaseRun {
|
||||||
static List<QATestItem> getAllTestCase() {
|
static List<QATestItem> getAllTestCase() {
|
||||||
List<QATestItem> tolTestCase = new ArrayList<>();
|
List<QATestItem> tolTestCase = new ArrayList<>();
|
||||||
Collections.addAll(tolTestCase, P1All.getTestCase());
|
Collections.addAll(tolTestCase, P1All.getTestCase());
|
||||||
|
Collections.addAll(tolTestCase, P3All.getTestCase());
|
||||||
|
|
||||||
Collections.addAll(tolTestCase, P2Login.getTestCase());
|
Collections.addAll(tolTestCase, P2Login.getTestCase());
|
||||||
Collections.addAll(tolTestCase, P2Logout.getTestCase());
|
Collections.addAll(tolTestCase, P2Logout.getTestCase());
|
||||||
|
@ -63,6 +69,11 @@ public interface TestCaseRun {
|
||||||
|
|
||||||
Collections.addAll(tolTestCase, P2Info.getTestCase());
|
Collections.addAll(tolTestCase, P2Info.getTestCase());
|
||||||
|
|
||||||
|
Collections.addAll(tolTestCase, P2TaskStart.getTestCase());
|
||||||
|
Collections.addAll(tolTestCase, P2TaskStartMulIp.getTestCase());
|
||||||
|
Collections.addAll(tolTestCase, P2TaskStop.getTestCase());
|
||||||
|
Collections.addAll(tolTestCase, P2TaskList.getTestCase());
|
||||||
|
|
||||||
return tolTestCase;
|
return tolTestCase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,6 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun {
|
||||||
.filter(k -> k.getCaseJsonValue() != null && k.getCaseJsonValue().length() > 0)
|
.filter(k -> k.getCaseJsonValue() != null && k.getCaseJsonValue().length() > 0)
|
||||||
.filter(k -> usedId.size() == 0 || usedId.stream().anyMatch(v -> Objects.equals(v, k.getId())))
|
.filter(k -> usedId.size() == 0 || usedId.stream().anyMatch(v -> Objects.equals(v, k.getId())))
|
||||||
.filter(k -> Arrays.stream(CommonEnvironment.commonPriorityFilter).anyMatch(v -> k.getPriority() == v))
|
.filter(k -> Arrays.stream(CommonEnvironment.commonPriorityFilter).anyMatch(v -> k.getPriority() == v))
|
||||||
//.filter(k-> k.getId() >= 700)
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,14 @@ import com.dispose.pojo.entity.DisposeDevice;
|
||||||
import com.dispose.test.common.QATestItem;
|
import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type P 1.
|
* The type P 1.
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P1All {
|
public class P1All {
|
||||||
/**
|
/**
|
||||||
* The Base p 1 id.
|
* The Base p 1 id.
|
||||||
|
|
|
@ -11,7 +11,6 @@ import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import com.dispose.test.qa.exec.TestCaseRun;
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P2DeviceAdd {
|
public class P2DeviceAdd {
|
||||||
/**
|
/**
|
||||||
* The constant BASE_P2_DEVICE_ADD_ID.
|
* The constant BASE_P2_DEVICE_ADD_ID.
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import com.dispose.test.qa.exec.TestCaseRun;
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@ -16,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P2DeviceDel {
|
public class P2DeviceDel {
|
||||||
/**
|
/**
|
||||||
* The constant BASE_P2_DEVICE_DEL_ID.
|
* The constant BASE_P2_DEVICE_DEL_ID.
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import com.dispose.test.qa.exec.TestCaseRun;
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ import java.util.HashMap;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P2DeviceUpgrade {
|
public class P2DeviceUpgrade {
|
||||||
/**
|
/**
|
||||||
* The constant BASE_P2_DEVICE_UPGRADE_ID.
|
* The constant BASE_P2_DEVICE_UPGRADE_ID.
|
||||||
|
|
|
@ -18,7 +18,6 @@ import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import com.dispose.test.qa.exec.TestCaseRun;
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@ -32,7 +31,6 @@ import java.util.Random;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P2Info {
|
public class P2Info {
|
||||||
/**
|
/**
|
||||||
* The constant BASE_P2_INFO_ID.
|
* The constant BASE_P2_INFO_ID.
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import com.dispose.test.qa.exec.TestCaseRun;
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@ -16,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P2Login {
|
public class P2Login {
|
||||||
/**
|
/**
|
||||||
* The constant BASE_P2_LOGIN_ID.
|
* The constant BASE_P2_LOGIN_ID.
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.dispose.test.common.QATestItem;
|
||||||
import com.dispose.test.common.TestPriority;
|
import com.dispose.test.common.TestPriority;
|
||||||
import com.dispose.test.common.VerifyProtoRespCallback;
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
import com.dispose.test.qa.exec.TestCaseRun;
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
@ -16,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
*
|
*
|
||||||
* @author <huangxin@cmhi.chinamoblie.com>
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
|
||||||
public class P2Logout {
|
public class P2Logout {
|
||||||
/**
|
/**
|
||||||
* The constant BASE_P2_LOGOUT_ID.
|
* The constant BASE_P2_LOGOUT_ID.
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.dispose.test.qa.testcase.v20;
|
||||||
|
|
||||||
|
import com.dispose.common.DDoSAttackType;
|
||||||
|
import com.dispose.common.DisposeCapacityType;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.NetflowDirection;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.GetTaskRsp;
|
||||||
|
import com.dispose.pojo.entity.DisposeTask;
|
||||||
|
import com.dispose.test.common.QATestItem;
|
||||||
|
import com.dispose.test.common.TestPriority;
|
||||||
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type P 2 task list.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class P2TaskList {
|
||||||
|
/**
|
||||||
|
* The constant BASE_P2_TASK_LIST_ID.
|
||||||
|
*/
|
||||||
|
public static final int BASE_P2_TASK_LIST_ID = 1100;
|
||||||
|
/**
|
||||||
|
* The constant testItemArray.
|
||||||
|
*/
|
||||||
|
private static final QATestItem[] testItemArray = new QATestItem[]{
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_LIST_ID)
|
||||||
|
.name("获取第二页20个设备信息")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":2," +
|
||||||
|
"\"pageSize\":20}}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.prepareCallback(P2TaskList::prepareDisposeDevice)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) (v, e, c) -> {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getCurPageNumber(), 2);
|
||||||
|
Assert.assertEquals((long)v.getMsgContent().getPageSize(), 20);
|
||||||
|
|
||||||
|
Assert.assertNotNull(v.getMsgContent().getItems());
|
||||||
|
Assert.assertEquals(v.getMsgContent().getItems().size(), 20);
|
||||||
|
|
||||||
|
Assert.assertNotEquals(v.getMsgContent().getItems().size(), 0);
|
||||||
|
v.getMsgContent().getItems().forEach(k -> {
|
||||||
|
Assert.assertNotNull(k.getTaskId());
|
||||||
|
Assert.assertNotEquals(k.getDisposeIp().length(), 0);
|
||||||
|
Assert.assertNotNull(k.getCurrentStatus());
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_LIST_ID)
|
||||||
|
.name("msgContent为空")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) (v, e, c) -> {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get test case qa test item [ ].
|
||||||
|
*
|
||||||
|
* @return the qa test item [ ]
|
||||||
|
*/
|
||||||
|
public static QATestItem[] getTestCase() {
|
||||||
|
return testItemArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare dispose device.
|
||||||
|
*
|
||||||
|
* @param c the c
|
||||||
|
*/
|
||||||
|
private static void prepareDisposeDevice(TestCaseRun c) {
|
||||||
|
for (int i = 1; i <= 100; i++) {
|
||||||
|
DisposeTask task = DisposeTask.builder()
|
||||||
|
.deviceId(1L)
|
||||||
|
.accountId(1L)
|
||||||
|
.disposeCapacity(DisposeCapacityType.CLEANUP)
|
||||||
|
.disposeIp("192.168.0." + i)
|
||||||
|
.planEndTime("60")
|
||||||
|
.flowDirection(NetflowDirection.DIRECTION_BI)
|
||||||
|
.attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))
|
||||||
|
.flowBandWidth(1024)
|
||||||
|
.build();
|
||||||
|
c.getDisposeTaskMapper().addNewTask(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,279 @@
|
||||||
|
package com.dispose.test.qa.testcase.v20;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.common.Helper;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.TaskStartRsp;
|
||||||
|
import com.dispose.test.common.QATestItem;
|
||||||
|
import com.dispose.test.common.TestPriority;
|
||||||
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type P 2 task start.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class P2TaskStart {
|
||||||
|
/**
|
||||||
|
* The constant BASE_P2_TASK_START_ID.
|
||||||
|
*/
|
||||||
|
public static final int BASE_P2_TASK_START_ID = 800;
|
||||||
|
/**
|
||||||
|
* The constant testItemArray.
|
||||||
|
*/
|
||||||
|
private static final QATestItem[] testItemArray = new QATestItem[]{
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID)
|
||||||
|
.name("对一个IP全部攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":\"192.168.51.2\",\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "192.168.51.2"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 1)
|
||||||
|
.name("对IPV6全部攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":\"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789\",\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "ABCD:EF01:2345" +
|
||||||
|
":6789:ABCD:EF01:2345:6789"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 2)
|
||||||
|
.name("对一个IP入向进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":0," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "192.168.50.2"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 3)
|
||||||
|
.name("对一个IP出向进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":\"192.168.50.3\",\"disposeTime\":10,\"flowDirection\":1," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "192.168.50.3"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 4)
|
||||||
|
.name("对一个IP进行高防处置")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":1," +
|
||||||
|
"\"disposeIp\":\"192.168.50.3\",\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "192.168.50.3"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 5)
|
||||||
|
.name("对一个IP进行压制处置")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":2," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "192.168.50.2"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 6)
|
||||||
|
.name("对一个IP进行检测处置")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":3," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) (v, e, c) -> verifySucceed(v, e, "192.168.50.2"))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 7)
|
||||||
|
.name("msgContent为空")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 8)
|
||||||
|
.name("type为null")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":null," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 9)
|
||||||
|
.name("type为字符串")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":\"0\"," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 10)
|
||||||
|
.name("disposeIp为null")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":null,\"disposeTime\":10,\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 11)
|
||||||
|
.name("disposeIp为非法IP地址")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":192.168.50.2,\"disposeTime\":10,\"flowDirection\":2,\"attackType\":[1," +
|
||||||
|
"2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 12)
|
||||||
|
.name("disposeTime为null")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":null,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_ID + 13)
|
||||||
|
.name("disposeTime为字符串")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":\"10\",\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>)P2TaskStart::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get test case qa test item [ ].
|
||||||
|
*
|
||||||
|
* @return the qa test item [ ]
|
||||||
|
*/
|
||||||
|
public static QATestItem[] getTestCase() {
|
||||||
|
return testItemArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify succeed.
|
||||||
|
*
|
||||||
|
* @param v the v
|
||||||
|
* @param e the e
|
||||||
|
* @param ipAddr the ip addr
|
||||||
|
*/
|
||||||
|
private static void verifySucceed(ProtocolRespDTO<TaskStartRsp> v, ErrorCode e, String ipAddr) {
|
||||||
|
String disposeIp = v.getMsgContent().getDisposeIp();
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
Assert.assertNotNull(disposeIp);
|
||||||
|
Assert.assertEquals(ipAddr, Helper.ipAddressNormalize(disposeIp));
|
||||||
|
Assert.assertNotEquals(v.getMsgContent().getDisposeIp().length(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify json exception resp.
|
||||||
|
*
|
||||||
|
* @param v the v
|
||||||
|
* @param e the e
|
||||||
|
* @param c the c
|
||||||
|
*/
|
||||||
|
private static void verifyJsonExceptionResp(ProtocolRespDTO<? extends BaseRespStatus> v, ErrorCode e,
|
||||||
|
TestCaseRun c) {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,370 @@
|
||||||
|
package com.dispose.test.qa.testcase.v20;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.TaskStartMulRsp;
|
||||||
|
import com.dispose.test.common.QATestItem;
|
||||||
|
import com.dispose.test.common.TestPriority;
|
||||||
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type P 2 task start mul ip.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class P2TaskStartMulIp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constant BASE_P2_TASK_START_MUL_ID.
|
||||||
|
*/
|
||||||
|
public static final int BASE_P2_TASK_START_MUL_ID = 900;
|
||||||
|
/**
|
||||||
|
* The constant testItemArray.
|
||||||
|
*/
|
||||||
|
private static final QATestItem[] testItemArray = new QATestItem[]{
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID)
|
||||||
|
.name("对一个IP全部攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 1)
|
||||||
|
.name("对多个IP全部攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 2)
|
||||||
|
.name("对多个IP全部攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 3)
|
||||||
|
.name("对多个IPV6指定攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789\"," +
|
||||||
|
"\"ABCD:EF01:2345:6789:ABCD:EF01:2345:1234\"],\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789", "ABCD:EF01:2345:6789:ABCD:EF01:2345:1234"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 4)
|
||||||
|
.name("对多个IPV6全部攻击类型进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789\"," +
|
||||||
|
"\"ABCD:EF01:2345:6789:ABCD:EF01:2345:1234\"],\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789", "ABCD:EF01:2345:6789:ABCD:EF01:2345:1234"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 5)
|
||||||
|
.name("对IPV4和IPV6进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"," +
|
||||||
|
"\"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789\"],\"disposeTime\":10,\"flowDirection\":2," +
|
||||||
|
"\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3","ABCD:EF01:2345:6789:ABCD:EF01:2345:6789"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 6)
|
||||||
|
.name("对多个IP入向进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":0,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 7)
|
||||||
|
.name("对多个IP出向进行清洗")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":1,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 8)
|
||||||
|
.name("对多个IP进行高防处置")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":1," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 9)
|
||||||
|
.name("对多个IP进行压制处置")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":2," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 10)
|
||||||
|
.name("对多个IP进行检测处置")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":3," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[-1]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) (v, e, c) -> verifySucceed(v, e, new String[]{
|
||||||
|
"192.168.50.4", "192.168.50.3"
|
||||||
|
}))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 11)
|
||||||
|
.name("msgContent为空")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 12)
|
||||||
|
.name("type为null")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":null," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 13)
|
||||||
|
.name("type为字符串")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":\"0\"," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 14)
|
||||||
|
.name("disposeIp为null")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":null,\"disposeTime\":10,\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 15)
|
||||||
|
.name("disposeIp为整形")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"disposeIp\":192.168.50.2,\"disposeTime\":10,\"flowDirection\":2,\"attackType\":[1," +
|
||||||
|
"2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 16)
|
||||||
|
.name("disposeTime为null")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":null," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_MUL_ID + 17)
|
||||||
|
.name("disposeTime为字符串")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":0," +
|
||||||
|
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":\"10\"," +
|
||||||
|
"\"flowDirection\":2,\"attackType\":[1,2,3,4,5]}}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback(P2TaskStartMulIp::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get test case qa test item [ ].
|
||||||
|
*
|
||||||
|
* @return the qa test item [ ]
|
||||||
|
*/
|
||||||
|
public static QATestItem[] getTestCase() {
|
||||||
|
return testItemArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify succeed.
|
||||||
|
*
|
||||||
|
* @param v the v
|
||||||
|
* @param e the e
|
||||||
|
* @param ipList the ip list
|
||||||
|
*/
|
||||||
|
private static void verifySucceed(ProtocolRespDTO<TaskStartMulRsp> v, ErrorCode e, String[] ipList) {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertNotNull(v.getMsgContent().getItems());
|
||||||
|
Assert.assertEquals(v.getMsgContent().getItems().size(), ipList.length);
|
||||||
|
|
||||||
|
v.getMsgContent().getItems().forEach(k -> {
|
||||||
|
Assert.assertNotNull(k.getDisposeIp());
|
||||||
|
Assert.assertEquals((long) k.getStatus(), e.getCode());
|
||||||
|
Assert.assertNotNull(k.getTaskId());
|
||||||
|
Assert.assertNotNull(k.getExpireTime());
|
||||||
|
Assert.assertTrue(Arrays.stream(ipList).anyMatch(m -> m.equals(k.getDisposeIp())));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify json exception resp.
|
||||||
|
*
|
||||||
|
* @param v the v
|
||||||
|
* @param e the e
|
||||||
|
* @param c the c
|
||||||
|
*/
|
||||||
|
private static void verifyJsonExceptionResp(ProtocolRespDTO<? extends BaseRespStatus> v, ErrorCode e,
|
||||||
|
TestCaseRun c) {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
package com.dispose.test.qa.testcase.v20;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.TaskStopRsp;
|
||||||
|
import com.dispose.test.common.QATestItem;
|
||||||
|
import com.dispose.test.common.TestPriority;
|
||||||
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type P 2 task stop.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class P2TaskStop {
|
||||||
|
/**
|
||||||
|
* The constant BASE_P2_TASK_START_MUL_ID.
|
||||||
|
*/
|
||||||
|
public static final int BASE_P2_TASK_START_STOP_ID = 1000;
|
||||||
|
/**
|
||||||
|
* The constant testItemArray.
|
||||||
|
*/
|
||||||
|
private static final QATestItem[] testItemArray = new QATestItem[]{
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_STOP_ID)
|
||||||
|
.name("停止多个处置任务")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/stop")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580," +
|
||||||
|
"\"msgContent\":{\"taskId\":[\"1\",\"2\",\"3\"]}}")
|
||||||
|
.rspClass(TaskStopRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_OK)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStopRsp>) (v, e, c) -> {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertNotNull(v.getMsgContent().getItems());
|
||||||
|
Assert.assertEquals(v.getMsgContent().getItems().size(), 3);
|
||||||
|
|
||||||
|
v.getMsgContent().getItems().forEach(k -> {
|
||||||
|
Assert.assertNotNull(k.getTaskId());
|
||||||
|
if("3".equals(k.getTaskId())){
|
||||||
|
Assert.assertEquals((long)k.getStatus(), ErrorCode.ERR_NOSUCHTASK.getCode());
|
||||||
|
} else {
|
||||||
|
Assert.assertEquals((long)k.getStatus(), e.getCode());
|
||||||
|
Assert.assertNotNull(k.getType());
|
||||||
|
Assert.assertNotEquals(k.getDisposeIp().length(), 0);
|
||||||
|
Assert.assertNotNull(k.getLeftTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P2_TASK_START_STOP_ID)
|
||||||
|
.name("msgContent为空")
|
||||||
|
.priority(TestPriority.P2_PRIORITY)
|
||||||
|
.urlPath("/task/stop")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":}")
|
||||||
|
.rspClass(TaskStopRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStopRsp>) (v, e, c) -> {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
})
|
||||||
|
.build(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get test case qa test item [ ].
|
||||||
|
*
|
||||||
|
* @return the qa test item [ ]
|
||||||
|
*/
|
||||||
|
public static QATestItem[] getTestCase() {
|
||||||
|
return testItemArray;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,353 @@
|
||||||
|
package com.dispose.test.qa.testcase.v20;
|
||||||
|
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
|
import com.dispose.pojo.dto.protocol.auth.LoginRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||||
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.info.GetDeviceInfoRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.device.manager.GetDeviceRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.GetTaskRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.TaskStartMulRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.TaskStartRsp;
|
||||||
|
import com.dispose.pojo.dto.protocol.task.TaskStopRsp;
|
||||||
|
import com.dispose.test.common.QATestItem;
|
||||||
|
import com.dispose.test.common.TestPriority;
|
||||||
|
import com.dispose.test.common.VerifyProtoRespCallback;
|
||||||
|
import com.dispose.test.qa.exec.TestCaseRun;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type P 3 all.
|
||||||
|
*
|
||||||
|
* @author <huangxin@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
public class P3All {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constant BASE_P2_TASK_START_STOP_ID.
|
||||||
|
*/
|
||||||
|
public static final int BASE_P3_ALL_ID = 1200;
|
||||||
|
/**
|
||||||
|
* The constant testItemArray.
|
||||||
|
*/
|
||||||
|
private static final QATestItem[] testItemArray = new QATestItem[]{
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 1)
|
||||||
|
.name("timeStamp为空")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/auth/logout")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":,\"msgContent\":{\"userName\":\"admin\"}}")
|
||||||
|
.rspClass(LoginRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<LoginRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 2)
|
||||||
|
.name("timeStamp为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/auth/logout")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":null,\"msgContent\":{\"userName\":\"admin\"}}")
|
||||||
|
.rspClass(LoginRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<LoginRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 3)
|
||||||
|
.name("userName为空")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/auth/logout")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598582999559,\"msgContent\":{\"userName\":}}")
|
||||||
|
.rspClass(LoginRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<LoginRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 4)
|
||||||
|
.name("userName为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/auth/logout")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598582999559,\"msgContent\":{\"userName\":null}}")
|
||||||
|
.rspClass(LoginRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<LoginRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 5)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/info/deviceVersion")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":null}")
|
||||||
|
.rspClass(GetDeviceInfoRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceInfoRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 6)
|
||||||
|
.name("id为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/info/deviceVersion")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"id\":null}}")
|
||||||
|
.rspClass(GetDeviceInfoRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceInfoRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 7)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/info/deviceLinkStatus")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":null}")
|
||||||
|
.rspClass(GetDeviceInfoRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceInfoRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 8)
|
||||||
|
.name("id为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/info/deviceLinkStatus")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"id\":null}}")
|
||||||
|
.rspClass(GetDeviceInfoRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceInfoRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 9)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/manager/deviceList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":null}")
|
||||||
|
.rspClass(GetDeviceRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 10)
|
||||||
|
.name("startPage为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/manager/deviceList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234," +
|
||||||
|
"\"msgContent\":{\"startPage\":null,\"pageSize\":10}}")
|
||||||
|
.rspClass(GetDeviceRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 11)
|
||||||
|
.name("startPage为字符串")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/manager/deviceList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234," +
|
||||||
|
"\"msgContent\":{\"startPage\":\"1\",\"pageSize\":10}}")
|
||||||
|
.rspClass(GetDeviceRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 12)
|
||||||
|
.name("pageSize为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/manager/deviceList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," +
|
||||||
|
"\"pageSize\":null}}")
|
||||||
|
.rspClass(GetDeviceRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 13)
|
||||||
|
.name("pageSize为字符串")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/manager/deviceList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," +
|
||||||
|
"\"pageSize\":\"10\"}}")
|
||||||
|
.rspClass(GetDeviceRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetDeviceRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 14)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/start")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":null}")
|
||||||
|
.rspClass(TaskStartRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 15)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/startMulIp")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":null}")
|
||||||
|
.rspClass(TaskStartMulRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStartMulRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 16)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/stop")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":null}")
|
||||||
|
.rspClass(TaskStopRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStopRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 17)
|
||||||
|
.name("id为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/stop")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"taskId\":null}}")
|
||||||
|
.rspClass(TaskStopRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<TaskStopRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 18)
|
||||||
|
.name("msgContent为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":null}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 19)
|
||||||
|
.name("startPage为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234," +
|
||||||
|
"\"msgContent\":{\"startPage\":null,\"pageSize\":10}}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 20)
|
||||||
|
.name("startPage为字符串")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234," +
|
||||||
|
"\"msgContent\":{\"startPage\":\"1\",\"pageSize\":10}}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 21)
|
||||||
|
.name("pageSize为null")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," +
|
||||||
|
"\"pageSize\":null}}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
QATestItem.builder()
|
||||||
|
.id(BASE_P3_ALL_ID + 22)
|
||||||
|
.name("pageSize为字符串")
|
||||||
|
.priority(TestPriority.P3_PRIORITY)
|
||||||
|
.urlPath("/task/taskList")
|
||||||
|
.method(RequestMethod.POST)
|
||||||
|
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598596065234,\"msgContent\":{\"startPage\":1," +
|
||||||
|
"\"pageSize\":\"10\"}}")
|
||||||
|
.rspClass(GetTaskRsp.class)
|
||||||
|
.rspCode(ErrorCode.ERR_PARAMEXCEPTION)
|
||||||
|
.autoLogin(true)
|
||||||
|
.verifyCallback((VerifyProtoRespCallback<GetTaskRsp>) P3All::verifyJsonExceptionResp)
|
||||||
|
.build(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get test case qa test item [ ].
|
||||||
|
*
|
||||||
|
* @return the qa test item [ ]
|
||||||
|
*/
|
||||||
|
public static QATestItem[] getTestCase() {
|
||||||
|
return testItemArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify json exception resp.
|
||||||
|
*
|
||||||
|
* @param v the v
|
||||||
|
* @param e the e
|
||||||
|
* @param c the c
|
||||||
|
*/
|
||||||
|
private static void verifyJsonExceptionResp(ProtocolRespDTO<? extends BaseRespStatus> v, ErrorCode e,
|
||||||
|
TestCaseRun c) {
|
||||||
|
Assert.assertNotNull(v);
|
||||||
|
Assert.assertNotNull(v.getMsgContent());
|
||||||
|
Assert.assertEquals((long) v.getCode(), e.getHttpCode());
|
||||||
|
Assert.assertEquals((long) v.getMsgContent().getStatus(), e.getCode());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue