mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-07 12:48:03 +02:00
#604 Fix HelpProvider tests
This commit is contained in:
parent
3ad00a45f9
commit
30b72bec4c
@ -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
|
||||
|
@ -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 <player>, 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);
|
||||
}
|
||||
|
@ -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"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user