mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-21 23:21:32 +01:00
Messing up the test.
This commit is contained in:
parent
bd5d341e67
commit
9eeb510b08
@ -70,9 +70,7 @@ public class PasswordSecurityTest {
|
|||||||
String playerLowerCase = playerName.toLowerCase();
|
String playerLowerCase = playerName.toLowerCase();
|
||||||
String clearTextPass = "myPassTest";
|
String clearTextPass = "myPassTest";
|
||||||
|
|
||||||
PlayerAuth auth = mock(PlayerAuth.class);
|
given(dataSource.getPassword(playerName)).willReturn(password);
|
||||||
given(auth.getPassword()).willReturn(password);
|
|
||||||
given(dataSource.getAuth(playerName)).willReturn(auth);
|
|
||||||
given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(true);
|
given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(true);
|
||||||
PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.BCRYPT, pluginManager, false);
|
PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.BCRYPT, pluginManager, false);
|
||||||
|
|
||||||
@ -81,7 +79,7 @@ public class PasswordSecurityTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(true));
|
assertThat(result, equalTo(true));
|
||||||
verify(dataSource).getAuth(playerName);
|
verify(dataSource).getPassword(playerName);
|
||||||
verify(pluginManager).callEvent(any(PasswordEncryptionEvent.class));
|
verify(pluginManager).callEvent(any(PasswordEncryptionEvent.class));
|
||||||
verify(method).comparePassword(clearTextPass, password, playerLowerCase);
|
verify(method).comparePassword(clearTextPass, password, playerLowerCase);
|
||||||
}
|
}
|
||||||
@ -95,8 +93,7 @@ public class PasswordSecurityTest {
|
|||||||
String clearTextPass = "passw0Rd1";
|
String clearTextPass = "passw0Rd1";
|
||||||
|
|
||||||
PlayerAuth auth = mock(PlayerAuth.class);
|
PlayerAuth auth = mock(PlayerAuth.class);
|
||||||
given(auth.getPassword()).willReturn(password);
|
given(dataSource.getPassword(playerName)).willReturn(password);
|
||||||
given(dataSource.getAuth(playerName)).willReturn(auth);
|
|
||||||
given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(false);
|
given(method.comparePassword(clearTextPass, password, playerLowerCase)).willReturn(false);
|
||||||
PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.CUSTOM, pluginManager, false);
|
PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.CUSTOM, pluginManager, false);
|
||||||
|
|
||||||
@ -105,7 +102,7 @@ public class PasswordSecurityTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(dataSource).getAuth(playerName);
|
verify(dataSource).getPassword(playerName);
|
||||||
verify(pluginManager).callEvent(any(PasswordEncryptionEvent.class));
|
verify(pluginManager).callEvent(any(PasswordEncryptionEvent.class));
|
||||||
verify(method).comparePassword(clearTextPass, password, playerLowerCase);
|
verify(method).comparePassword(clearTextPass, password, playerLowerCase);
|
||||||
}
|
}
|
||||||
@ -116,7 +113,7 @@ public class PasswordSecurityTest {
|
|||||||
String playerName = "bobby";
|
String playerName = "bobby";
|
||||||
String clearTextPass = "tables";
|
String clearTextPass = "tables";
|
||||||
|
|
||||||
given(dataSource.getAuth(playerName)).willReturn(null);
|
given(dataSource.getPassword(playerName)).willReturn(null);
|
||||||
PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.MD5, pluginManager, false);
|
PasswordSecurity security = new PasswordSecurity(dataSource, HashAlgorithm.MD5, pluginManager, false);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -124,7 +121,7 @@ public class PasswordSecurityTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
verify(dataSource).getAuth(playerName);
|
verify(dataSource).getPassword(playerName);
|
||||||
verify(pluginManager, never()).callEvent(any(Event.class));
|
verify(pluginManager, never()).callEvent(any(Event.class));
|
||||||
verify(method, never()).comparePassword(anyString(), any(HashedPassword.class), anyString());
|
verify(method, never()).comparePassword(anyString(), any(HashedPassword.class), anyString());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user