use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testFindPrincipalsDefaultParameters.
@Test
public void testFindPrincipalsDefaultParameters() {
final PrincipalQuery expectedQuery = PrincipalQuery.create().build();
final PrincipalQueryResult result = PrincipalQueryResult.create().addPrincipal(TestDataFixtures.getTestGroup()).addPrincipal(TestDataFixtures.getTestRole()).addPrincipal(TestDataFixtures.getTestUser()).totalSize(3).build();
Mockito.when(securityService.query(Mockito.eq(expectedQuery))).thenReturn(result);
runFunction("/test/findPrincipals-test.js", "findPrincipalsDefaultParameters");
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testFindPrincipalsByName.
@Test
public void testFindPrincipalsByName() {
final PrincipalQuery expectedQuery = PrincipalQuery.create().idProvider(IdProviderKey.from("enonic")).name("user1").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", "findPrincipalsByName");
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandler method findPrincipals.
public PrincipalsResultMapper findPrincipals() {
final PrincipalQuery.Builder query = PrincipalQuery.create();
if (this.type != null) {
query.includeTypes(this.type);
}
if (this.idProvider != null) {
query.idProvider(this.idProvider);
}
query.name(this.name);
query.from(this.start);
query.size(this.count);
query.searchText(this.searchText);
final PrincipalQueryResult result = this.securityService.get().query(query.build());
return new PrincipalsResultMapper(result.getPrincipals(), result.getTotalSize());
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class FindPrincipalsHandlerTest method testFindPrincipalsRoles.
@Test
public void testFindPrincipalsRoles() {
final PrincipalQuery expectedQuery = PrincipalQuery.create().includeRoles().idProvider(IdProviderKey.from("enonic")).from(2).size(3).build();
final PrincipalQueryResult result = PrincipalQueryResult.create().addPrincipal(TestDataFixtures.getTestRole()).totalSize(3).build();
Mockito.when(securityService.query(Mockito.eq(expectedQuery))).thenReturn(result);
runFunction("/test/findPrincipals-test.js", "findPrincipalsRoles");
}
use of com.enonic.xp.security.PrincipalQueryResult in project xp by enonic.
the class SecurityServiceImpl method findPrincipals.
@Override
@Deprecated
public Principals findPrincipals(final IdProviderKey idProvider, final List<PrincipalType> types, final String query) {
final PrincipalQuery.Builder principalQuery = PrincipalQuery.create().getAll().includeTypes(types).searchText(query);
if (idProvider != null) {
principalQuery.idProvider(idProvider);
}
final PrincipalQueryResult result = query(principalQuery.build());
return result.getPrincipals();
}
Aggregations