use of com.enonic.xp.security.PrincipalKeys 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");
}
use of com.enonic.xp.security.PrincipalKeys in project xp by enonic.
the class GetMembershipsHandlerTest method testGetUserMemberships.
@Test
public void testGetUserMemberships() {
final Group group = TestDataFixtures.getTestGroup();
final PrincipalKeys principalKeys = PrincipalKeys.from(group.getKey());
final PrincipalKey pKey = PrincipalKey.from("user:myIdProvider:userId");
Mockito.when(securityService.getMemberships(pKey)).thenReturn(principalKeys);
Mockito.verify(securityService, Mockito.never()).getAllMemberships(pKey);
Mockito.when(securityService.getPrincipals(principalKeys)).thenReturn(Principals.from(group));
runFunction("/test/getMemberships-test.js", "getUserMemberships");
}
use of com.enonic.xp.security.PrincipalKeys in project xp by enonic.
the class GetMembershipsHandlerTest method testGetUserMembershipsWithRoleAndGroup.
@Test
public void testGetUserMembershipsWithRoleAndGroup() {
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));
runFunction("/test/getMemberships-test.js", "getUserMembershipsWithRoleAndGroup");
}
Aggregations