From d46a2f0755973e8cd1d3083172f9bb4b624ce6c6 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Thu, 31 Dec 2015 13:52:16 +0100 Subject: [PATCH] Fix test in PasswordSecurity for new savePassword() --- .../authme/security/PasswordSecurityTest.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java index 3e963ed92..d36810ab6 100644 --- a/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java +++ b/src/test/java/fr/xephi/authme/security/PasswordSecurityTest.java @@ -127,7 +127,6 @@ public class PasswordSecurityTest { verify(method, never()).comparePassword(anyString(), any(HashedPassword.class), anyString()); } - @Ignore @Test public void shouldTryOtherMethodsForFailedPassword() { // given @@ -140,11 +139,7 @@ public class PasswordSecurityTest { // MD5 hash for "Test" HashedPassword newPassword = new HashedPassword("0cbc6611f5540bd0809a388dc95a615b"); - PlayerAuth auth = mock(PlayerAuth.class); - doCallRealMethod().when(auth).getPassword(); - doCallRealMethod().when(auth).setPassword(any(HashedPassword.class)); - auth.setPassword(password); - given(dataSource.getAuth(argThat(equalToIgnoringCase(playerName)))).willReturn(auth); + given(dataSource.getPassword(argThat(equalToIgnoringCase(playerName)))).willReturn(password); given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(false); given(method.computeHash(clearTextPass, playerLowerCase)).willReturn(newPassword); PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.MD5, pluginManager, true); @@ -157,14 +152,10 @@ public class PasswordSecurityTest { // Note ljacqu 20151230: We need to check the player name in a case-insensitive way because the methods within // PasswordSecurity may convert the name into all lower-case. This is desired because EncryptionMethod methods // should only be invoked with all lower-case names. Data source is case-insensitive itself, so this is fine. - verify(dataSource, times(2)).getAuth(argThat(equalToIgnoringCase(playerName))); + verify(dataSource).getPassword(argThat(equalToIgnoringCase(playerName))); verify(pluginManager, times(2)).callEvent(any(PasswordEncryptionEvent.class)); verify(method).comparePassword(clearTextPass, password, playerLowerCase); - verify(auth).setPassword(newPassword); - - ArgumentCaptor captor = ArgumentCaptor.forClass(PlayerAuth.class); - verify(dataSource).updatePassword(captor.capture()); - assertThat(captor.getValue().getPassword(), equalTo(newPassword)); + verify(dataSource).updatePassword(playerLowerCase, newPassword); } @Test