Search in sources :

Example 1 with ResourceService

use of org.apache.syncope.common.rest.api.service.ResourceService in project syncope by apache.

the class ResourceITCase method authorizations.

@Test
public void authorizations() {
    SyncopeClient puccini = clientFactory.create("puccini", ADMIN_PWD);
    ResourceService prs = puccini.getService(ResourceService.class);
    // 1. attempt to read a resource for a connector with a different admin realm: fail
    try {
        prs.read(RESOURCE_NAME_WS1);
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.DelegatedAdministration, e.getType());
    }
    // 2. read and upate a resource for a connector in the realm for which entitlements are owned: succeed
    try {
        ResourceTO scriptedsql = prs.read(RESOURCE_NAME_DBSCRIPTED);
        assertEquals(TraceLevel.ALL, scriptedsql.getCreateTraceLevel());
        scriptedsql.setCreateTraceLevel(TraceLevel.FAILURES);
        prs.update(scriptedsql);
        scriptedsql = prs.read(RESOURCE_NAME_DBSCRIPTED);
        assertEquals(TraceLevel.FAILURES, scriptedsql.getCreateTraceLevel());
    } finally {
        ResourceTO scriptedsql = resourceService.read(RESOURCE_NAME_DBSCRIPTED);
        scriptedsql.setCreateTraceLevel(TraceLevel.ALL);
        resourceService.update(scriptedsql);
    }
}
Also used : ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) Test(org.junit.jupiter.api.Test)

Example 2 with ResourceService

use of org.apache.syncope.common.rest.api.service.ResourceService in project syncope by apache.

the class ResourceRestClient method create.

public ResourceTO create(final ResourceTO resourceTO) {
    ResourceService service = getService(ResourceService.class);
    Response response = service.create(resourceTO);
    return getObject(service, response.getLocation(), ResourceTO.class);
}
Also used : Response(javax.ws.rs.core.Response) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService)

Aggregations

ResourceService (org.apache.syncope.common.rest.api.service.ResourceService)2 Response (javax.ws.rs.core.Response)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)1 Test (org.junit.jupiter.api.Test)1