Search in sources :

Example 76 with UserPatch

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

the class UserIssuesITCase method issueSYNCOPE710.

@Test
public void issueSYNCOPE710() {
    // 1. create groups for indirect resource assignment
    GroupTO ldapGroup = GroupITCase.getBasicSampleTO("syncope710.ldap");
    ldapGroup.getResources().add(RESOURCE_NAME_LDAP);
    ldapGroup = createGroup(ldapGroup).getEntity();
    GroupTO dbGroup = GroupITCase.getBasicSampleTO("syncope710.db");
    dbGroup.getResources().add(RESOURCE_NAME_TESTDB);
    dbGroup = createGroup(dbGroup).getEntity();
    // 2. create user with memberships for the groups created above
    UserTO userTO = UserITCase.getUniqueSampleTO("syncope710@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getMemberships().add(new MembershipTO.Builder().group(ldapGroup.getKey()).build());
    userTO.getMemberships().add(new MembershipTO.Builder().group(dbGroup.getKey()).build());
    ProvisioningResult<UserTO> result = createUser(userTO);
    assertEquals(2, result.getPropagationStatuses().size());
    userTO = result.getEntity();
    // 3. request to propagate passwod only to db
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.setPassword(new PasswordPatch.Builder().onSyncope(false).resource(RESOURCE_NAME_TESTDB).value("newpassword123").build());
    result = updateUser(userPatch);
    assertEquals(1, result.getPropagationStatuses().size());
    assertEquals(RESOURCE_NAME_TESTDB, result.getPropagationStatuses().get(0).getResource());
}
Also used : PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 77 with UserPatch

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

the class UserIssuesITCase method issueSYNCOPE420.

@Test
public void issueSYNCOPE420() throws IOException {
    ImplementationTO logicActions = new ImplementationTO();
    logicActions.setKey("DoubleValueLogicActions");
    logicActions.setEngine(ImplementationEngine.GROOVY);
    logicActions.setType(ImplementationType.LOGIC_ACTIONS);
    logicActions.setBody(org.apache.commons.io.IOUtils.toString(getClass().getResourceAsStream("/DoubleValueLogicActions.groovy"), StandardCharsets.UTF_8));
    Response response = implementationService.create(logicActions);
    logicActions = implementationService.read(logicActions.getType(), response.getHeaderString(RESTHeaders.RESOURCE_KEY));
    assertNotNull(logicActions);
    RealmTO realm = realmService.list("/even/two").iterator().next();
    assertNotNull(realm);
    realm.getActions().add(logicActions.getKey());
    realmService.update(realm);
    UserTO userTO = UserITCase.getUniqueSampleTO("syncope420@syncope.apache.org");
    userTO.setRealm(realm.getFullPath());
    userTO.getPlainAttrs().add(attrTO("makeItDouble", "3"));
    userTO = createUser(userTO).getEntity();
    assertEquals("6", userTO.getPlainAttr("makeItDouble").get().getValues().get(0));
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.getPlainAttrs().add(attrAddReplacePatch("makeItDouble", "7"));
    userTO = updateUser(userPatch).getEntity();
    assertEquals("14", userTO.getPlainAttr("makeItDouble").get().getValues().get(0));
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) UserTO(org.apache.syncope.common.lib.to.UserTO) RealmTO(org.apache.syncope.common.lib.to.RealmTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 78 with UserPatch

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

the class UserIssuesITCase method issueSYNCOPE383.

@Test
public void issueSYNCOPE383() {
    // 1. create user without resources
    UserTO userTO = UserITCase.getUniqueSampleTO("syncope383@apache.org");
    userTO.getResources().clear();
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    // 2. assign resource without specifying a new pwd and check propagation failure
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_TESTDB).build());
    ProvisioningResult<UserTO> result = updateUser(userPatch);
    assertNotNull(result);
    userTO = result.getEntity();
    assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
    assertNotEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
    assertNotNull(result.getPropagationStatuses().get(0).getFailureReason());
    userTO = result.getEntity();
    // 3. request to change password only on testdb
    userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    userPatch.setPassword(new PasswordPatch.Builder().value(getUUIDString() + "abbcbcbddd123").resource(RESOURCE_NAME_TESTDB).build());
    result = updateUser(userPatch);
    assertEquals(RESOURCE_NAME_TESTDB, userTO.getResources().iterator().next());
    assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 79 with UserPatch

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

the class UserIssuesITCase method issueSYNCOPE1166.

@Test
public void issueSYNCOPE1166() {
    UserTO userTO = UserITCase.getUniqueSampleTO("syncope1166@apache.org");
    userTO = createUser(userTO).getEntity();
    assertNotNull(userTO);
    UserPatch userPatch = new UserPatch();
    userPatch.setKey(userTO.getKey());
    // resource-ldap has password mapped, resource-db-virattr does not
    userPatch.setPassword(new PasswordPatch.Builder().onSyncope(true).resource(RESOURCE_NAME_LDAP).value("new2Password").build());
    userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_LDAP).build());
    userPatch.getResources().add(new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(RESOURCE_NAME_DBVIRATTR).build());
    ProvisioningResult<UserTO> result = updateUser(userPatch);
    assertNotNull(result);
    assertEquals(2, result.getPropagationStatuses().size());
    assertEquals(RESOURCE_NAME_LDAP, result.getPropagationStatuses().get(0).getResource());
    assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
    assertEquals(RESOURCE_NAME_DBVIRATTR, result.getPropagationStatuses().get(1).getResource());
    assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(1).getStatus());
}
Also used : PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Example 80 with UserPatch

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

the class UserIssuesITCase method issueSYNCOPE265.

@Test
public void issueSYNCOPE265() {
    String[] userKeys = new String[] { "1417acbe-cbf6-4277-9372-e75e04f97000", "74cd8ece-715a-44a4-a736-e17b46c4e7e6", "b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee", "c9b2dec2-00a7-4855-97c0-d854842b4b24", "823074dc-d280-436d-a7dd-07399fae48ec" };
    for (String userKey : userKeys) {
        UserPatch userPatch = new UserPatch();
        userPatch.setKey(userKey);
        userPatch.getPlainAttrs().add(attrAddReplacePatch("ctype", "a type"));
        UserTO userTO = updateUser(userPatch).getEntity();
        assertEquals("a type", userTO.getPlainAttr("ctype").get().getValues().get(0));
    }
}
Also used : UserTO(org.apache.syncope.common.lib.to.UserTO) UserPatch(org.apache.syncope.common.lib.patch.UserPatch) Test(org.junit.jupiter.api.Test)

Aggregations

UserPatch (org.apache.syncope.common.lib.patch.UserPatch)102 UserTO (org.apache.syncope.common.lib.to.UserTO)73 Test (org.junit.jupiter.api.Test)59 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)37 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)18 AttrTO (org.apache.syncope.common.lib.to.AttrTO)17 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)17 Response (javax.ws.rs.core.Response)16 Map (java.util.Map)12 StringReplacePatchItem (org.apache.syncope.common.lib.patch.StringReplacePatchItem)12 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)11 GroupTO (org.apache.syncope.common.lib.to.GroupTO)11 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)11 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)11 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)11 GenericType (javax.ws.rs.core.GenericType)10 Pair (org.apache.commons.lang3.tuple.Pair)10 PatchOperation (org.apache.syncope.common.lib.types.PatchOperation)10 List (java.util.List)9 AttrPatch (org.apache.syncope.common.lib.patch.AttrPatch)9