diff --git a/src/main/java/fr/xephi/authme/command/CommandDescription.java b/src/main/java/fr/xephi/authme/command/CommandDescription.java index 595f513d..7ff0e739 100644 --- a/src/main/java/fr/xephi/authme/command/CommandDescription.java +++ b/src/main/java/fr/xephi/authme/command/CommandDescription.java @@ -1,6 +1,5 @@ package fr.xephi.authme.command; -import fr.xephi.authme.permission.DefaultPermission; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.util.CollectionUtils; import fr.xephi.authme.util.StringUtils; @@ -287,7 +286,7 @@ public class CommandDescription { } /** - * Add a permission node that the a user must have to execute the command. + * Add a permission node that a user must have to execute the command. * * @param permission The PermissionNode to add * @return The builder diff --git a/src/test/java/fr/xephi/authme/command/TestCommandsUtil.java b/src/test/java/fr/xephi/authme/command/TestCommandsUtil.java index 2fc4c215..65fb74e2 100644 --- a/src/test/java/fr/xephi/authme/command/TestCommandsUtil.java +++ b/src/test/java/fr/xephi/authme/command/TestCommandsUtil.java @@ -1,7 +1,7 @@ package fr.xephi.authme.command; import fr.xephi.authme.command.executable.HelpCommand; -import fr.xephi.authme.permission.DefaultPermission; +import fr.xephi.authme.permission.AdminPermission; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.permission.PlayerPermission; @@ -43,8 +43,8 @@ public final class TestCommandsUtil { .description("test").detailedDescription("Test.").withArgument("Query", "", false).build(); // Register /unregister , alias: /unreg - CommandDescription unregisterBase = createCommand(null, null, asList("unregister", "unreg"), - newArgument("player", false)); + CommandDescription unregisterBase = createCommand(AdminPermission.UNREGISTER, null, + asList("unregister", "unreg"), newArgument("player", false)); return newHashSet(authMeBase, emailBase, unregisterBase); } diff --git a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java index 7c6cf74d..1c877b73 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpProviderTest.java @@ -4,15 +4,14 @@ import fr.xephi.authme.command.CommandDescription; import fr.xephi.authme.command.FoundCommandResult; import fr.xephi.authme.command.FoundResultStatus; import fr.xephi.authme.command.TestCommandsUtil; +import fr.xephi.authme.permission.AdminPermission; import fr.xephi.authme.permission.PermissionsManager; -import fr.xephi.authme.permission.PlayerPermission; import fr.xephi.authme.settings.NewSetting; import fr.xephi.authme.settings.properties.PluginSettings; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import java.util.Arrays; @@ -125,14 +124,12 @@ public class HelpProviderTest { } @Test - @Ignore - // TODO Gnat008 20160530: Update tests for new PermissionNode setup public void shouldShowAndEvaluatePermissions() { // given - CommandDescription command = getCommandWithLabel(commands, "authme", "login"); - FoundCommandResult result = newFoundResult(command, Collections.singletonList("authme")); + CommandDescription command = getCommandWithLabel(commands, "unregister"); + FoundCommandResult result = newFoundResult(command, Collections.singletonList("unreg")); given(sender.isOp()).willReturn(true); - given(permissionsManager.hasPermission(sender, PlayerPermission.LOGIN)).willReturn(true); + given(permissionsManager.hasPermission(sender, AdminPermission.UNREGISTER)).willReturn(true); given(permissionsManager.hasPermission(sender, command)).willReturn(true); // when @@ -142,20 +139,18 @@ public class HelpProviderTest { assertThat(lines, hasSize(5)); assertThat(removeColors(lines.get(1)), containsString("Permissions:")); assertThat(removeColors(lines.get(2)), - containsString(PlayerPermission.LOGIN.getNode() + " (You have permission)")); + containsString(AdminPermission.UNREGISTER.getNode() + " (You have permission)")); assertThat(removeColors(lines.get(3)), containsString("Default: OP's only (You have permission)")); assertThat(removeColors(lines.get(4)), containsString("Result: You have permission")); } @Test - @Ignore - // TODO Gnat008 20160530: Update tests for new PermissionNode setup public void shouldShowAndEvaluateForbiddenPermissions() { // given - CommandDescription command = getCommandWithLabel(commands, "authme", "login"); - FoundCommandResult result = newFoundResult(command, Collections.singletonList("authme")); + CommandDescription command = getCommandWithLabel(commands, "unregister"); + FoundCommandResult result = newFoundResult(command, Collections.singletonList("unregister")); given(sender.isOp()).willReturn(false); - given(permissionsManager.hasPermission(sender, PlayerPermission.LOGIN)).willReturn(false); + given(permissionsManager.hasPermission(sender, AdminPermission.UNREGISTER)).willReturn(false); given(permissionsManager.hasPermission(sender, command)).willReturn(false); // when @@ -165,7 +160,7 @@ public class HelpProviderTest { assertThat(lines, hasSize(5)); assertThat(removeColors(lines.get(1)), containsString("Permissions:")); assertThat(removeColors(lines.get(2)), - containsString(PlayerPermission.LOGIN.getNode() + " (No permission)")); + containsString(AdminPermission.UNREGISTER.getNode() + " (No permission)")); assertThat(removeColors(lines.get(3)), containsString("Default: OP's only (No permission)")); assertThat(removeColors(lines.get(4)), containsString("Result: No permission")); }