use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ResourceTest method saveInvalidProvision.
@Test
public void saveInvalidProvision() {
assertThrows(InvalidEntityException.class, () -> {
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey("invalidProvision");
Provision provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findUser());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
Mapping mapping = entityFactory.newEntity(Mapping.class);
mapping.setProvision(provision);
provision.setMapping(mapping);
MappingItem connObjectKey = entityFactory.newEntity(MappingItem.class);
connObjectKey.setExtAttrName("username");
connObjectKey.setIntAttrName("fullname");
connObjectKey.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(connObjectKey);
provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findGroup());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
resource.setConnector(connector);
// save the resource
resourceDAO.save(resource);
});
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnInstanceHistoryConfTest method createDelete.
@Test
public void createDelete() {
ConnInstance ldapConnector = connInstanceDAO.find("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
assertNotNull(ldapConnector);
ConnInstanceHistoryConf ldapHistory = entityFactory.newEntity(ConnInstanceHistoryConf.class);
ldapHistory.setCreation(new Date());
ldapHistory.setCreator("me");
ldapHistory.setEntity(ldapConnector);
ldapHistory.setConf(new ConnInstanceTO());
ldapHistory = connInstanceHistoryConfDAO.save(ldapHistory);
assertNotNull(ldapHistory.getKey());
connInstanceHistoryConfDAO.flush();
List<ConnInstanceHistoryConf> history = connInstanceHistoryConfDAO.findByEntity(ldapConnector);
assertEquals(1, history.size());
assertEquals(ldapHistory, history.get(0));
connInstanceHistoryConfDAO.delete(ldapHistory.getKey());
connInstanceHistoryConfDAO.flush();
assertNull(connInstanceHistoryConfDAO.find(ldapHistory.getKey()));
assertTrue(connInstanceHistoryConfDAO.findByEntity(ldapConnector).isEmpty());
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnInstanceTest method save.
@Test
public void save() throws ClassNotFoundException {
ConnInstance connInstance = entityFactory.newEntity(ConnInstance.class);
connInstance.setLocation(new File(System.getProperty("java.io.tmpdir")).toURI().toString());
// set connector version
connInstance.setVersion("1.0");
// set connector name
connInstance.setConnectorName("WebService");
// set bundle name
connInstance.setBundleName("org.apache.syncope.core.persistence.test.util");
connInstance.setDisplayName("New");
connInstance.setConnRequestTimeout(60);
// 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://host.domain");
ConnConfPropSchema servicenameSchema = new ConnConfPropSchema();
servicenameSchema.setName("servicename");
servicenameSchema.setType(String.class.getName());
servicenameSchema.setRequired(true);
ConnConfProperty servicename = new ConnConfProperty();
servicename.setSchema(servicenameSchema);
endpoint.getValues().add("Provisioning");
conf.add(endpoint);
conf.add(servicename);
// set connector configuration
connInstance.setConf(conf);
assertFalse(connInstance.getConf().isEmpty());
// perform save operation
ConnInstance actual = connInstanceDAO.save(connInstance);
assertNotNull("save did not work", actual.getKey());
assertEquals("WebService", actual.getConnectorName());
assertEquals("org.apache.syncope.core.persistence.test.util", actual.getBundleName());
assertEquals("1.0", connInstance.getVersion());
assertEquals("New", actual.getDisplayName());
assertEquals(60, actual.getConnRequestTimeout().intValue());
conf = connInstance.getConf();
assertFalse(conf.isEmpty());
assertNotNull(conf);
assertTrue(conf.size() == 2);
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnInstanceTest method findById.
@Test
public void findById() {
ConnInstance connInstance = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
assertNotNull(connInstance);
assertEquals("net.tirasa.connid.bundles.soap.WebServiceConnector", connInstance.getConnectorName());
assertEquals("net.tirasa.connid.bundles.soap", connInstance.getBundleName());
try {
connInstanceDAO.authFind("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
fail("This should not happen");
} catch (DelegatedAdministrationException e) {
assertNotNull(e);
}
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnInstanceTest method findAll.
@Test
public void findAll() {
List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails("Master"));
SecurityContextHolder.getContext().setAuthentication(auth);
try {
List<ConnInstance> connectors = connInstanceDAO.findAll();
assertNotNull(connectors);
assertFalse(connectors.isEmpty());
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
Aggregations