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.");
}
}
Aggregations