You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/06/30 11:31:40 UTC
[2/4] syncope git commit: Re-consolidating Core IT in a single
execution group
Re-consolidating Core IT in a single execution group
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/a4166f98
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/a4166f98
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/a4166f98
Branch: refs/heads/2_0_X
Commit: a4166f984aaee568ce9afcb1021869d63254b25b
Parents: a088946
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Jun 30 13:31:03 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Jun 30 13:31:07 2017 +0200
----------------------------------------------------------------------
fit/core-reference/pom.xml | 6 -
.../apache/syncope/fit/core/GroupITCase.java | 193 +++++++
.../syncope/fit/core/GroupIssuesITCase.java | 235 --------
.../fit/core/NotificationTaskITCase.java | 175 ++++++
.../fit/core/NotificationTaskIssuesITCase.java | 207 -------
.../apache/syncope/fit/core/PullTaskITCase.java | 489 ++++++++++++++++-
.../syncope/fit/core/PullTaskIssuesITCase.java | 550 -------------------
.../apache/syncope/fit/core/PushTaskITCase.java | 148 +++++
.../syncope/fit/core/PushTaskIssuesITCase.java | 185 -------
.../apache/syncope/fit/core/ReportITCase.java | 57 ++
.../syncope/fit/core/ReportIssuesITCase.java | 90 ---
.../org/apache/syncope/fit/core/UserITCase.java | 18 -
.../syncope/fit/core/UserIssuesITCase.java | 13 -
.../apache/syncope/fit/core/VirAttrITCase.java | 7 +-
14 files changed, 1061 insertions(+), 1312 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/a4166f98/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index b23636e..ee88bc9 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -230,9 +230,6 @@ under the License.
<includes>
<include>**/org/apache/syncope/fit/core/*ITCase.java</include>
</includes>
- <excludes>
- <exclude>**/*IssuesITCase.java</exclude>
- </excludes>
</configuration>
<executions>
<execution>
@@ -401,9 +398,6 @@ under the License.
<includes>
<include>**/*ITCase.java</include>
</includes>
- <excludes>
- <exclude>**/*Test.java</exclude>
- </excludes>
</configuration>
<executions>
<execution>
http://git-wip-us.apache.org/repos/asf/syncope/blob/a4166f98/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
index 8b7b0f8..082adf7 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupITCase.java
@@ -30,11 +30,17 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import javax.ws.rs.ForbiddenException;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.IterableUtils;
import org.apache.commons.collections4.Predicate;
+import org.apache.commons.lang3.SerializationUtils;
import org.apache.syncope.client.lib.AnonymousAuthenticationHandler;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.AnyOperations;
@@ -55,21 +61,27 @@ import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.BulkActionResult;
import org.apache.syncope.common.lib.to.ConnInstanceTO;
import org.apache.syncope.common.lib.to.ConnObjectTO;
+import org.apache.syncope.common.lib.to.DerSchemaTO;
import org.apache.syncope.common.lib.to.ExecTO;
import org.apache.syncope.common.lib.to.PagedResult;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
import org.apache.syncope.common.lib.to.ResourceTO;
import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.MappingItemTO;
+import org.apache.syncope.common.lib.to.MappingTO;
import org.apache.syncope.common.lib.to.MembershipTO;
import org.apache.syncope.common.lib.to.PropagationStatus;
+import org.apache.syncope.common.lib.to.ProvisionTO;
import org.apache.syncope.common.lib.to.ProvisioningResult;
import org.apache.syncope.common.lib.to.SchedTaskTO;
import org.apache.syncope.common.lib.to.TypeExtensionTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.AttrSchemaType;
import org.apache.syncope.common.lib.types.BulkMembersActionType;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.ConnectorCapability;
+import org.apache.syncope.common.lib.types.MappingPurpose;
import org.apache.syncope.common.lib.types.PatchOperation;
import org.apache.syncope.common.lib.types.PropagationTaskExecStatus;
import org.apache.syncope.common.lib.types.ResourceAssociationAction;
@@ -876,4 +888,185 @@ public class GroupITCase extends AbstractITCase {
userService.delete(userTO.getKey());
}
}
+
+ @Test
+ public void issue178() {
+ GroupTO groupTO = new GroupTO();
+ String groupName = "torename" + getUUIDString();
+ groupTO.setName(groupName);
+ groupTO.setRealm("/");
+
+ GroupTO actual = createGroup(groupTO).getEntity();
+
+ assertNotNull(actual);
+ assertEquals(groupName, actual.getName());
+
+ GroupPatch groupPatch = new GroupPatch();
+ groupPatch.setKey(actual.getKey());
+ String renamedGroup = "renamed" + getUUIDString();
+ groupPatch.setName(new StringReplacePatchItem.Builder().value(renamedGroup).build());
+
+ actual = updateGroup(groupPatch).getEntity();
+ assertNotNull(actual);
+ assertEquals(renamedGroup, actual.getName());
+ }
+
+ @Test
+ public void issueSYNCOPE632() {
+ DerSchemaTO orig = schemaService.read(SchemaType.DERIVED, "displayProperty");
+ DerSchemaTO modified = SerializationUtils.clone(orig);
+ modified.setExpression("icon + '_' + show");
+
+ GroupTO groupTO = GroupITCase.getSampleTO("lastGroup");
+ try {
+ schemaService.update(SchemaType.DERIVED, modified);
+
+ // 0. create group
+ groupTO.getPlainAttrs().add(attrTO("icon", "anIcon"));
+ groupTO.getPlainAttrs().add(attrTO("show", "true"));
+ groupTO.getResources().clear();
+
+ groupTO = createGroup(groupTO).getEntity();
+ assertNotNull(groupTO);
+
+ // 1. create new LDAP resource having ConnObjectKey mapped to a derived attribute
+ ResourceTO newLDAP = resourceService.read(RESOURCE_NAME_LDAP);
+ newLDAP.setKey("new-ldap");
+ newLDAP.setPropagationPriority(0);
+
+ for (ProvisionTO provision : newLDAP.getProvisions()) {
+ provision.getVirSchemas().clear();
+ }
+
+ MappingTO mapping = newLDAP.getProvision(AnyTypeKind.GROUP.name()).getMapping();
+
+ MappingItemTO connObjectKey = mapping.getConnObjectKeyItem();
+ connObjectKey.setIntAttrName("displayProperty");
+ connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
+ mapping.setConnObjectKeyItem(connObjectKey);
+ mapping.setConnObjectLink("'cn=' + displayProperty + ',ou=groups,o=isp'");
+
+ MappingItemTO description = new MappingItemTO();
+ description.setIntAttrName("key");
+ description.setExtAttrName("description");
+ description.setPurpose(MappingPurpose.PROPAGATION);
+ mapping.add(description);
+
+ newLDAP = createResource(newLDAP);
+ assertNotNull(newLDAP);
+
+ // 2. update group and give the resource created above
+ GroupPatch patch = new GroupPatch();
+ patch.setKey(groupTO.getKey());
+ patch.getResources().add(new StringPatchItem.Builder().
+ operation(PatchOperation.ADD_REPLACE).
+ value("new-ldap").build());
+
+ groupTO = updateGroup(patch).getEntity();
+ assertNotNull(groupTO);
+
+ // 3. update the group
+ GroupPatch groupPatch = new GroupPatch();
+ groupPatch.setKey(groupTO.getKey());
+ groupPatch.getPlainAttrs().add(attrAddReplacePatch("icon", "anotherIcon"));
+
+ groupTO = updateGroup(groupPatch).getEntity();
+ assertNotNull(groupTO);
+
+ // 4. check that a single group exists in LDAP for the group created and updated above
+ int entries = 0;
+ DirContext ctx = null;
+ try {
+ ctx = getLdapResourceDirContext(null, null);
+
+ SearchControls ctls = new SearchControls();
+ ctls.setReturningAttributes(new String[] { "*", "+" });
+ ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+
+ NamingEnumeration<SearchResult> result =
+ ctx.search("ou=groups,o=isp", "(description=" + groupTO.getKey() + ")", ctls);
+ while (result.hasMore()) {
+ result.next();
+ entries++;
+ }
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ if (ctx != null) {
+ try {
+ ctx.close();
+ } catch (NamingException e) {
+ // ignore
+ }
+ }
+ }
+
+ assertEquals(1, entries);
+ } finally {
+ schemaService.update(SchemaType.DERIVED, orig);
+ if (groupTO.getKey() != null) {
+ groupService.delete(groupTO.getKey());
+ }
+ resourceService.delete("new-ldap");
+ }
+ }
+
+ @Test
+ public void issueSYNCOPE717() {
+ String doubleSchemaName = "double" + getUUIDString();
+
+ // 1. create double schema without conversion pattern
+ PlainSchemaTO schema = new PlainSchemaTO();
+ schema.setKey(doubleSchemaName);
+ schema.setType(AttrSchemaType.Double);
+
+ schema = createSchema(SchemaType.PLAIN, schema);
+ assertNotNull(schema);
+ assertNull(schema.getConversionPattern());
+
+ AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal group");
+ assertNotNull(minimalGroup);
+ minimalGroup.getPlainSchemas().add(doubleSchemaName);
+ anyTypeClassService.update(minimalGroup);
+
+ // 2. create group, provide valid input value
+ GroupTO groupTO = GroupITCase.getBasicSampleTO("syncope717");
+ groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
+
+ groupTO = createGroup(groupTO).getEntity();
+ assertNotNull(groupTO);
+ assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+
+ // 3. update schema, set conversion pattern
+ schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
+ schema.setConversionPattern("0.000");
+ schemaService.update(SchemaType.PLAIN, schema);
+
+ // 4. re-read group, verify that pattern was applied
+ groupTO = groupService.read(groupTO.getKey());
+ assertNotNull(groupTO);
+ assertEquals("11.230", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+
+ // 5. modify group with new double value
+ GroupPatch patch = new GroupPatch();
+ patch.setKey(groupTO.getKey());
+ patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
+
+ groupTO = updateGroup(patch).getEntity();
+ assertNotNull(groupTO);
+ assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+
+ // 6. update schema, unset conversion pattern
+ schema.setConversionPattern(null);
+ schemaService.update(SchemaType.PLAIN, schema);
+
+ // 7. modify group with new double value, verify that no pattern is applied
+ patch = new GroupPatch();
+ patch.setKey(groupTO.getKey());
+ patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
+
+ groupTO = updateGroup(patch).getEntity();
+ assertNotNull(groupTO);
+ assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a4166f98/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
deleted file mode 100644
index 7f1a03d..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/GroupIssuesITCase.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import org.apache.commons.lang3.SerializationUtils;
-import org.apache.syncope.common.lib.patch.AttrPatch;
-import org.apache.syncope.common.lib.patch.GroupPatch;
-import org.apache.syncope.common.lib.patch.StringPatchItem;
-import org.apache.syncope.common.lib.patch.StringReplacePatchItem;
-import org.apache.syncope.common.lib.to.AnyTypeClassTO;
-import org.apache.syncope.common.lib.to.DerSchemaTO;
-import org.apache.syncope.common.lib.to.MappingItemTO;
-import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.MappingTO;
-import org.apache.syncope.common.lib.to.ProvisionTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.AttrSchemaType;
-import org.apache.syncope.common.lib.types.MappingPurpose;
-import org.apache.syncope.common.lib.types.PatchOperation;
-import org.apache.syncope.common.lib.types.SchemaType;
-import org.apache.syncope.fit.AbstractITCase;
-import org.junit.Test;
-
-public class GroupIssuesITCase extends AbstractITCase {
-
- @Test
- public void issue178() {
- GroupTO groupTO = new GroupTO();
- String groupName = "torename" + getUUIDString();
- groupTO.setName(groupName);
- groupTO.setRealm("/");
-
- GroupTO actual = createGroup(groupTO).getEntity();
-
- assertNotNull(actual);
- assertEquals(groupName, actual.getName());
-
- GroupPatch groupPatch = new GroupPatch();
- groupPatch.setKey(actual.getKey());
- String renamedGroup = "renamed" + getUUIDString();
- groupPatch.setName(new StringReplacePatchItem.Builder().value(renamedGroup).build());
-
- actual = updateGroup(groupPatch).getEntity();
- assertNotNull(actual);
- assertEquals(renamedGroup, actual.getName());
- }
-
- @Test
- public void issueSYNCOPE632() {
- DerSchemaTO orig = schemaService.read(SchemaType.DERIVED, "displayProperty");
- DerSchemaTO modified = SerializationUtils.clone(orig);
- modified.setExpression("icon + '_' + show");
-
- GroupTO groupTO = GroupITCase.getSampleTO("lastGroup");
- try {
- schemaService.update(SchemaType.DERIVED, modified);
-
- // 0. create group
- groupTO.getPlainAttrs().add(attrTO("icon", "anIcon"));
- groupTO.getPlainAttrs().add(attrTO("show", "true"));
- groupTO.getDerAttrs().add(attrTO("displayProperty", null));
- groupTO.getResources().clear();
-
- groupTO = createGroup(groupTO).getEntity();
- assertNotNull(groupTO);
-
- // 1. create new LDAP resource having ConnObjectKey mapped to a derived attribute
- ResourceTO newLDAP = resourceService.read(RESOURCE_NAME_LDAP);
- newLDAP.setKey("new-ldap");
- newLDAP.setPropagationPriority(0);
-
- for (ProvisionTO provision : newLDAP.getProvisions()) {
- provision.getVirSchemas().clear();
- }
-
- MappingTO mapping = newLDAP.getProvision(AnyTypeKind.GROUP.name()).getMapping();
-
- MappingItemTO connObjectKey = mapping.getConnObjectKeyItem();
- connObjectKey.setIntAttrName("displayProperty");
- connObjectKey.setPurpose(MappingPurpose.PROPAGATION);
- mapping.setConnObjectKeyItem(connObjectKey);
- mapping.setConnObjectLink("'cn=' + displayProperty + ',ou=groups,o=isp'");
-
- MappingItemTO description = new MappingItemTO();
- description.setIntAttrName("key");
- description.setExtAttrName("description");
- description.setPurpose(MappingPurpose.PROPAGATION);
- mapping.add(description);
-
- newLDAP = createResource(newLDAP);
- assertNotNull(newLDAP);
-
- // 2. update group and give the resource created above
- GroupPatch patch = new GroupPatch();
- patch.setKey(groupTO.getKey());
- patch.getResources().add(new StringPatchItem.Builder().
- operation(PatchOperation.ADD_REPLACE).
- value("new-ldap").build());
-
- groupTO = updateGroup(patch).getEntity();
- assertNotNull(groupTO);
-
- // 3. update the group
- GroupPatch groupPatch = new GroupPatch();
- groupPatch.setKey(groupTO.getKey());
- groupPatch.getPlainAttrs().add(attrAddReplacePatch("icon", "anotherIcon"));
-
- groupTO = updateGroup(groupPatch).getEntity();
- assertNotNull(groupTO);
-
- // 4. check that a single group exists in LDAP for the group created and updated above
- int entries = 0;
- DirContext ctx = null;
- try {
- ctx = getLdapResourceDirContext(null, null);
-
- SearchControls ctls = new SearchControls();
- ctls.setReturningAttributes(new String[] { "*", "+" });
- ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
-
- NamingEnumeration<SearchResult> result =
- ctx.search("ou=groups,o=isp", "(description=" + groupTO.getKey() + ")", ctls);
- while (result.hasMore()) {
- result.next();
- entries++;
- }
- } catch (Exception e) {
- // ignore
- } finally {
- if (ctx != null) {
- try {
- ctx.close();
- } catch (NamingException e) {
- // ignore
- }
- }
- }
-
- assertEquals(1, entries);
- } finally {
- schemaService.update(SchemaType.DERIVED, orig);
- if (groupTO.getKey() != null) {
- groupService.delete(groupTO.getKey());
- }
- resourceService.delete("new-ldap");
- }
- }
-
- @Test
- public void issueSYNCOPE717() {
- String doubleSchemaName = "double" + getUUIDString();
-
- // 1. create double schema without conversion pattern
- PlainSchemaTO schema = new PlainSchemaTO();
- schema.setKey(doubleSchemaName);
- schema.setType(AttrSchemaType.Double);
-
- schema = createSchema(SchemaType.PLAIN, schema);
- assertNotNull(schema);
- assertNull(schema.getConversionPattern());
-
- AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal group");
- assertNotNull(minimalGroup);
- minimalGroup.getPlainSchemas().add(doubleSchemaName);
- anyTypeClassService.update(minimalGroup);
-
- // 2. create group, provide valid input value
- GroupTO groupTO = GroupITCase.getBasicSampleTO("syncope717");
- groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
-
- groupTO = createGroup(groupTO).getEntity();
- assertNotNull(groupTO);
- assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-
- // 3. update schema, set conversion pattern
- schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
- schema.setConversionPattern("0.000");
- schemaService.update(SchemaType.PLAIN, schema);
-
- // 4. re-read group, verify that pattern was applied
- groupTO = groupService.read(groupTO.getKey());
- assertNotNull(groupTO);
- assertEquals("11.230", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-
- // 5. modify group with new double value
- GroupPatch patch = new GroupPatch();
- patch.setKey(groupTO.getKey());
- patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
-
- groupTO = updateGroup(patch).getEntity();
- assertNotNull(groupTO);
- assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
-
- // 6. update schema, unset conversion pattern
- schema.setConversionPattern(null);
- schemaService.update(SchemaType.PLAIN, schema);
-
- // 7. modify group with new double value, verify that no pattern is applied
- patch = new GroupPatch();
- patch.setKey(groupTO.getKey());
- patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
-
- groupTO = updateGroup(patch).getEntity();
- assertNotNull(groupTO);
- assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).getValues().get(0));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a4166f98/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
index 421dab7..2f568b5 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskITCase.java
@@ -23,12 +23,24 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
+import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.NotificationTaskTO;
import org.apache.syncope.common.lib.to.ExecTO;
+import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.NotificationTO;
+import org.apache.syncope.common.lib.to.PagedResult;
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.TaskType;
import org.apache.syncope.common.lib.types.TraceLevel;
+import org.apache.syncope.common.rest.api.beans.ExecuteQuery;
+import org.apache.syncope.common.rest.api.beans.TaskQuery;
+import org.apache.syncope.common.rest.api.service.NotificationService;
import org.apache.syncope.core.provisioning.java.job.notification.NotificationJob;
+import org.apache.syncope.fit.core.reference.TestNotificationRecipientsProvider;
import org.junit.Test;
public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
@@ -110,4 +122,167 @@ public class NotificationTaskITCase extends AbstractNotificationTaskITCase {
configurationService.set(origMaxRetries);
}
}
+
+ @Test
+ public void issueSYNCOPE81() {
+ String sender = "syncope81@syncope.apache.org";
+ Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, "Test notification");
+ NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
+ assertNotNull(taskTO);
+ assertNotNull(taskTO.getNotification());
+ assertTrue(taskTO.getExecutions().isEmpty());
+
+ // generate an execution in order to verify the deletion of a notification task with one or more executions
+ execNotificationTask(taskService, taskTO.getKey(), 50);
+
+ taskTO = taskService.read(taskTO.getKey(), true);
+ assertTrue(taskTO.isExecuted());
+ assertFalse(taskTO.getExecutions().isEmpty());
+
+ taskService.delete(taskTO.getKey());
+ }
+
+ @Test
+ public void issueSYNCOPE86() {
+ // 1. create notification task
+ String sender = "syncope86@syncope.apache.org";
+ Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, "Test notification");
+
+ // 2. get NotificationTaskTO for user just created
+ NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
+ assertNotNull(taskTO);
+ assertNotNull(taskTO.getNotification());
+ assertTrue(taskTO.getExecutions().isEmpty());
+
+ try {
+ // 3. execute the generated NotificationTask
+ execNotificationTask(taskService, taskTO.getKey(), 50);
+
+ // 4. verify
+ taskTO = taskService.read(taskTO.getKey(), true);
+ assertNotNull(taskTO);
+ assertTrue(taskTO.isExecuted());
+ assertEquals(1, taskTO.getExecutions().size());
+ } finally {
+ // Remove execution to make test re-runnable
+ taskService.deleteExecution(taskTO.getExecutions().get(0).getKey());
+ }
+ }
+
+ @Test
+ public void issueSYNCOPE192() throws Exception {
+ String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
+ String subject = "Test notification " + getUUIDString();
+ Pair<String, String> created = createNotificationTask(true, true, TraceLevel.NONE, sender, subject);
+ NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
+ assertNotNull(taskTO);
+ assertNotNull(taskTO.getNotification());
+ assertTrue(taskTO.getExecutions().isEmpty());
+
+ taskService.execute(new ExecuteQuery.Builder().key(taskTO.getKey()).build());
+
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ }
+
+ assertTrue(verifyMail(sender, subject, created.getRight()));
+
+ // verify that last exec status was updated
+ taskTO = taskService.read(taskTO.getKey(), true);
+ assertNotNull(taskTO);
+ assertTrue(taskTO.isExecuted());
+ assertTrue(taskTO.getExecutions().isEmpty());
+ assertTrue(StringUtils.isNotBlank(taskTO.getLatestExecStatus()));
+ }
+
+ @Test
+ public void issueSYNCOPE445() throws Exception {
+ String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
+ String subject = "Test notification " + getUUIDString();
+ Pair<String, String> created = createNotificationTask(
+ true, true, TraceLevel.ALL, sender, subject, "syncope445@syncope.apache.org");
+ NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
+ assertNotNull(taskTO);
+ assertNotNull(taskTO.getNotification());
+ assertTrue(taskTO.getExecutions().isEmpty());
+
+ execNotificationTask(taskService, taskTO.getKey(), 50);
+
+ assertTrue(verifyMail(sender, subject, created.getRight()));
+
+ // verify task
+ taskTO = taskService.read(taskTO.getKey(), true);
+ assertTrue(taskTO.isExecuted());
+ assertNotNull(taskTO);
+ assertTrue(taskTO.getRecipients().contains("syncope445@syncope.apache.org"));
+ }
+
+ @Test
+ public void issueSYNCOPE446() throws Exception {
+ // 1. Create notification
+ NotificationTO notification = new NotificationTO();
+ notification.setTraceLevel(TraceLevel.ALL);
+ notification.getEvents().add("[LOGIC]:[GroupLogic]:[]:[create]:[SUCCESS]");
+
+ String groupName = "group" + getUUIDString();
+ notification.getAbouts().put(AnyTypeKind.GROUP.name(),
+ SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo(groupName).query());
+
+ notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().
+ inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
+ notification.setSelfAsRecipient(false);
+ notification.setRecipientAttrName("email");
+ notification.getStaticRecipients().add("notificationtest@syncope.apache.org");
+ notification.setRecipientsProviderClassName(TestNotificationRecipientsProvider.class.getName());
+
+ String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
+ notification.setSender(sender);
+ String subject = "Test notification " + getUUIDString();
+ notification.setSubject(subject);
+ notification.setTemplate("optin");
+ notification.setActive(true);
+
+ Response response = notificationService.create(notification);
+ notification = getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
+ assertNotNull(notification);
+ assertEquals(TestNotificationRecipientsProvider.class.getName(), notification.getRecipientsProviderClassName());
+
+ // 2. create group
+ GroupTO groupTO = new GroupTO();
+ groupTO.setName(groupName);
+ groupTO.setRealm("/even/two");
+ groupTO = createGroup(groupTO).getEntity();
+ assertNotNull(groupTO);
+
+ // 3. verify
+ NotificationTaskTO taskTO = findNotificationTask(notification.getKey(), 50);
+ assertNotNull(taskTO);
+ assertNotNull(taskTO.getNotification());
+ assertTrue(taskTO.getRecipients().containsAll(
+ new TestNotificationRecipientsProvider().provideRecipients(null)));
+
+ NotificationTaskTO foundViaList = taskService.<NotificationTaskTO>list(
+ new TaskQuery.Builder(TaskType.NOTIFICATION).notification(notification.getKey()).build()).
+ getResult().get(0);
+ assertEquals(taskTO, foundViaList);
+
+ execNotificationTask(taskService, taskTO.getKey(), 50);
+
+ assertTrue(verifyMail(sender, subject, "notificationtest@syncope.apache.org"));
+ }
+
+ @Test
+ public void issueSYNCOPE492() throws Exception {
+ String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
+ String subject = "Test notification " + getUUIDString();
+ Pair<String, String> created =
+ createNotificationTask(false, true, TraceLevel.NONE, sender, subject, "syncope445@syncope.apache.org");
+
+ // verify that no task was created for disabled notification
+ PagedResult<NotificationTaskTO> tasks =
+ taskService.list(new TaskQuery.Builder(TaskType.NOTIFICATION).notification(created.getLeft()).build());
+ assertEquals(0, tasks.getSize());
+ }
+
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a4166f98/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
deleted file mode 100644
index a695eb7..0000000
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/NotificationTaskIssuesITCase.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.fit.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.syncope.client.lib.SyncopeClient;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.NotificationTO;
-import org.apache.syncope.common.lib.to.NotificationTaskTO;
-import org.apache.syncope.common.lib.to.PagedResult;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.TaskType;
-import org.apache.syncope.common.lib.types.TraceLevel;
-import org.apache.syncope.common.rest.api.beans.ExecuteQuery;
-import org.apache.syncope.common.rest.api.beans.TaskQuery;
-import org.apache.syncope.common.rest.api.service.NotificationService;
-import org.apache.syncope.fit.core.reference.TestNotificationRecipientsProvider;
-import org.junit.Test;
-
-public class NotificationTaskIssuesITCase extends AbstractNotificationTaskITCase {
-
- @Test
- public void issueSYNCOPE81() {
- String sender = "syncope81@syncope.apache.org";
- Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, "Test notification");
- NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
- assertNotNull(taskTO);
- assertNotNull(taskTO.getNotification());
- assertTrue(taskTO.getExecutions().isEmpty());
-
- // generate an execution in order to verify the deletion of a notification task with one or more executions
- execNotificationTask(taskService, taskTO.getKey(), 50);
-
- taskTO = taskService.read(taskTO.getKey(), true);
- assertTrue(taskTO.isExecuted());
- assertFalse(taskTO.getExecutions().isEmpty());
-
- taskService.delete(taskTO.getKey());
- }
-
- @Test
- public void issueSYNCOPE86() {
- // 1. create notification task
- String sender = "syncope86@syncope.apache.org";
- Pair<String, String> created = createNotificationTask(true, true, TraceLevel.ALL, sender, "Test notification");
-
- // 2. get NotificationTaskTO for user just created
- NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
- assertNotNull(taskTO);
- assertNotNull(taskTO.getNotification());
- assertTrue(taskTO.getExecutions().isEmpty());
-
- try {
- // 3. execute the generated NotificationTask
- execNotificationTask(taskService, taskTO.getKey(), 50);
-
- // 4. verify
- taskTO = taskService.read(taskTO.getKey(), true);
- assertNotNull(taskTO);
- assertTrue(taskTO.isExecuted());
- assertEquals(1, taskTO.getExecutions().size());
- } finally {
- // Remove execution to make test re-runnable
- taskService.deleteExecution(taskTO.getExecutions().get(0).getKey());
- }
- }
-
- @Test
- public void issueSYNCOPE192() throws Exception {
- String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
- String subject = "Test notification " + getUUIDString();
- Pair<String, String> created = createNotificationTask(true, true, TraceLevel.NONE, sender, subject);
- NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
- assertNotNull(taskTO);
- assertNotNull(taskTO.getNotification());
- assertTrue(taskTO.getExecutions().isEmpty());
-
- taskService.execute(new ExecuteQuery.Builder().key(taskTO.getKey()).build());
-
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- }
-
- assertTrue(verifyMail(sender, subject, created.getRight()));
-
- // verify that last exec status was updated
- taskTO = taskService.read(taskTO.getKey(), true);
- assertNotNull(taskTO);
- assertTrue(taskTO.isExecuted());
- assertTrue(taskTO.getExecutions().isEmpty());
- assertTrue(StringUtils.isNotBlank(taskTO.getLatestExecStatus()));
- }
-
- @Test
- public void issueSYNCOPE445() throws Exception {
- String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
- String subject = "Test notification " + getUUIDString();
- Pair<String, String> created = createNotificationTask(
- true, true, TraceLevel.ALL, sender, subject, "syncope445@syncope.apache.org");
- NotificationTaskTO taskTO = findNotificationTask(created.getLeft(), 50);
- assertNotNull(taskTO);
- assertNotNull(taskTO.getNotification());
- assertTrue(taskTO.getExecutions().isEmpty());
-
- execNotificationTask(taskService, taskTO.getKey(), 50);
-
- assertTrue(verifyMail(sender, subject, created.getRight()));
-
- // verify task
- taskTO = taskService.read(taskTO.getKey(), true);
- assertTrue(taskTO.isExecuted());
- assertNotNull(taskTO);
- assertTrue(taskTO.getRecipients().contains("syncope445@syncope.apache.org"));
- }
-
- @Test
- public void issueSYNCOPE446() throws Exception {
- // 1. Create notification
- NotificationTO notification = new NotificationTO();
- notification.setTraceLevel(TraceLevel.ALL);
- notification.getEvents().add("[LOGIC]:[GroupLogic]:[]:[create]:[SUCCESS]");
-
- String groupName = "group" + getUUIDString();
- notification.getAbouts().put(AnyTypeKind.GROUP.name(),
- SyncopeClient.getGroupSearchConditionBuilder().is("name").equalTo(groupName).query());
-
- notification.setRecipientsFIQL(SyncopeClient.getUserSearchConditionBuilder().
- inGroups("f779c0d4-633b-4be5-8f57-32eb478a3ca5").query());
- notification.setSelfAsRecipient(false);
- notification.setRecipientAttrName("email");
- notification.getStaticRecipients().add("notificationtest@syncope.apache.org");
- notification.setRecipientsProviderClassName(TestNotificationRecipientsProvider.class.getName());
-
- String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
- notification.setSender(sender);
- String subject = "Test notification " + getUUIDString();
- notification.setSubject(subject);
- notification.setTemplate("optin");
- notification.setActive(true);
-
- Response response = notificationService.create(notification);
- notification = getObject(response.getLocation(), NotificationService.class, NotificationTO.class);
- assertNotNull(notification);
- assertEquals(TestNotificationRecipientsProvider.class.getName(), notification.getRecipientsProviderClassName());
-
- // 2. create group
- GroupTO groupTO = new GroupTO();
- groupTO.setName(groupName);
- groupTO.setRealm("/even/two");
- groupTO = createGroup(groupTO).getEntity();
- assertNotNull(groupTO);
-
- // 3. verify
- NotificationTaskTO taskTO = findNotificationTask(notification.getKey(), 50);
- assertNotNull(taskTO);
- assertNotNull(taskTO.getNotification());
- assertTrue(taskTO.getRecipients().containsAll(
- new TestNotificationRecipientsProvider().provideRecipients(null)));
-
- NotificationTaskTO foundViaList = taskService.<NotificationTaskTO>list(
- new TaskQuery.Builder(TaskType.NOTIFICATION).notification(notification.getKey()).build()).
- getResult().get(0);
- assertEquals(taskTO, foundViaList);
-
- execNotificationTask(taskService, taskTO.getKey(), 50);
-
- assertTrue(verifyMail(sender, subject, "notificationtest@syncope.apache.org"));
- }
-
- @Test
- public void issueSYNCOPE492() throws Exception {
- String sender = "syncopetest-" + getUUIDString() + "@syncope.apache.org";
- String subject = "Test notification " + getUUIDString();
- Pair<String, String> created =
- createNotificationTask(false, true, TraceLevel.NONE, sender, subject, "syncope445@syncope.apache.org");
-
- // verify that no task was created for disabled notification
- PagedResult<NotificationTaskTO> tasks =
- taskService.list(new TaskQuery.Builder(TaskType.NOTIFICATION).notification(created.getLeft()).build());
- assertEquals(0, tasks.getSize());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a4166f98/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
index 67d8f78..59e290e 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PullTaskITCase.java
@@ -32,6 +32,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
@@ -41,10 +43,14 @@ import org.apache.commons.collections4.IterableUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.SerializationUtils;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.patch.DeassociationPatch;
+import org.apache.syncope.common.lib.patch.PasswordPatch;
+import org.apache.syncope.common.lib.patch.UserPatch;
+import org.apache.syncope.common.lib.policy.PullPolicyTO;
import org.apache.syncope.common.lib.to.AbstractTaskTO;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.AttrTO;
@@ -58,8 +64,10 @@ import org.apache.syncope.common.lib.to.ProvisionTO;
import org.apache.syncope.common.lib.to.MappingItemTO;
import org.apache.syncope.common.lib.to.PullTaskTO;
import org.apache.syncope.common.lib.to.ExecTO;
+import org.apache.syncope.common.lib.to.ProvisioningResult;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.CipherAlgorithm;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.ConnConfProperty;
import org.apache.syncope.common.lib.types.ConnectorCapability;
@@ -71,10 +79,15 @@ import org.apache.syncope.common.rest.api.beans.AnyQuery;
import org.apache.syncope.common.rest.api.beans.TaskQuery;
import org.apache.syncope.common.rest.api.service.ConnectorService;
import org.apache.syncope.common.rest.api.service.TaskService;
+import org.apache.syncope.core.provisioning.java.pushpull.DBPasswordPullActions;
+import org.apache.syncope.core.provisioning.java.pushpull.LDAPPasswordPullActions;
+import org.apache.syncope.core.spring.security.Encryptor;
import org.apache.syncope.fit.ActivitiDetector;
import org.apache.syncope.fit.core.reference.PrefixMappingItemTransformer;
import org.apache.syncope.fit.core.reference.TestReconciliationFilterBuilder;
import org.apache.syncope.fit.core.reference.TestPullActions;
+import org.apache.syncope.fit.core.reference.TestPullRule;
+import org.identityconnectors.framework.common.objects.Name;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -186,7 +199,6 @@ public class PullTaskITCase extends AbstractTaskITCase {
inUserTO.getPlainAttrs().add(attrTO("userId", "puccini@syncope.apache.org"));
inUserTO.getPlainAttrs().add(attrTO("email", "puccini@syncope.apache.org"));
inUserTO.getAuxClasses().add("csv");
- inUserTO.getDerAttrs().add(attrTO("csvuserid", null));
inUserTO = createUser(inUserTO).getEntity();
assertNotNull(inUserTO);
@@ -526,7 +538,7 @@ public class PullTaskITCase extends AbstractTaskITCase {
} finally {
jdbcTemplate.execute("DELETE FROM testpull WHERE id = '" + user1OnTestPull + "'");
jdbcTemplate.execute("DELETE FROM testpull WHERE id = '" + user2OnTestPull + "'");
- if (task != null && !"83f7e85d-9774-43fe-adba-ccd856312994".equals(task.getKey())) {
+ if (task != null && !"7c2242f4-14af-4ab5-af31-cdae23783655".equals(task.getKey())) {
taskService.delete(task.getKey());
}
if (userTO != null) {
@@ -617,4 +629,477 @@ public class PullTaskITCase extends AbstractTaskITCase {
jdbcTemplate.execute("DELETE FROM testpull WHERE ID=1041");
}
}
+
+ @Test
+ public void issueSYNCOPE68() {
+ //-----------------------------
+ // Create a new user ... it should be updated applying pull policy
+ //-----------------------------
+ UserTO userTO = new UserTO();
+ userTO.setRealm(SyncopeConstants.ROOT_REALM);
+ userTO.setPassword("password123");
+ userTO.setUsername("testuser2");
+
+ userTO.getPlainAttrs().add(attrTO("firstname", "testuser2"));
+ userTO.getPlainAttrs().add(attrTO("surname", "testuser2"));
+ userTO.getPlainAttrs().add(attrTO("ctype", "a type"));
+ userTO.getPlainAttrs().add(attrTO("fullname", "a type"));
+ userTO.getPlainAttrs().add(attrTO("userId", "testuser2@syncope.apache.org"));
+ userTO.getPlainAttrs().add(attrTO("email", "testuser2@syncope.apache.org"));
+
+ userTO.getResources().add(RESOURCE_NAME_NOPROPAGATION2);
+ userTO.getResources().add(RESOURCE_NAME_NOPROPAGATION4);
+
+ userTO.getMemberships().add(
+ new MembershipTO.Builder().group("bf825fe1-7320-4a54-bd64-143b5c18ab97").build());
+
+ userTO = createUser(userTO).getEntity();
+ assertNotNull(userTO);
+ assertEquals("testuser2", userTO.getUsername());
+ assertEquals(1, userTO.getMemberships().size());
+ assertEquals(3, userTO.getResources().size());
+ //-----------------------------
+
+ try {
+ //-----------------------------
+ // add user template
+ //-----------------------------
+ UserTO template = new UserTO();
+
+ template.getMemberships().add(
+ new MembershipTO.Builder().group("b8d38784-57e7-4595-859a-076222644b55").build());
+
+ template.getResources().add(RESOURCE_NAME_NOPROPAGATION4);
+ //-----------------------------
+
+ // Update pull task
+ PullTaskTO task = taskService.read("81d88f73-d474-4450-9031-605daa4e313f", true);
+ assertNotNull(task);
+
+ task.getTemplates().put(AnyTypeKind.USER.name(), template);
+
+ taskService.update(task);
+ PullTaskTO actual = taskService.read(task.getKey(), true);
+ assertNotNull(actual);
+ assertEquals(task.getKey(), actual.getKey());
+ assertFalse(actual.getTemplates().get(AnyTypeKind.USER.name()).getResources().isEmpty());
+ assertFalse(((UserTO) actual.getTemplates().get(AnyTypeKind.USER.name())).getMemberships().isEmpty());
+
+ ExecTO execution = execProvisioningTask(taskService, actual.getKey(), 50, false);
+ assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
+
+ userTO = userService.read("testuser2");
+ assertNotNull(userTO);
+ assertEquals("testuser2@syncope.apache.org", userTO.getPlainAttr("userId").getValues().get(0));
+ assertEquals(2, userTO.getMemberships().size());
+ assertEquals(4, userTO.getResources().size());
+ } finally {
+ UserTO dUserTO = deleteUser(userTO.getKey()).getEntity();
+ assertNotNull(dUserTO);
+ }
+ }
+
+ @Test
+ public void issueSYNCOPE230() {
+ JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
+
+ String id = "a54b3794-b231-47be-b24a-11e1a42949f6";
+
+ // 1. populate the external table
+ jdbcTemplate.execute("INSERT INTO testpull VALUES"
+ + "('" + id + "', 'issuesyncope230', 'Surname', 'syncope230@syncope.apache.org', NULL)");
+
+ // 2. execute PullTask for resource-db-pull (table TESTPULL on external H2)
+ execProvisioningTask(taskService, "7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
+
+ // 3. read e-mail address for user created by the PullTask first execution
+ UserTO userTO = userService.read("issuesyncope230");
+ assertNotNull(userTO);
+ String email = userTO.getPlainAttr("email").getValues().iterator().next();
+ assertNotNull(email);
+
+ // 4. update TESTPULL on external H2 by changing e-mail address
+ jdbcTemplate.execute("UPDATE TESTPULL SET email='updatedSYNCOPE230@syncope.apache.org' WHERE id='" + id + "'");
+
+ // 5. re-execute the PullTask
+ execProvisioningTask(taskService, "7c2242f4-14af-4ab5-af31-cdae23783655", 50, false);
+
+ // 6. verify that the e-mail was updated
+ userTO = userService.read("issuesyncope230");
+ assertNotNull(userTO);
+ email = userTO.getPlainAttr("email").getValues().iterator().next();
+ assertNotNull(email);
+ assertEquals("updatedSYNCOPE230@syncope.apache.org", email);
+ }
+
+ @Test
+ public void issueSYNCOPE258() {
+ // -----------------------------
+ // Add a custom correlation rule
+ // -----------------------------
+ PullPolicyTO policyTO = policyService.read("9454b0d7-2610-400a-be82-fc23cf553dd6");
+ policyTO.getSpecification().getCorrelationRules().put(AnyTypeKind.USER.name(), TestPullRule.class.getName());
+ policyService.update(policyTO);
+ // -----------------------------
+
+ PullTaskTO task = new PullTaskTO();
+ task.setDestinationRealm(SyncopeConstants.ROOT_REALM);
+ task.setName("Test Pull Rule");
+ task.setActive(true);
+ task.setResource(RESOURCE_NAME_WS2);
+ task.setPullMode(PullMode.FULL_RECONCILIATION);
+ task.setPerformCreate(true);
+ task.setPerformDelete(true);
+ task.setPerformUpdate(true);
+
+ Response response = taskService.create(task);
+ task = getObject(response.getLocation(), TaskService.class, PullTaskTO.class);
+
+ UserTO userTO = UserITCase.getUniqueSampleTO("s258_1@apache.org");
+ userTO.getResources().clear();
+ userTO.getResources().add(RESOURCE_NAME_WS2);
+
+ createUser(userTO);
+
+ userTO = UserITCase.getUniqueSampleTO("s258_2@apache.org");
+ userTO.getResources().clear();
+ userTO.getResources().add(RESOURCE_NAME_WS2);
+
+ userTO = createUser(userTO).getEntity();
+
+ // change email in order to unmatch the second user
+ UserPatch userPatch = new UserPatch();
+ userPatch.setKey(userTO.getKey());
+ userPatch.getPlainAttrs().add(attrAddReplacePatch("email", "s258@apache.org"));
+
+ userService.update(userPatch);
+
+ execProvisioningTask(taskService, task.getKey(), 50, false);
+
+ PullTaskTO executed = taskService.read(task.getKey(), true);
+ assertEquals(1, executed.getExecutions().size());
+
+ // asser for just one match
+ assertTrue(executed.getExecutions().get(0).getMessage().substring(0, 55) + "...",
+ executed.getExecutions().get(0).getMessage().contains("[updated/failures]: 1/0"));
+ }
+
+ @Test
+ public void issueSYNCOPE272() {
+ removeTestUsers();
+
+ // create user with testdb resource
+ UserTO userTO = UserITCase.getUniqueSampleTO("syncope272@syncope.apache.org");
+ userTO.getResources().add(RESOURCE_NAME_TESTDB);
+
+ ProvisioningResult<UserTO> result = createUser(userTO);
+ userTO = result.getEntity();
+ try {
+ assertNotNull(userTO);
+ assertEquals(1, result.getPropagationStatuses().size());
+ assertEquals(PropagationTaskExecStatus.SUCCESS, result.getPropagationStatuses().get(0).getStatus());
+
+ ExecTO taskExecTO = execProvisioningTask(
+ taskService, "986867e2-993b-430e-8feb-aa9abb4c1dcd", 50, false);
+
+ assertNotNull(taskExecTO.getStatus());
+ assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(taskExecTO.getStatus()));
+
+ userTO = userService.read(userTO.getKey());
+ assertNotNull(userTO);
+ assertNotNull(userTO.getPlainAttr("firstname").getValues().get(0));
+ } finally {
+ removeTestUsers();
+ }
+ }
+
+ @Test
+ public void issueSYNCOPE307() {
+ UserTO userTO = UserITCase.getUniqueSampleTO("s307@apache.org");
+ userTO.setUsername("test0");
+ userTO.getPlainAttr("firstname").getValues().clear();
+ userTO.getPlainAttr("firstname").getValues().add("nome0");
+ userTO.getAuxClasses().add("csv");
+
+ userTO.getResources().clear();
+ userTO.getResources().add(RESOURCE_NAME_WS2);
+
+ userTO = createUser(userTO).getEntity();
+ assertNotNull(userTO);
+
+ userTO = userService.read(userTO.getKey());
+ assertTrue(userTO.getVirAttrs().isEmpty());
+
+ // Update pull task
+ PullTaskTO task = taskService.read("38abbf9e-a1a3-40a1-a15f-7d0ac02f47f1", true);
+ assertNotNull(task);
+
+ UserTO template = new UserTO();
+ template.setPassword("'password123'");
+ template.getResources().add(RESOURCE_NAME_DBVIRATTR);
+ template.getVirAttrs().add(attrTO("virtualdata", "'virtualvalue'"));
+
+ task.getTemplates().put(AnyTypeKind.USER.name(), template);
+
+ taskService.update(task);
+
+ // exec task: one user from CSV will match the user created above and template will be applied
+ execProvisioningTask(taskService, task.getKey(), 50, false);
+
+ // check that template was successfully applied...
+ userTO = userService.read(userTO.getKey());
+ assertEquals("virtualvalue", userTO.getVirAttr("virtualdata").getValues().get(0));
+
+ // ...and that propagation to db succeeded
+ JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
+ String value = queryForObject(
+ jdbcTemplate, 50, "SELECT USERNAME FROM testpull WHERE ID=?", String.class, userTO.getKey());
+ assertEquals("virtualvalue", value);
+ }
+
+ @Test
+ public void issueSYNCOPE313DB() throws Exception {
+ // 1. create user in DB
+ UserTO user = UserITCase.getUniqueSampleTO("syncope313-db@syncope.apache.org");
+ user.setPassword("security123");
+ user.getResources().add(RESOURCE_NAME_TESTDB);
+ user = createUser(user).getEntity();
+ assertNotNull(user);
+ assertFalse(user.getResources().isEmpty());
+
+ // 2. Check that the DB resource has the correct password
+ JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
+ String value = queryForObject(
+ jdbcTemplate, 50, "SELECT PASSWORD FROM test WHERE ID=?", String.class, user.getUsername());
+ assertEquals(Encryptor.getInstance().encode("security123", CipherAlgorithm.SHA1), value.toUpperCase());
+
+ // 3. Update the password in the DB
+ String newCleanPassword = "new-security";
+ String newPassword = Encryptor.getInstance().encode(newCleanPassword, CipherAlgorithm.SHA1);
+ jdbcTemplate.execute("UPDATE test set PASSWORD='" + newPassword + "' where ID='" + user.getUsername() + "'");
+
+ // 4. Pull the user from the resource
+ PullTaskTO pullTask = new PullTaskTO();
+ pullTask.setDestinationRealm(SyncopeConstants.ROOT_REALM);
+ pullTask.setName("DB Pull Task");
+ pullTask.setActive(true);
+ pullTask.setPerformCreate(true);
+ pullTask.setPerformUpdate(true);
+ pullTask.setPullMode(PullMode.FULL_RECONCILIATION);
+ pullTask.setResource(RESOURCE_NAME_TESTDB);
+ pullTask.getActionsClassNames().add(DBPasswordPullActions.class.getName());
+ Response taskResponse = taskService.create(pullTask);
+
+ PullTaskTO actual = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
+ assertNotNull(actual);
+
+ pullTask = taskService.read(actual.getKey(), true);
+ assertNotNull(pullTask);
+ assertEquals(actual.getKey(), pullTask.getKey());
+ assertEquals(actual.getJobDelegateClassName(), pullTask.getJobDelegateClassName());
+
+ ExecTO execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+ assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
+
+ // 5. Test the pulled user
+ Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(user.getUsername(), newCleanPassword).self();
+ assertNotNull(self);
+
+ // 6. Delete PullTask + user
+ taskService.delete(pullTask.getKey());
+ deleteUser(user.getKey());
+ }
+
+ @Test
+ public void issueSYNCOPE313LDAP() throws Exception {
+ // First of all, clear any potential conflict with existing user / group
+ ldapCleanup();
+
+ UserTO user = null;
+ PullTaskTO pullTask = null;
+ ConnInstanceTO resourceConnector = null;
+ ConnConfProperty property = null;
+ try {
+ // 1. create user in LDAP
+ String oldCleanPassword = "security123";
+ user = UserITCase.getUniqueSampleTO("syncope313-ldap@syncope.apache.org");
+ user.setPassword(oldCleanPassword);
+ user.getResources().add(RESOURCE_NAME_LDAP);
+ user = createUser(user).getEntity();
+ assertNotNull(user);
+ assertFalse(user.getResources().isEmpty());
+
+ // 2. request to change password only on Syncope and not on LDAP
+ String newCleanPassword = "new-security123";
+ UserPatch userPatch = new UserPatch();
+ userPatch.setKey(user.getKey());
+ userPatch.setPassword(new PasswordPatch.Builder().value(newCleanPassword).build());
+ user = updateUser(userPatch).getEntity();
+
+ // 3. Check that the Syncope user now has the changed password
+ Pair<Map<String, Set<String>>, UserTO> self =
+ clientFactory.create(user.getUsername(), newCleanPassword).self();
+ assertNotNull(self);
+
+ // 4. Check that the LDAP resource has the old password
+ ConnObjectTO connObject =
+ resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
+ assertNotNull(getLdapRemoteObject(
+ connObject.getAttr(Name.NAME).getValues().get(0),
+ oldCleanPassword,
+ connObject.getAttr(Name.NAME).getValues().get(0)));
+
+ // 5. Update the LDAP Connector to retrieve passwords
+ ResourceTO ldapResource = resourceService.read(RESOURCE_NAME_LDAP);
+ resourceConnector = connectorService.read(
+ ldapResource.getConnector(), Locale.ENGLISH.getLanguage());
+ property = resourceConnector.getConfMap().get("retrievePasswordsWithSearch");
+ property.getValues().clear();
+ property.getValues().add(Boolean.TRUE);
+ connectorService.update(resourceConnector);
+
+ // 6. Pull the user from the resource
+ pullTask = new PullTaskTO();
+ pullTask.setDestinationRealm(SyncopeConstants.ROOT_REALM);
+ pullTask.setName("LDAP Pull Task");
+ pullTask.setActive(true);
+ pullTask.setPerformCreate(true);
+ pullTask.setPerformUpdate(true);
+ pullTask.setPullMode(PullMode.FULL_RECONCILIATION);
+ pullTask.setResource(RESOURCE_NAME_LDAP);
+ pullTask.getActionsClassNames().add(LDAPPasswordPullActions.class.getName());
+ Response taskResponse = taskService.create(pullTask);
+
+ pullTask = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
+ assertNotNull(pullTask);
+
+ ExecTO execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+ assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
+
+ // 7. Test the pulled user
+ self = clientFactory.create(user.getUsername(), oldCleanPassword).self();
+ assertNotNull(self);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ } finally {
+ // Delete PullTask + user + reset the connector
+ if (pullTask != null) {
+ taskService.delete(pullTask.getKey());
+ }
+
+ if (resourceConnector != null && property != null) {
+ property.getValues().clear();
+ property.getValues().add(Boolean.FALSE);
+ connectorService.update(resourceConnector);
+ }
+
+ if (user != null) {
+ deleteUser(user.getKey());
+ }
+ }
+ }
+
+ @Test
+ public void issueSYNCOPE1062() {
+ GroupTO propagationGroup = null;
+ PullTaskTO pullTask = null;
+ UserTO user = null;
+ GroupTO group = null;
+ try {
+ // 1. create group with resource for propagation
+ propagationGroup = GroupITCase.getBasicSampleTO("SYNCOPE1062");
+ propagationGroup.getResources().add(RESOURCE_NAME_DBPULL);
+ propagationGroup = createGroup(propagationGroup).getEntity();
+
+ // 2. create pull task for another resource, with user template assigning the group above
+ pullTask = new PullTaskTO();
+ pullTask.setDestinationRealm(SyncopeConstants.ROOT_REALM);
+ pullTask.setName("SYNCOPE1062");
+ pullTask.setActive(true);
+ pullTask.setPerformCreate(true);
+ pullTask.setPerformUpdate(true);
+ pullTask.setPullMode(PullMode.FULL_RECONCILIATION);
+ pullTask.setResource(RESOURCE_NAME_LDAP);
+
+ UserTO template = new UserTO();
+ template.getAuxClasses().add("minimal group");
+ template.getMemberships().add(new MembershipTO.Builder().group(propagationGroup.getKey()).build());
+ template.getPlainAttrs().add(attrTO("firstname", "'fixed'"));
+ pullTask.getTemplates().put(AnyTypeKind.USER.name(), template);
+
+ Response taskResponse = taskService.create(pullTask);
+ pullTask = getObject(taskResponse.getLocation(), TaskService.class, PullTaskTO.class);
+ assertNotNull(pullTask);
+ assertFalse(pullTask.getTemplates().isEmpty());
+
+ // 3. exec the pull task
+ ExecTO execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+ assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
+
+ // the user is successfully pulled...
+ user = userService.read("pullFromLDAP");
+ assertNotNull(user);
+ assertEquals("pullFromLDAP@syncope.apache.org", user.getPlainAttr("email").getValues().get(0));
+
+ group = groupService.read("testLDAPGroup");
+ assertNotNull(group);
+
+ ConnObjectTO connObject =
+ resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
+ assertNotNull(connObject);
+ assertEquals("pullFromLDAP@syncope.apache.org", connObject.getAttr("mail").getValues().get(0));
+ AttrTO userDn = connObject.getAttr(Name.NAME);
+ assertNotNull(userDn);
+ assertEquals(1, userDn.getValues().size());
+ assertNotNull(
+ getLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD, userDn.getValues().get(0)));
+
+ // ...and propagated
+ PagedResult<AbstractTaskTO> propagationTasks = taskService.list(new TaskQuery.Builder(TaskType.PROPAGATION).
+ resource(RESOURCE_NAME_DBPULL).
+ anyTypeKind(AnyTypeKind.USER).entityKey(user.getKey()).build());
+ assertEquals(1, propagationTasks.getSize());
+
+ // 4. update the user on the external resource
+ updateLdapRemoteObject(RESOURCE_LDAP_ADMIN_DN, RESOURCE_LDAP_ADMIN_PWD,
+ userDn.getValues().get(0), Pair.of("mail", "pullFromLDAP2@syncope.apache.org"));
+
+ connObject = resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.USER.name(), user.getKey());
+ assertNotNull(connObject);
+ assertEquals("pullFromLDAP2@syncope.apache.org", connObject.getAttr("mail").getValues().get(0));
+
+ // 5. exec the pull task again
+ execution = execProvisioningTask(taskService, pullTask.getKey(), 50, false);
+ assertEquals(PropagationTaskExecStatus.SUCCESS, PropagationTaskExecStatus.valueOf(execution.getStatus()));
+
+ // the internal is updated...
+ user = userService.read("pullFromLDAP");
+ assertNotNull(user);
+ assertEquals("pullFromLDAP2@syncope.apache.org", user.getPlainAttr("email").getValues().get(0));
+
+ // ...and propagated
+ propagationTasks = taskService.list(new TaskQuery.Builder(TaskType.PROPAGATION).
+ resource(RESOURCE_NAME_DBPULL).
+ anyTypeKind(AnyTypeKind.USER).entityKey(user.getKey()).build());
+ assertEquals(2, propagationTasks.getSize());
+ } catch (Exception e) {
+ LOG.error("Unexpected during issueSYNCOPE1062()", e);
+ fail(e.getMessage());
+ } finally {
+ if (pullTask != null) {
+ taskService.delete(pullTask.getKey());
+ }
+
+ if (propagationGroup != null) {
+ groupService.delete(propagationGroup.getKey());
+ }
+
+ if (group != null) {
+ groupService.delete(group.getKey());
+ }
+ if (user != null) {
+ userService.delete(user.getKey());
+ }
+ }
+ }
}