Merge remote-tracking branch 'origin/master'

This commit is contained in:
PushM
2024-04-17 22:16:39 +08:00
32 changed files with 410 additions and 93 deletions

View File

@@ -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());
});
}
}

View File

@@ -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));
});
}
}