Search in sources :

Example 1 with PermissionPolicy

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.");
    }
}
Also used : PermissionPolicy(fr.neatmonster.nocheatplus.permissions.PermissionPolicy)

Example 2 with PermissionPolicy

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);
}
Also used : PermissionPolicy(fr.neatmonster.nocheatplus.permissions.PermissionPolicy) Test(org.junit.Test)

Example 3 with PermissionPolicy

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());
        }
    }
}
Also used : PermissionPolicy(fr.neatmonster.nocheatplus.permissions.PermissionPolicy)

Example 4 with PermissionPolicy

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");
}
Also used : PermissionPolicy(fr.neatmonster.nocheatplus.permissions.PermissionPolicy) Test(org.junit.Test)

Example 5 with PermissionPolicy

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.");
    }
}
Also used : PermissionRule(fr.neatmonster.nocheatplus.permissions.PermissionSettings.PermissionRule) PermissionPolicy(fr.neatmonster.nocheatplus.permissions.PermissionPolicy) Test(org.junit.Test)

Aggregations

PermissionPolicy (fr.neatmonster.nocheatplus.permissions.PermissionPolicy)6 Test (org.junit.Test)3 ConfigFile (fr.neatmonster.nocheatplus.config.ConfigFile)1 PermissionSettings (fr.neatmonster.nocheatplus.permissions.PermissionSettings)1 PermissionRule (fr.neatmonster.nocheatplus.permissions.PermissionSettings.PermissionRule)1 RegisteredPermission (fr.neatmonster.nocheatplus.permissions.RegisteredPermission)1 UUID (java.util.UUID)1