1. 重构审核状态,将其转换为状态模式,添加Using状态(使用中)
2. 策略模板添加方法,通过反射判断防护等级中是否有字段为true
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.realtime.protection.configuration.entity.defense.template;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class TemplateTest {
|
||||
|
||||
@Test
|
||||
public void testSetHasProtectLevel() {
|
||||
Template template = new Template();
|
||||
ProtectLevel protectLevel = new ProtectLevel();
|
||||
protectLevel.setHasDNS(true);
|
||||
|
||||
template.setProtectLevelLow(new ProtectLevel());
|
||||
template.setProtectLevelMedium(new ProtectLevel());
|
||||
template.setProtectLevelHigh(new ProtectLevel());
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
template.setProtectLevelHigh(protectLevel);
|
||||
template.setHasProtectLevel();
|
||||
assertTrue(template.getHasProtectLevelHigh());
|
||||
assertFalse(template.getHasProtectLevelMedium());
|
||||
assertFalse(template.getHasProtectLevelLow());
|
||||
});
|
||||
|
||||
assertDoesNotThrow(() -> {
|
||||
template.setProtectLevelMedium(protectLevel);
|
||||
template.setProtectLevelHigh(new ProtectLevel());
|
||||
template.setHasProtectLevel();
|
||||
assertFalse(template.getHasProtectLevelHigh());
|
||||
assertTrue(template.getHasProtectLevelMedium());
|
||||
assertFalse(template.getHasProtectLevelLow());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.realtime.protection.configuration.utils.enums;
|
||||
|
||||
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class RuleEnumTest {
|
||||
StaticRuleObject staticRuleObject;
|
||||
|
||||
public RuleEnumTest() {
|
||||
staticRuleObject = new StaticRuleObject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleEnum() {
|
||||
assertDoesNotThrow(() -> {
|
||||
this.staticRuleObject.setStaticRuleDip("255.255.255.255");
|
||||
assertTrue(RuleEnum.checkValidate(staticRuleObject));
|
||||
this.staticRuleObject.setStaticRuleMsip("255.255.255.255");
|
||||
assertFalse(RuleEnum.checkValidate(staticRuleObject));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
|
||||
object.setDynamicRuleRange("北京");
|
||||
object.setDynamicRuleProtectLevel(2);
|
||||
object.setTemplateId(templates.get(0).getTemplateId());
|
||||
object.setLogRuleId(1);
|
||||
object.setLogRuleId(1L);
|
||||
object.setProtectObjectIds(List.of(new Integer[]{protectObject.get(0).getProtectObjectId()}));
|
||||
Integer dynamicRuleId = dynamicRuleService.newDynamicRuleObject(object);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user