use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBeanTest method shouldFailWhenCheckingWithInactiveUser.
@Test
public void shouldFailWhenCheckingWithInactiveUser() {
User testUser = new User();
testUser.setLogin("testUser");
testUser.setActive(false);
Link testLink = new Link();
testLink.setLink("linkTest");
testLink.setUser("testUser");
testLink.setInsertDate(new Date());
doReturn(Arrays.asList(testLink)).when(sutMock).getLinksWithLink("linkTest");
doReturn(testUser).when(sutMock).getUserByName(testLink.getUser());
String result = sutMock.checkLinkAndResetPassword(testLink.getLink());
assertThat(result, equalTo("<p>El enlace no existe o ha caducado</p>"));
}
use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBeanTest method shouldProcessPasswordResetRequest.
@Test
public void shouldProcessPasswordResetRequest() {
User testUser = new User();
testUser.setLogin("testName");
testUser.setActive(true);
testUser.setEmail("test@mail.com");
sutMock.setName("testName");
Link testLink = new Link();
testLink.setLink("randomLink");
doReturn(testUser).when(sutMock).getUserByName("testName");
doReturn(externalContext).when(sutMock).getFacesExternalContext();
doReturn(testLink).when(sutMock).generateLink("testName");
String result = sutMock.passwordResetRequest();
verify(sutMock).sendMail(testLink, "test@mail.com");
assertThat(result, equalTo("emailSent"));
}
use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBeanTest method shouldFailWhenCheckingExpiredLink.
@Test
public void shouldFailWhenCheckingExpiredLink() {
Link testLink = new Link();
testLink.setLink("linkTest");
testLink.setUser("testUser");
Date yesterday = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(yesterday);
cal.add(Calendar.DATE, -1);
yesterday = cal.getTime();
testLink.setInsertDate(yesterday);
doReturn(Arrays.asList(testLink)).when(sutMock).getLinksWithLink("linkTest");
String result = sutMock.checkLinkAndResetPassword(testLink.getLink());
assertThat(result, equalTo("<p>El enlace no existe o ha caducado</p>"));
}
use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBeanTest method shouldCheckLinkAndCallResetPassword.
@Test
public void shouldCheckLinkAndCallResetPassword() {
User testUser = new User();
testUser.setLogin("testUser");
testUser.setActive(true);
Link testLink = new Link();
testLink.setLink("linkTest");
testLink.setUser("testUser");
testLink.setInsertDate(new Date());
doReturn(Arrays.asList(testLink)).when(sutMock).getLinksWithLink("linkTest");
doReturn(testUser).when(sutMock).getUserByName(testLink.getUser());
doReturn("changedPassword").when(sutMock).resetPassword(testUser);
String result = sutMock.checkLinkAndResetPassword(testLink.getLink());
assertThat(result, equalTo("Tu nueva contraseña es: <b>changedPassword</b></br> <p>Se te pedirá que la modifiques al entrar por primera vez.</p>"));
}
use of com.autentia.tnt.businessobject.Link in project TNTConcept by autentia.
the class LinkBeanTest method shouldSendMail.
@Test
public void shouldSendMail() throws MessagingException {
Link link = new Link();
link.setLink("dgfjhsadgflkjasghajksdhfk");
String mailAddress = "test@mail.com";
sutMock.sendMail(link, mailAddress);
verify(mailService).send(mailAddress, "[RESETEO DE CONTRASEÑA] Email de verificación", "Haz click en el siguiente link para verificar que eres tú si quieres cambiar la contraseña: http://localhost:8080/tntconcept/linkEmailVerification.jsf?link=dgfjhsadgflkjasghajksdhfk");
}