#573 Remove exclusion for permission node check in test

This commit is contained in:
ljacqu 2016-03-01 20:48:15 +01:00
parent 8432e67fd8
commit 86042070e9

View File

@ -1,14 +1,13 @@
package fr.xephi.authme.command; package fr.xephi.authme.command;
import static fr.xephi.authme.permission.DefaultPermission.OP_ONLY; import fr.xephi.authme.permission.AdminPermission;
import static org.hamcrest.Matchers.equalTo; import fr.xephi.authme.permission.PermissionNode;
import static org.hamcrest.Matchers.not; import fr.xephi.authme.util.StringUtils;
import static org.hamcrest.Matchers.nullValue; import fr.xephi.authme.util.WrapperMock;
import static org.junit.Assert.assertThat; import org.junit.BeforeClass;
import static org.junit.Assert.fail; import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -17,13 +16,12 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.junit.BeforeClass; import static fr.xephi.authme.permission.DefaultPermission.OP_ONLY;
import org.junit.Test; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import fr.xephi.authme.permission.AdminPermission; import static org.hamcrest.Matchers.nullValue;
import fr.xephi.authme.permission.PermissionNode; import static org.junit.Assert.assertThat;
import fr.xephi.authme.util.StringUtils; import static org.junit.Assert.fail;
import fr.xephi.authme.util.WrapperMock;
/** /**
* Test for {@link CommandInitializer} to guarantee the integrity of the defined commands. * Test for {@link CommandInitializer} to guarantee the integrity of the defined commands.
@ -241,15 +239,11 @@ public class CommandInitializerTest {
public void shouldNotHavePlayerPermissionIfDefaultsToOpOnly() { public void shouldNotHavePlayerPermissionIfDefaultsToOpOnly() {
// given // given
BiConsumer adminPermissionChecker = new BiConsumer() { BiConsumer adminPermissionChecker = new BiConsumer() {
// The only exception to this check is the force login command, which should default to OP_ONLY
// but semantically it is a player permission
final List<String> forceLoginLabels = Arrays.asList("forcelogin", "login");
@Override @Override
public void accept(CommandDescription command, int depth) { public void accept(CommandDescription command, int depth) {
CommandPermissions permissions = command.getCommandPermissions(); CommandPermissions permissions = command.getCommandPermissions();
if (permissions != null && OP_ONLY.equals(permissions.getDefaultPermission())) { if (permissions != null && OP_ONLY.equals(permissions.getDefaultPermission())) {
if (!hasAdminNode(permissions) && !command.getLabels().equals(forceLoginLabels)) { if (!hasAdminNode(permissions)) {
fail("The command with labels " + command.getLabels() + " has OP_ONLY default " fail("The command with labels " + command.getLabels() + " has OP_ONLY default "
+ "permission but no permission node on admin level"); + "permission but no permission node on admin level");
} }