Merge branch 'v2.0.0_dev' of git.komect.net:DDOSAQ/phoenix_ddos_handle into v2.0.0_dev
This commit is contained in:
commit
f288e01197
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
<select id="addUserAccount" resultMap="user_account">
|
<select id="addUserAccount" resultMap="user_account">
|
||||||
INSERT INTO user_account(username, password, operators, status)
|
INSERT INTO user_account(username, password, operators, status)
|
||||||
SELECT #{username}, #{password}, #{operators}, ${@com.dispose.common.ObjectStatus@NORMAL.getCode()}
|
SELECT #{username}, #{password}, #{operators}, ${@com.dispose.common.ObjectStatus@NORMAL.getValue()}
|
||||||
FROM DUAL
|
FROM DUAL
|
||||||
WHERE NOT EXISTS(
|
WHERE NOT EXISTS(
|
||||||
SELECT username
|
SELECT username
|
||||||
|
|
|
@ -119,16 +119,12 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
userAccountManager.setUserPwdErrTimes(v.getUsername(), i);
|
userAccountManager.setUserPwdErrTimes(v.getUsername(), i);
|
||||||
|
|
||||||
UserAccount user = userAccountMapper.getUserByName(v.getUsername());
|
|
||||||
|
|
||||||
int times = userAccountManager.getUsrPwdErrTimes(v.getUsername());
|
int times = userAccountManager.getUsrPwdErrTimes(v.getUsername());
|
||||||
|
|
||||||
Assert.assertNotNull(user);
|
|
||||||
Assert.assertEquals(i, (long) user.getPwdErrTimes());
|
|
||||||
Assert.assertEquals(i, times);
|
Assert.assertEquals(i, times);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(user));
|
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(userAccountManager.getUserByName(v.getUsername())));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
|
@ -147,12 +143,15 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
String userToken = userAccountManager.getUserToken(v.getUsername());
|
String userToken = userAccountManager.getUserToken(v.getUsername());
|
||||||
UserAccount user = userAccountMapper.getUserByName(v.getUsername());
|
UserAccount user = userAccountMapper.getUserByName(v.getUsername());
|
||||||
|
|
||||||
Assert.assertNotNull(userToken);
|
if(user.getToken().length() != 0){
|
||||||
Assert.assertEquals(user.getToken(), userToken);
|
Assert.assertNotNull(userToken);
|
||||||
|
|
||||||
userAccountManager.cleanUserToken(v.getUsername());
|
Assert.assertEquals(user.getToken(), userToken);
|
||||||
|
|
||||||
Assert.assertEquals(ErrorCode.ERR_LOGOUT, userAccountManager.verifyToken(userToken));
|
userAccountManager.cleanUserToken(v.getUsername());
|
||||||
|
|
||||||
|
Assert.assertEquals(ErrorCode.ERR_LOGOUT, userAccountManager.verifyToken(userToken));
|
||||||
|
}
|
||||||
|
|
||||||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(v));
|
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(v));
|
||||||
} catch (JsonProcessingException | NoSuchAlgorithmException e) {
|
} catch (JsonProcessingException | NoSuchAlgorithmException e) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.dispose.common.DisposeCapacityType;
|
||||||
import com.dispose.common.DisposeObjectType;
|
import com.dispose.common.DisposeObjectType;
|
||||||
import com.dispose.common.IpAddrType;
|
import com.dispose.common.IpAddrType;
|
||||||
import com.dispose.mapper.DisposeCapacityMapper;
|
import com.dispose.mapper.DisposeCapacityMapper;
|
||||||
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
import com.dispose.pojo.entity.DisposeCapacity;
|
import com.dispose.pojo.entity.DisposeCapacity;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -40,6 +41,11 @@ public class DisposeCapacityMapperTest {
|
||||||
*/
|
*/
|
||||||
@Resource
|
@Resource
|
||||||
DisposeCapacityMapper disposeCapacityMapper;
|
DisposeCapacityMapper disposeCapacityMapper;
|
||||||
|
/**
|
||||||
|
* The Dispose device mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
DisposeDeviceMapper disposeDeviceMapper;
|
||||||
/**
|
/**
|
||||||
* The Object mapper.
|
* The Object mapper.
|
||||||
*/
|
*/
|
||||||
|
@ -55,23 +61,28 @@ public class DisposeCapacityMapperTest {
|
||||||
public void a1_addNewDisposeCapacity() throws JsonProcessingException {
|
public void a1_addNewDisposeCapacity() throws JsonProcessingException {
|
||||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||||
|
|
||||||
|
Long deviceId = disposeDeviceMapper.selectAll().get(0).getId();
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
|
||||||
.capacityType(DisposeCapacityType.CLEANUP)
|
.capacityType(DisposeCapacityType.CLEANUP)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.protectIp("")
|
.protectIp("")
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLOCKING)
|
||||||
.objectType(DisposeObjectType.URL)
|
.objectType(DisposeObjectType.URL)
|
||||||
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.protectIp("")
|
.protectIp("")
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(newCapList));
|
||||||
|
|
||||||
int items = disposeCapacityMapper.addNewDisposeCapacity(newCapList);
|
int items = disposeCapacityMapper.addNewDisposeCapacity(newCapList);
|
||||||
|
log.info("+++++++++++++item {}", items);
|
||||||
|
|
||||||
Assert.assertEquals(items, newCapList.size());
|
Assert.assertEquals(items, newCapList.size());
|
||||||
|
|
||||||
|
@ -89,8 +100,10 @@ public class DisposeCapacityMapperTest {
|
||||||
public void a2_delDisposeCapacity() throws JsonProcessingException {
|
public void a2_delDisposeCapacity() throws JsonProcessingException {
|
||||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||||
|
|
||||||
|
Long deviceId = disposeDeviceMapper.selectAll().get(0).getId();
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.CLEANUP)
|
.capacityType(DisposeCapacityType.CLEANUP)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
@ -98,7 +111,7 @@ public class DisposeCapacityMapperTest {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLOCKING)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
@ -116,7 +129,7 @@ public class DisposeCapacityMapperTest {
|
||||||
items = disposeCapacityMapper.delDisposeCapacity(capList.get(0).getDeviceId(),
|
items = disposeCapacityMapper.delDisposeCapacity(capList.get(0).getDeviceId(),
|
||||||
capList.get(0).getCapacityType().getValue());
|
capList.get(0).getCapacityType().getValue());
|
||||||
|
|
||||||
Assert.assertEquals(items, 2);
|
Assert.assertNotEquals(items, 0);
|
||||||
|
|
||||||
List<DisposeCapacity> caps = disposeCapacityMapper.selectAll();
|
List<DisposeCapacity> caps = disposeCapacityMapper.selectAll();
|
||||||
|
|
||||||
|
@ -132,8 +145,10 @@ public class DisposeCapacityMapperTest {
|
||||||
public void a3_delDeviceDisposeCapacity() {
|
public void a3_delDeviceDisposeCapacity() {
|
||||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||||
|
|
||||||
|
Long deviceId = disposeDeviceMapper.selectAll().get(0).getId();
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.CLEANUP)
|
.capacityType(DisposeCapacityType.CLEANUP)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
@ -141,7 +156,7 @@ public class DisposeCapacityMapperTest {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLOCKING)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
@ -150,10 +165,7 @@ public class DisposeCapacityMapperTest {
|
||||||
|
|
||||||
Assert.assertEquals(disposeCapacityMapper.addNewDisposeCapacity(newCapList), newCapList.size());
|
Assert.assertEquals(disposeCapacityMapper.addNewDisposeCapacity(newCapList), newCapList.size());
|
||||||
|
|
||||||
List<DisposeCapacity> capList = disposeCapacityMapper.getDeviceDisposeCapacity(1L);
|
Assert.assertNotEquals(disposeCapacityMapper.delDeviceDisposeCapacity(newCapList.get(0).getDeviceId()), 0);
|
||||||
|
|
||||||
Assert.assertEquals(disposeCapacityMapper.delDeviceDisposeCapacity(newCapList.get(0).getDeviceId()),
|
|
||||||
capList.size());
|
|
||||||
|
|
||||||
Assert.assertEquals(0, disposeCapacityMapper.selectAll().size());
|
Assert.assertEquals(0, disposeCapacityMapper.selectAll().size());
|
||||||
}
|
}
|
||||||
|
@ -167,8 +179,10 @@ public class DisposeCapacityMapperTest {
|
||||||
public void b1_getDeviceDisposeCapacity() throws JsonProcessingException {
|
public void b1_getDeviceDisposeCapacity() throws JsonProcessingException {
|
||||||
List<DisposeCapacity> newCapList = new ArrayList<>();
|
List<DisposeCapacity> newCapList = new ArrayList<>();
|
||||||
|
|
||||||
|
Long deviceId = disposeDeviceMapper.selectAll().get(0).getId();
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.CLEANUP)
|
.capacityType(DisposeCapacityType.CLEANUP)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
@ -176,7 +190,7 @@ public class DisposeCapacityMapperTest {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
newCapList.add(DisposeCapacity.builder()
|
newCapList.add(DisposeCapacity.builder()
|
||||||
.deviceId(1L)
|
.deviceId(deviceId)
|
||||||
.ipType(IpAddrType.IPV4_IPV6)
|
.ipType(IpAddrType.IPV4_IPV6)
|
||||||
.capacityType(DisposeCapacityType.BLOCKING)
|
.capacityType(DisposeCapacityType.BLOCKING)
|
||||||
.objectType(DisposeObjectType.IP)
|
.objectType(DisposeObjectType.IP)
|
||||||
|
|
|
@ -110,40 +110,42 @@ public class DisposeDeviceMapperTest {
|
||||||
List<DisposeDevice> devList = disposeDeviceMapper.selectAll();
|
List<DisposeDevice> devList = disposeDeviceMapper.selectAll();
|
||||||
|
|
||||||
devList.forEach(v -> {
|
devList.forEach(v -> {
|
||||||
DisposeDevice dev = disposeDeviceMapper.getDeviceByAddress(v.getIpAddr(), v.getIpPort());
|
if(v.getIpPort().length() != 0){
|
||||||
|
DisposeDevice dev = disposeDeviceMapper.getDeviceByAddress(v.getIpAddr(), v.getIpPort());
|
||||||
|
|
||||||
String beforeVer = dev.getVersion();
|
String beforeVer = dev.getVersion();
|
||||||
if (dev.getVersion().equals("B5.2.27.7")) {
|
if (dev.getVersion().equals("B5.2.27.7")) {
|
||||||
dev.setVersion("5.7.13");
|
dev.setVersion("5.7.13");
|
||||||
} else {
|
} else {
|
||||||
dev.setVersion("B5.2.27.7");
|
dev.setVersion("B5.2.27.7");
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeDevice newDev = DisposeDevice.builder()
|
DisposeDevice newDev = DisposeDevice.builder()
|
||||||
.id(dev.getId())
|
.id(dev.getId())
|
||||||
.ipAddr("10.88.77.15")
|
.ipAddr("10.88.77.15")
|
||||||
.ipPort("")
|
.ipPort("")
|
||||||
.deviceType(DisposeDeviceType.DPTECH_UMC)
|
.deviceType(DisposeDeviceType.DPTECH_UMC)
|
||||||
.areaCode(0)
|
.areaCode(0)
|
||||||
.deviceName("中移杭研实验室迪普清洗设备")
|
.deviceName("中移杭研实验室迪普清洗设备")
|
||||||
.manufacturer("DPTech")
|
.manufacturer("DPTech")
|
||||||
.model("UMC")
|
.model("UMC")
|
||||||
.version(dev.getVersion())
|
.version(dev.getVersion())
|
||||||
.userName("admin")
|
.userName("admin")
|
||||||
.password("UMCAdministrator")
|
.password("UMCAdministrator")
|
||||||
.urlPath("UMC/service/AbnormalFlowCleaningService")
|
.urlPath("UMC/service/AbnormalFlowCleaningService")
|
||||||
.urlType(HttpType.HTTP)
|
.urlType(HttpType.HTTP)
|
||||||
.readme("实验室测试设备")
|
.readme("实验室测试设备")
|
||||||
.status(ObjectStatus.NORMAL)
|
.status(ObjectStatus.NORMAL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Assert.assertEquals(1, disposeDeviceMapper.upgradeDisposeDevice(newDev));
|
Assert.assertEquals(1, disposeDeviceMapper.upgradeDisposeDevice(newDev));
|
||||||
Assert.assertNotNull(dev.getId());
|
Assert.assertNotNull(dev.getId());
|
||||||
Assert.assertNotEquals(disposeDeviceMapper.getDeviceById(newDev.getId()).getVersion(), beforeVer);
|
Assert.assertNotEquals(disposeDeviceMapper.getDeviceById(newDev.getId()).getVersion(), beforeVer);
|
||||||
try {
|
try {
|
||||||
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dev));
|
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(dev));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -152,9 +154,7 @@ public class DisposeDeviceMapperTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* D 1 get dispose device by ipAddr and ipPort.
|
* D 1 get dispose device by ipAddr and ipPort.processing exception
|
||||||
*
|
|
||||||
* @throws JsonProcessingException the json processing exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void d1_getDeviceByAddress() {
|
public void d1_getDeviceByAddress() {
|
||||||
|
@ -164,10 +164,12 @@ public class DisposeDeviceMapperTest {
|
||||||
DisposeDevice dev = disposeDeviceMapper.getDeviceByAddress(v.getIpAddr(), v.getIpPort());
|
DisposeDevice dev = disposeDeviceMapper.getDeviceByAddress(v.getIpAddr(), v.getIpPort());
|
||||||
Assert.assertNotNull(dev);
|
Assert.assertNotNull(dev);
|
||||||
|
|
||||||
dev = disposeDeviceMapper.getDeviceByAddress(v.getIpAddr(),
|
if(v.getIpPort().length() != 0){
|
||||||
String.valueOf(Long.parseLong(Optional.ofNullable(v.getIpPort()).orElse("123")) + 1));
|
dev = disposeDeviceMapper.getDeviceByAddress(v.getIpAddr(),
|
||||||
|
String.valueOf(Long.parseLong(Optional.ofNullable(v.getIpPort()).orElse("123")) + 1));
|
||||||
|
|
||||||
Assert.assertNull(dev);
|
Assert.assertNull(dev);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue