use of com.enonic.xp.security.Group in project xp by enonic.
the class SecurityServiceImplTest method testUpdateGroup.
@Test
public void testUpdateGroup() throws Exception {
runAsAdmin(() -> {
final CreateGroupParams createGroup = CreateGroupParams.create().groupKey(PrincipalKey.ofGroup(SYSTEM, "Group-a")).displayName("Group A").build();
final Group group = securityService.createGroup(createGroup);
refresh();
final UpdateGroupParams groupUpdate = UpdateGroupParams.create(group).displayName("___Group B___").description("description").build();
final Group updatedGroupResult = securityService.updateGroup(groupUpdate);
refresh();
final Group updatedGroup = securityService.getGroup(group.getKey()).get();
assertEquals("___Group B___", updatedGroupResult.getDisplayName());
assertEquals("___Group B___", updatedGroup.getDisplayName());
assertEquals("description", updatedGroupResult.getDescription());
assertEquals("description", updatedGroup.getDescription());
});
}
use of com.enonic.xp.security.Group in project xp by enonic.
the class ModifyGroupHandlerTest method invokeUpdate.
private Group invokeUpdate(final UpdateGroupParams params) {
final GroupEditor editor = params.getEditor();
assertNotNull(editor);
final Group group = TestDataFixtures.getTestGroup();
final EditableGroup editable = new EditableGroup(group);
editor.edit(editable);
return editable.build();
}
use of com.enonic.xp.security.Group in project xp by enonic.
the class GetMembersHandlerTest method testGetMembers.
@Test
public void testGetMembers() {
final Group group = TestDataFixtures.getTestGroup();
final User user1 = TestDataFixtures.getTestUser();
final User user2 = TestDataFixtures.getTestUser2();
final PrincipalKeys principalKeys = PrincipalKeys.from(user1.getKey(), user2.getKey());
final PrincipalRelationships relationships = PrincipalRelationships.from(PrincipalRelationship.from(group.getKey()).to(user1.getKey()), PrincipalRelationship.from(group.getKey()).to(user2.getKey()));
Mockito.when(securityService.getRelationships(group.getKey())).thenReturn(relationships);
Mockito.when(securityService.getPrincipals(principalKeys)).thenReturn(Principals.from(user1, user2));
runFunction("/test/getMembers-test.js", "getMembers");
}
use of com.enonic.xp.security.Group in project xp by enonic.
the class GetMembersHandlerTest method testExamples.
@Test
public void testExamples() {
final Group group = TestDataFixtures.getTestGroup();
final User user1 = TestDataFixtures.getTestUser();
final User user2 = TestDataFixtures.getTestUser2();
final PrincipalKeys principalKeys = PrincipalKeys.from(user1.getKey(), user2.getKey());
final PrincipalRelationships relationships = PrincipalRelationships.from(PrincipalRelationship.from(group.getKey()).to(user1.getKey()), PrincipalRelationship.from(group.getKey()).to(user2.getKey()));
Mockito.when(securityService.getRelationships(group.getKey())).thenReturn(relationships);
Mockito.when(securityService.getPrincipals(principalKeys)).thenReturn(Principals.from(user1, user2));
runScript("/lib/xp/examples/auth/getMembers.js");
}
use of com.enonic.xp.security.Group in project xp by enonic.
the class GetMembershipsHandlerTest method testExamples.
@Test
public void testExamples() {
final Role role = TestDataFixtures.getTestRole();
final Group group = TestDataFixtures.getTestGroup();
final PrincipalKeys principalKeys = PrincipalKeys.from(role.getKey(), group.getKey());
Mockito.when(securityService.getMemberships(PrincipalKey.from("user:myIdProvider:userId"))).thenReturn(principalKeys);
Mockito.when(securityService.getPrincipals(principalKeys)).thenReturn(Principals.from(role, group));
runScript("/lib/xp/examples/auth/getMemberships.js");
}
Aggregations