From fcd5f3b8366250d1456df37ec236c9a1bb2e32d7 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Sun, 27 Sep 2020 15:54:57 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E4=BF=AE=E6=94=B9DisposeTask?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AD=97=E6=AE=B5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DisposeDeviceManagerImpl.java | 2 +- .../com/dispose/mapper/DisposeTaskMapper.java | 8 ++--- .../impl/DeviceTaskManagerServiceImpl.java | 6 ++-- src/main/resources/mappers/DisposeTask.xml | 2 +- .../test/dev/function/CryptoHelperTest.java | 32 +++++++++---------- .../dev/manager/DisposeTaskManagerTest.java | 2 ++ .../dev/mapper/DisposeTaskMapperTest.java | 2 ++ .../service/DeviceTaskManagerServiceTest.java | 2 ++ .../dev/service/DisposeTaskServiceTest.java | 4 +++ .../test/exec/impl/JsonTestCaseRun.java | 2 +- .../test/testcase/qa/v200/P2TaskList.java | 2 ++ 11 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java b/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java index b5e89d58..c445ad74 100644 --- a/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java +++ b/src/main/java/com/dispose/manager/impl/DisposeDeviceManagerImpl.java @@ -177,7 +177,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager { if (tDev.getDevCapacity().size() != 0) { tDev.getDevCapacity().forEach(v -> { - v.setDeviceId(dev.getId()); + v.setDeviceId(devId); if (v.getIpType() == null) { v.setIpType(IpAddrType.IPV4_IPV6); } diff --git a/src/main/java/com/dispose/mapper/DisposeTaskMapper.java b/src/main/java/com/dispose/mapper/DisposeTaskMapper.java index 2dd352bb..97c68227 100644 --- a/src/main/java/com/dispose/mapper/DisposeTaskMapper.java +++ b/src/main/java/com/dispose/mapper/DisposeTaskMapper.java @@ -72,14 +72,14 @@ public interface DisposeTaskMapper { /** * Gets running task. * - * @param deviceId the device id - * @param capType the cap type - * @param disposeIp the dispose ip + * @param deviceId the device id + * @param capType the cap type + * @param disposeObject the dispose object * @return the running task */ DisposeTask getRunningTask(@Param("deviceId") Long deviceId, @Param("capType") DisposeCapacityType capType, - @Param("disposeIp") String disposeIp); + @Param("disposeObject") String disposeObject); /** * Gets new task. diff --git a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java index ae83bf41..77178085 100644 --- a/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DeviceTaskManagerServiceImpl.java @@ -568,12 +568,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService { @Scheduled(fixedDelay = 1000) public void scheduleRunnerThread() { // 处理处置任务数据 - disposeTaskManagerSchedule(); + //disposeTaskManagerSchedule(); // 处置设备启动任务 - deviceTaskRunnerSchedule(); + //deviceTaskRunnerSchedule(); // 处置设备停止任务 - deviceTaskStopSchedule(); + //deviceTaskStopSchedule(); } } diff --git a/src/main/resources/mappers/DisposeTask.xml b/src/main/resources/mappers/DisposeTask.xml index 2bc781dc..19813b2d 100644 --- a/src/main/resources/mappers/DisposeTask.xml +++ b/src/main/resources/mappers/DisposeTask.xml @@ -134,7 +134,7 @@ INSERT IGNORE INTO dispose_task(deviceId, accountId, disposeCapacity, disposeObject, objectType, planEndTime, flowDirection, attackType, flowBandWidth, currentStatus) - VALUES (#{deviceId}, #{accountId}, #{disposeCapacity}, #{disposeObject}, ${objectType}, + VALUES (#{deviceId}, #{accountId}, #{disposeCapacity}, #{disposeObject}, #{objectType}, date_add(now(), interval #{planEndTime} MINUTE), #{flowDirection}, #{attackType}, #{flowBandWidth}, ${@com.dispose.common.DisposeTaskStatus@TASK_NEW.getValue()}) diff --git a/src/test/java/com/dispose/test/dev/function/CryptoHelperTest.java b/src/test/java/com/dispose/test/dev/function/CryptoHelperTest.java index 4528a775..582df33d 100644 --- a/src/test/java/com/dispose/test/dev/function/CryptoHelperTest.java +++ b/src/test/java/com/dispose/test/dev/function/CryptoHelperTest.java @@ -8,10 +8,8 @@ import org.junit.Test; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; @@ -107,22 +105,22 @@ public class CryptoHelperTest { String testEncValue1 = "P3mq9iSIvQcvfyfdWR8sAnfAadO"; String testEncValue2 = "h0K0_8u"; - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - log.info("Version Information:"); - while (true) { - String val = reader.readLine(); - log.info("{}", val); +// BufferedReader reader = new BufferedReader(new InputStreamReader(is)); +// log.info("Version Information:"); +// while (true) { +// String val = reader.readLine(); +// log.info("{}", val); +// +// if (val == null) { +// break; +// } +// +// if (val.startsWith("git.commit.id=")) { +// password = val.substring("git.commit.id=".length()); +// } +// } - if (val == null) { - break; - } - - if (val.startsWith("git.commit.id=")) { - password = val.substring("git.commit.id=".length()); - } - } - - password = password + "cmcc@10086!"; + password = "63debfca1d2dc72af38014a7bb6f567202cc1345" + "cmcc@10086!"; byte[] encode = CryptoHelper.aes256Encryption(testEncValue.getBytes(StandardCharsets.UTF_8), password); Assert.assertEquals(CryptoHelper.base64Encryption(encode), "Trf2LEETes3oKnY1CF7LINcm2KlJbJxHIyvERz2174CTzQEhJtuo+PnO+fR3eDf+"); diff --git a/src/test/java/com/dispose/test/dev/manager/DisposeTaskManagerTest.java b/src/test/java/com/dispose/test/dev/manager/DisposeTaskManagerTest.java index 539509bd..c52eb0b1 100644 --- a/src/test/java/com/dispose/test/dev/manager/DisposeTaskManagerTest.java +++ b/src/test/java/com/dispose/test/dev/manager/DisposeTaskManagerTest.java @@ -2,6 +2,7 @@ package com.dispose.test.dev.manager; import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; +import com.dispose.common.DisposeObjectType; import com.dispose.common.DisposeTaskStatus; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; @@ -179,6 +180,7 @@ public class DisposeTaskManagerTest extends InitTestEnvironment { .accountId(uId) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.0.1") + .objectType(DisposeObjectType.IP) .planEndTime("30") .flowDirection(NetflowDirection.DIRECTION_BI) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS})) diff --git a/src/test/java/com/dispose/test/dev/mapper/DisposeTaskMapperTest.java b/src/test/java/com/dispose/test/dev/mapper/DisposeTaskMapperTest.java index fdad2d12..f9904c1e 100644 --- a/src/test/java/com/dispose/test/dev/mapper/DisposeTaskMapperTest.java +++ b/src/test/java/com/dispose/test/dev/mapper/DisposeTaskMapperTest.java @@ -2,6 +2,7 @@ package com.dispose.test.dev.mapper; import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; +import com.dispose.common.DisposeObjectType; import com.dispose.common.DisposeTaskStatus; import com.dispose.common.NetflowDirection; import com.dispose.mapper.DisposeDeviceMapper; @@ -77,6 +78,7 @@ public class DisposeTaskMapperTest extends InitTestEnvironment { .accountId(uId) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.0.1") + .objectType(DisposeObjectType.IP) .planEndTime("30") .flowDirection(NetflowDirection.DIRECTION_BI) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS})) diff --git a/src/test/java/com/dispose/test/dev/service/DeviceTaskManagerServiceTest.java b/src/test/java/com/dispose/test/dev/service/DeviceTaskManagerServiceTest.java index dee5f256..a7ee324c 100644 --- a/src/test/java/com/dispose/test/dev/service/DeviceTaskManagerServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/DeviceTaskManagerServiceTest.java @@ -2,6 +2,7 @@ package com.dispose.test.dev.service; import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; +import com.dispose.common.DisposeObjectType; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; import com.dispose.manager.DisposeDeviceManager; @@ -99,6 +100,7 @@ public class DeviceTaskManagerServiceTest extends InitTestEnvironment { .accountId(uId) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.0.1") + .objectType(DisposeObjectType.IP) .planEndTime("30") .flowDirection(NetflowDirection.DIRECTION_BI) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS})) diff --git a/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java b/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java index cf84643f..649d4929 100644 --- a/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java @@ -3,6 +3,7 @@ package com.dispose.test.dev.service; import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; import com.dispose.common.DisposeConfigValue; +import com.dispose.common.DisposeObjectType; import com.dispose.common.DisposeTaskStatus; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; @@ -100,6 +101,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment { .accountId(1L) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.5.2") + .objectType(DisposeObjectType.IP) .planEndTime("30") .flowDirection(NetflowDirection.DIRECTION_IN) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})) @@ -138,6 +140,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment { .accountId(1L) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.5.2") + .objectType(DisposeObjectType.IP) .planEndTime("30") .flowDirection(NetflowDirection.DIRECTION_IN) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})) @@ -176,6 +179,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment { .accountId(1L) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.10.2") + .objectType(DisposeObjectType.IP) .planEndTime("60") .flowDirection(NetflowDirection.DIRECTION_IN) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new Integer[]{DDoSAttackType.ALL_ATTACKS.getValue()})) diff --git a/src/test/java/com/dispose/test/exec/impl/JsonTestCaseRun.java b/src/test/java/com/dispose/test/exec/impl/JsonTestCaseRun.java index f6e1e433..f87b8c06 100644 --- a/src/test/java/com/dispose/test/exec/impl/JsonTestCaseRun.java +++ b/src/test/java/com/dispose/test/exec/impl/JsonTestCaseRun.java @@ -54,7 +54,7 @@ public class JsonTestCaseRun extends CommonRestfulJson implements TestCaseRun { /** * The constant jsonIdFilter. */ - private static final Integer[] jsonIdFilter = new Integer[]{5}; + private static final Integer[] jsonIdFilter = new Integer[]{}; /** * The Spring method rule. */ diff --git a/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java b/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java index dbc5110a..e556bc96 100644 --- a/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java +++ b/src/test/java/com/dispose/test/testcase/qa/v200/P2TaskList.java @@ -2,6 +2,7 @@ package com.dispose.test.testcase.qa.v200; import com.dispose.common.DDoSAttackType; import com.dispose.common.DisposeCapacityType; +import com.dispose.common.DisposeObjectType; import com.dispose.common.ErrorCode; import com.dispose.common.NetflowDirection; import com.dispose.pojo.dto.protocol.task.GetTaskRsp; @@ -101,6 +102,7 @@ public class P2TaskList { .accountId(1L) .disposeCapacity(DisposeCapacityType.CLEANUP) .disposeObject("192.168.0." + i) + .objectType(DisposeObjectType.IP) .planEndTime("60") .flowDirection(NetflowDirection.DIRECTION_BI) .attackType(DDoSAttackType.getTypeMaskFromAttackType(new DDoSAttackType[]{DDoSAttackType.ALL_ATTACKS}))