Search in sources :

Example 1 with PASSWORD_RESET_TOKEN_URL

use of org.simbasecurity.core.config.SimbaConfigurationParameter.PASSWORD_RESET_TOKEN_URL 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"));
}
Also used : Token.generateToken(org.simbasecurity.core.domain.communication.token.Token.generateToken) Token(org.simbasecurity.core.domain.communication.token.Token) EmailAddress(org.simbasecurity.core.domain.user.EmailAddress) PASSWORD_RESET_TOKEN_URL(org.simbasecurity.core.config.SimbaConfigurationParameter.PASSWORD_RESET_TOKEN_URL) URL(java.net.URL) Test(org.junit.Test)

Aggregations

URL (java.net.URL)1 Test (org.junit.Test)1 PASSWORD_RESET_TOKEN_URL (org.simbasecurity.core.config.SimbaConfigurationParameter.PASSWORD_RESET_TOKEN_URL)1 Token (org.simbasecurity.core.domain.communication.token.Token)1 Token.generateToken (org.simbasecurity.core.domain.communication.token.Token.generateToken)1 EmailAddress (org.simbasecurity.core.domain.user.EmailAddress)1