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());
}
}
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);
}
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;
}
Aggregations