1、任务、规则、白名单、策略模板新增更多的分页查询条件

This commit is contained in:
PushM
2024-05-07 22:33:59 +08:00
parent d6c487cd12
commit 3ce05a1e11
32 changed files with 317 additions and 85 deletions

View File

@@ -49,7 +49,7 @@ public class AlertMessageTest {
null, null, null, null,
null, null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 1);
null, null, null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2");

View File

@@ -84,7 +84,7 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test
void testQueryTemplate() {
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 5);
null, null, null,null, null,1, 5);
templates.forEach(item -> System.out.println(item)) ;
//// assertEquals(5, templates.size());
// for (Template template : templates) {i
@@ -97,7 +97,7 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTemplateSuccess() {
List<Template> templates = templateService.queryTemplates(
"DDOS", null, null, 1, 1);
"DDOS", null, null, null, null,1, 1);
Template testTemplate = templates.get(0);
testTemplate.setTemplateName("洪泛型DDOS攻击-" + LocalDateTime.now());
@@ -107,7 +107,7 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTemplateAuditStatus(){
List<Template> templates = templateService.queryTemplates(
null, null, null, 1, 1);
null, null, null, null, null,1, 1);
Template testTemplate = templates.get(0);
templateService.updateAuditStatus(testTemplate.getTemplateId(), 2);
}

View File

@@ -42,7 +42,7 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
null,null,null,null,
null,null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null, 1, 1);
null, null, null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2");
@@ -71,7 +71,7 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
null,
1, 1);
List<Template> templates = templateService.queryTemplates(
null, null,null, 1, 1);
null, null,null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2");
@@ -129,24 +129,24 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
@Test
void testQueryDynamicRuleObject() {
List<DynamicRuleObject> objects = dynamicRuleService.queryDynamicRuleObject(
null,null,null, null,2,1, 10);
null,null,null, null,2,null,null,null,1, 10);
System.out.println(objects);
}
@Test
void testQueryDynamicRuleTotalNum(){
Integer num = dynamicRuleService.queryDynamicRuleTotalNum(
null,null,null,null,null);
null,null,null,null,null,null,null,null);
System.out.println(num);
}
@Test
void testUpdateDynamicRuleAuditStatusBatch(){
Map<Integer, Integer> map = new HashMap<>();
map.put(101, 1);
map.put(102, 2);
map.put(103, 2);
// map.put(101, 1);
map.put(110, 2);
map.put(112, 2);
// System.out.println(dynamicRuleMapper.queryAuditStatusByIds(map));
System.out.println(dynamicRuleService.updateAuditStatusBatch(map));
}

View File

@@ -99,13 +99,13 @@ public class StaticRuleServiceTest extends ProtectionApplicationTests {
@Test
void testQueryStaticRules(){
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(null, null, null, null,2, 1, 10);
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(null, null, null, null,null, null, null,2, 1, 10);
System.out.println(staticRuleObjects);
}
@Test
void testUpdateStaticRuleAuditStatusBatch(){
Map<Integer, Integer> map = new HashMap<>();
map.put(1325, 0);
map.put(1300, 0);
map.put(1326, 1);
map.put(1328, 1);

View File

@@ -73,14 +73,14 @@ class TaskServiceTest extends ProtectionApplicationTests {
void testNewTaskSuccess() {
for (int i = 1; i < 10; i++) {
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null,2, i, 2);
null, null, null, null,null, null, null,2, i, 2);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject ->
staticRuleIds.add(staticRuleObject.getStaticRuleId()));
task.setStaticRuleIds(staticRuleIds);
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleObject(
null, null, null, null,null, i, 2
null, null, null, null,null, null,null,null,i, 2
);
List<Integer> dynamicRuleIds = new ArrayList<>();
dynamicRuleObjects.forEach(dynamicRuleObject ->
@@ -107,7 +107,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testPageQueryTask(){
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, 1, 10);
List<Task> tasks = taskService.queryTasks(null, null, null, null, null,null, null, null, null, 1, 10);
System.out.println(tasks);
}
@@ -120,14 +120,14 @@ class TaskServiceTest extends ProtectionApplicationTests {
task.setTaskName(testName);
task.setTaskCreateUsername(testCreateName);
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null, null,1, 5);
null, null, null, null, null,null, null, null,1, 5);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject ->
staticRuleIds.add(staticRuleObject.getStaticRuleId()));
task.setStaticRuleIds(staticRuleIds);
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleObject(
null, null, null, null, null,1, 5
null, null, null, null, null,null, null, null, 1, 5
);
List<Integer> dynamicRuleIds = new ArrayList<>();
dynamicRuleObjects.forEach(dynamicRuleObject ->
@@ -142,17 +142,17 @@ class TaskServiceTest extends ProtectionApplicationTests {
}
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, 1, 10);
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 10);
assertEquals(10, tasks.size());
tasks = taskService.queryTasks(0, null, null, null, null, 1, 10);
tasks = taskService.queryTasks(0, null, null, null, null,null, null, null, null, 1, 10);
assertEquals(10, tasks.size());
tasks.forEach(task -> assertEquals(0, task.getTaskStatus()));
tasks = taskService.queryTasks(null, 0, null, null, null, 1, 10);
tasks = taskService.queryTasks(null, 0, null, null, null, null, null, null, null,1, 10);
assertEquals(0, tasks.size());
tasks = taskService.queryTasks(null, null, testName, null, null, 1, 10);
tasks = taskService.queryTasks(null, null, testName, null, null, null, null, null, null,1, 10);
assertEquals(10, tasks.size());
tasks.forEach(task -> assertEquals(testName, task.getTaskName()));
}
@@ -160,11 +160,11 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTasks() {
Task originalTask = taskService.queryTasks(
null, null, null, null, null, 1, 1)
null, null, null, null, null, null, null, null, null,1, 1)
.get(0);
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null, null,1, 4
null, null, null, null, null,null, null, null,1, 4
);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject -> staticRuleIds.add(staticRuleObject.getStaticRuleId()));
@@ -177,7 +177,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testDeleteTask() {
long testNum = taskService.queryTasks(null, null, null, null, null, 1, 10)
long testNum = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 10)
.get(0).getTaskId();
assertTrue(taskService.deleteTask(testNum));
@@ -186,7 +186,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testChangeAuditStatus() {
long testNum = taskService.queryTasks(null, null, null, null, null, 1, 1)
long testNum = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1)
.get(0).getTaskId();
assertTrue(taskService.changeTaskAuditStatus(testNum, 2));
@@ -294,7 +294,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
null, null, null, null,
null, null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 1);
null, null, null,null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("testStartDynamicTask");
@@ -332,4 +332,25 @@ class TaskServiceTest extends ProtectionApplicationTests {
System.out.println(commandService.queryCommandInfos(taskId, null, null, null, null, 1, 5));
}
}
@Test
void testUpdateDynamicRuleAuditStatusBatch(){
Map<Integer, Integer> map = new HashMap<>();
// map.put(101, 1);
map.put(43848, 0);
map.put(43849,0);
// System.out.println(dynamicRuleMapper.queryAuditStatusByIds(map));
System.out.println(taskService.updateAuditStatusBatch(map));
}
@Test
void testQueryDynamicRuleAuditStatus(){
System.out.println(taskService.queryTaskAuditStatus(43848L));
Map<Integer, Integer> map = new HashMap<>();
map.put(43848, 0);
map.put(43849,0);
System.out.println(taskService.queryAuditStatusBatch(map));
}
}

View File

@@ -36,7 +36,7 @@ class CommandServiceTest extends ProtectionApplicationTests {
@BeforeEach
void mockCommand() {
Task task = taskService.queryTasks(null, null, null, null, null, 1, 1).get(0);
Task task = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1).get(0);
FiveTupleWithMask fiveTupleWithMask = new FiveTupleWithMask();
fiveTupleWithMask.setMaskSourceIP("192.168.155.24");
@@ -66,7 +66,7 @@ class CommandServiceTest extends ProtectionApplicationTests {
@Test
void createCommands() {
List<TaskCommandInfo> taskCommandInfos = ListUtils.newArrayListWithExpectedSize(100);
Task task = taskService.queryTasks(null, null, null, null, null, 1, 1).get(0);
Task task = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1).get(0);
for (int i = 0; i < 100; i++) {
int port = i + 1000;
TaskCommandInfo taskCommandInfo = new TaskCommandInfo();
@@ -92,7 +92,7 @@ class CommandServiceTest extends ProtectionApplicationTests {
@Test
void queryCommandInfos() {
Task task = taskService.queryTasks(null, null, null, null, null, 1, 1).get(0);
Task task = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1).get(0);
List<TaskCommandInfo> taskCommandInfos = commandService.queryCommandInfos(task.getTaskId(),
null, null, null, null,1, 5);
assertTrue(taskCommandInfos != null && !taskCommandInfos.isEmpty());

View File

@@ -114,7 +114,7 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
Integer id = staticRuleService.newStaticRuleObject(staticRuleTest);
List<Integer> ruleIds = new ArrayList<>(List.of(id));
List<StaticRuleObject> staticRules= staticRuleService.queryStaticRule(null,null,null,null,null,1,2);
List<StaticRuleObject> staticRules= staticRuleService.queryStaticRule(null,null,null,null,null,null, null, null,1,2);
for (StaticRuleObject staticRule : staticRules) {
ruleIds.add(staticRule.getStaticRuleId());
}
@@ -128,4 +128,10 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
whiteListService.newWhiteListObject(whiteListObject);
System.out.println(whiteListService.whiteListStaticRulesCheck(ruleIds));
}
@Test
void testQueryWhiteListObject() {
List<WhiteListObject> whiteListObjects = whiteListService.queryWhiteListObject(null, null, null, null, null, 1, 2);
System.out.println(whiteListObjects);
}
}