use of fr.neatmonster.nocheatplus.permissions.PermissionPolicy in project NoCheatPlus by NoCheatPlus.
the class TestPermissionPolicy method testFromConfigString.
private void testFromConfigString(PermissionPolicy policy) {
String to = policy.policyToConfigLine();
PermissionPolicy policy2 = new PermissionPolicy();
policy2.setPolicyFromConfigLine(to);
if (!policy.isPolicyEquivalent(policy2)) {
fail("to+from config string yields non equivalent policy.");
}
}
use of fr.neatmonster.nocheatplus.permissions.PermissionPolicy in project NoCheatPlus by NoCheatPlus.
the class TestPermissionPolicy method testFromConfigString.
@Test
public void testFromConfigString() {
PermissionPolicy policy1 = new PermissionPolicy();
testFromConfigString(policy1, "ALWAYS", "ALWAYS +offline", "ALWAYS +WORLD", "ALWAYS +world +offline", "ALWAYS:+offline +world");
testFromConfigString(policy1);
policy1.fetchingPolicyInterval(100);
testFromConfigString(policy1, "INTERVAL0.1", "INTERVAL 0.1", "Interval 0.1 +ofFline");
testFromConfigString(policy1);
policy1.invalidationOffline(false);
testFromConfigString(policy1, "INTERVAL 0.1 -offline");
testFromConfigString(policy1);
policy1.invalidationWorld(false);
testFromConfigString(policy1, "INTERVAL 0.1 -world -offline", "INTERVAL 0.1 -offline -world");
testFromConfigString(policy1);
}
use of fr.neatmonster.nocheatplus.permissions.PermissionPolicy in project NoCheatPlus by NoCheatPlus.
the class TestPermissionPolicy method testFromConfigString.
private void testFromConfigString(PermissionPolicy equivalent, String... inputs) {
for (String input : inputs) {
PermissionPolicy policy2 = new PermissionPolicy();
policy2.setPolicyFromConfigLine(input);
if (!equivalent.isPolicyEquivalent(policy2)) {
fail("Expect equivalent policy to '" + equivalent.policyToConfigLine() + "', got instead: " + policy2.policyToConfigLine());
}
}
}
use of fr.neatmonster.nocheatplus.permissions.PermissionPolicy in project NoCheatPlus by NoCheatPlus.
the class TestPermissionPolicy method testConfigString.
@Test
public void testConfigString() {
PermissionPolicy policy1 = new PermissionPolicy();
testToConfigString(policy1, "ALWAYS");
policy1.fetchingPolicyInterval(100);
testToConfigString(policy1, "INTERVAL:0.1");
policy1.invalidationOffline(false);
testToConfigString(policy1, "INTERVAL:0.1,-offline");
policy1.invalidationWorld(false);
testToConfigString(policy1, "INTERVAL:0.1,-offline,-world");
}
use of fr.neatmonster.nocheatplus.permissions.PermissionPolicy in project NoCheatPlus by NoCheatPlus.
the class TestPermissionSettings method testRegex.
@Test
public void testRegex() {
PermissionPolicy dummy = new PermissionPolicy();
String regex = "^nocheatplus\\.checks\\..*\\.silent$";
String permissionName = "nocheatplus.checks.moving.survivalfly.silent";
// Also/rather a config test.
if (!permissionName.matches(regex)) {
fail("Expect regex to match.");
}
PermissionRule rule = PermissionSettings.getMatchingRule("regex:" + regex, dummy);
if (rule == null) {
fail("Expect factory to return a regex rule.");
}
if (!rule.matches(permissionName)) {
fail("Expect rule to match permissions name.");
}
if (rule.matches("xy" + permissionName) || rule.matches(permissionName + "yx")) {
fail("Rule matches wrong start/end.");
}
}
Aggregations