use of org.mamute.model.User in project mamute by caelum.
the class UserDAOTest method should_search_by_email_and_legacy_password_and_update_password.
@Test
public void should_search_by_email_and_legacy_password_and_update_password() {
String password = "654321";
User gui = user("Guilherme Sonar", "gui@email.com.br");
LoginMethod brutalLogin = LoginMethod.brutalLogin(gui, "gui@email.com.br", password);
new Mirror().on(brutalLogin).set().field("token").withValue(MD5.crypt(password));
gui.add(brutalLogin);
users.save(gui);
session.save(brutalLogin);
assertNull(users.findByMailAndPassword("gui@email.com.br", password));
User found = users.findByMailAndLegacyPasswordAndUpdatePassword("gui@email.com.br", password);
assertEquals(gui, found);
assertEquals(Digester.encrypt(password), found.getBrutalLogin().getToken());
assertNull(users.findByMailAndPassword("joao.silveira@email.com.br", password));
assertNull(users.findByMailAndPassword("gui@email.com.br", "123456"));
}
use of org.mamute.model.User in project mamute by caelum.
the class UserDAOTest method should_search_by_email_and_password.
@Test
public void should_search_by_email_and_password() {
User gui = user("Guilherme Sonar", "gui@email.com.br");
LoginMethod brutalLogin = LoginMethod.brutalLogin(gui, "gui@email.com.br", "654321");
gui.add(brutalLogin);
users.save(gui);
session.save(brutalLogin);
assertEquals(gui, users.findByMailAndPassword("gui@email.com.br", "654321"));
assertNull(users.findByMailAndPassword("gui@email.com.br", "1234567"));
assertNull(users.findByMailAndPassword("joao.silveira@email.com.br", "654321"));
}
use of org.mamute.model.User in project mamute by caelum.
the class UserDAOTest method saveUser.
private User saveUser(String name, String email) {
User user = user(name, email);
LoginMethod facebookLogin = LoginMethod.facebookLogin(user, user.getEmail(), "1234");
user.add(facebookLogin);
session.save(user);
session.save(facebookLogin);
return user;
}
use of org.mamute.model.User in project mamute by caelum.
the class WatcherDAOTest method should_get_subscribed_users_of_a_question.
@Test
public void should_get_subscribed_users_of_a_question() {
User subscribedWatcher = user("watcher", "watcher@watcher.com");
session.save(subscribedWatcher);
watchers.add(question, new Watcher(subscribedWatcher));
assertThat(watchers.of(question), not(empty()));
}
use of org.mamute.model.User in project mamute by caelum.
the class WatcherDAOTest method set_up.
@Before
public void set_up() {
User leo = user("Leonardo", "leo@leo.com");
session.save(leo);
Tag java = tag("java");
session.save(java);
question = question(leo, java);
session.save(question);
watchers = new WatcherDAO(session, new InvisibleForUsersRule(new LoggedUser(leo, null)));
}
Aggregations