Search in sources :

Example 6 with DeassociationPatch

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

the class AuthenticationITCase method issueSYNCOPE164.

@Test
public void issueSYNCOPE164() throws Exception {
    // 1. create user with db resource
    UserTO user = UserITCase.getUniqueSampleTO("syncope164@syncope.apache.org");
    user.setRealm("/even/two");
    user.setPassword("password123");
    user.getResources().add(RESOURCE_NAME_TESTDB);
    user = createUser(user).getEntity();
    assertNotNull(user);
    // 2. unlink the resource from the created user
    DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(user.getKey()).action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_TESTDB).build();
    assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
    // 3. change password on Syncope
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(user.getKey());
    userPatch.setPassword(new PasswordPatch.Builder().value("password234").build());
    user = updateUser(userPatch).getEntity();
    assertNotNull(user);
    // 4. check that the db resource has still the initial password value
    final JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
    String value = queryForObject(jdbcTemplate, 50, "SELECT PASSWORD FROM test WHERE ID=?", String.class, user.getUsername());
    assertEquals(Encryptor.getInstance().encode("password123", CipherAlgorithm.SHA1), value.toUpperCase());
    // 5. successfully authenticate with old (on db resource) and new (on internal storage) password values
    Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(user.getUsername(), "password123").self();
    assertNotNull(self);
    self = clientFactory.create(user.getUsername(), "password234").self();
    assertNotNull(self);
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) Map(java.util.Map) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 7 with DeassociationPatch

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

the class GroupITCase method unlink.

@Test
public void unlink() {
    GroupTO actual = createGroup(getSampleTO("unlink")).getEntity();
    assertNotNull(actual);
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
    DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build();
    assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
    actual = groupService.read(actual.getKey());
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 8 with DeassociationPatch

use of org.apache.syncope.common.lib.patch.DeassociationPatch 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 9 with DeassociationPatch

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

the class UserITCase method unassign.

@Test
public void unassign() {
    UserTO userTO = getUniqueSampleTO("unassign@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    userTO.getResources().add(RESOURCE_NAME_CSV);
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
    DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.UNASSIGN).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) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AccessControlException(java.security.AccessControlException) Test(org.junit.jupiter.api.Test)

Example 10 with DeassociationPatch

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

the class UserITCase method deprovision.

@Test
public void deprovision() {
    UserTO userTO = getUniqueSampleTO("deprovision@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    userTO.getResources().add(RESOURCE_NAME_CSV);
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    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);
    assertFalse(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
        fail("This should not happen");
    } catch (SyncopeClientException e) {
        assertEquals(ClientExceptionType.NotFound, e.getType());
    }
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) Test(org.junit.jupiter.api.Test)

Aggregations

DeassociationPatch (org.apache.syncope.common.lib.patch.DeassociationPatch)13 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)13 Test (org.junit.jupiter.api.Test)10 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 UserTO (org.apache.syncope.common.lib.to.UserTO)6 AccessControlException (java.security.AccessControlException)5 GroupTO (org.apache.syncope.common.lib.to.GroupTO)5 NamingException (javax.naming.NamingException)3 ForbiddenException (javax.ws.rs.ForbiddenException)3 AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)2 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)2 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)2 Map (java.util.Map)1 DataSource (javax.sql.DataSource)1 Response (javax.ws.rs.core.Response)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 AttrPatch (org.apache.syncope.common.lib.patch.AttrPatch)1 MembershipPatch (org.apache.syncope.common.lib.patch.MembershipPatch)1 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)1 AttrTO (org.apache.syncope.common.lib.to.AttrTO)1