diff --git a/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java b/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java index cc5a0315e..243e4b121 100644 --- a/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/register/RegisterCommand.java @@ -75,7 +75,7 @@ public class RegisterCommand extends PlayerCommand { RegistrationArgumentType registrationType = commonService.getProperty(REGISTRATION_TYPE); if (registrationType == PASSWORD_WITH_CONFIRMATION && !arguments.get(0).equals(arguments.get(1))) { commonService.send(player, MessageKey.PASSWORD_MATCH_ERROR); - } else if (registrationType == PASSWORD_WITH_EMAIL) { + } else if (registrationType == PASSWORD_WITH_EMAIL && arguments.size() > 1) { handlePasswordWithEmailRegistration(player, arguments); } else { management.performRegister(player, registrationExecutorProvider diff --git a/src/main/java/fr/xephi/authme/settings/properties/RegistrationArgumentType.java b/src/main/java/fr/xephi/authme/settings/properties/RegistrationArgumentType.java index 88bfcf3ec..60bcdfca8 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RegistrationArgumentType.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RegistrationArgumentType.java @@ -20,7 +20,7 @@ public enum RegistrationArgumentType { EMAIL_WITH_CONFIRMATION(Execution.EMAIL, 2, MessageKey.REGISTER_EMAIL_MESSAGE), /** /register [password] [email] */ - PASSWORD_WITH_EMAIL(Execution.PASSWORD, 2, MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE); + PASSWORD_WITH_EMAIL(Execution.PASSWORD, 1, MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE); private final Execution execution; private final int requiredNumberOfArgs; diff --git a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java index d896c4fb9..7b111cf96 100644 --- a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java @@ -27,6 +27,8 @@ import java.util.Arrays; import java.util.Collections; import static org.hamcrest.Matchers.containsString; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -276,17 +278,19 @@ public class RegisterCommandTest { } @Test - public void shouldFailForInsufficientArguments() { + public void shouldPerformNormalPasswordRegisterForOneArgument() { // given given(commonService.getProperty(RegistrationSettings.REGISTRATION_TYPE)) .willReturn(RegistrationArgumentType.PASSWORD_WITH_EMAIL); Player player = mock(Player.class); + RegistrationExecutor executor = mock(RegistrationExecutor.class); + given(registrationExecutorProvider.getPasswordRegisterExecutor(eq(player), anyString())).willReturn(executor); // when command.executeCommand(player, Collections.singletonList("myPass")); // then - verify(commonService).send(player, MessageKey.USAGE_REGISTER); - verifyZeroInteractions(management); + verify(registrationExecutorProvider).getPasswordRegisterExecutor(player, "myPass"); + verify(management).performRegister(player, executor); } }