use of org.apache.syncope.common.lib.SyncopeClientException 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.SyncopeClientException in project syncope by apache.
the class ConnectorITCase method authorizations.
@Test
public void authorizations() {
SyncopeClient puccini = clientFactory.create("puccini", ADMIN_PWD);
ConnectorService pcs = puccini.getService(ConnectorService.class);
// 1. list connectors: get only the ones allowed
List<ConnInstanceTO> connInstances = pcs.list(null);
assertEquals(2, connInstances.size());
assertTrue(connInstances.stream().allMatch(connInstance -> "a6d017fd-a705-4507-bb7c-6ab6a6745997".equals(connInstance.getKey()) || "44c02549-19c3-483c-8025-4919c3283c37".equals(connInstance.getKey())));
// 2. attempt to read a connector with a different admin realm: fail
try {
pcs.read("88a7a819-dab5-46b4-9b90-0b9769eabdb8", null);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.DelegatedAdministration, e.getType());
}
// 3. read and upate a connector in the realm for which entitlements are owned: succeed
try {
ConnInstanceTO scriptedsql = pcs.read("a6d017fd-a705-4507-bb7c-6ab6a6745997", null);
ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
assertEquals("true", reloadScriptOnExecution.getValues().get(0).toString());
reloadScriptOnExecution.getValues().set(0, "false");
pcs.update(scriptedsql);
scriptedsql = pcs.read(scriptedsql.getKey(), null);
reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
assertEquals("false", reloadScriptOnExecution.getValues().get(0).toString());
} finally {
ConnInstanceTO scriptedsql = connectorService.read("a6d017fd-a705-4507-bb7c-6ab6a6745997", null);
ConnConfProperty reloadScriptOnExecution = scriptedsql.getConf("reloadScriptOnExecution").get();
reloadScriptOnExecution.getValues().set(0, "true");
connectorService.update(scriptedsql);
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class DerSchemaITCase method issueSYNCOPE418.
@Test
public void issueSYNCOPE418() {
DerSchemaTO schema = new DerSchemaTO();
schema.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
schema.setExpression("derived_sx + '_' + derived_dx");
try {
createSchema(SchemaType.DERIVED, schema);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidDerSchema, e.getType());
assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidKey.name()));
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class DomainITCase method create.
@Test
public void create() {
DomainTO domain = new DomainTO();
domain.setKey("last");
domain.setAdminCipherAlgorithm(CipherAlgorithm.SSHA512);
domain.setAdminPwd("password");
try {
domainService.create(domain);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
use of org.apache.syncope.common.lib.SyncopeClientException in project syncope by apache.
the class DomainITCase method delete.
@Test
public void delete() {
DomainTO two = domainService.read("Two");
assertNotNull(two);
try {
domainService.delete(two.getKey());
try {
domainService.read(two.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
} finally {
restoreTwo();
}
}
Aggregations