You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2015/10/30 12:34:46 UTC
[07/50] [abbrv] syncope git commit: [SYNCOPE-714] Add specific test +
introducing PropagationTaskExecStatus.NOT_ATTEMPTED
[SYNCOPE-714] Add specific test + introducing PropagationTaskExecStatus.NOT_ATTEMPTED
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/509d30ed
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/509d30ed
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/509d30ed
Branch: refs/heads/SYNCOPE-156
Commit: 509d30edad9365fe0d97d6c3d5d2288c92d5c69b
Parents: 1347c10
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Oct 26 11:56:36 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Oct 26 11:56:36 2015 +0100
----------------------------------------------------------------------
.../lib/types/PropagationTaskExecStatus.java | 3 +-
.../provisioning/java/ConnectorFacadeProxy.java | 4 +-
.../AbstractPropagationTaskExecutor.java | 19 ++-
.../fit/core/reference/AbstractITCase.java | 4 +-
.../syncope/fit/core/reference/GroupITCase.java | 126 ++++++++++++++++---
.../fit/core/reference/ResourceITCase.java | 8 +-
.../syncope/fit/core/reference/UserITCase.java | 3 +-
7 files changed, 128 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/common/lib/src/main/java/org/apache/syncope/common/lib/types/PropagationTaskExecStatus.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/types/PropagationTaskExecStatus.java b/common/lib/src/main/java/org/apache/syncope/common/lib/types/PropagationTaskExecStatus.java
index c676c3b..6ae4a36 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/types/PropagationTaskExecStatus.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/types/PropagationTaskExecStatus.java
@@ -28,6 +28,7 @@ public enum PropagationTaskExecStatus {
CREATED,
SUCCESS,
- FAILURE;
+ FAILURE,
+ NOT_ATTEMPTED;
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
index a3b865f..8640c50 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
@@ -226,8 +226,8 @@ public class ConnectorFacadeProxy implements Connector {
}
} else {
LOG.info("Update for {} was attempted, although the "
- + "connector only has these capabilities: {}. No action.", uid.getUidValue(), connInstance.
- getCapabilities());
+ + "connector only has these capabilities: {}. No action.",
+ uid.getUidValue(), connInstance.getCapabilities());
}
return result;
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
index c083187..e87cd00 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java
@@ -387,7 +387,9 @@ public abstract class AbstractPropagationTaskExecutor implements PropagationTask
default:
}
- execution.setStatus(PropagationTaskExecStatus.SUCCESS.name());
+ execution.setStatus(propagationAttempted[0]
+ ? PropagationTaskExecStatus.SUCCESS.name()
+ : PropagationTaskExecStatus.NOT_ATTEMPTED.name());
for (PropagationActions action : actions) {
action.after(task, execution, afterObj);
@@ -437,24 +439,19 @@ public abstract class AbstractPropagationTaskExecutor implements PropagationTask
}
}
- LOG.debug("Update execution for {}", task);
-
execution.setStartDate(startDate);
execution.setMessage(taskExecutionMessage);
execution.setEndDate(new Date());
+ LOG.debug("Execution finished: {}", execution);
+
if (hasToBeregistered(task, execution)) {
- if (!propagationAttempted[0]) {
- LOG.debug("No propagation attempted for {}", execution);
- } else {
- execution.setTask(task);
- task.addExec(execution);
+ LOG.debug("Execution to be stored: {}", execution);
- LOG.debug("Execution finished: {}", execution);
- }
+ execution.setTask(task);
+ task.addExec(execution);
taskDAO.save(task);
-
// this flush call is needed to generate a value for the execution id
taskDAO.flush();
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
index 60565e1..3e4381d 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java
@@ -341,7 +341,7 @@ public abstract class AbstractITCase {
throw (RuntimeException) ex;
}
}
- return getObject(response.getLocation(), AnyObjectService.class, AnyObjectTO.class);
+ return response.readEntity(AnyObjectTO.class);
}
protected AnyObjectTO updateAnyObject(final AnyObjectPatch anyObjectPatch) {
@@ -360,7 +360,7 @@ public abstract class AbstractITCase {
throw (RuntimeException) ex;
}
}
- return getObject(response.getLocation(), GroupService.class, GroupTO.class);
+ return response.readEntity(GroupTO.class);
}
protected GroupTO updateGroup(final GroupPatch groupPatch) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
index 148f0eb..db12a2b 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java
@@ -52,6 +52,7 @@ import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.common.lib.to.AnyTypeTO;
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.MappingItemTO;
import org.apache.syncope.common.lib.to.PagedResult;
@@ -63,9 +64,11 @@ import org.apache.syncope.common.lib.to.ProvisionTO;
import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.ClientExceptionType;
+import org.apache.syncope.common.lib.types.ConnectorCapability;
import org.apache.syncope.common.lib.types.IntMappingType;
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;
import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
import org.apache.syncope.common.lib.types.SchemaType;
@@ -610,6 +613,111 @@ public class GroupITCase extends AbstractITCase {
}
@Test
+ public void dynMembership() {
+ assertTrue(userService.read(4L).getDynGroups().isEmpty());
+
+ GroupTO group = getBasicSampleTO("dynMembership");
+ group.setUDynMembershipCond("cool==true");
+ group = createGroup(group);
+ assertNotNull(group);
+
+ assertTrue(userService.read(4L).getDynGroups().contains(group.getKey()));
+
+ GroupPatch mod = new GroupPatch();
+ mod.setKey(group.getKey());
+ mod.setUDynMembershipCond(new StringReplacePatchItem.Builder().value("cool==false").build());
+ groupService.update(mod);
+
+ assertTrue(userService.read(4L).getDynGroups().isEmpty());
+ }
+
+ @Test
+ public void capabilitiesOverride() {
+ // resource with no capability override
+ ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
+ assertNotNull(ldap);
+ assertFalse(ldap.isOverrideCapabilities());
+ assertTrue(ldap.getCapabilitiesOverride().isEmpty());
+
+ // connector with all required for create and update
+ ConnInstanceTO conn = connectorService.read(ldap.getConnector(), null);
+ assertNotNull(conn);
+ assertTrue(conn.getCapabilities().contains(ConnectorCapability.CREATE));
+ assertTrue(conn.getCapabilities().contains(ConnectorCapability.UPDATE));
+
+ try {
+ // 1. create succeeds
+ GroupTO group = getSampleTO("syncope714");
+ group.getPlainAttrs().add(attrTO("title", "first"));
+ group.getResources().add(RESOURCE_NAME_LDAP);
+
+ group = createGroup(group);
+ assertNotNull(group);
+ assertEquals(1, group.getPropagationStatusTOs().size());
+ assertEquals(RESOURCE_NAME_LDAP, group.getPropagationStatusTOs().get(0).getResource());
+ assertEquals(PropagationTaskExecStatus.SUCCESS, group.getPropagationStatusTOs().get(0).getStatus());
+
+ // 2. update succeeds
+ GroupPatch patch = new GroupPatch();
+ patch.setKey(group.getKey());
+ patch.getPlainAttrs().add(new AttrPatch.Builder().
+ operation(PatchOperation.ADD_REPLACE).attrTO(attrTO("title", "second")).build());
+
+ group = groupService.update(patch).readEntity(GroupTO.class);
+ assertNotNull(group);
+ assertEquals(1, group.getPropagationStatusTOs().size());
+ assertEquals(RESOURCE_NAME_LDAP, group.getPropagationStatusTOs().get(0).getResource());
+ assertEquals(PropagationTaskExecStatus.SUCCESS, group.getPropagationStatusTOs().get(0).getStatus());
+
+ // 3. set capability override with only search allowed, but not enable
+ ldap.getCapabilitiesOverride().add(ConnectorCapability.SEARCH);
+ resourceService.update(ldap);
+ ldap = resourceService.read(RESOURCE_NAME_LDAP);
+ assertNotNull(ldap);
+ assertFalse(ldap.isOverrideCapabilities());
+ assertEquals(1, ldap.getCapabilitiesOverride().size());
+ assertTrue(ldap.getCapabilitiesOverride().contains(ConnectorCapability.SEARCH));
+
+ // 4. update succeeds again
+ patch = new GroupPatch();
+ patch.setKey(group.getKey());
+ patch.getPlainAttrs().add(new AttrPatch.Builder().
+ operation(PatchOperation.ADD_REPLACE).attrTO(attrTO("title", "third")).build());
+
+ group = groupService.update(patch).readEntity(GroupTO.class);
+ assertNotNull(group);
+ assertEquals(1, group.getPropagationStatusTOs().size());
+ assertEquals(RESOURCE_NAME_LDAP, group.getPropagationStatusTOs().get(0).getResource());
+ assertEquals(PropagationTaskExecStatus.SUCCESS, group.getPropagationStatusTOs().get(0).getStatus());
+
+ // 5. enable capability override
+ ldap.setOverrideCapabilities(true);
+ resourceService.update(ldap);
+ ldap = resourceService.read(RESOURCE_NAME_LDAP);
+ assertNotNull(ldap);
+ assertTrue(ldap.isOverrideCapabilities());
+ assertEquals(1, ldap.getCapabilitiesOverride().size());
+ assertTrue(ldap.getCapabilitiesOverride().contains(ConnectorCapability.SEARCH));
+
+ // 6. update now fails
+ patch = new GroupPatch();
+ patch.setKey(group.getKey());
+ patch.getPlainAttrs().add(new AttrPatch.Builder().
+ operation(PatchOperation.ADD_REPLACE).attrTO(attrTO("title", "fourth")).build());
+
+ group = groupService.update(patch).readEntity(GroupTO.class);
+ assertNotNull(group);
+ assertEquals(1, group.getPropagationStatusTOs().size());
+ assertEquals(RESOURCE_NAME_LDAP, group.getPropagationStatusTOs().get(0).getResource());
+ assertEquals(PropagationTaskExecStatus.NOT_ATTEMPTED, group.getPropagationStatusTOs().get(0).getStatus());
+ } finally {
+ ldap.getCapabilitiesOverride().clear();
+ ldap.setOverrideCapabilities(false);
+ resourceService.update(ldap);
+ }
+ }
+
+ @Test
public void issueSYNCOPE632() {
GroupTO groupTO = null;
try {
@@ -695,22 +803,4 @@ public class GroupITCase extends AbstractITCase {
}
}
- @Test
- public void dynMembership() {
- assertTrue(userService.read(4L).getDynGroups().isEmpty());
-
- GroupTO group = getBasicSampleTO("dynMembership");
- group.setUDynMembershipCond("cool==true");
- group = createGroup(group);
- assertNotNull(group);
-
- assertTrue(userService.read(4L).getDynGroups().contains(group.getKey()));
-
- GroupPatch mod = new GroupPatch();
- mod.setKey(group.getKey());
- mod.setUDynMembershipCond(new StringReplacePatchItem.Builder().value("cool==false").build());
- groupService.update(mod);
-
- assertTrue(userService.read(4L).getDynGroups().isEmpty());
- }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
index 5d4d176..9aa64ce 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ResourceITCase.java
@@ -161,15 +161,15 @@ public class ResourceITCase extends AbstractITCase {
resourceTO.setKey(resourceName);
resourceTO.setConnector(102L);
- ConnConfProperty p = new ConnConfProperty();
+ ConnConfProperty prop = new ConnConfProperty();
ConnConfPropSchema schema = new ConnConfPropSchema();
schema.setType("java.lang.String");
schema.setName("endpoint");
schema.setRequired(true);
- p.setSchema(schema);
- p.getValues().add("http://invalidurl/");
+ prop.setSchema(schema);
+ prop.getValues().add("http://invalidurl/");
- Set<ConnConfProperty> connectorConfigurationProperties = new HashSet<>(Arrays.asList(p));
+ Set<ConnConfProperty> connectorConfigurationProperties = new HashSet<>(Arrays.asList(prop));
resourceTO.getConfOverride().addAll(connectorConfigurationProperties);
Response response = resourceService.create(resourceTO);
http://git-wip-us.apache.org/repos/asf/syncope/blob/509d30ed/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
index ebaf02b..1811805 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserITCase.java
@@ -171,7 +171,8 @@ public class UserITCase extends AbstractITCase {
// get last task
PropagationTaskTO taskTO = taskService.read(newMaxId);
assertNotNull(taskTO);
- assertTrue(taskTO.getExecutions().isEmpty());
+ assertFalse(taskTO.getExecutions().isEmpty());
+ assertEquals(PropagationTaskExecStatus.NOT_ATTEMPTED.name(), taskTO.getExecutions().get(0).getStatus());
}
@Test