parent
8c44bb712c
commit
d79105f084
|
@ -0,0 +1,136 @@
|
|||
package com.dispose.test.dptech;
|
||||
|
||||
import com.dispose.ability.DisposeAbility;
|
||||
import com.dispose.ability.impl.DpTechAbilityImpl;
|
||||
import com.dispose.common.*;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.test.Global.InitTestEnvironment;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The type Dp tech interface test case.
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||
public static Integer DPTECH_UMC = 0;
|
||||
|
||||
/**
|
||||
* User login.
|
||||
*/
|
||||
@Override
|
||||
public void userLogin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets ability map key.
|
||||
*
|
||||
* @param ipAddr the ip addr
|
||||
* @param ipPort the ip port
|
||||
* @return the ability map key
|
||||
*/
|
||||
private String getAbilityMapKey(String ipAddr, String ipPort) {
|
||||
return (ipPort == null || ipPort.length() == 0) ? ipAddr : (ipAddr + ":" + ipPort);
|
||||
}
|
||||
|
||||
/**
|
||||
* T 1 get all detection object from umc.
|
||||
*/
|
||||
@Test
|
||||
public void t1_runDisposeTest() {
|
||||
DisposeAbility db;
|
||||
|
||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
||||
|
||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.15")
|
||||
.ipPort("")
|
||||
.deviceType(DisposeDeviceType.DPTECH_UMC)
|
||||
.areaCode(0)
|
||||
.deviceName("中移杭研实验室迪普清洗设备")
|
||||
.manufacturer("DPTech")
|
||||
.model("UMC")
|
||||
.version("5.7.13")
|
||||
.userName("admin")
|
||||
.password("UMCAdministrator")
|
||||
.urlPath("UMC/service/AbnormalFlowCleaningService")
|
||||
.urlType(HttpType.HTTP)
|
||||
.readme("实验室测试设备")
|
||||
.status(ObjectStatus.NORMAL)
|
||||
.build();
|
||||
|
||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
||||
String url = httpType + addr + "/" + dev.getUrlPath();
|
||||
|
||||
if (dev.getDeviceType().getValue().equals(DPTECH_UMC)) {
|
||||
db = new DpTechAbilityImpl();
|
||||
|
||||
// 初始化设备
|
||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
MulReturnType<ErrorCode, Long> ret = db.runDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
nfDirection, ddoSAttackType, -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* T 2 stop dispose task.
|
||||
*/
|
||||
@Test
|
||||
public void t2_stopDisposeTest() {
|
||||
DisposeAbility db;
|
||||
|
||||
NetflowDirection[] nfDirection = {NetflowDirection.DIRECTION_IN};
|
||||
|
||||
DDoSAttackType[] ddoSAttackType = {DDoSAttackType.ACK_FLOOD, DDoSAttackType.CHARGED_AMPLIFICATION};
|
||||
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr("10.88.77.15")
|
||||
.ipPort("")
|
||||
.deviceType(DisposeDeviceType.DPTECH_UMC)
|
||||
.areaCode(0)
|
||||
.deviceName("中移杭研实验室迪普清洗设备")
|
||||
.manufacturer("DPTech")
|
||||
.model("UMC")
|
||||
.version("5.7.13")
|
||||
.userName("admin")
|
||||
.password("UMCAdministrator")
|
||||
.urlPath("UMC/service/AbnormalFlowCleaningService")
|
||||
.urlType(HttpType.HTTP)
|
||||
.readme("实验室测试设备")
|
||||
.status(ObjectStatus.NORMAL)
|
||||
.build();
|
||||
|
||||
String httpType = dev.getUrlType() == HttpType.HTTP ? "http://" : "https://";
|
||||
String addr = getAbilityMapKey(dev.getIpAddr(), dev.getIpPort());
|
||||
String url = httpType + addr + "/" + dev.getUrlPath();
|
||||
|
||||
if (dev.getDeviceType().getValue().equals(DPTECH_UMC)) {
|
||||
db = new DpTechAbilityImpl();
|
||||
|
||||
// 初始化设备
|
||||
db.initDeviceEnv(url, dev.getUserName(), dev.getPassword());
|
||||
|
||||
Assert.assertTrue(db.getDeviceLinkStatus());
|
||||
MulReturnType<ErrorCode, Long> ret = db.stopDispose("192.168.3.5", DisposeCapacityType.CLEANUP,
|
||||
nfDirection, ddoSAttackType, -1L);
|
||||
|
||||
Assert.assertEquals(ret.getFirstParam(), ErrorCode.ERR_OK);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue