DinnerPermsResolver implements PermissionsResolver { @Override public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } DinnerPermsResolver(Server server); static PermissionsResolver factory(Server server, YAMLProcessor config); @Override void load(); @Override boolean hasPermission(String name, String permission); @Override boolean hasPermission(String worldName, String name, String permission); @Override boolean inGroup(String name, String group); @Override String[] getGroups(String name); @Override boolean hasPermission(OfflinePlayer player, String permission); @Override boolean hasPermission(String worldName, OfflinePlayer player, String permission); @Override boolean inGroup(OfflinePlayer player, String group); @Override String[] getGroups(OfflinePlayer player); Permissible getPermissible(OfflinePlayer offline); int internalHasPermission(Permissible perms, String permission); @Override String getDetectionMessage(); static final String GROUP_PREFIX; }
@Test public void testBasicResolving() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); permissible.setPermission("testperm.test1", true); assertTrue(resolver.hasPermission(permissible, "testperm.test1")); assertFalse(resolver.hasPermission(permissible, "testperm.somethingelse")); assertFalse(resolver.hasPermission(permissible, "testperm.test1.anything")); assertFalse(resolver.hasPermission(permissible, "completely.unrelated")); permissible.clearPermissions(); }
@Test public void testBasicWildcardResolution() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); permissible.setPermission("commandbook.spawnmob.*", true); assertTrue(resolver.hasPermission(permissible, "commandbook.spawnmob.pig")); assertTrue(resolver.hasPermission(permissible, "commandbook.spawnmob.spider")); assertTrue(resolver.hasPermission(permissible, "commandbook.spawnmob.spider.skeleton")); permissible.clearPermissions(); }
@Test public void testNegatingNodes() { final TestOfflinePermissible permissible = new TestOfflinePermissible(); permissible.setPermission("commandbook.*", true); permissible.setPermission("commandbook.cuteasianboys", false); permissible.setPermission("commandbook.warp.*", false); permissible.setPermission("commandbook.warp.create", true); assertTrue(resolver.hasPermission(permissible, "commandbook.motd")); assertFalse(resolver.hasPermission(permissible, "commandbook.cuteasianboys")); assertFalse(resolver.hasPermission(permissible, "commandbook.warp.remove")); assertTrue(resolver.hasPermission(permissible, "commandbook.warp.create")); permissible.clearPermissions(); }