Search in sources :

Example 1 with PermissionRule

use of fr.neatmonster.nocheatplus.permissions.PermissionSettings.PermissionRule 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)1 PermissionRule (fr.neatmonster.nocheatplus.permissions.PermissionSettings.PermissionRule)1 Test (org.junit.Test)1