Search in sources :

Example 1 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class UserIssuesITCase method issue280.

@Test
public void issue280() {
    UserTO userTO = UserITCase.getUniqueSampleTO("issue280@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_TESTDB).value("123password").build());
    userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_TESTDB).build());
    ProvisioningResult<UserTO> result = updateUser(userPatch);
    assertNotNull(result);
    List<PropagationStatus> propagations = result.getPropagationStatuses();
    assertNotNull(propagations);
    assertEquals(1, propagations.size());
    assertEquals(PropagationTaskExecStatus.SUCCESS, propagations.get(0).getStatus());
    String resource = propagations.get(0).getResource();
    assertEquals(RESOURCE_NAME_TESTDB, resource);
}
Also used : PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 2 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class UserIssuesITCase method issueSYNCOPE686.

@Test
public void issueSYNCOPE686() {
    // 1. read configured cipher algorithm in order to be able to restore it at the end of test
    AttrTO pwdCipherAlgo = configurationService.get("password.cipher.algorithm");
    String origpwdCipherAlgo = pwdCipherAlgo.getValues().get(0);
    // 2. set AES password cipher algorithm
    pwdCipherAlgo.getValues().set(0, "AES");
    configurationService.set(pwdCipherAlgo);
    try {
        // 3. create group with LDAP resource assigned
        GroupTO group = GroupITCase.getBasicSampleTO("syncope686");
        group.getResources().add(RESOURCE_NAME_LDAP);
        group = createGroup(group).getEntity();
        assertNotNull(group);
        // 4. create user with no resources
        UserTO userTO = UserITCase.getUniqueSampleTO("syncope686@apache.org");
        userTO.getResources().clear();
        userTO = createUser(userTO).getEntity();
        assertNotNull(userTO);
        // 5. update user with the new group, and don't provide any password
        UserPatch userPatch = new UserPatch();
        userPatch.setKey(userTO.getKey());
        userPatch.getMemberships().add(new MembershipPatch.Builder().operation(PatchOperation.ADD_REPLACE).group(group.getKey()).build());
        ProvisioningResult<UserTO> result = updateUser(userPatch);
        assertNotNull(result);
        // 5. verify that propagation was successful
        List<PropagationStatus> props = result.getPropagationStatuses();
        assertNotNull(props);
        assertEquals(1, props.size());
        PropagationStatus prop = props.iterator().next();
        assertNotNull(prop);
        assertEquals(RESOURCE_NAME_LDAP, prop.getResource());
        assertEquals(PropagationTaskExecStatus.SUCCESS, prop.getStatus());
    } finally {
        // restore initial cipher algorithm
        pwdCipherAlgo.getValues().set(0, origpwdCipherAlgo);
        configurationService.set(pwdCipherAlgo);
    }
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 3 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class UserIssuesITCase method issue281.

@Test
public void issue281() {
    UserTO userTO = UserITCase.getUniqueSampleTO("issue281@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getResources().add(RESOURCE_NAME_CSV);
    ProvisioningResult<UserTO> result = createUser(userTO);
    assertNotNull(result);
    List<PropagationStatus> propagations = result.getPropagationStatuses();
    assertNotNull(propagations);
    assertEquals(1, propagations.size());
    assertNotEquals(PropagationTaskExecStatus.SUCCESS, propagations.get(0).getStatus());
    String resource = propagations.get(0).getResource();
    assertEquals(RESOURCE_NAME_CSV, resource);
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) Test(org.junit.jupiter.api.Test)

Example 4 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class UserIssuesITCase method issueSYNCOPE136Random.

@Test
public void issueSYNCOPE136Random() {
    // 1. create user with no resources
    UserTO userTO = UserITCase.getUniqueSampleTO("syncope136_Random@apache.org");
    userTO.getResources().clear();
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    // 2. update user, assign a propagation priority resource but don't provide any password
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_LDAP).build());
    userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_LDAP).build());
    ProvisioningResult<UserTO> result = updateUser(userPatch);
    assertNotNull(result);
    // 3. verify that propagation was successful
    List<PropagationStatus> props = result.getPropagationStatuses();
    assertNotNull(props);
    assertEquals(1, props.size());
    PropagationStatus prop = props.iterator().next();
    assertNotNull(prop);
    assertEquals(RESOURCE_NAME_LDAP, prop.getResource());
    assertEquals(PropagationTaskExecStatus.SUCCESS, prop.getStatus());
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 5 with PropagationStatus

use of org.apache.syncope.common.lib.to.PropagationStatus in project syncope by apache.

the class AnyObjectLogic method deprovision.

@Override
public ProvisioningResult<AnyObjectTO> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    // security checks
    AnyObjectTO anyObjectTO = binder.getAnyObjectTO(key);
    Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(AnyEntitlement.UPDATE.getFor(anyObjectTO.getType())), anyObjectTO.getRealm());
    securityChecks(effectiveRealms, anyObjectTO.getRealm(), anyObjectTO.getKey());
    List<PropagationStatus> statuses = provisioningManager.deprovision(key, resources, nullPriorityAsync);
    ProvisioningResult<AnyObjectTO> result = new ProvisioningResult<>();
    result.setEntity(binder.getAnyObjectTO(key));
    result.getPropagationStatuses().addAll(statuses);
    return result;
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus)

Aggregations

PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)24 UserTO (org.apache.syncope.common.lib.to.UserTO)12 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)11 Test (org.junit.jupiter.api.Test)9 GroupTO (org.apache.syncope.common.lib.to.GroupTO)7 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 List (java.util.List)4 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)4 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)3 Group (org.apache.syncope.core.persistence.api.entity.group.Group)3 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)2 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)2 AttrTO (org.apache.syncope.common.lib.to.AttrTO)2 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)2 UserService (org.apache.syncope.common.rest.api.service.UserService)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1