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