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 2015/06/11 16:17:32 UTC
[42/70] syncope git commit: [SYNCOPE-666] All tests are green,
time to add more
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
index 5dc3f5c..37bf12c 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractTaskITCase.java
@@ -57,7 +57,9 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
private final boolean dryRun;
- public ThreadExec(AbstractTaskITCase test, Long taskKey, int maxWaitSeconds, boolean dryRun) {
+ public ThreadExec(
+ final AbstractTaskITCase test, final Long taskKey, final int maxWaitSeconds, final boolean dryRun) {
+
this.test = test;
this.taskKey = taskKey;
this.maxWaitSeconds = maxWaitSeconds;
@@ -66,7 +68,7 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
@Override
public TaskExecTO call() throws Exception {
- return test.execSyncTask(taskKey, maxWaitSeconds, dryRun);
+ return test.execProvisioningTask(taskKey, maxWaitSeconds, dryRun);
}
}
@@ -85,7 +87,7 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
}
}
- protected TaskExecTO execSyncTask(final Long taskKey, final int maxWaitSeconds, final boolean dryRun) {
+ protected TaskExecTO execProvisioningTask(final Long taskKey, final int maxWaitSeconds, final boolean dryRun) {
AbstractTaskTO taskTO = taskService.read(taskKey);
assertNotNull(taskTO);
assertNotNull(taskTO.getExecutions());
@@ -117,17 +119,17 @@ public abstract class AbstractTaskITCase extends AbstractITCase {
return taskTO.getExecutions().get(taskTO.getExecutions().size() - 1);
}
- protected Map<Long, TaskExecTO> execSyncTasks(
+ protected Map<Long, TaskExecTO> execProvisioningTasks(
final Set<Long> taskKeys, final int maxWaitSeconds, final boolean dryRun) throws Exception {
- final ExecutorService service = Executors.newFixedThreadPool(taskKeys.size());
- final List<Future<TaskExecTO>> futures = new ArrayList<>();
+ ExecutorService service = Executors.newFixedThreadPool(taskKeys.size());
+ List<Future<TaskExecTO>> futures = new ArrayList<>();
for (Long key : taskKeys) {
futures.add(service.submit(new ThreadExec(this, key, maxWaitSeconds, dryRun)));
}
- final Map<Long, TaskExecTO> res = new HashMap<>();
+ Map<Long, TaskExecTO> res = new HashMap<>();
for (Future<TaskExecTO> future : futures) {
TaskExecTO taskExecTO = future.get(100, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
index fcb988b..1a086e2 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CamelRouteITCase.java
@@ -18,12 +18,14 @@
*/
package org.apache.syncope.fit.core.reference;
+import static org.apache.syncope.fit.core.reference.AbstractITCase.anyTypeClassService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.syncope.common.lib.SyncopeConstants;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.common.lib.to.CamelRouteTO;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
import org.apache.syncope.common.lib.to.UserTO;
@@ -147,8 +149,14 @@ public class CamelRouteITCase extends AbstractITCase {
schemaTO.setType(AttrSchemaType.String);
createSchema(SchemaType.PLAIN, schemaTO);
+ AnyTypeClassTO typeClass = new AnyTypeClassTO();
+ typeClass.setKey("camelAttribute");
+ typeClass.getPlainSchemas().add(schemaTO.getKey());
+ anyTypeClassService.create(typeClass);
+
UserTO userTO = new UserTO();
userTO.setRealm(SyncopeConstants.ROOT_REALM);
+ userTO.getAuxClasses().add(typeClass.getKey());
String userId = getUUIDString() + "camelUser@syncope.apache.org";
userTO.setUsername(userId);
userTO.setPassword("password123");
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
index 7c1ca19..e311e41 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConfigurationITCase.java
@@ -27,20 +27,15 @@ import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.to.ConfTO;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
-import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.common.lib.types.AttrSchemaType;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.EntityViolationType;
@@ -153,91 +148,4 @@ public class ConfigurationITCase extends AbstractITCase {
assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
}
}
-
- private static String[] substringsBetween(final String str, final String open, final String close) {
- if (str == null || StringUtils.isEmpty(open) || StringUtils.isEmpty(close)) {
- return null;
- }
- final int strLen = str.length();
- if (strLen == 0) {
- return ArrayUtils.EMPTY_STRING_ARRAY;
- }
- final int closeLen = close.length();
- final int openLen = open.length();
- final List<String> list = new ArrayList<>();
- int pos = 0;
- while (pos < strLen - closeLen) {
- int start = StringUtils.indexOfIgnoreCase(str, open, pos);
- if (start < 0) {
- break;
- }
- start += openLen;
- final int end = StringUtils.indexOfIgnoreCase(str, close, start);
- if (end < 0) {
- break;
- }
- list.add(str.substring(start, end));
- pos = end + closeLen;
- }
- if (list.isEmpty()) {
- return null;
- }
- return list.toArray(new String[list.size()]);
- }
-
- @Test
- public void issueSYNCOPE629() throws IOException {
- PlainSchemaTO membershipKey = new PlainSchemaTO();
- membershipKey.setKey("membershipKey" + getUUIDString());
- membershipKey.setType(AttrSchemaType.String);
- createSchema(SchemaType.PLAIN, membershipKey);
-
- PlainSchemaTO groupKey = new PlainSchemaTO();
- groupKey.setKey("group"
- + "Key" + getUUIDString());
- groupKey.setType(AttrSchemaType.String);
- createSchema(SchemaType.PLAIN, groupKey);
-
- GroupTO groupTO = new GroupTO();
- groupTO.setRealm("/");
- groupTO.setName("aGroup" + getUUIDString());
- groupTO = createGroup(groupTO);
-
- try {
- Response response = configurationService.export();
- assertNotNull(response);
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode());
- assertTrue(response.getMediaType().toString().startsWith(MediaType.TEXT_XML));
- String contentDisposition = response.getHeaderString(HttpHeaders.CONTENT_DISPOSITION);
- assertNotNull(contentDisposition);
-
- Object entity = response.getEntity();
- assertTrue(entity instanceof InputStream);
- String configExport = IOUtils.toString((InputStream) entity, SyncopeConstants.DEFAULT_ENCODING);
- assertFalse(configExport.isEmpty());
- assertTrue(configExport.length() > 1000);
-
- String[] result = substringsBetween(configExport, "<GPLAINATTRTEMPLATE", "/>");
- assertNotNull(result);
- boolean rattrExists = false;
- for (String entry : result) {
- if (entry.contains(groupKey.getKey())) {
- rattrExists = true;
- }
- }
- assertTrue(rattrExists);
-
- result = substringsBetween(configExport, "<MPLAINATTRTEMPLATE", "/>");
- assertNotNull(result);
- boolean mattrExists = false;
- for (String entry : result) {
- if (entry.contains(membershipKey.getKey())) {
- mattrExists = true;
- }
- }
- assertTrue(mattrExists);
- } finally {
- deleteGroup(groupTO.getKey());
- }
- }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
index 5d75e7c..2cd33a5 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java
@@ -273,7 +273,7 @@ public class ConnectorITCase extends AbstractITCase {
List<ResourceTO> result = new ArrayList<>();
for (ResourceTO resource : input) {
- if (connectorKey.equals(resource.getConnectorId())) {
+ if (connectorKey.equals(resource.getConnector())) {
result.add(resource);
}
}
@@ -320,7 +320,7 @@ public class ConnectorITCase extends AbstractITCase {
long connId = connInstanceTO.getKey();
// Link resourceTO to the new connector instance.
- resourceTO.setConnectorId(connId);
+ resourceTO.setConnector(connId);
// ----------------------------------
// ----------------------------------
@@ -639,7 +639,7 @@ public class ConnectorITCase extends AbstractITCase {
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(connectorTO.getKey());
+ resourceTO.setConnector(connectorTO.getKey());
conf = new HashSet<>();
endpoint.getValues().clear();
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
index e13e400..ae823e1 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ExceptionMapperITCase.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.fit.core.reference;
+import static org.apache.syncope.fit.core.reference.AbstractITCase.anyTypeClassService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -27,6 +28,7 @@ import java.util.Properties;
import org.apache.commons.io.IOUtils;
import org.apache.syncope.common.lib.SyncopeClientCompositeException;
import org.apache.syncope.common.lib.SyncopeConstants;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
import org.apache.syncope.common.lib.to.RoleTO;
import org.apache.syncope.common.lib.to.UserTO;
@@ -65,9 +67,15 @@ public class ExceptionMapperITCase extends AbstractITCase {
schemaTO.setUniqueConstraint(true);
createSchema(SchemaType.PLAIN, schemaTO);
+ AnyTypeClassTO typeClass = new AnyTypeClassTO();
+ typeClass.setKey("camelAttribute");
+ typeClass.getPlainSchemas().add(schemaTO.getKey());
+ anyTypeClassService.create(typeClass);
+
// 2. create an user with mandatory attributes and unique
UserTO userTO1 = new UserTO();
userTO1.setRealm(SyncopeConstants.ROOT_REALM);
+ userTO1.getAuxClasses().add(typeClass.getKey());
String userId1 = getUUIDString() + "issue654_1@syncope.apache.org";
userTO1.setUsername(userId1);
userTO1.setPassword("password123");
@@ -82,6 +90,7 @@ public class ExceptionMapperITCase extends AbstractITCase {
// 3. create an other user with mandatory attributes and unique with the same value of userTO1
UserTO userTO2 = new UserTO();
userTO2.setRealm(SyncopeConstants.ROOT_REALM);
+ userTO2.getAuxClasses().add(typeClass.getKey());
String userId2 = getUUIDString() + "issue654_2@syncope.apache.org";
userTO2.setUsername(userId2);
userTO2.setPassword("password123");
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/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 d0a4be1..391e8e7 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
@@ -44,6 +44,8 @@ import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.common.lib.mod.ReferenceMod;
import org.apache.syncope.common.lib.mod.GroupMod;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
+import org.apache.syncope.common.lib.to.AnyTypeTO;
import org.apache.syncope.common.lib.to.BulkActionResult;
import org.apache.syncope.common.lib.to.ConnObjectTO;
import org.apache.syncope.common.lib.to.MappingItemTO;
@@ -418,6 +420,7 @@ public class GroupITCase extends AbstractITCase {
public void deprovision() {
GroupTO actual = createGroup(getSampleTO("deprovision"));
assertNotNull(actual);
+ assertNotNull(actual.getKey());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
@@ -507,8 +510,8 @@ public class GroupITCase extends AbstractITCase {
}
@Test
- public void createWithMandatorySchemaNotTemplate() {
- // 1. create a group mandatory schema
+ public void createWithMandatorySchema() {
+ // 1. create a mandatory schema
PlainSchemaTO badge = new PlainSchemaTO();
badge.setKey("badge" + getUUIDString());
badge.setMandatoryCondition("true");
@@ -521,24 +524,40 @@ public class GroupITCase extends AbstractITCase {
assertNotNull(groupTO);
assertFalse(groupTO.getPlainAttrMap().containsKey(badge.getKey()));
- // 3. add a template for badge to the group just created -
- // failure since no values are provided and it is mandatory
- GroupMod groupMod = new GroupMod();
- groupMod.setKey(groupTO.getKey());
+ // 3. add the new mandatory schema to the default group type
+ AnyTypeTO type = anyTypeService.read(AnyTypeKind.GROUP.name());
+ String typeClassName = type.getClasses().get(0);
+ AnyTypeClassTO typeClass = anyTypeClassService.read(typeClassName);
+ typeClass.getPlainSchemas().add(badge.getKey());
+ anyTypeClassService.update(typeClassName, typeClass);
+ typeClass = anyTypeClassService.read(typeClassName);
+ assertTrue(typeClass.getPlainSchemas().contains(badge.getKey()));
try {
- updateGroup(groupMod);
- fail();
- } catch (SyncopeClientException e) {
- assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
- }
+ // 4. update group: failure since no values are provided and it is mandatory
+ GroupMod groupMod = new GroupMod();
+ groupMod.setKey(groupTO.getKey());
+
+ try {
+ updateGroup(groupMod);
+ fail();
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
+ }
- // 4. also add an actual attribute for badge - it will work
- groupMod.getPlainAttrsToUpdate().add(attrMod(badge.getKey(), "xxxxxxxxxx"));
+ // 5. also add an actual attribute for badge - it will work
+ groupMod.getPlainAttrsToUpdate().add(attrMod(badge.getKey(), "xxxxxxxxxx"));
- groupTO = updateGroup(groupMod);
- assertNotNull(groupTO);
- assertTrue(groupTO.getPlainAttrMap().containsKey(badge.getKey()));
+ groupTO = updateGroup(groupMod);
+ assertNotNull(groupTO);
+ assertTrue(groupTO.getPlainAttrMap().containsKey(badge.getKey()));
+ } finally {
+ // restore the original group class
+ typeClass.getPlainSchemas().remove(badge.getKey());
+ anyTypeClassService.update(typeClassName, typeClass);
+ typeClass = anyTypeClassService.read(typeClassName);
+ assertFalse(typeClass.getPlainSchemas().contains(badge.getKey()));
+ }
}
@Test
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
index e77f343..e6e450c 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java
@@ -32,6 +32,7 @@ import org.apache.commons.lang3.SerializationUtils;
import org.apache.syncope.common.lib.AnyOperations;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.mod.UserMod;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.common.lib.to.MembershipTO;
import org.apache.syncope.common.lib.to.PlainSchemaTO;
import org.apache.syncope.common.lib.to.UserTO;
@@ -63,8 +64,12 @@ public class PlainSchemaITCase extends AbstractITCase {
PlainSchemaTO newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO);
assertEquals(schemaTO, newPlainSchemaTO);
- newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO);
- assertEquals(schemaTO, newPlainSchemaTO);
+ try {
+ createSchema(SchemaType.PLAIN, schemaTO);
+ fail();
+ } catch (SyncopeClientException e) {
+ assertEquals(ClientExceptionType.EntityExists, e.getType());
+ }
}
@Test
@@ -79,8 +84,7 @@ public class PlainSchemaITCase extends AbstractITCase {
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
- assertTrue(e.getElements().iterator().next().toString().
- contains(EntityViolationType.InvalidName.name()));
+ assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
}
}
@@ -202,7 +206,13 @@ public class PlainSchemaITCase extends AbstractITCase {
schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
assertNotNull(schemaTO);
+ AnyTypeClassTO typeClass = new AnyTypeClassTO();
+ typeClass.setKey("issue258");
+ typeClass.getPlainSchemas().add(schemaTO.getKey());
+ anyTypeClassService.create(typeClass);
+
UserTO userTO = UserITCase.getUniqueSampleTO("issue258@syncope.apache.org");
+ userTO.getAuxClasses().add(typeClass.getKey());
userTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "1.2"));
userTO = createUser(userTO);
@@ -225,7 +235,13 @@ public class PlainSchemaITCase extends AbstractITCase {
schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
assertNotNull(schemaTO);
+ AnyTypeClassTO typeClass = new AnyTypeClassTO();
+ typeClass.setKey("issue259");
+ typeClass.getPlainSchemas().add(schemaTO.getKey());
+ anyTypeClassService.create(typeClass);
+
UserTO userTO = UserITCase.getUniqueSampleTO("issue259@syncope.apache.org");
+ userTO.getAuxClasses().add(typeClass.getKey());
userTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "1"));
userTO = createUser(userTO);
assertNotNull(userTO);
@@ -249,7 +265,13 @@ public class PlainSchemaITCase extends AbstractITCase {
schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
assertNotNull(schemaTO);
+ AnyTypeClassTO typeClass = new AnyTypeClassTO();
+ typeClass.setKey("issue260");
+ typeClass.getPlainSchemas().add(schemaTO.getKey());
+ anyTypeClassService.create(typeClass);
+
UserTO userTO = UserITCase.getUniqueSampleTO("issue260@syncope.apache.org");
+ userTO.getAuxClasses().add(typeClass.getKey());
userTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "1.2"));
userTO = createUser(userTO);
assertNotNull(userTO);
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
index 1f498cc..9a169c3 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PushTaskITCase.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.fit.core.reference;
+import static org.apache.syncope.fit.core.reference.AbstractITCase.anyTypeClassService;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -31,6 +32,7 @@ import java.util.Set;
import javax.ws.rs.core.Response;
import org.apache.syncope.client.lib.SyncopeClient;
import org.apache.syncope.common.lib.to.AbstractTaskTO;
+import org.apache.syncope.common.lib.to.AnyTypeClassTO;
import org.apache.syncope.common.lib.to.MappingItemTO;
import org.apache.syncope.common.lib.to.MappingTO;
import org.apache.syncope.common.lib.to.NotificationTO;
@@ -120,12 +122,12 @@ public class PushTaskITCase extends AbstractTaskITCase {
public void pushMatchingUnmatchingGroups() {
assertFalse(groupService.read(3L).getResources().contains(RESOURCE_NAME_LDAP));
- execSyncTask(23L, 50, false);
+ execProvisioningTask(23L, 50, false);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), 3L));
assertTrue(groupService.read(3L).getResources().contains(RESOURCE_NAME_LDAP));
- execSyncTask(23L, 50, false);
+ execProvisioningTask(23L, 50, false);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), 3L));
assertFalse(groupService.read(3L).getResources().contains(RESOURCE_NAME_LDAP));
@@ -144,17 +146,17 @@ public class PushTaskITCase extends AbstractTaskITCase {
// ------------------------------------------
// Unmatching --> Assign --> dryRuyn
// ------------------------------------------
- execSyncTask(13L, 50, true);
+ execProvisioningTask(13L, 50, true);
assertEquals(0, jdbcTemplate.queryForList("SELECT ID FROM test2 WHERE ID='vivaldi'").size());
assertFalse(userService.read(3L).getResources().contains(RESOURCE_NAME_TESTDB2));
// ------------------------------------------
- final Set<Long> pushTaskIds = new HashSet<>();
+ Set<Long> pushTaskIds = new HashSet<>();
pushTaskIds.add(13L);
pushTaskIds.add(14L);
pushTaskIds.add(15L);
pushTaskIds.add(16L);
- execSyncTasks(pushTaskIds, 50, false);
+ execProvisioningTasks(pushTaskIds, 50, false);
// ------------------------------------------
// Unatching --> Ignore
@@ -199,17 +201,17 @@ public class PushTaskITCase extends AbstractTaskITCase {
// ------------------------------------------
// Matching --> Deprovision --> dryRuyn
// ------------------------------------------
- execSyncTask(19L, 50, true);
+ execProvisioningTask(19L, 50, true);
assertTrue(userService.read(1L).getResources().contains(RESOURCE_NAME_TESTDB2));
assertEquals(1, jdbcTemplate.queryForList("SELECT ID FROM test2 WHERE ID='rossini'").size());
// ------------------------------------------
- final Set<Long> pushTaskIds = new HashSet<>();
- pushTaskIds.add(18L);
- pushTaskIds.add(19L);
- pushTaskIds.add(16L);
+ Set<Long> pushTaskKeys = new HashSet<>();
+ pushTaskKeys.add(18L);
+ pushTaskKeys.add(19L);
+ pushTaskKeys.add(16L);
- execSyncTasks(pushTaskIds, 50, false);
+ execProvisioningTasks(pushTaskKeys, 50, false);
// ------------------------------------------
// Matching --> Deprovision && Ignore
@@ -230,16 +232,16 @@ public class PushTaskITCase extends AbstractTaskITCase {
// ------------------------------------------
// Matching --> Link
// ------------------------------------------
- execSyncTask(20L, 50, false);
+ execProvisioningTask(20L, 50, false);
assertTrue(userService.read(2L).getResources().contains(RESOURCE_NAME_TESTDB2));
assertEquals(1, jdbcTemplate.queryForList("SELECT ID FROM test2 WHERE ID='verdi'").size());
// ------------------------------------------
- pushTaskIds.clear();
- pushTaskIds.add(21L);
- pushTaskIds.add(22L);
+ pushTaskKeys.clear();
+ pushTaskKeys.add(21L);
+ pushTaskKeys.add(22L);
- execSyncTasks(pushTaskIds, 50, false);
+ execProvisioningTasks(pushTaskKeys, 50, false);
// ------------------------------------------
// Matching --> Unlink && Update
@@ -257,15 +259,21 @@ public class PushTaskITCase extends AbstractTaskITCase {
schemaTO.setType(AttrSchemaType.String);
schemaTO.setMandatoryCondition("true");
- PlainSchemaTO newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO);
- assertEquals(schemaTO, newPlainSchemaTO);
+ schemaTO = createSchema(SchemaType.PLAIN, schemaTO);
+ assertNotNull(schemaTO);
+
+ AnyTypeClassTO typeClass = new AnyTypeClassTO();
+ typeClass.setKey("SYNCOPE-598");
+ typeClass.getPlainSchemas().add(schemaTO.getKey());
+ anyTypeClassService.create(typeClass);
// create a new sample group
GroupTO groupTO = new GroupTO();
groupTO.setName("all" + getUUIDString());
groupTO.setRealm("/even");
+ groupTO.getAuxClasses().add(typeClass.getKey());
- groupTO.getPlainAttrs().add(attrTO(newPlainSchemaTO.getKey(), "all"));
+ groupTO.getPlainAttrs().add(attrTO(schemaTO.getKey(), "all"));
groupTO = createGroup(groupTO);
assertNotNull(groupTO);
@@ -277,29 +285,28 @@ public class PushTaskITCase extends AbstractTaskITCase {
// Create resource ad-hoc
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(105L);
+ resourceTO.setConnector(105L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.GROUP.name());
provisionTO.setObjectClass(ObjectClass.GROUP_NAME);
resourceTO.getProvisions().add(provisionTO);
- MappingTO rmapping = new MappingTO();
- provisionTO.setMapping(rmapping);
+ MappingTO mapping = new MappingTO();
+ provisionTO.setMapping(mapping);
MappingItemTO item = new MappingItemTO();
item.setIntMappingType(IntMappingType.GroupPlainSchema);
item.setExtAttrName("cn");
- item.setIntAttrName(newPlainSchemaTO.getKey());
+ item.setIntAttrName(schemaTO.getKey());
item.setConnObjectKey(true);
item.setPurpose(MappingPurpose.BOTH);
- rmapping.setConnObjectKeyItem(item);
+ mapping.setConnObjectKeyItem(item);
- rmapping.setConnObjectLink("'cn=' + " + newPlainSchemaTO.getKey() + " + ',ou=groups,o=isp'");
+ mapping.setConnObjectLink("'cn=' + " + schemaTO.getKey() + " + ',ou=groups,o=isp'");
Response response = resourceService.create(resourceTO);
newResourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
-
assertNotNull(newResourceTO);
assertNull(newResourceTO.getProvision(AnyTypeKind.USER.name()));
assertNotNull(newResourceTO.getProvision(AnyTypeKind.GROUP.name()).getMapping());
@@ -316,11 +323,10 @@ public class PushTaskITCase extends AbstractTaskITCase {
response = taskService.create(task);
PushTaskTO push = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
-
assertNotNull(push);
// execute the new task
- TaskExecTO pushExec = execSyncTask(push.getKey(), 50, false);
+ TaskExecTO pushExec = execProvisioningTask(push.getKey(), 50, false);
assertTrue(PropagationTaskExecStatus.valueOf(pushExec.getStatus()).isSuccessful());
} finally {
groupService.delete(groupTO.getKey());
@@ -332,7 +338,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
@Test
public void issueSYNCOPE648() {
- //1. Create Push Task
+ // 1. Create Push Task
PushTaskTO task = new PushTaskTO();
task.setName("Test create Push");
task.setResource(RESOURCE_NAME_LDAP);
@@ -343,8 +349,8 @@ public class PushTaskITCase extends AbstractTaskITCase {
task.setMatchingRule(MatchingRule.IGNORE);
task.setUnmatchingRule(UnmatchingRule.IGNORE);
- final Response response = taskService.create(task);
- final PushTaskTO actual = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
+ Response response = taskService.create(task);
+ PushTaskTO actual = getObject(response.getLocation(), TaskService.class, PushTaskTO.class);
assertNotNull(actual);
// 2. Create notification
@@ -368,7 +374,7 @@ public class PushTaskITCase extends AbstractTaskITCase {
notification = getObject(responseNotification.getLocation(), NotificationService.class, NotificationTO.class);
assertNotNull(notification);
- execSyncTask(actual.getKey(), 50, false);
+ execProvisioningTask(actual.getKey(), 50, false);
NotificationTaskTO taskTO = findNotificationTaskBySender("syncope648@syncope.apache.org");
assertNotNull(taskTO);
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/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 2e6cf21..faf4701 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
@@ -58,7 +58,7 @@ public class ResourceITCase extends AbstractITCase {
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
@@ -151,7 +151,7 @@ public class ResourceITCase extends AbstractITCase {
mapping.add(item);
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
ConnConfProperty p = new ConnConfProperty();
ConnConfPropSchema schema = new ConnConfPropSchema();
@@ -178,7 +178,7 @@ public class ResourceITCase extends AbstractITCase {
String resourceName = RESOURCE_NAME_CREATE_SINGLE;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
@@ -228,7 +228,7 @@ public class ResourceITCase extends AbstractITCase {
String resourceName = RESOURCE_NAME_CREATE_WRONG;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
@@ -264,7 +264,7 @@ public class ResourceITCase extends AbstractITCase {
String resourceName = RESOURCE_NAME_CREATE_WRONG;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
@@ -294,7 +294,7 @@ public class ResourceITCase extends AbstractITCase {
String resourceName = "res-with-password-policy";
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
resourceTO.setPasswordPolicy(4L);
ProvisionTO provisionTO = new ProvisionTO();
@@ -342,7 +342,7 @@ public class ResourceITCase extends AbstractITCase {
String resourceName = RESOURCE_NAME_UPDATE;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(101L);
+ resourceTO.setConnector(101L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
@@ -510,7 +510,7 @@ public class ResourceITCase extends AbstractITCase {
assertNotNull(resource);
assertNotNull(resource.getProvision(AnyTypeKind.USER.name()).getMapping());
- resource.getProvision(AnyTypeKind.USER.name()).setMapping(new MappingTO());
+ resource.getProvision(AnyTypeKind.USER.name()).setMapping(null);
resourceService.update(name, resource);
resource = resourceService.read(name);
@@ -525,7 +525,7 @@ public class ResourceITCase extends AbstractITCase {
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(name);
- resourceTO.setConnectorId(105L);
+ resourceTO.setConnector(105L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.GROUP.name());
@@ -586,7 +586,7 @@ public class ResourceITCase extends AbstractITCase {
String resourceName = RESOURCE_NAME_CREATE_NONE;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(102L);
+ resourceTO.setConnector(102L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
index 479c96f..1d809ea 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/SyncTaskITCase.java
@@ -126,7 +126,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
assertEquals(actual.getKey(), task.getKey());
assertEquals(actual.getJobClassName(), task.getJobClassName());
assertEquals(userTemplate, task.getTemplates().get(AnyTypeKind.USER.name()));
- assertEquals(groupTemplate, task.getTemplates().get(AnyTypeKind.USER.name()));
+ assertEquals(groupTemplate, task.getTemplates().get(AnyTypeKind.GROUP.name()));
}
@Test
@@ -147,6 +147,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
inUserTO.getPlainAttrs().add(attrTO("fullname", "nome cognome"));
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);
@@ -160,7 +161,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
page(1).size(1).build()).getTotalCount();
assertNotNull(usersPre);
- execSyncTask(SYNC_TASK_ID, 50, false);
+ execProvisioningTask(SYNC_TASK_ID, 50, false);
// after execution of the sync task the user data should have been synced from CSV
// and processed by user template
@@ -229,13 +230,13 @@ public class SyncTaskITCase extends AbstractTaskITCase {
assertEquals("active", userTO.getStatus());
// SYNCOPE-317
- execSyncTask(SYNC_TASK_ID, 50, false);
+ execProvisioningTask(SYNC_TASK_ID, 50, false);
final Set<Long> pushTaskIds = new HashSet<>();
pushTaskIds.add(25L);
pushTaskIds.add(26L);
- execSyncTasks(pushTaskIds, 50, false);
+ execProvisioningTasks(pushTaskIds, 50, false);
// Matching --> UNLINK
assertFalse(readUser("test9").getResources().contains(RESOURCE_NAME_CSV));
assertFalse(readUser("test7").getResources().contains(RESOURCE_NAME_CSV));
@@ -246,7 +247,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
@Test
public void dryRun() {
- TaskExecTO execution = execSyncTask(SYNC_TASK_ID, 50, true);
+ TaskExecTO execution = execProvisioningTask(SYNC_TASK_ID, 50, true);
assertEquals("Execution of task " + execution.getTask() + " failed with message " + execution.getMessage(),
"SUCCESS", execution.getStatus());
}
@@ -254,7 +255,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
@Test
public void reconcileFromDB() {
// update sync task
- TaskExecTO execution = execSyncTask(7L, 50, false);
+ TaskExecTO execution = execProvisioningTask(7L, 50, false);
assertNotNull(execution.getStatus());
assertTrue(PropagationTaskExecStatus.valueOf(execution.getStatus()).isSuccessful());
@@ -268,7 +269,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
jdbcTemplate.execute("UPDATE TEST SET STATUS=TRUE");
// re-execute the same SyncTask: now user must be active
- execution = execSyncTask(7L, 50, false);
+ execution = execProvisioningTask(7L, 50, false);
assertNotNull(execution.getStatus());
assertTrue(PropagationTaskExecStatus.valueOf(execution.getStatus()).isSuccessful());
@@ -312,8 +313,8 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// First of all, clear any potential conflict with existing user / group
ldapCleanup();
- // Update sync task
- TaskExecTO execution = execSyncTask(11L, 50, false);
+ // 0. synchronize
+ TaskExecTO execution = execProvisioningTask(11L, 50, false);
// 1. verify execution status
String status = execution.getStatus();
@@ -343,19 +344,12 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// Check for SYNCOPE-123
assertNotNull(matchingUsers.getResult().get(0).getPlainAttrMap().get("photo"));
- final GroupTO groupTO = matchingGroups.getResult().iterator().next();
+ GroupTO groupTO = matchingGroups.getResult().iterator().next();
assertNotNull(groupTO);
assertEquals("testLDAPGroup", groupTO.getName());
assertEquals("true", groupTO.getPlainAttrMap().get("show").getValues().get(0));
assertEquals(matchingUsers.getResult().iterator().next().getKey(), groupTO.getUserOwner(), 0);
assertNull(groupTO.getGroupOwner());
-
- // 3. verify that LDAP group membership is propagated as Syncope group membership
- PagedResult<UserTO> members = userService.search(
- SyncopeClient.getAnySearchQueryBuilder().realm(SyncopeConstants.ROOT_REALM).
- fiql(SyncopeClient.getUserSearchConditionBuilder().inGroups(groupTO.getKey()).query()).build());
- assertNotNull(members);
- assertEquals(1, members.getResult().size());
}
@Test
@@ -415,9 +409,9 @@ public class SyncTaskITCase extends AbstractTaskITCase {
assertNotNull(actual);
assertEquals(task.getKey(), actual.getKey());
assertFalse(actual.getTemplates().get(AnyTypeKind.USER.name()).getResources().isEmpty());
- assertFalse(actual.getTemplates().get(AnyTypeKind.USER.name()).getMemberships().isEmpty());
+ assertFalse(((UserTO) actual.getTemplates().get(AnyTypeKind.USER.name())).getMemberships().isEmpty());
- TaskExecTO execution = execSyncTask(actual.getKey(), 50, false);
+ TaskExecTO execution = execProvisioningTask(actual.getKey(), 50, false);
final String status = execution.getStatus();
assertNotNull(status);
assertTrue(PropagationTaskExecStatus.valueOf(status).isSuccessful());
@@ -436,7 +430,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
@Test
public void issueSYNCOPE230() {
// 1. read SyncTask for resource-db-sync (table TESTSYNC on external H2)
- execSyncTask(10L, 50, false);
+ execProvisioningTask(10L, 50, false);
// 3. read e-mail address for user created by the SyncTask first execution
UserTO userTO = readUser("issuesyncope230");
@@ -449,7 +443,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
jdbcTemplate.execute("UPDATE TESTSYNC SET email='updatedSYNCOPE230@syncope.apache.org'");
// 5. re-execute the SyncTask
- execSyncTask(10L, 50, false);
+ execProvisioningTask(10L, 50, false);
// 6. verify that the e-mail was updated
userTO = readUser("issuesyncope230");
@@ -511,7 +505,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
userService.update(userMod.getKey(), userMod);
- execSyncTask(actual.getKey(), 50, false);
+ execProvisioningTask(actual.getKey(), 50, false);
SyncTaskTO executed = taskService.read(actual.getKey());
assertEquals(1, executed.getExecutions().size());
@@ -535,7 +529,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
assertEquals(1, userTO.getPropagationStatusTOs().size());
assertTrue(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
- TaskExecTO taskExecTO = execSyncTask(24L, 50, false);
+ TaskExecTO taskExecTO = execProvisioningTask(24L, 50, false);
assertNotNull(taskExecTO.getStatus());
assertTrue(PropagationTaskExecStatus.valueOf(taskExecTO.getStatus()).isSuccessful());
@@ -551,6 +545,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
@Test
public void issueSYNCOPE307() {
UserTO userTO = UserITCase.getUniqueSampleTO("s307@apache.org");
+ userTO.getAuxClasses().add("csv");
AttrTO csvuserid = new AttrTO();
csvuserid.setSchema("csvuserid");
@@ -583,7 +578,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
task.getTemplates().put(AnyTypeKind.USER.name(), template);
taskService.update(task.getKey(), task);
- execSyncTask(task.getKey(), 50, false);
+ execProvisioningTask(task.getKey(), 50, false);
// check for sync policy
userTO = userService.read(userTO.getKey());
@@ -640,7 +635,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
assertEquals(actual.getKey(), syncTask.getKey());
assertEquals(actual.getJobClassName(), syncTask.getJobClassName());
- TaskExecTO execution = execSyncTask(syncTask.getKey(), 50, false);
+ TaskExecTO execution = execProvisioningTask(syncTask.getKey(), 50, false);
final String status = execution.getStatus();
assertNotNull(status);
assertTrue(PropagationTaskExecStatus.valueOf(status).isSuccessful());
@@ -692,11 +687,11 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// 5. Update the LDAP Connector to retrieve passwords
ResourceTO ldapResource = resourceService.read(RESOURCE_NAME_LDAP);
- ConnInstanceTO resourceConnector = connectorService.read(ldapResource.getConnectorId());
+ ConnInstanceTO resourceConnector = connectorService.read(ldapResource.getConnector());
ConnConfProperty property = resourceConnector.getConfigurationMap().get("retrievePasswordsWithSearch");
property.getValues().clear();
property.getValues().add(Boolean.TRUE);
- connectorService.update(ldapResource.getConnectorId(), resourceConnector);
+ connectorService.update(ldapResource.getConnector(), resourceConnector);
// 6. Sync the user from the resource
SyncTaskTO syncTask = new SyncTaskTO();
@@ -717,8 +712,8 @@ public class SyncTaskITCase extends AbstractTaskITCase {
assertEquals(actual.getKey(), syncTask.getKey());
assertEquals(actual.getJobClassName(), syncTask.getJobClassName());
- TaskExecTO execution = execSyncTask(syncTask.getKey(), 50, false);
- final String status = execution.getStatus();
+ TaskExecTO execution = execProvisioningTask(syncTask.getKey(), 50, false);
+ String status = execution.getStatus();
assertNotNull(status);
assertTrue(PropagationTaskExecStatus.valueOf(status).isSuccessful());
@@ -731,7 +726,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
taskService.delete(syncTask.getKey());
property.getValues().clear();
property.getValues().add(Boolean.FALSE);
- connectorService.update(ldapResource.getConnectorId(), resourceConnector);
+ connectorService.update(ldapResource.getConnector(), resourceConnector);
deleteUser(updatedUser.getKey());
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/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 107c953..4574b5b 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
@@ -95,12 +95,18 @@ import org.springframework.jdbc.core.JdbcTemplate;
@FixMethodOrder(MethodSorters.JVM)
public class UserITCase extends AbstractITCase {
- private String getStringAttribute(final ConnObjectTO connObjectTO, final String attrName) {
- return connObjectTO.getPlainAttrMap().get(attrName).getValues().get(0);
- }
+ private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
+
+ @Override
+ protected SimpleDateFormat initialValue() {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ sdf.applyPattern("yyyy-MM-dd");
+ return sdf;
+ }
+ };
private boolean getBooleanAttribute(final ConnObjectTO connObjectTO, final String attrName) {
- return Boolean.parseBoolean(getStringAttribute(connObjectTO, attrName));
+ return Boolean.parseBoolean(connObjectTO.getPlainAttrMap().get(attrName).getValues().get(0));
}
public static UserTO getUniqueSampleTO(final String email) {
@@ -120,7 +126,7 @@ public class UserITCase extends AbstractITCase {
userTO.getPlainAttrs().add(attrTO("type", "a type"));
userTO.getPlainAttrs().add(attrTO("userId", uid));
userTO.getPlainAttrs().add(attrTO("email", uid));
- userTO.getPlainAttrs().add(attrTO("loginDate", new SimpleDateFormat("yyyy-MM-dd").format(new Date())));
+ userTO.getPlainAttrs().add(attrTO("loginDate", DATE_FORMAT.get().format(new Date())));
userTO.getDerAttrs().add(attrTO("cn", null));
userTO.getVirAttrs().add(attrTO("virtualdata", "virtualvalue"));
return userTO;
@@ -261,6 +267,7 @@ public class UserITCase extends AbstractITCase {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO = createUser(userTO);
@@ -655,7 +662,7 @@ public class UserITCase extends AbstractITCase {
userMod.getDerAttrsToAdd().add("cn");
userMod.getMembershipsToAdd().add(8L);
- userMod.getMembershipsToRemove().add(userTO.getMemberships().iterator().next().getKey());
+ userMod.getMembershipsToRemove().add(userTO.getMemberships().get(0).getRightKey());
userTO = updateUser(userMod);
assertNotNull(userTO);
@@ -1102,6 +1109,7 @@ public class UserITCase extends AbstractITCase {
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
MembershipTO membershipTO = new MembershipTO();
@@ -1157,6 +1165,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
MembershipTO memb12 = new MembershipTO();
@@ -1186,7 +1195,7 @@ public class UserITCase extends AbstractITCase {
UserMod userMod = new UserMod();
userMod.setKey(actual.getKey());
- userMod.getMembershipsToRemove().add(actual.getMemberships().get(0).getKey());
+ userMod.getMembershipsToRemove().add(actual.getMemberships().get(0).getRightKey());
actual = updateUser(userMod);
assertNotNull(actual);
@@ -1219,7 +1228,7 @@ public class UserITCase extends AbstractITCase {
userMod = new UserMod();
userMod.setKey(actual.getKey());
- userMod.getMembershipsToRemove().add(actual.getMemberships().get(0).getKey());
+ userMod.getMembershipsToRemove().add(actual.getMemberships().get(0).getRightKey());
actual = updateUser(userMod);
assertNotNull(actual);
@@ -1490,6 +1499,7 @@ public class UserITCase extends AbstractITCase {
@Test
public void mappingPurpose() {
UserTO userTO = getUniqueSampleTO("mpurpose@apache.org");
+ userTO.getAuxClasses().add("csv");
AttrTO csvuserid = new AttrTO();
csvuserid.setSchema("csvuserid");
@@ -1526,7 +1536,7 @@ public class UserITCase extends AbstractITCase {
@Test
public void bulkActions() {
- final BulkAction bulkAction = new BulkAction();
+ BulkAction bulkAction = new BulkAction();
for (int i = 0; i < 10; i++) {
UserTO userTO = getUniqueSampleTO("bulk_" + i + "@apache.org");
@@ -1598,7 +1608,7 @@ public class UserITCase extends AbstractITCase {
// 4. remove membership
UserMod userMod = new UserMod();
userMod.setKey(userTO.getKey());
- userMod.getMembershipsToRemove().add(userTO.getMemberships().iterator().next().getKey());
+ userMod.getMembershipsToRemove().add(userTO.getMemberships().get(0).getRightKey());
userTO = updateUser(userMod);
assertTrue(userTO.getResources().contains(RESOURCE_NAME_LDAP));
@@ -1746,6 +1756,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO.getResources().add(RESOURCE_NAME_CSV);
@@ -1772,6 +1783,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
UserTO actual = createUser(userTO);
@@ -1810,6 +1822,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO.getResources().add(RESOURCE_NAME_CSV);
@@ -1841,6 +1854,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
UserTO actual = createUser(userTO);
@@ -1875,6 +1889,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO.getResources().add(RESOURCE_NAME_CSV);
@@ -1906,6 +1921,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
UserTO actual = createUser(userTO);
@@ -1941,6 +1957,7 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
UserTO actual = createUser(userTO);
@@ -2280,6 +2297,7 @@ public class UserITCase extends AbstractITCase {
userTO.getPlainAttrs().add(attrTO("email", "syncope391@syncope.apache.org"));
userTO.getDerAttrs().add(attrTO("csvuserid", null));
+ userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
userTO = createUser(userTO, false);
assertNotNull(userTO);
@@ -2299,6 +2317,7 @@ public class UserITCase extends AbstractITCase {
userTO.setPassword("passwordTESTNULL1");
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO.getResources().add(RESOURCE_NAME_CSV);
@@ -2319,6 +2338,7 @@ public class UserITCase extends AbstractITCase {
userTO.setPassword("passwordTESTNULL1");
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO.getResources().add(RESOURCE_NAME_CSV);
@@ -2347,6 +2367,7 @@ public class UserITCase extends AbstractITCase {
userTO.setPassword(null);
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
userTO.getResources().add(RESOURCE_NAME_CSV);
@@ -2369,11 +2390,11 @@ public class UserITCase extends AbstractITCase {
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
userTO.getVirAttrs().clear();
+ userTO.getAuxClasses().add("csv");
userTO.getDerAttrs().add(attrTO("csvuserid", null));
- MembershipTO membershipTO = new MembershipTO();
- membershipTO.setRightKey(12L);
- userTO.getMemberships().add(membershipTO);
+ userTO.getAuxClasses().add("generic membership");
+ userTO.getPlainAttrs().add(attrTO("postalAddress", "postalAddress"));
userTO.getResources().add(RESOURCE_NAME_LDAP);
@@ -2388,9 +2409,7 @@ public class UserITCase extends AbstractITCase {
UserMod userMod = new UserMod();
userMod.setKey(actual.getKey());
-
- userMod.getMembershipsToAdd().add(12L);
- userMod.getMembershipsToRemove().add(actual.getMemberships().iterator().next().getKey());
+ userMod.getPlainAttrsToUpdate().add(attrMod("postalAddress", "newPostalAddress"));
actual = updateUser(userMod);
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
index 457f66d..3bbb7e1 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/UserWorkflowITCase.java
@@ -74,10 +74,19 @@ public class UserWorkflowITCase extends AbstractITCase {
assertNotNull(form.getTaskId());
assertNull(form.getOwner());
- // 3. claim task from rossini, not in group 7 (designated for approval in workflow definition): fail
- UserWorkflowService userService2 = clientFactory.create(
- "rossini", ADMIN_PWD).getService(UserWorkflowService.class);
+ // 3. claim task as rossini, with role 2 granting entitlement to claim forms but not in group 7,
+ // designated for approval in workflow definition: fail
+ UserTO rossini = userService.read(1L);
+ if (!rossini.getRoles().contains(2L)) {
+ UserMod userMod = new UserMod();
+ userMod.setKey(1L);
+ userMod.getRolesToAdd().add(2L);
+ rossini = updateUser(userMod);
+ }
+ assertTrue(rossini.getRoles().contains(2L));
+ UserWorkflowService userService2 = clientFactory.create("rossini", ADMIN_PWD).
+ getService(UserWorkflowService.class);
try {
userService2.claimForm(form.getTaskId());
fail();
@@ -85,10 +94,9 @@ public class UserWorkflowITCase extends AbstractITCase {
assertEquals(ClientExceptionType.Workflow, e.getType());
}
- // 4. claim task from bellini, in role 2
- UserWorkflowService userService3 = clientFactory.create(
- "bellini", ADMIN_PWD).getService(UserWorkflowService.class);
-
+ // 4. claim task from bellini, with role 2 and in group 7
+ UserWorkflowService userService3 = clientFactory.create("bellini", ADMIN_PWD).
+ getService(UserWorkflowService.class);
form = userService3.claimForm(form.getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
@@ -237,9 +245,8 @@ public class UserWorkflowITCase extends AbstractITCase {
assertNotNull(form);
// 3. first claim ny bellini ....
- UserWorkflowService userService3 = clientFactory.create(
- "bellini", ADMIN_PWD).getService(UserWorkflowService.class);
-
+ UserWorkflowService userService3 = clientFactory.create("bellini", ADMIN_PWD).
+ getService(UserWorkflowService.class);
form = userService3.claimForm(form.getTaskId());
assertNotNull(form);
assertNotNull(form.getTaskId());
@@ -250,7 +257,7 @@ public class UserWorkflowITCase extends AbstractITCase {
assertNotNull(form);
// 5. approve user
- final Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap();
+ Map<String, WorkflowFormPropertyTO> props = form.getPropertyMap();
props.get("approve").setValue(Boolean.TRUE.toString());
form.getProperties().clear();
form.getProperties().addAll(props.values());
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd88efbd/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirAttrITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirAttrITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirAttrITCase.java
index a373df5..2c2065f 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirAttrITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/VirAttrITCase.java
@@ -228,7 +228,7 @@ public class VirAttrITCase extends AbstractITCase {
assertEquals("virattrcache", actual.getVirAttrMap().get("virtualdata").getValues().get(0));
// 3. update virtual attribute directly
- final JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
+ JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
String value = jdbcTemplate.queryForObject(
"SELECT USERNAME FROM testsync WHERE ID=?", String.class, actual.getKey());
@@ -296,6 +296,7 @@ public class VirAttrITCase extends AbstractITCase {
// create a new user
UserTO userTO = UserITCase.getUniqueSampleTO("syncope397@syncope.apache.org");
+ userTO.getAuxClasses().add("csv");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getDerAttrs().clear();
@@ -450,7 +451,7 @@ public class VirAttrITCase extends AbstractITCase {
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceName);
- resourceTO.setConnectorId(107L);
+ resourceTO.setConnector(107L);
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
@@ -463,7 +464,7 @@ public class VirAttrITCase extends AbstractITCase {
MappingItemTO item = new MappingItemTO();
item.setIntAttrName("aLong");
item.setIntMappingType(IntMappingType.UserPlainSchema);
- item.setExtAttrName(groupName);
+ item.setExtAttrName("ID");
item.setPurpose(MappingPurpose.PROPAGATION);
item.setConnObjectKey(true);
mapping.setConnObjectKeyItem(item);