Search in sources :

Example 41 with SyncopeClientException

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());
    }
}
Also used : MappingTO(org.apache.syncope.common.lib.to.MappingTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) ItemTO(org.apache.syncope.common.lib.to.ItemTO) Test(org.junit.jupiter.api.Test)

Example 42 with SyncopeClientException

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);
    }
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) SerializationUtils(org.apache.commons.lang3.SerializationUtils) ConnConfPropSchema(org.apache.syncope.common.lib.types.ConnConfPropSchema) HashSet(java.util.HashSet) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) GuardedString(org.identityconnectors.common.security.GuardedString) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BeforeAll(org.junit.jupiter.api.BeforeAll) Locale(java.util.Locale) ItemTO(org.apache.syncope.common.lib.to.ItemTO) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AbstractITCase(org.apache.syncope.fit.AbstractITCase) EnumSet(java.util.EnumSet) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Properties(java.util.Properties) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) MappingTO(org.apache.syncope.common.lib.to.MappingTO) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) UUID(java.util.UUID) ConnIdObjectClassTO(org.apache.syncope.common.lib.to.ConnIdObjectClassTO) ResourceService(org.apache.syncope.common.rest.api.service.ResourceService) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) List(java.util.List) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) Response(javax.ws.rs.core.Response) ConnectorCapability(org.apache.syncope.common.lib.types.ConnectorCapability) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) InputStream(java.io.InputStream) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) ConnBundleTO(org.apache.syncope.common.lib.to.ConnBundleTO) ConnPoolConfTO(org.apache.syncope.common.lib.to.ConnPoolConfTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) ConnectorService(org.apache.syncope.common.rest.api.service.ConnectorService) Test(org.junit.jupiter.api.Test)

Example 43 with SyncopeClientException

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()));
    }
}
Also used : SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) Test(org.junit.jupiter.api.Test)

Example 44 with SyncopeClientException

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());
    }
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 45 with SyncopeClientException

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();
    }
}
Also used : DomainTO(org.apache.syncope.common.lib.to.DomainTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Aggregations

SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)240 Test (org.junit.jupiter.api.Test)105 UserTO (org.apache.syncope.common.lib.to.UserTO)50 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)42 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)40 Response (javax.ws.rs.core.Response)34 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)20 PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)19 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)18 Realm (org.apache.syncope.core.persistence.api.entity.Realm)18 GroupTO (org.apache.syncope.common.lib.to.GroupTO)17 ClientExceptionType (org.apache.syncope.common.lib.types.ClientExceptionType)16 AttrTO (org.apache.syncope.common.lib.to.AttrTO)15 Map (java.util.Map)14 SyncopeClientCompositeException (org.apache.syncope.common.lib.SyncopeClientCompositeException)14 ArrayList (java.util.ArrayList)12 List (java.util.List)12 ItemTO (org.apache.syncope.common.lib.to.ItemTO)12 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)11