use of fr.xephi.authme.service.ValidationService.ValidationResult in project AuthMeReloaded by AuthMe.
the class InputValidator method validatePassword.
private void validatePassword(CommandSender sender, String password) {
ValidationResult validationResult = validationService.validatePassword(password, "");
sender.sendMessage("Validation of password '" + password + "' returned:");
if (validationResult.hasError()) {
messages.send(sender, validationResult.getMessageKey(), validationResult.getArgs());
} else {
sender.sendMessage(ChatColor.DARK_GREEN + "Valid password!");
}
}
use of fr.xephi.authme.service.ValidationService.ValidationResult in project AuthMeReloaded by AuthMe.
the class PasswordRegisterExecutorTest method shouldDetectInvalidPasswordAndInformPlayer.
@Test
public void shouldDetectInvalidPasswordAndInformPlayer() {
// given
String password = "myPass";
String name = "player040";
given(validationService.validatePassword(password, name)).willReturn(new ValidationResult(MessageKey.PASSWORD_CHARACTERS_ERROR, "[a-z]"));
Player player = mockPlayerWithName(name);
PasswordRegisterParams params = PasswordRegisterParams.of(player, password, null);
// when
boolean result = executor.isRegistrationAdmitted(params);
// then
assertThat(result, equalTo(false));
verify(validationService).validatePassword(password, name);
verify(commonService).send(player, MessageKey.PASSWORD_CHARACTERS_ERROR, "[a-z]");
}
use of fr.xephi.authme.service.ValidationService.ValidationResult in project AuthMeReloaded by AuthMe.
the class ChangePasswordCommandTest method shouldRejectInvalidPassword.
@Test
public void shouldRejectInvalidPassword() {
// given
CommandSender sender = initPlayerWithName("abc12", true);
String password = "newPW";
given(validationService.validatePassword(password, "abc12")).willReturn(new ValidationResult(MessageKey.INVALID_PASSWORD_LENGTH));
// when
command.executeCommand(sender, Arrays.asList("tester", password));
// then
verify(validationService).validatePassword(password, "abc12");
verify(commandService).send(sender, MessageKey.INVALID_PASSWORD_LENGTH, new String[0]);
}
use of fr.xephi.authme.service.ValidationService.ValidationResult in project AuthMeReloaded by AuthMe.
the class ChangePasswordCommandTest method shouldForwardTheDataForValidPassword.
@Test
public void shouldForwardTheDataForValidPassword() {
// given
String oldPass = "oldpass";
String newPass = "abc123";
Player player = initPlayerWithName("parker", true);
given(validationService.validatePassword("abc123", "parker")).willReturn(new ValidationResult());
// when
command.executeCommand(player, Arrays.asList(oldPass, newPass));
// then
verify(validationService).validatePassword(newPass, "parker");
verify(commandService, never()).send(eq(player), any(MessageKey.class));
verify(management).performPasswordChange(player, oldPass, newPass);
}
use of fr.xephi.authme.service.ValidationService.ValidationResult in project AuthMeReloaded by AuthMe.
the class RegisterAdminCommandTest method shouldRejectAlreadyRegisteredAccount.
@Test
public void shouldRejectAlreadyRegisteredAccount() {
// given
String user = "my_name55";
String password = "@some-pass@";
given(validationService.validatePassword(password, user)).willReturn(new ValidationResult());
given(dataSource.isAuthAvailable(user)).willReturn(true);
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Arrays.asList(user, password));
TestHelper.runOptionallyAsyncTask(bukkitService);
// then
verify(validationService).validatePassword(password, user);
verify(commandService).send(sender, MessageKey.NAME_ALREADY_REGISTERED);
verify(dataSource, never()).saveAuth(any(PlayerAuth.class));
}
Aggregations