Search in sources :

Example 6 with RoleTO

use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.

the class ApplicationITCase method read.

@Test
public void read() {
    ApplicationTO mightyApp = applicationService.read("mightyApp");
    assertNotNull(mightyApp);
    assertEquals(2, mightyApp.getPrivileges().size());
    assertTrue(mightyApp.getPrivileges().stream().anyMatch(privilege -> "postMighty".equals(privilege.getKey())));
    PrivilegeTO getMighty = applicationService.readPrivilege("getMighty");
    assertNotNull(getMighty);
    assertEquals("mightyApp", getMighty.getApplication());
    RoleTO role = roleService.read("Other");
    assertFalse(role.getPrivileges().isEmpty());
    assertEquals(1, role.getPrivileges().size());
    assertTrue(role.getPrivileges().stream().anyMatch(privilege -> "postMighty".equals(privilege)));
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) RoleService(org.apache.syncope.common.rest.api.service.RoleService) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) PrivilegeTO(org.apache.syncope.common.lib.to.PrivilegeTO) Test(org.junit.jupiter.api.Test) EntityTO(org.apache.syncope.common.lib.to.EntityTO) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Response(javax.ws.rs.core.Response) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) ApplicationService(org.apache.syncope.common.rest.api.service.ApplicationService) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ApplicationTO(org.apache.syncope.common.lib.to.ApplicationTO) AbstractITCase(org.apache.syncope.fit.AbstractITCase) ApplicationTO(org.apache.syncope.common.lib.to.ApplicationTO) PrivilegeTO(org.apache.syncope.common.lib.to.PrivilegeTO) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Test(org.junit.jupiter.api.Test)

Example 7 with RoleTO

use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.

the class SearchITCase method searchByDynRole.

@Test
public void searchByDynRole() {
    RoleTO role = RoleITCase.getSampleRoleTO("dynMembership");
    role.setDynMembershipCond("cool==true");
    Response response = roleService.create(role);
    role = getObject(response.getLocation(), RoleService.class, RoleTO.class);
    assertNotNull(role);
    if (ElasticsearchDetector.isElasticSearchEnabled(syncopeService)) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException ex) {
        // ignore
        }
    }
    PagedResult<UserTO> matchingUsers = userService.search(new AnyQuery.Builder().realm(SyncopeConstants.ROOT_REALM).fiql(SyncopeClient.getUserSearchConditionBuilder().inRoles(role.getKey()).query()).build());
    assertNotNull(matchingUsers);
    assertFalse(matchingUsers.getResult().isEmpty());
    assertTrue(matchingUsers.getResult().stream().anyMatch(user -> "c9b2dec2-00a7-4855-97c0-d854842b4b24".equals(user.getKey())));
}
Also used : Response(javax.ws.rs.core.Response) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ElasticsearchDetector(org.apache.syncope.fit.ElasticsearchDetector) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) AnyObjectPatch(org.apache.syncope.common.lib.patch.AnyObjectPatch) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) MembershipPatch(org.apache.syncope.common.lib.patch.MembershipPatch) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) AnyQuery(org.apache.syncope.common.rest.api.beans.AnyQuery) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) PagedResult(org.apache.syncope.common.lib.to.PagedResult) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) RoleService(org.apache.syncope.common.rest.api.service.RoleService) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) AttrPatch(org.apache.syncope.common.lib.patch.AttrPatch) Response(javax.ws.rs.core.Response) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) UserTO(org.apache.syncope.common.lib.to.UserTO) AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) RoleService(org.apache.syncope.common.rest.api.service.RoleService) UserTO(org.apache.syncope.common.lib.to.UserTO) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Test(org.junit.jupiter.api.Test)

Example 8 with RoleTO

use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.

the class RoleITCase method create.

@Test
public void create() {
    RoleTO role = new RoleTO();
    role.getRealms().add(SyncopeConstants.ROOT_REALM);
    role.getRealms().add("/even/two");
    role.getEntitlements().add(StandardEntitlement.LOG_LIST);
    role.getEntitlements().add(StandardEntitlement.LOG_SET_LEVEL);
    try {
        createRole(role);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.InvalidRole, e.getType());
    }
    role.setKey("new" + getUUIDString());
    role = createRole(role);
    assertNotNull(role);
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Test(org.junit.jupiter.api.Test)

Example 9 with RoleTO

use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.

the class RoleITCase method read.

@Test
public void read() {
    RoleTO roleTO = roleService.read("Search for realm evenTwo");
    assertNotNull(roleTO);
    assertTrue(roleTO.getEntitlements().contains(StandardEntitlement.USER_READ));
}
Also used : RoleTO(org.apache.syncope.common.lib.to.RoleTO) Test(org.junit.jupiter.api.Test)

Example 10 with RoleTO

use of org.apache.syncope.common.lib.to.RoleTO in project syncope by apache.

the class RoleITCase method delete.

@Test
public void delete() {
    RoleTO role = getSampleRoleTO("delete");
    Response response = roleService.create(role);
    RoleTO actual = getObject(response.getLocation(), RoleService.class, RoleTO.class);
    assertNotNull(actual);
    roleService.delete(actual.getKey());
    try {
        roleService.read(actual.getKey());
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.NotFound, e.getType());
    }
}
Also used : Response(javax.ws.rs.core.Response) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) RoleTO(org.apache.syncope.common.lib.to.RoleTO) Test(org.junit.jupiter.api.Test)

Aggregations

RoleTO (org.apache.syncope.common.lib.to.RoleTO)18 Test (org.junit.jupiter.api.Test)12 Response (javax.ws.rs.core.Response)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)8 UserTO (org.apache.syncope.common.lib.to.UserTO)6 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)4 RoleService (org.apache.syncope.common.rest.api.service.RoleService)4 AbstractITCase (org.apache.syncope.fit.AbstractITCase)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)3 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)3 PagedResult (org.apache.syncope.common.lib.to.PagedResult)3 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)3 AnyTypeKind (org.apache.syncope.common.lib.types.AnyTypeKind)3 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)3 AnyQuery (org.apache.syncope.common.rest.api.beans.AnyQuery)3 UserService (org.apache.syncope.common.rest.api.service.UserService)3 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)3