package ca.nexapp.core.authentication;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static com.google.common.truth.Truth.assertThat;

@RunWith(MockitoJUnitRunner.class)
public class PasswordTest {

    byte[] aSalt = new byte[]{1, 2, 3, 4};
    byte[] aHash = new byte[]{11, 22, 33, 44, 55, 66, 77, 88};

    @Test
    public void givenASameHashAndSalt_ShouldBeEquals() {
        Password password1 = Password.fromHash(aHash, aSalt, null);
        Password password2 = Password.fromHash(aHash.clone(), aSalt.clone(), null);

        assertThat(password1).isEqualTo(password2);
    }

    @Test
    public void givenASameHashAndSalt_ShouldHaveEqualsHashCode() {
        int password1HashCode = Password.fromHash(aHash, aSalt, null).hashCode();
        int password2HashCode = Password.fromHash(aHash.clone(), aSalt.clone(), null).hashCode();

        assertThat(password1HashCode).isEqualTo(password2HashCode);
    }
}

@@ -33,16 +33,77 @@
 ation;%0A%0A
+import ca.nexapp.core.authentication.hashers.PasswordHasher;%0A
 import o
@@ -150,16 +150,41 @@
 unWith;%0A
+import org.mockito.Mock;%0A
 import o
@@ -352,20 +352,88 @@
     
+@Mock%0A    PasswordHasher passwordHasher;%0A%0A    private static final 
 byte%5B%5D 
-aSalt
+A_SALT
  = n
@@ -463,64 +463,248 @@
     
-byte%5B%5D aHash = new byte%5B%5D%7B11, 22, 33, 44, 55, 66, 77, 88
+private static final byte%5B%5D ANOTHER_SALT = new byte%5B%5D%7B5, 6, 7, 8%7D;%0A    private static final byte%5B%5D A_HASH = new byte%5B%5D%7B11, 22, 33, 44, 55, 66, 77, 88%7D;%0A    private static final byte%5B%5D ANOTHER_HASH = new byte%5B%5D%7B12, 23, 34, 45, 56, 67, 78, 89
 %7D;%0A%0A
@@ -726,37 +726,55 @@
 ublic void given
-ASame
+PasswordsWithEquivalent
 HashAndSalt_Shou
@@ -839,28 +839,276 @@
 ash(
-aHash, aSalt, null);
+A_HASH, A_SALT, passwordHasher);%0A        Password password2 = Password.fromHash(A_HASH.clone(), A_SALT.clone(), passwordHasher);%0A%0A        assertThat(password1).isEqualTo(password2);%0A    %7D%0A%0A    @Test%0A    public void givenPasswordsWithDifferentHash_ShouldNotBeEquals() %7B
 %0A   
@@ -1121,33 +1121,33 @@
 assword password
-2
+1
  = Password.from
@@ -1155,42 +1155,449 @@
 ash(
-aHash.clone(), aSalt.clone(), null
+A_HASH, A_SALT, passwordHasher);%0A        Password password2 = Password.fromHash(ANOTHER_HASH, A_SALT.clone(), passwordHasher);%0A%0A        assertThat(password1).isNotEqualTo(password2);%0A    %7D%0A%0A    @Test%0A    public void givenPasswordsWithDifferentSalt_ShouldNotBeEquals() %7B%0A        Password password1 = Password.fromHash(A_HASH, A_SALT, passwordHasher);%0A        Password password2 = Password.fromHash(A_HASH.clone(), ANOTHER_SALT, passwordHasher
 );%0A%0A
@@ -1620,32 +1620,35 @@
 at(password1).is
+Not
 EqualTo(password
@@ -1693,13 +1693,31 @@
 iven
-ASame
+PasswordsWithEquivalent
 Hash
@@ -1807,124 +1807,887 @@
 ash(
-aHash, aSalt, null).hashCode();%0A        int password2HashCode = Password.fromHash(aHash.clone(), aSalt.clone(), null
+A_HASH, A_SALT, passwordHasher).hashCode();%0A        int password2HashCode = Password.fromHash(A_HASH.clone(), A_SALT.clone(), passwordHasher).hashCode();%0A%0A        assertThat(password1HashCode).isEqualTo(password2HashCode);%0A    %7D%0A%0A    @Test%0A    public void givenPasswordsWithDifferentHash_ShouldNotHaveEqualsHashCode() %7B%0A        int password1HashCode = Password.fromHash(A_HASH, A_SALT, passwordHasher).hashCode();%0A        int password2HashCode = Password.fromHash(ANOTHER_HASH, A_SALT.clone(), passwordHasher).hashCode();%0A%0A        assertThat(password1HashCode).isNotEqualTo(password2HashCode);%0A    %7D%0A%0A    @Test%0A    public void givenPasswordsWithDifferentSalt_ShouldNotHaveEqualsHashCode() %7B%0A        int password1HashCode = Password.fromHash(A_HASH, A_SALT, passwordHasher).hashCode();%0A        int password2HashCode = Password.fromHash(A_HASH.clone(), ANOTHER_SALT, passwordHasher
 ).ha
@@ -2729,32 +2729,35 @@
 ord1HashCode).is
+Not
 EqualTo(password

Add tests for different passwords