Search in sources :

Example 21 with MappingTO

use of org.apache.syncope.common.lib.to.MappingTO 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 22 with MappingTO

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

the class UserIssuesITCase method issueSYNCOPE493.

@Test
public void issueSYNCOPE493() {
    // 1.  create user and check that firstname is not propagated on resource with mapping for firstname set to NONE
    UserTO userTO = UserITCase.getUniqueSampleTO("493@test.org");
    userTO.getResources().add(RESOURCE_NAME_WS1);
    ProvisioningResult<UserTO> result = createUser(userTO);
    assertNotNull(userTO);
    assertEquals(1, result.getPropagationStatuses().size());
    assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
    userTO = result.getEntity();
    ConnObjectTO actual = resourceService.readConnObject(RESOURCE_NAME_WS1, AnyTypeKind.USER.name(), userTO.getKey());
    assertNotNull(actual);
    // check if mapping attribute with purpose NONE really hasn't been propagated
    assertFalse(actual.getAttr("NAME").isPresent());
    // 2.  update resource ws-target-resource-1
    ResourceTO ws1 = resourceService.read(RESOURCE_NAME_WS1);
    assertNotNull(ws1);
    MappingTO ws1NewUMapping = ws1.getProvision(AnyTypeKind.USER.name()).get().getMapping();
    // change purpose from NONE to BOTH
    for (ItemTO itemTO : ws1NewUMapping.getItems()) {
        if ("firstname".equals(itemTO.getIntAttrName())) {
            itemTO.setPurpose(MappingPurpose.BOTH);
        }
    }
    ws1.getProvision(AnyTypeKind.USER.name()).get().setMapping(ws1NewUMapping);
    resourceService.update(ws1);
    ResourceTO newWs1 = resourceService.read(ws1.getKey());
    assertNotNull(newWs1);
    // check for existence
    Collection<ItemTO> mapItems = newWs1.getProvision(AnyTypeKind.USER.name()).get().getMapping().getItems();
    assertNotNull(mapItems);
    assertEquals(7, mapItems.size());
    // 3.  update user and check firstname propagation
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.setPassword(new PasswordPatch());
    userPatch.getPlainAttrs().add(attrAddReplacePatch("firstname", "firstnameNew"));
    result = updateUser(userPatch);
    assertNotNull(userTO);
    assertEquals(1, result.getPropagationStatuses().size());
    assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
    userTO = result.getEntity();
    ConnObjectTO newUser = resourceService.readConnObject(RESOURCE_NAME_WS1, AnyTypeKind.USER.name(), userTO.getKey());
    assertNotNull(newUser.getAttr("NAME"));
    assertEquals("firstnameNew", newUser.getAttr("NAME").get().getValues().get(0));
    // 4.  restore resource ws-target-resource-1 mapping
    ws1NewUMapping = newWs1.getProvision(AnyTypeKind.USER.name()).get().getMapping();
    // restore purpose from BOTH to NONE
    for (ItemTO itemTO : ws1NewUMapping.getItems()) {
        if ("firstname".equals(itemTO.getIntAttrName())) {
            itemTO.setPurpose(MappingPurpose.NONE);
        }
    }
    newWs1.getProvision(AnyTypeKind.USER.name()).get().setMapping(ws1NewUMapping);
    resourceService.update(newWs1);
}
Also used : MappingTO(org.apache.syncope.common.lib.to.MappingTO) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) UserTO(org.apache.syncope.common.lib.to.UserTO) ConnObjectTO(org.apache.syncope.common.lib.to.ConnObjectTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 23 with MappingTO

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

the class ProvisionWizardBuilder method buildModelSteps.

@Override
protected WizardModel buildModelSteps(final ResourceProvision modelObject, final WizardModel wizardModel) {
    wizardModel.add(new ObjectType(modelObject));
    wizardModel.add(new AuxClasses(modelObject));
    Mapping mapping = new Mapping(modelObject);
    mapping.setOutputMarkupId(true);
    ItemTransformersTogglePanel itemTransformers = new ItemTransformersTogglePanel(mapping, pageRef);
    addOuterObject(itemTransformers);
    JEXLTransformersTogglePanel jexlTransformers = new JEXLTransformersTogglePanel(mapping, pageRef);
    addOuterObject(jexlTransformers);
    if (modelObject.getProvisionTO() != null && modelObject.getProvisionTO().getMapping() == null) {
        modelObject.getProvisionTO().setMapping(new MappingTO());
    }
    mapping.add(new ResourceMappingPanel("mapping", resourceTO, adminRealm, modelObject, itemTransformers, jexlTransformers));
    wizardModel.add(mapping);
    wizardModel.add(new ConnObjectLink(modelObject));
    return wizardModel;
}
Also used : MappingTO(org.apache.syncope.common.lib.to.MappingTO)

Aggregations

MappingTO (org.apache.syncope.common.lib.to.MappingTO)23 ItemTO (org.apache.syncope.common.lib.to.ItemTO)21 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)21 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)21 Test (org.junit.jupiter.api.Test)17 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)10 Response (javax.ws.rs.core.Response)8 HashSet (java.util.HashSet)6 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)5 GroupTO (org.apache.syncope.common.lib.to.GroupTO)5 ResourceService (org.apache.syncope.common.rest.api.service.ResourceService)5 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 OrgUnitTO (org.apache.syncope.common.lib.to.OrgUnitTO)4 UserTO (org.apache.syncope.common.lib.to.UserTO)4 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)4 MappingPurpose (org.apache.syncope.common.lib.types.MappingPurpose)3 ObjectClass (org.identityconnectors.framework.common.objects.ObjectClass)3 ParseException (java.text.ParseException)2 Collections (java.util.Collections)2