use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceIT method testDisableProfile.
@Test
public void testDisableProfile() throws Exception {
Profile profile = profileService.createProfile(DEFAULT_TENANT, AVASQUEZ_USERNAME, AVASQUEZ_PASSWORD1, AVASQUEZ_EMAIL1, true, AVASQUEZ_ROLES1, null, VERIFICATION_URL);
try {
assertNotNull(profile);
assertTrue(profile.isEnabled());
Profile updatedProfile = profileService.disableProfile(profile.getId().toString());
assertNotNull(updatedProfile);
assertEquals(profile.getId(), updatedProfile.getId());
assertEquals(profile.getUsername(), updatedProfile.getUsername());
assertNull(updatedProfile.getPassword());
assertEquals(profile.getEmail(), updatedProfile.getEmail());
assertEquals(profile.isVerified(), updatedProfile.isVerified());
assertFalse(updatedProfile.isEnabled());
assertEquals(profile.getCreatedOn(), updatedProfile.getCreatedOn());
assertTrue(profile.getLastModified().before(updatedProfile.getLastModified()));
assertEquals(profile.getTenant(), updatedProfile.getTenant());
assertEquals(profile.getRoles(), updatedProfile.getRoles());
assertEquals(profile.getAttributes(), updatedProfile.getAttributes());
} finally {
profileService.deleteProfile(profile.getId().toString());
}
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceIT method testUpdateProfile.
@Test
public void testUpdateProfile() throws Exception {
Profile profile = profileService.createProfile(DEFAULT_TENANT, AVASQUEZ_USERNAME, AVASQUEZ_PASSWORD1, AVASQUEZ_EMAIL1, true, AVASQUEZ_ROLES1, null, VERIFICATION_URL);
try {
assertNotNull(profile);
Map<String, Object> attributes = new LinkedHashMap<>(2);
attributes.put("firstName", AVASQUEZ_FIRST_NAME);
attributes.put("lastName", AVASQUEZ_LAST_NAME);
Profile updatedProfile = profileService.updateProfile(profile.getId().toString(), AVASQUEZ_USERNAME, AVASQUEZ_PASSWORD2, AVASQUEZ_EMAIL2, false, AVASQUEZ_ROLES2, attributes);
assertNotNull(updatedProfile);
assertEquals(profile.getId(), updatedProfile.getId());
assertEquals(profile.getUsername(), updatedProfile.getUsername());
assertNull(updatedProfile.getPassword());
assertEquals(AVASQUEZ_EMAIL2, updatedProfile.getEmail());
assertEquals(profile.isVerified(), updatedProfile.isVerified());
assertFalse(updatedProfile.isEnabled());
assertEquals(profile.getCreatedOn(), updatedProfile.getCreatedOn());
assertTrue(profile.getLastModified().before(updatedProfile.getLastModified()));
assertEquals(profile.getTenant(), updatedProfile.getTenant());
assertEquals(AVASQUEZ_ROLES2, updatedProfile.getRoles());
assertEquals(attributes, updatedProfile.getAttributes());
} finally {
profileService.deleteProfile(profile.getId().toString());
}
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceIT method testGetProfileByIds.
@Test
public void testGetProfileByIds() throws Exception {
ObjectId adminProfileId = profileService.getProfileByUsername(DEFAULT_TENANT, ADMIN_USERNAME).getId();
ObjectId jdoeProfileId = profileService.getProfileByUsername(DEFAULT_TENANT, JDOE_USERNAME).getId();
List<Profile> profiles = profileService.getProfilesByIds(Arrays.asList(adminProfileId.toString(), jdoeProfileId.toString()), null, null);
assertNotNull(profiles);
assertEquals(2, profiles.size());
assertAdminProfile(profiles.get(0));
assertJdoeProfile(profiles.get(1));
// With sort
profiles = profileService.getProfilesByIds(Arrays.asList(adminProfileId.toString(), jdoeProfileId.toString()), "username", SortOrder.DESC);
assertNotNull(profiles);
assertEquals(2, profiles.size());
assertJdoeProfile(profiles.get(0));
assertAdminProfile(profiles.get(1));
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceIT method testGetProfileByTicket.
@Test(expected = ProfileRestServiceException.class)
public void testGetProfileByTicket() throws Exception {
Ticket ticket = authenticationService.authenticate(DEFAULT_TENANT, ADMIN_USERNAME, ADMIN_PASSWORD);
assertNotNull(ticket);
Profile profile = profileService.getProfileByTicket(ticket.getId());
assertAdminProfile(profile);
authenticationService.invalidateTicket(ticket.getId());
// Try with invalid ticket
profileService.getProfileByTicket("507c7f79bcf86cd7994f6c0e");
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceIT method testDeleteVerificationToken.
@Test
public void testDeleteVerificationToken() throws Exception {
Profile profile = profileService.getProfileByUsername(DEFAULT_TENANT, ADMIN_USERNAME);
String profileId = profile.getId().toString();
VerificationToken token = profileService.createVerificationToken(profileId);
assertNotNull(token);
profileService.deleteVerificationToken(token.getId());
token = profileService.getVerificationToken(token.getId());
assertNull(token);
}
Aggregations