Search in sources :

Example 11 with VerificationToken

use of org.craftercms.profile.api.VerificationToken in project profile by craftercms.

the class ProfileServiceImplTest method testResetPassword.

@Test
public void testResetPassword() throws Exception {
    Profile expected = getTenant1Profile();
    expected.setAttributes(getAttributesWithoutPrivateAttribute());
    Profile actual = profileService.resetPassword(PROFILE1_ID.toString(), RESET_PASSWORD_URL);
    assertEqualProfiles(expected, actual);
    VerificationToken token = new VerificationToken();
    token.setId(VERIFICATION_TOKEN_ID1);
    verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
    verify(profileRepository).findById(PROFILE1_ID.toString(), new String[0]);
    verify(verificationService).createToken(actual);
    verify(verificationService).sendEmail(token, actual, RESET_PASSWORD_URL, RESET_PASSWORD_FROM_ADDRESS, RESET_PASSWORD_SUBJECT, RESET_PASSWORD_TEMPLATE_NAME);
}
Also used : VerificationToken(org.craftercms.profile.api.VerificationToken) Profile(org.craftercms.profile.api.Profile) Test(org.junit.Test)

Example 12 with VerificationToken

use of org.craftercms.profile.api.VerificationToken in project profile by craftercms.

the class ProfileServiceImplTest method testCreateVerificationToken.

@Test
public void testCreateVerificationToken() throws Exception {
    VerificationToken token = profileService.createVerificationToken(PROFILE1_ID.toString());
    assertNotNull(token);
    assertEquals(VERIFICATION_TOKEN_ID1, token.getId());
    assertEquals(TENANT1_NAME, token.getTenant());
    assertEquals(PROFILE1_ID.toString(), token.getProfileId());
    assertNotNull(token.getTimestamp());
    verify(verificationService).createToken(getTenant1Profile());
}
Also used : VerificationToken(org.craftercms.profile.api.VerificationToken) Test(org.junit.Test)

Example 13 with VerificationToken

use of org.craftercms.profile.api.VerificationToken in project profile by craftercms.

the class VerificationServiceImplTest method testSendEmail.

@Test
public void testSendEmail() throws Exception {
    Profile profile = new Profile();
    profile.setId(PROFILE_ID);
    profile.setEmail(PROFILE_EMAIL);
    VerificationToken token = new VerificationToken();
    token.setId(TOKEN_ID);
    verificationService.sendEmail(token, profile, VERIFICATION_BASE_URL, FROM, SUBJECT, TEMPLATE_NAME);
    verify(emailFactory).getEmail(FROM, TO, null, null, SUBJECT, TEMPLATE_NAME, VERIFICATION_TEMPLATE_ARGS, true);
    verify(email).send();
}
Also used : VerificationToken(org.craftercms.profile.api.VerificationToken) Profile(org.craftercms.profile.api.Profile) Test(org.junit.Test)

Example 14 with VerificationToken

use of org.craftercms.profile.api.VerificationToken in project profile by craftercms.

the class VerificationServiceImplTest method getToken.

private VerificationToken getToken() {
    VerificationToken token = new VerificationToken();
    token.setId(TOKEN_ID);
    token.setProfileId(PROFILE_ID.toString());
    token.setTimestamp(new Date());
    return token;
}
Also used : VerificationToken(org.craftercms.profile.api.VerificationToken) Date(java.util.Date)

Example 15 with VerificationToken

use of org.craftercms.profile.api.VerificationToken in project profile by craftercms.

the class VerificationServiceImplTest method testCreateToken.

@Test
public void testCreateToken() throws Exception {
    Profile profile = new Profile();
    profile.setId(PROFILE_ID);
    profile.setTenant(TENANT_NAME);
    VerificationToken token = verificationService.createToken(profile);
    assertEquals(TOKEN_ID, token.getId());
    assertEquals(TENANT_NAME, token.getTenant());
    assertEquals(PROFILE_ID.toString(), token.getProfileId());
    assertNotNull(token.getTimestamp());
    verify(tokenRepository).insert(any(VerificationToken.class));
}
Also used : VerificationToken(org.craftercms.profile.api.VerificationToken) Profile(org.craftercms.profile.api.Profile) Test(org.junit.Test)

Aggregations

VerificationToken (org.craftercms.profile.api.VerificationToken)18 Profile (org.craftercms.profile.api.Profile)12 Test (org.junit.Test)10 Date (java.util.Date)4 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)3 MongoDataException (org.craftercms.commons.mongo.MongoDataException)2 AttributeDefinition (org.craftercms.profile.api.AttributeDefinition)2 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)2 NoSuchVerificationTokenException (org.craftercms.profile.exceptions.NoSuchVerificationTokenException)2 Before (org.junit.Before)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 ObjectId (org.bson.types.ObjectId)1 DuplicateKeyException (org.craftercms.commons.mongo.DuplicateKeyException)1 Tenant (org.craftercms.profile.api.Tenant)1 InvalidEmailAddressException (org.craftercms.profile.exceptions.InvalidEmailAddressException)1 ProfileExistsException (org.craftercms.profile.exceptions.ProfileExistsException)1