use of org.simbasecurity.core.domain.user.EmailAddress in project simba-os by cegeka.
the class CredentialServiceImplTest method findUserByMail_UserFoundForGivenEmail_ReturnsOptionalWithFoundUser.
@Test
public void findUserByMail_UserFoundForGivenEmail_ReturnsOptionalWithFoundUser() throws Exception {
EmailAddress email = emailFactory.email("bruce@wayneindustries.com");
User user = aUser().build();
when(mockUserRepository.findByEmail(email)).thenReturn(user);
Optional<User> maybeUser = credentialService.findUserByMail(email);
assertThat(maybeUser).contains(user);
}
use of org.simbasecurity.core.domain.user.EmailAddress in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method findUserByMail_WillNOTReturnUser_IfPresentInDatabase_AndInactive.
@Test
public void findUserByMail_WillNOTReturnUser_IfPresentInDatabase_AndInactive() throws Exception {
EmailAddress email = emailFactory.email("morganfreeman@wayneindustries.com");
User inactiveUser = aDefaultUser().withUserName("fmorgan").withEmail(email).withStatus(Status.INACTIVE).build();
persistAndRefresh(inactiveUser);
User user = userDatabaseRepository.findByEmail(email);
Assertions.assertThat(user).isEqualTo(null);
}
use of org.simbasecurity.core.domain.user.EmailAddress in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method findUserByMailCaseInsensitive2_WillReturnUser_IfPresentInDatabase.
@Test
public void findUserByMailCaseInsensitive2_WillReturnUser_IfPresentInDatabase() throws Exception {
EmailAddress email = emailFactory.email("Alfred@WayneIndustries.com");
EmailAddress otherEmail = emailFactory.email("alfred@wayneindustries.com");
User expectedUser = aDefaultUser().withEmail(email).build();
persistAndRefresh(expectedUser);
User user = userDatabaseRepository.findByEmail(otherEmail);
Assertions.assertThat(user).isEqualTo(expectedUser);
}
use of org.simbasecurity.core.domain.user.EmailAddress in project simba-os by cegeka.
the class LinkGeneratorTest method generateResetPasswordUrl_WillGenerateLinksToResetPassword_BasedOnSimbaProperty_WithTokenAndUsername.
@Test
public void generateResetPasswordUrl_WillGenerateLinksToResetPassword_BasedOnSimbaProperty_WithTokenAndUsername() throws Exception {
List<String> links = Arrays.asList("https://www.simba.be:1000/simba", "https://www.dag.no:8080/FYFAEN");
when(configurationServiceMock.getValue(PASSWORD_RESET_TOKEN_URL)).thenReturn(links);
EmailAddress email = emailFactory.email("myEmail@myProvider.com");
String urlEscapedEmail = "myEmail%40myProvider.com";
Token token = generateToken();
List<URL> urls = linkGenerator.generateResetPasswordLinks(email, token);
String queryParams = String.format("email=%s&token=%s", urlEscapedEmail, token.asString());
assertThat(urls).extracting(URL::getHost, URL::getProtocol, URL::getPort, URL::getQuery, URL::getPath).containsExactly(tuple("www.simba.be", "https", 1000, queryParams, "/simba/http/simba-new-pwd"), tuple("www.dag.no", "https", 8080, queryParams, "/FYFAEN/http/simba-new-pwd"));
}
use of org.simbasecurity.core.domain.user.EmailAddress in project simba-os by cegeka.
the class UserDatabaseRepositoryTest method findUserByMail_WillReturnUser_IfPresentInDatabase_AndActiveOrBlocked.
@Test
public void findUserByMail_WillReturnUser_IfPresentInDatabase_AndActiveOrBlocked() throws Exception {
EmailAddress email = emailFactory.email("alfred@wayneindustries.com");
User expectedUser = aDefaultUser().withEmail(email).withStatus(Status.ACTIVE).build();
persistAndRefresh(expectedUser);
User user = userDatabaseRepository.findByEmail(email);
Assertions.assertThat(user).isEqualTo(expectedUser);
}
Aggregations