Search in sources :

Example 6 with ConnInstanceTO

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

the class GroupITCase method capabilitiesOverride.

@Test
public void capabilitiesOverride() {
    // resource with no capability override
    ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
    assertNotNull(ldap);
    assertFalse(ldap.isOverrideCapabilities());
    assertTrue(ldap.getCapabilitiesOverride().isEmpty());
    // connector with all required for create and update
    ConnInstanceTO conn = connectorService.read(ldap.getConnector(), null);
    assertNotNull(conn);
    assertTrue(conn.getCapabilities().contains(ConnectorCapability.CREATE));
    assertTrue(conn.getCapabilities().contains(ConnectorCapability.UPDATE));
    try {
        // 1. create succeeds
        GroupTO group = getSampleTO("syncope714");
        group.getPlainAttrs().add(attrTO("title", "first"));
        group.getResources().add(RESOURCE_NAME_LDAP);
        ProvisioningResult<GroupTO> result = createGroup(group);
        assertNotNull(result);
        assertEquals(1, result.getPropagationStatuses().size());
        assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
        assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
        group = result.getEntity();
        // 2. update succeeds
        GroupPatch patch = new GroupPatch();
        patch.setKey(group.getKey());
        patch.getPlainAttrs().add(new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO("title", "second")).build());
        result = updateGroup(patch);
        assertNotNull(result);
        assertEquals(1, result.getPropagationStatuses().size());
        assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
        assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
        group = result.getEntity();
        // 3. set capability override with only search allowed, but not enable
        ldap.getCapabilitiesOverride().add(ConnectorCapability.SEARCH);
        resourceService.update(ldap);
        ldap = resourceService.read(RESOURCE_NAME_LDAP);
        assertNotNull(ldap);
        assertFalse(ldap.isOverrideCapabilities());
        assertEquals(1, ldap.getCapabilitiesOverride().size());
        assertTrue(ldap.getCapabilitiesOverride().contains(ConnectorCapability.SEARCH));
        // 4. update succeeds again
        patch = new GroupPatch();
        patch.setKey(group.getKey());
        patch.getPlainAttrs().add(new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO("title", "third")).build());
        result = updateGroup(patch);
        assertNotNull(result);
        assertEquals(1, result.getPropagationStatuses().size());
        assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
        assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
        group = result.getEntity();
        // 5. enable capability override
        ldap.setOverrideCapabilities(true);
        resourceService.update(ldap);
        ldap = resourceService.read(RESOURCE_NAME_LDAP);
        assertNotNull(ldap);
        assertTrue(ldap.isOverrideCapabilities());
        assertEquals(1, ldap.getCapabilitiesOverride().size());
        assertTrue(ldap.getCapabilitiesOverride().contains(ConnectorCapability.SEARCH));
        // 6. update now fails
        patch = new GroupPatch();
        patch.setKey(group.getKey());
        patch.getPlainAttrs().add(new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO("title", "fourth")).build());
        result = updateGroup(patch);
        assertNotNull(result);
        assertEquals(1, result.getPropagationStatuses().size());
        assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
        assertEquals(PropagationTaskExecStatus.NOT_ATTEMPTED, result.getPropagationStatuses().get(0).getStatus());
    } finally {
        ldap.getCapabilitiesOverride().clear();
        ldap.setOverrideCapabilities(false);
        resourceService.update(ldap);
    }
}
Also used : ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 7 with ConnInstanceTO

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

the class ConnectorITCase method issueSYNCOPE10.

@Test
public void issueSYNCOPE10() {
    // ----------------------------------
    // Copy resource and connector in order to create new objects.
    // ----------------------------------
    // Retrieve a connector instance template.
    ConnInstanceTO connInstanceTO = connectorService.read("fcf9f2b0-f7d6-42c9-84a6-61b28255a42b", Locale.ENGLISH.getLanguage());
    assertNotNull(connInstanceTO);
    // check for resource
    List<ResourceTO> resources = resourceService.list().stream().filter(resource -> "fcf9f2b0-f7d6-42c9-84a6-61b28255a42b".equals(resource.getConnector())).collect(Collectors.toList());
    assertEquals(4, resources.size());
    // Retrieve a resource TO template.
    ResourceTO resourceTO = resources.get(0);
    // Make it new.
    resourceTO.setKey("newAbout103" + getUUIDString());
    // Make it new.
    connInstanceTO.setKey(null);
    connInstanceTO.setDisplayName("newDisplayName" + getUUIDString());
    // ----------------------------------
    // ----------------------------------
    // Create a new connector instance.
    // ----------------------------------
    Response response = connectorService.create(connInstanceTO);
    if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
        throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
    }
    connInstanceTO = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
    assertNotNull(connInstanceTO);
    assertFalse(connInstanceTO.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
    final String connKey = connInstanceTO.getKey();
    // Link resourceTO to the new connector instance.
    resourceTO.setConnector(connKey);
    // ----------------------------------
    // ----------------------------------
    // Check for connector instance update after resource creation.
    // ----------------------------------
    response = resourceService.create(resourceTO);
    resourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
    assertNotNull(resourceTO);
    resources = resourceService.list().stream().filter(resource -> connKey.equals(resource.getConnector())).collect(Collectors.toList());
    assertEquals(1, resources.size());
    // ----------------------------------
    // ----------------------------------
    // Check for spring bean.
    // ----------------------------------
    ConnInstanceTO connInstanceBean = connectorService.readByResource(resourceTO.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(connInstanceBean);
    assertFalse(connInstanceBean.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
    // ----------------------------------
    // ----------------------------------
    // Check for spring bean update after connector instance update.
    // ----------------------------------
    connInstanceTO.getCapabilities().add(ConnectorCapability.AUTHENTICATE);
    connectorService.update(connInstanceTO);
    ConnInstanceTO actual = connectorService.read(connInstanceTO.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(actual);
    assertTrue(connInstanceTO.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
    // check for spring bean update
    connInstanceBean = connectorService.readByResource(resourceTO.getKey(), Locale.ENGLISH.getLanguage());
    assertTrue(connInstanceBean.getCapabilities().contains(ConnectorCapability.AUTHENTICATE));
// ----------------------------------
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) SerializationUtils(org.apache.commons.lang3.SerializationUtils) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) Locale(java.util.Locale) ItemTO(org.apache.syncope.common.lib.to.ItemTO) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) EnumSet(java.util.EnumSet) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Properties(java.util.Properties) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) MappingTO(org.apache.syncope.common.lib.to.MappingTO) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) UUID(java.util.UUID) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) Response(javax.ws.rs.core.Response) ConnectorCapability(org.apache.syncope.common.lib.types.ConnectorCapability) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) InputStream(java.io.InputStream) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) ConnBundleTO(org.apache.syncope.common.lib.to.ConnBundleTO) ConnPoolConfTO(org.apache.syncope.common.lib.to.ConnPoolConfTO) Response(javax.ws.rs.core.Response) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) GuardedString(org.identityconnectors.common.security.GuardedString) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) Test(org.junit.jupiter.api.Test)

Example 8 with ConnInstanceTO

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

the class ConnectorITCase method issueSYNCOPE605.

@Test
public void issueSYNCOPE605() {
    ConnInstanceTO connectorInstanceTO = connectorService.read("fcf9f2b0-f7d6-42c9-84a6-61b28255a42b", Locale.ENGLISH.getLanguage());
    assertTrue(connectorInstanceTO.getCapabilities().isEmpty());
    connectorInstanceTO.getCapabilities().add(ConnectorCapability.SEARCH);
    connectorService.update(connectorInstanceTO);
    ConnInstanceTO updatedCapabilities = connectorService.read(connectorInstanceTO.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(updatedCapabilities.getCapabilities());
    assertTrue(updatedCapabilities.getCapabilities().size() == 1);
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) Test(org.junit.jupiter.api.Test)

Example 9 with ConnInstanceTO

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

the class ConnectorITCase method update.

@Test
public void update() {
    ConnInstanceTO connectorTO = new ConnInstanceTO();
    connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
    // set connector instance key
    connectorTO.setKey("fcf9f2b0-f7d6-42c9-84a6-61b28255a42b");
    // set connector version
    connectorTO.setVersion(connIdSoapVersion);
    // set connector name
    connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
    // set bundle name
    connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
    connectorTO.setConnRequestTimeout(20);
    // set the connector configuration using PropertyTO
    Set<ConnConfProperty> conf = new HashSet<>();
    ConnConfPropSchema endpointSchema = new ConnConfPropSchema();
    endpointSchema.setName("endpoint");
    endpointSchema.setType(String.class.getName());
    endpointSchema.setRequired(true);
    ConnConfProperty endpoint = new ConnConfProperty();
    endpoint.setSchema(endpointSchema);
    endpoint.getValues().add("http://localhost:8888/syncope-fit-build-tools/cxf/soap");
    conf.add(endpoint);
    ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
    servicenameSchema.setName("servicename");
    servicenameSchema.setType(String.class.getName());
    servicenameSchema.setRequired(true);
    ConnConfProperty servicename = new ConnConfProperty();
    servicename.setSchema(servicenameSchema);
    servicename.getValues().add("Provisioning");
    conf.add(servicename);
    // set connector configuration
    connectorTO.getConf().addAll(conf);
    connectorService.update(connectorTO);
    ConnInstanceTO actual = connectorService.read(connectorTO.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(actual);
    actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
    assertNotNull(actual);
    assertEquals(actual.getBundleName(), connectorTO.getBundleName());
    assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
    assertEquals(actual.getVersion(), connectorTO.getVersion());
    assertEquals(Integer.valueOf(20), actual.getConnRequestTimeout());
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 10 with ConnInstanceTO

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

the class ConnectorITCase method read.

@Test
public void read() {
    ConnInstanceTO connectorInstanceTO = connectorService.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", Locale.ENGLISH.getLanguage());
    assertNotNull(connectorInstanceTO);
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) Test(org.junit.jupiter.api.Test)

Aggregations

ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)42 Test (org.junit.jupiter.api.Test)21 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)15 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)14 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)14 ConnectorService (org.apache.syncope.common.rest.api.service.ConnectorService)11 Response (javax.ws.rs.core.Response)10 HashSet (java.util.HashSet)8 ConnConfPropSchema (org.apache.syncope.common.lib.types.ConnConfPropSchema)8 GuardedString (org.identityconnectors.common.security.GuardedString)8 IOException (java.io.IOException)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 ConnBundleTO (org.apache.syncope.common.lib.to.ConnBundleTO)6 ConnPoolConfTO (org.apache.syncope.common.lib.to.ConnPoolConfTO)6 ItemTO (org.apache.syncope.common.lib.to.ItemTO)6 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)6 Locale (java.util.Locale)5 Properties (java.util.Properties)5