use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class SecurityServiceImplTest method testQuery.
@Test
public void testQuery() throws Exception {
runAsAdmin(() -> {
final PrincipalKey userKey1 = PrincipalKey.ofUser(SYSTEM, "User1");
final CreateUserParams createUser1 = CreateUserParams.create().userKey(userKey1).displayName("User 1").email("user1@enonic.com").login("User1").password("123456").build();
refresh();
final PrincipalQuery query = PrincipalQuery.create().idProvider(IdProviderKey.system()).build();
PrincipalQueryResult queryResult = securityService.query(query);
queryResult = securityService.query(query);
assertEquals(2, queryResult.getTotalSize());
final User user1 = securityService.createUser(createUser1);
refresh();
queryResult = securityService.query(query);
assertEquals(3, queryResult.getTotalSize());
assertEquals(user1, queryResult.getPrincipals().getPrincipal(userKey1));
});
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testExamples.
@Test
public void testExamples() {
final PrincipalQueryResult result = PrincipalQueryResult.create().addPrincipal(TestDataFixtures.getTestGroup()).addPrincipal(TestDataFixtures.getTestRole()).addPrincipal(TestDataFixtures.getTestUser()).totalSize(3).build();
Mockito.when(securityService.query(Mockito.any(PrincipalQuery.class))).thenReturn(result);
runScript("/lib/xp/examples/auth/findPrincipals.js");
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testFindPrincipalsUsers.
@Test
public void testFindPrincipalsUsers() {
final PrincipalQuery expectedQuery = PrincipalQuery.create().includeUsers().idProvider(IdProviderKey.from("enonic")).from(2).size(3).build();
final PrincipalQueryResult result = PrincipalQueryResult.create().addPrincipal(TestDataFixtures.getTestUser()).totalSize(3).build();
Mockito.when(securityService.query(Mockito.eq(expectedQuery))).thenReturn(result);
runFunction("/test/findPrincipals-test.js", "findPrincipalsUsers");
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testFindPrincipalsBySearchText.
@Test
public void testFindPrincipalsBySearchText() {
final PrincipalQuery expectedQuery = PrincipalQuery.create().searchText("enonic").build();
final PrincipalQueryResult result = PrincipalQueryResult.create().addPrincipal(TestDataFixtures.getTestUser()).totalSize(1).build();
Mockito.when(securityService.query(Mockito.eq(expectedQuery))).thenReturn(result);
runFunction("/test/findPrincipals-test.js", "findPrincipalsBySearchText");
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testFindPrincipalsGroups.
@Test
public void testFindPrincipalsGroups() {
final PrincipalQuery expectedQuery = PrincipalQuery.create().includeGroups().idProvider(IdProviderKey.from("enonic")).from(2).size(3).build();
final PrincipalQueryResult result = PrincipalQueryResult.create().addPrincipal(TestDataFixtures.getTestGroup()).totalSize(3).build();
Mockito.when(securityService.query(Mockito.eq(expectedQuery))).thenReturn(result);
runFunction("/test/findPrincipals-test.js", "findPrincipalsGroups");
}
Aggregations