Search in sources :

Example 6 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch in project syncope by apache.

the class GroupITCase method provision.

@Test
public void provision() {
    GroupTO groupTO = getSampleTO("provision");
    groupTO.getResources().clear();
    try {
        groupTO = createGroup(groupTO).getEntity();
        assertNotNull(groupTO);
        try {
            resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
            fail("This should not happen");
        } catch (Exception e) {
            assertNotNull(e);
        }
        AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
        assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
        groupTO = groupService.read(groupTO.getKey());
        assertTrue(groupTO.getResources().isEmpty());
        assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
    } finally {
        if (groupTO.getKey() != null) {
            groupService.delete(groupTO.getKey());
        }
    }
}
Also used : BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NamingException(javax.naming.NamingException) AccessControlException(java.security.AccessControlException) ForbiddenException(javax.ws.rs.ForbiddenException) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 7 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch in project syncope by apache.

the class UserITCase method deprovisionUnlinked.

@Test
public void deprovisionUnlinked() {
    UserTO userTO = getUniqueSampleTO("provision@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
    AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
    assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
    actual = userService.read(actual.getKey());
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
    DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
    assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
    actual = userService.read(actual.getKey());
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AccessControlException(java.security.AccessControlException) Test(org.junit.jupiter.api.Test)

Example 8 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch in project syncope by apache.

the class UserITCase method assign.

@Test
public void assign() {
    UserTO userTO = getUniqueSampleTO("assign@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
    AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).value("password").action(ResourceAssociationAction.ASSIGN).resource(RESOURCE_NAME_CSV).build();
    assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
    actual = userService.read(actual.getKey());
    assertNotNull(actual);
    assertFalse(actual.getResources().isEmpty());
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AccessControlException(java.security.AccessControlException) Test(org.junit.jupiter.api.Test)

Example 9 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch in project syncope by apache.

the class UserITCase method link.

@Test
public void link() {
    UserTO userTO = getUniqueSampleTO("link@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
    AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).action(ResourceAssociationAction.LINK).resource(RESOURCE_NAME_CSV).build();
    assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
    actual = userService.read(actual.getKey());
    assertNotNull(actual);
    assertFalse(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AccessControlException(java.security.AccessControlException) Test(org.junit.jupiter.api.Test)

Example 10 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch in project syncope by apache.

the class UserITCase method provision.

@Test
public void provision() {
    UserTO userTO = getUniqueSampleTO("provision@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
    AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
    assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
    actual = userService.read(actual.getKey());
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AccessControlException(java.security.AccessControlException) Test(org.junit.jupiter.api.Test)

Aggregations

AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)11 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)11 AccessControlException (java.security.AccessControlException)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)8 Test (org.junit.jupiter.api.Test)8 NamingException (javax.naming.NamingException)4 ForbiddenException (javax.ws.rs.ForbiddenException)4 GroupTO (org.apache.syncope.common.lib.to.GroupTO)4 UserTO (org.apache.syncope.common.lib.to.UserTO)4 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)3 DeassociationPatch (org.apache.syncope.common.lib.patch.DeassociationPatch)2