Search in sources :

Example 6 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.

the class ConnectorITCase method issueSYNCOPE112.

@Test
public void issueSYNCOPE112() {
    // ----------------------------------------
    // Create a new connector
    // ----------------------------------------
    ConnInstanceTO connectorTO = new ConnInstanceTO();
    connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
    connectorTO.setLocation(connectorService.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", Locale.ENGLISH.getLanguage()).getLocation());
    // 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");
    // set display name
    connectorTO.setDisplayName("WSSoap");
    // set the connector configuration using PropertyTO
    Set<ConnConfProperty> conf = new HashSet<>();
    ConnConfPropSchema userSchema = new ConnConfPropSchema();
    userSchema.setName("endpoint");
    userSchema.setType(String.class.getName());
    userSchema.setRequired(true);
    ConnConfProperty endpoint = new ConnConfProperty();
    endpoint.setSchema(userSchema);
    endpoint.getValues().add("http://localhost:9080/does_not_work");
    endpoint.setOverridable(true);
    ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
    keyColumnSchema.setName("servicename");
    keyColumnSchema.setType(String.class.getName());
    keyColumnSchema.setRequired(true);
    ConnConfProperty servicename = new ConnConfProperty();
    servicename.setSchema(keyColumnSchema);
    servicename.getValues().add("net.tirasa.connid.bundles.soap.provisioning.interfaces.Provisioning");
    servicename.setOverridable(false);
    conf.add(endpoint);
    conf.add(servicename);
    // set connector configuration
    connectorTO.getConf().addAll(conf);
    try {
        try {
            connectorService.check(connectorTO);
            fail("This should not happen");
        } catch (Exception e) {
            assertNotNull(e);
        }
        Response response = connectorService.create(connectorTO);
        if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
            throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
        }
        connectorTO = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
        assertNotNull(connectorTO);
        // ----------------------------------------
        // ----------------------------------------
        // create a resourceTO
        // ----------------------------------------
        String resourceName = "checkForPropOverriding";
        ResourceTO resourceTO = new ResourceTO();
        resourceTO.setKey(resourceName);
        resourceTO.setConnector(connectorTO.getKey());
        conf = new HashSet<>();
        endpoint.getValues().clear();
        endpoint.getValues().add("http://localhost:9080/syncope-fit-build-tools/cxf/soap/provisioning");
        conf.add(endpoint);
        resourceTO.getConfOverride().addAll(conf);
        ProvisionTO provisionTO = new ProvisionTO();
        provisionTO.setAnyType(AnyTypeKind.USER.name());
        provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
        resourceTO.getProvisions().add(provisionTO);
        MappingTO mapping = new MappingTO();
        provisionTO.setMapping(mapping);
        ItemTO mapItem = new ItemTO();
        mapItem.setExtAttrName("uid");
        mapItem.setIntAttrName("userId");
        mapItem.setConnObjectKey(true);
        mapping.setConnObjectKeyItem(mapItem);
        // ----------------------------------------
        try {
            resourceService.check(resourceTO);
        } catch (Exception e) {
            fail(ExceptionUtils.getStackTrace(e));
        }
    // ----------------------------------------
    } finally {
        // Remove connector from db to make test re-runnable
        connectorService.delete(connectorTO.getKey());
    }
}
Also used : ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) GuardedString(org.identityconnectors.common.security.GuardedString) ItemTO(org.apache.syncope.common.lib.to.ItemTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) IOException(java.io.IOException) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) Response(javax.ws.rs.core.Response) MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 7 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.

the class ConnectorITCase method validate.

@Test
public void validate() {
    ConnInstanceTO connectorTO = new ConnInstanceTO();
    connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
    connectorTO.setLocation(connectorServerLocation);
    connectorTO.setVersion(connIdDbVersion);
    connectorTO.setConnectorName("net.tirasa.connid.bundles.db.table.DatabaseTableConnector");
    connectorTO.setBundleName("net.tirasa.connid.bundles.db.table");
    connectorTO.setDisplayName("H2Test");
    // set the connector configuration using PropertyTO
    Set<ConnConfProperty> conf = new HashSet<>();
    ConnConfPropSchema jdbcDriverSchema = new ConnConfPropSchema();
    jdbcDriverSchema.setName("jdbcDriver");
    jdbcDriverSchema.setType(String.class.getName());
    jdbcDriverSchema.setRequired(true);
    ConnConfProperty jdbcDriver = new ConnConfProperty();
    jdbcDriver.setSchema(jdbcDriverSchema);
    jdbcDriver.getValues().add("org.h2.Driver");
    conf.add(jdbcDriver);
    ConnConfPropSchema jdbcUrlTemplateSchema = new ConnConfPropSchema();
    jdbcUrlTemplateSchema.setName("jdbcUrlTemplate");
    jdbcUrlTemplateSchema.setType(String.class.getName());
    jdbcUrlTemplateSchema.setRequired(true);
    ConnConfProperty jdbcUrlTemplate = new ConnConfProperty();
    jdbcUrlTemplate.setSchema(jdbcUrlTemplateSchema);
    jdbcUrlTemplate.getValues().add(testJDBCURL);
    conf.add(jdbcUrlTemplate);
    ConnConfPropSchema userSchema = new ConnConfPropSchema();
    userSchema.setName("user");
    userSchema.setType(String.class.getName());
    userSchema.setRequired(false);
    ConnConfProperty user = new ConnConfProperty();
    user.setSchema(userSchema);
    user.getValues().add("sa");
    conf.add(user);
    ConnConfPropSchema passwordSchema = new ConnConfPropSchema();
    passwordSchema.setName("password");
    passwordSchema.setType(GuardedString.class.getName());
    passwordSchema.setRequired(true);
    ConnConfProperty password = new ConnConfProperty();
    password.setSchema(passwordSchema);
    password.getValues().add("sa");
    conf.add(password);
    ConnConfPropSchema tableSchema = new ConnConfPropSchema();
    tableSchema.setName("table");
    tableSchema.setType(String.class.getName());
    tableSchema.setRequired(true);
    ConnConfProperty table = new ConnConfProperty();
    table.setSchema(tableSchema);
    table.getValues().add("test");
    conf.add(table);
    ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
    keyColumnSchema.setName("keyColumn");
    keyColumnSchema.setType(String.class.getName());
    keyColumnSchema.setRequired(true);
    ConnConfProperty keyColumn = new ConnConfProperty();
    keyColumn.setSchema(keyColumnSchema);
    keyColumn.getValues().add("id");
    conf.add(keyColumn);
    ConnConfPropSchema passwordColumnSchema = new ConnConfPropSchema();
    passwordColumnSchema.setName("passwordColumn");
    passwordColumnSchema.setType(String.class.getName());
    passwordColumnSchema.setRequired(true);
    ConnConfProperty passwordColumn = new ConnConfProperty();
    passwordColumn.setSchema(passwordColumnSchema);
    passwordColumn.getValues().add("password");
    conf.add(passwordColumn);
    // set connector configuration
    connectorTO.getConf().addAll(conf);
    try {
        connectorService.check(connectorTO);
    } catch (Exception e) {
        fail(ExceptionUtils.getStackTrace(e));
    }
    conf.remove(password);
    password.getValues().clear();
    password.getValues().add("password");
    conf.add(password);
    try {
        connectorService.check(connectorTO);
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) GuardedString(org.identityconnectors.common.security.GuardedString) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) IOException(java.io.IOException) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 8 with ConnConfPropSchema

use of org.apache.syncope.common.lib.types.ConnConfPropSchema in project syncope by apache.

the class ConnectorITCase method create.

@Test
public void create() {
    ConnInstanceTO connectorTO = new ConnInstanceTO();
    connectorTO.setAdminRealm(SyncopeConstants.ROOT_REALM);
    connectorTO.setLocation(connectorService.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", Locale.ENGLISH.getLanguage()).getLocation());
    connectorTO.setVersion(connIdSoapVersion);
    connectorTO.setConnectorName("net.tirasa.connid.bundles.soap.WebServiceConnector");
    connectorTO.setBundleName("net.tirasa.connid.bundles.soap");
    connectorTO.setDisplayName("Display name");
    connectorTO.setConnRequestTimeout(15);
    // 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");
    endpoint.getValues().add("Provisioning");
    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);
    conf.add(servicename);
    // set connector configuration
    connectorTO.getConf().addAll(conf);
    // set connector capabilities
    connectorTO.getCapabilities().add(ConnectorCapability.CREATE);
    connectorTO.getCapabilities().add(ConnectorCapability.UPDATE);
    // set connector pool conf
    ConnPoolConfTO cpc = new ConnPoolConfTO();
    cpc.setMaxObjects(1534);
    connectorTO.setPoolConf(cpc);
    Response response = connectorService.create(connectorTO);
    if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) {
        throw (RuntimeException) clientFactory.getExceptionMapper().fromResponse(response);
    }
    ConnInstanceTO actual = getObject(response.getLocation(), ConnectorService.class, ConnInstanceTO.class);
    assertNotNull(actual);
    assertEquals(actual.getBundleName(), connectorTO.getBundleName());
    assertEquals(actual.getConnectorName(), connectorTO.getConnectorName());
    assertEquals(actual.getVersion(), connectorTO.getVersion());
    assertEquals("Display name", actual.getDisplayName());
    assertEquals(Integer.valueOf(15), actual.getConnRequestTimeout());
    assertEquals(connectorTO.getCapabilities(), actual.getCapabilities());
    assertNotNull(actual.getPoolConf());
    assertEquals(1534, actual.getPoolConf().getMaxObjects().intValue());
    assertEquals(10, actual.getPoolConf().getMaxIdle().intValue());
    Throwable t = null;
    // check update
    actual.getCapabilities().remove(ConnectorCapability.UPDATE);
    actual.getPoolConf().setMaxObjects(null);
    try {
        connectorService.update(actual);
        actual = connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
    } catch (SyncopeClientException e) {
        LOG.error("update failed", e);
        t = e;
    }
    assertNull(t);
    assertNotNull(actual);
    assertEquals(EnumSet.of(ConnectorCapability.CREATE), actual.getCapabilities());
    assertEquals(10, actual.getPoolConf().getMaxObjects().intValue());
    // check also for the deletion of the created object
    try {
        connectorService.delete(actual.getKey());
    } catch (SyncopeClientException e) {
        LOG.error("delete failed", e);
        t = e;
    }
    assertNull(t);
    // check the non existence
    try {
        connectorService.read(actual.getKey(), Locale.ENGLISH.getLanguage());
    } catch (SyncopeClientException e) {
        assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
    }
}
Also used : Response(javax.ws.rs.core.Response) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) GuardedString(org.identityconnectors.common.security.GuardedString) ConnPoolConfTO(org.apache.syncope.common.lib.to.ConnPoolConfTO) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

ConnConfPropSchema (org.apache.syncope.common.lib.types.ConnConfPropSchema)8 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)7 HashSet (java.util.HashSet)6 Test (org.junit.jupiter.api.Test)6 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)5 GuardedString (org.identityconnectors.common.security.GuardedString)4 Response (javax.ws.rs.core.Response)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 IOException (java.io.IOException)2 ConnPoolConfTO (org.apache.syncope.common.lib.to.ConnPoolConfTO)2 ItemTO (org.apache.syncope.common.lib.to.ItemTO)2 MappingTO (org.apache.syncope.common.lib.to.MappingTO)2 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)2 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)2 File (java.io.File)1 URI (java.net.URI)1 Collection (java.util.Collection)1 ConnectorService (org.apache.syncope.common.rest.api.service.ConnectorService)1 ConnInstance (org.apache.syncope.core.persistence.api.entity.ConnInstance)1 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)1