use of org.apache.syncope.common.lib.to.ProvisionTO in project syncope by apache.
the class ResourceITCase method issueSYNCOPE493.
@Test
public void issueSYNCOPE493() {
// create resource with attribute mapping set to NONE and check its propagation
String resourceKey = RESOURCE_NAME_CREATE_NONE;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
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 item = new ItemTO();
item.setIntAttrName("key");
item.setExtAttrName("userId");
item.setConnObjectKey(true);
item.setPurpose(MappingPurpose.PROPAGATION);
mapping.setConnObjectKeyItem(item);
ItemTO item2 = new ItemTO();
item2.setConnObjectKey(false);
item2.setIntAttrName("gender");
item2.setExtAttrName("gender");
item2.setPurpose(MappingPurpose.NONE);
mapping.add(item2);
Response response = resourceService.create(resourceTO);
ResourceTO actual = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
assertNotNull(actual);
assertNotNull(actual.getProvision(AnyTypeKind.USER.name()).get().getMapping());
assertNotNull(actual.getProvision(AnyTypeKind.USER.name()).get().getMapping().getItems());
assertEquals(MappingPurpose.PROPAGATION, actual.getProvision(AnyTypeKind.USER.name()).get().getMapping().getConnObjectKeyItem().getPurpose());
actual.getProvision(AnyTypeKind.USER.name()).get().getMapping().getItems().stream().filter(itemTO -> ("gender".equals(itemTO.getIntAttrName()))).forEach(itemTO -> assertEquals(MappingPurpose.NONE, itemTO.getPurpose()));
}
use of org.apache.syncope.common.lib.to.ProvisionTO in project syncope by apache.
the class ResourceITCase method createWithInvalidMapping.
@Test
public void createWithInvalidMapping() {
String resourceKey = RESOURCE_NAME_CREATE_WRONG;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
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 item = new ItemTO();
item.setIntAttrName("key");
item.setExtAttrName("userId");
item.setConnObjectKey(true);
mapping.setConnObjectKeyItem(item);
item = new ItemTO();
item.setExtAttrName("email");
// missing intAttrName ...
mapping.add(item);
try {
createResource(resourceTO);
fail("Create should not have worked");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
assertEquals("intAttrName", e.getElements().iterator().next());
}
}
use of org.apache.syncope.common.lib.to.ProvisionTO in project syncope by apache.
the class ResourceITCase method issueSYNCOPE368.
@Test
public void issueSYNCOPE368() {
final String name = "SYNCOPE368-" + getUUIDString();
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(name);
resourceTO.setConnector("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.GROUP.name());
provisionTO.setObjectClass(ObjectClass.GROUP_NAME);
resourceTO.getProvisions().add(provisionTO);
MappingTO mapping = new MappingTO();
provisionTO.setMapping(mapping);
ItemTO item = new ItemTO();
item.setIntAttrName("name");
item.setExtAttrName("cn");
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
item = new ItemTO();
item.setIntAttrName("userOwner");
item.setExtAttrName("owner");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
resourceTO = createResource(resourceTO);
assertNotNull(resourceTO);
assertEquals(2, resourceTO.getProvision(AnyTypeKind.GROUP.name()).get().getMapping().getItems().size());
}
use of org.apache.syncope.common.lib.to.ProvisionTO in project syncope by apache.
the class ResourceITCase method issueSYNCOPE888.
@Test
public void issueSYNCOPE888() {
String resourceKey = RESOURCE_NAME_CREATE_WRONG;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
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 item = new ItemTO();
item.setIntAttrName("key");
item.setExtAttrName("userId");
item.setConnObjectKey(true);
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
// Add mapping for a not existing internal attribute
item = new ItemTO();
item.setIntAttrName("locatio");
item.setExtAttrName("location");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
try {
createResource(resourceTO);
fail("Create should not have worked");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidMapping, e.getType());
assertEquals(1, e.getElements().size());
assertEquals("'locatio' not existing", e.getElements().iterator().next());
}
}
use of org.apache.syncope.common.lib.to.ProvisionTO in project syncope by apache.
the class ResourceITCase method update.
@Test
public void update() {
String resourceKey = RESOURCE_NAME_UPDATE;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5aa5b8be-7521-481a-9651-c557aea078c1");
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);
// Update with an existing and already assigned mapping
ItemTO item = new ItemTO();
item.setKey("cc973ed6-d031-4790-adab-fc059ac0c818");
item.setExtAttrName("test3");
item.setIntAttrName("fullname");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
// Update defining new mappings
for (int i = 4; i < 6; i++) {
item = new ItemTO();
item.setExtAttrName("test" + i);
item.setIntAttrName("fullname");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
}
item = new ItemTO();
item.setExtAttrName("username");
item.setIntAttrName("key");
item.setConnObjectKey(true);
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
resourceService.update(resourceTO);
ResourceTO actual = resourceService.read(resourceTO.getKey());
assertNotNull(actual);
// check for existence
Collection<ItemTO> mapItems = actual.getProvision(AnyTypeKind.USER.name()).get().getMapping().getItems();
assertNotNull(mapItems);
assertEquals(4, mapItems.size());
}
Aggregations