use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldSendMessageToPlayerWithTagReplacement.
@Test
public void shouldSendMessageToPlayerWithTagReplacement() {
// given
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = Mockito.mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
messages.send(sender, key, "1234");
// then
verify(sender, times(1)).sendMessage("Use /captcha 1234 to solve the captcha");
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class MessagesIntegrationTest method shouldLoadMessageAndSplitAtNewLines.
@Test
public void shouldLoadMessageAndSplitAtNewLines() {
// given
MessageKey key = MessageKey.UNKNOWN_USER;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when
String[] message = messages.retrieve(key, sender);
// then
String[] lines = new String[] { "We've got", "new lines", "and ' apostrophes" };
assertThat(message, equalTo(lines));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class AsyncChangePasswordTest method shouldUpdatePasswordOfLoggedInUser.
@Test
public void shouldUpdatePasswordOfLoggedInUser() {
// given
CommandSender sender = mock(CommandSender.class);
String player = "my_user12";
String password = "passPass";
given(playerCache.isAuthenticated(player)).willReturn(true);
HashedPassword hashedPassword = mock(HashedPassword.class);
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
given(dataSource.updatePassword(player, hashedPassword)).willReturn(true);
// when
asyncChangePassword.changePasswordAsAdmin(sender, player, password);
// then
verify(commonService).send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
verify(passwordSecurity).computeHash(password, player);
verify(dataSource).updatePassword(player, hashedPassword);
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class AsyncChangePasswordTest method shouldRejectCommandForUnknownUser.
@Test
public void shouldRejectCommandForUnknownUser() {
// given
CommandSender sender = mock(CommandSender.class);
String player = "player";
String password = "password";
given(playerCache.isAuthenticated(player)).willReturn(false);
given(dataSource.isAuthAvailable(player)).willReturn(false);
// when
asyncChangePassword.changePasswordAsAdmin(sender, player, password);
// then
verify(commonService).send(sender, MessageKey.UNKNOWN_USER);
verify(dataSource, only()).isAuthAvailable(player);
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class AsyncChangePasswordTest method shouldUpdatePasswordOfOfflineUser.
@Test
public void shouldUpdatePasswordOfOfflineUser() {
// given
CommandSender sender = mock(CommandSender.class);
String player = "my_user12";
String password = "passPass";
given(playerCache.isAuthenticated(player)).willReturn(false);
given(dataSource.isAuthAvailable(player)).willReturn(true);
HashedPassword hashedPassword = mock(HashedPassword.class);
given(passwordSecurity.computeHash(password, player)).willReturn(hashedPassword);
given(dataSource.updatePassword(player, hashedPassword)).willReturn(true);
// when
asyncChangePassword.changePasswordAsAdmin(sender, player, password);
// then
verify(commonService).send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
verify(passwordSecurity).computeHash(password, player);
verify(dataSource).updatePassword(player, hashedPassword);
}
Aggregations