use of org.icij.datashare.Repository in project datashare by ICIJ.
the class UsersInDbTest method find_user_in_db_with_password.
@Test
public void find_user_in_db_with_password() {
Repository repository = mock(Repository.class);
User expected = new User("foo", "bar", "mail", "icij", new HashMap<String, Object>() {
{
put("password", Hasher.SHA_256.hash("bar"));
}
});
when(repository.getUser("foo")).thenReturn(expected);
User actual = (User) new UsersInDb(repository).find("foo", "bar");
assertThat(actual.id).isEqualTo(expected.id);
assertThat(actual.name).isEqualTo(expected.name);
assertThat(actual.email).isEqualTo(expected.email);
assertThat(actual.details).isEqualTo(expected.details);
assertThat(actual.provider).isEqualTo(expected.provider);
}
use of org.icij.datashare.Repository in project datashare by ICIJ.
the class UsersInDbTest method find_user_in_db_with_bad_password.
@Test
public void find_user_in_db_with_bad_password() {
Repository repository = mock(Repository.class);
User expected = new User("foo", "bar", "mail", "icij", new HashMap<String, Object>() {
{
put("password", "unused");
}
});
when(repository.getUser("foo")).thenReturn(expected);
assertThat(new UsersInDb(repository).find("foo", "bad")).isNull();
}
use of org.icij.datashare.Repository in project datashare by ICIJ.
the class UsersInDbTest method find_user_in_db.
@Test
public void find_user_in_db() {
Repository repository = mock(Repository.class);
User expected = new User("foo", "bar", "mail", "icij", new HashMap<String, Object>() {
{
put("field1", "val1");
}
});
when(repository.getUser("foo")).thenReturn(expected);
User actual = (User) new UsersInDb(repository).find("foo");
assertThat(actual.id).isEqualTo(expected.id);
assertThat(actual.name).isEqualTo(expected.name);
assertThat(actual.email).isEqualTo(expected.email);
assertThat(actual.details).isEqualTo(expected.details);
assertThat(actual.provider).isEqualTo(expected.provider);
}
Aggregations