use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method getTenant2Profile.
private Profile getTenant2Profile() {
Profile profile = new Profile();
profile.setId(PROFILE2_ID);
profile.setTenant(TENANT2_NAME);
profile.setUsername(USERNAME2);
profile.setPassword(CryptoUtils.hashPassword(PASSWORD2));
profile.setEmail(EMAIL2);
profile.setRoles(new HashSet<>(ROLES2));
profile.setVerified(false);
profile.setEnabled(false);
profile.setAttributes(getAttributes());
return profile;
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testGetProfile.
@Test
public void testGetProfile() throws Exception {
Profile expected = getTenant1Profile();
expected.setAttributes(getAttributesWithoutPrivateAttribute());
Profile actual = profileService.getProfile(PROFILE1_ID.toString());
assertEqualProfiles(expected, actual);
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findById(PROFILE1_ID.toString(), new String[0]);
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testEnableProfile.
@Test
public void testEnableProfile() throws Exception {
Profile expected = getTenant2Profile();
expected.setEnabled(true);
expected.setAttributes(getAttributesWithoutPrivateAttribute());
Profile actual = profileService.enableProfile(PROFILE2_ID.toString());
assertEqualProfiles(expected, actual);
ArgumentMatcher<Object> setParamMatcher = new ArgumentMatcher<Object>() {
@Override
public boolean matches(Object argument) {
Map<String, Object> param = (Map<String, Object>) argument;
return param.size() == 2 && param.get("enabled").equals(true) && param.containsKey("lastModified");
}
};
verify(tenantPermissionEvaluator).isAllowed(TENANT2_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findById(PROFILE2_ID.toString(), new String[0]);
verify(profileRepository).update(eq(PROFILE2_ID.toString()), eq("{$set: #}"), eq(false), eq(false), argThat(setParamMatcher));
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testGetProfilesByAttribute.
@Test
public void testGetProfilesByAttribute() throws Exception {
List<Profile> expected = getAllTenant1Profiles();
for (Profile profile : expected) {
profile.setAttributes(getAttributesWithoutPrivateAttribute());
}
List<Profile> actual = profileService.getProfilesByAttributeValue(TENANT1_NAME, ATTRIB_NAME_FIRST_NAME, FIRST_NAME, SORT_BY, SortOrder.ASC);
assertEqualProfileLists(expected, actual);
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findByTenantAndAttributeValue(TENANT1_NAME, ATTRIB_NAME_FIRST_NAME, FIRST_NAME, SORT_BY, SortOrder.ASC);
}
use of org.craftercms.profile.api.Profile in project profile by craftercms.
the class ProfileServiceImplTest method testGetProfileByUsername.
@Test
public void testGetProfileByUsername() throws Exception {
Profile expected = getTenant1Profile();
expected.setAttributes(getAttributesWithoutPrivateAttribute());
Profile actual = profileService.getProfileByUsername(TENANT1_NAME, USERNAME1);
assertEqualProfiles(expected, actual);
verify(tenantPermissionEvaluator).isAllowed(TENANT1_NAME, TenantAction.MANAGE_PROFILES.toString());
verify(profileRepository).findByTenantAndUsername(TENANT1_NAME, USERNAME1, new String[0]);
}
Aggregations