Search in sources :

Example 6 with PrincipalQuery

use of com.enonic.xp.security.PrincipalQuery 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");
}
Also used : PrincipalQuery(com.enonic.xp.security.PrincipalQuery) PrincipalQueryResult(com.enonic.xp.security.PrincipalQueryResult) Test(org.junit.jupiter.api.Test)

Example 7 with PrincipalQuery

use of com.enonic.xp.security.PrincipalQuery 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");
}
Also used : PrincipalQuery(com.enonic.xp.security.PrincipalQuery) PrincipalQueryResult(com.enonic.xp.security.PrincipalQueryResult) Test(org.junit.jupiter.api.Test)

Example 8 with PrincipalQuery

use of com.enonic.xp.security.PrincipalQuery 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");
}
Also used : PrincipalQuery(com.enonic.xp.security.PrincipalQuery) PrincipalQueryResult(com.enonic.xp.security.PrincipalQueryResult) Test(org.junit.jupiter.api.Test)

Aggregations

PrincipalQuery (com.enonic.xp.security.PrincipalQuery)8 PrincipalQueryResult (com.enonic.xp.security.PrincipalQueryResult)8 Test (org.junit.jupiter.api.Test)7 AbstractElasticsearchIntegrationTest (com.enonic.xp.repo.impl.elasticsearch.AbstractElasticsearchIntegrationTest)1 CreateUserParams (com.enonic.xp.security.CreateUserParams)1 PrincipalKey (com.enonic.xp.security.PrincipalKey)1 User (com.enonic.xp.security.User)1