#415 Move some permission nodes out of authme.player.*

- Move certain permission nodes outside of the authme.player branch
- Update classes / permissions list
- Remove wildcard node from code completely (since not used)
This commit is contained in:
ljacqu
2016-02-14 14:15:02 +01:00
parent 5dc1598f6e
commit b3734f4010
16 changed files with 169 additions and 101 deletions
@@ -0,0 +1,56 @@
package fr.xephi.authme.permission;
import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
import static com.google.common.collect.Sets.newHashSet;
import static org.junit.Assert.fail;
/**
* Test for {@link PlayerStatePermission}.
*/
public class PlayerStatePermissionTest {
@Test
public void shouldStartWithAuthMeAdminPrefix() {
// given
String requiredPrefix = "authme.";
Set<String> forbiddenPrefixes = newHashSet("authme.player", "authme.admin");
// when/then
for (PlayerStatePermission permission : PlayerStatePermission.values()) {
if (!permission.getNode().startsWith(requiredPrefix)) {
fail("The permission '" + permission + "' does not start with the required prefix '"
+ requiredPrefix + "'");
} else if (hasAnyPrefix(permission.getNode(), forbiddenPrefixes)) {
fail("The permission '" + permission + "' should not start with any of " + forbiddenPrefixes);
}
}
}
@Test
public void shouldHaveUniqueNodes() {
// given
Set<String> nodes = new HashSet<>();
// when/then
for (PlayerStatePermission permission : PlayerStatePermission.values()) {
if (nodes.contains(permission.getNode())) {
fail("More than one enum value defines the node '" + permission.getNode() + "'");
}
nodes.add(permission.getNode());
}
}
private static boolean hasAnyPrefix(String node, Set<String> prefixes) {
for (String prefix : prefixes) {
if (node.startsWith(prefix)) {
return true;
}
}
return false;
}
}