parent
38a45d451d
commit
c40e1154ae
|
@ -173,7 +173,6 @@ public class DisposeTaskController {
|
|||
rspInfo.setExpireTime(ret.getSecondParam().getPlanEndTime());
|
||||
}
|
||||
|
||||
|
||||
rspInfo.setStatus(ret.getFirstParam().getCode());
|
||||
rspInfo.setMessage(new String[]{ret.getFirstParam().getMsg()});
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.dispose.pojo.dto.protocol.base.IdArraysReq;
|
|||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStartReq;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStartRsp;
|
||||
import com.dispose.pojo.dto.protocol.task.TaskStopRsp;
|
||||
import com.dispose.pojo.entity.DisposeTask;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
|
@ -90,7 +91,7 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
TaskStartReq req = TaskStartReq.builder()
|
||||
.id(String.valueOf(disposeDeviceMapper.selectAll().get(0).getId()))
|
||||
.type(DisposeCapacityType.CLEANUP.getValue())
|
||||
.disposeIp("192.168.5.3")
|
||||
.disposeIp("192.168.100.100")
|
||||
.disposeTime(60)
|
||||
.flowDirection(NetflowDirection.DIRECTION_IN.getValue())
|
||||
.attackType(new Integer[]{DDoSAttackType.ACK_FLOOD.getValue()})
|
||||
|
@ -148,7 +149,7 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
DisposeTask disposeTask = disposeTaskManager.selectAll().get(0);
|
||||
|
||||
TaskStartReq req = TaskStartReq.builder()
|
||||
.id(String.valueOf(disposeTask.getId()))
|
||||
.id(String.valueOf(disposeTask.getDeviceId()))
|
||||
.type(disposeTask.getDisposeCapacity().getValue())
|
||||
.disposeIp(disposeTask.getDisposeIp())
|
||||
.disposeTime(60)
|
||||
|
@ -264,4 +265,62 @@ public class DisposeTaskControllerTest extends InitTestEnvironment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A 4 stop task protocol resp dto.
|
||||
*
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Test
|
||||
public void a4_startTaskMulIp() throws Exception {
|
||||
String[] mulDisposeIp = {"192.168.5.2", "192.168.5.3"};
|
||||
|
||||
TaskStartReq req = TaskStartReq.builder()
|
||||
.id(String.valueOf(disposeDeviceMapper.selectAll().get(0).getId()))
|
||||
.type(DisposeCapacityType.CLEANUP.getValue())
|
||||
.mulDisposeIp(mulDisposeIp)
|
||||
.disposeTime(60)
|
||||
.flowDirection(NetflowDirection.DIRECTION_IN.getValue())
|
||||
.attackType(new Integer[]{DDoSAttackType.ACK_FLOOD.getValue()})
|
||||
.flowBandwidth(DisposeConfigValue.DEFAULT_DISPOSE_BANDWIDTH)
|
||||
.build();
|
||||
|
||||
ProtocolReqDTO<TaskStartReq> reqInfo = new ProtocolReqDTO<>();
|
||||
|
||||
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||
reqInfo.setCryptoType(ProtoCryptoType.CRYPTO_NONE.getCode());
|
||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||
reqInfo.setMsgContent(req);
|
||||
|
||||
String ret = mockMvc.perform(MockMvcRequestBuilders
|
||||
.post("/task/startMulIp")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", ConstValue.STRING_HTTP_AUTH_HEAD + getLoginToken())
|
||||
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||
.andDo(print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.code").value(HttpStatus.ok().status()))
|
||||
.andReturn()
|
||||
.getResponse()
|
||||
.getContentAsString();
|
||||
|
||||
ProtocolRespDTO<List<TaskStartRsp>> rspInfo = objectMapper.readValue(ret,
|
||||
new TypeReference<ProtocolRespDTO<List<TaskStartRsp>>>() {
|
||||
});
|
||||
|
||||
verifyRespProtocol(rspInfo);
|
||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(rspInfo));
|
||||
|
||||
Assert.assertNotNull(rspInfo.getMsgContent());
|
||||
rspInfo.getMsgContent().forEach(v->{
|
||||
Assert.assertNotNull(v.getStatus());
|
||||
Assert.assertNotNull(v.getMessage());
|
||||
Assert.assertNotNull(v.getDisposeIp());
|
||||
|
||||
if(v.getStatus() == ErrorCode.ERR_OK.getCode() ||
|
||||
v.getStatus() == ErrorCode.ERR_TASKRUNNING.getCode()){
|
||||
Assert.assertNotNull(v.getTaskId());
|
||||
Assert.assertNotNull(v.getExpireTime());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue