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 2016/02/19 16:41:11 UTC
syncope git commit: [SYNCOPE-768] this fix extends search to null
attributes as well + improve plain schema validation by preventing usage of
TO classes field names
Repository: syncope
Updated Branches:
refs/heads/master d2feda5e6 -> 915f3c325
[SYNCOPE-768] this fix extends search to null attributes as well + improve plain schema validation by preventing usage of TO classes field names
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/915f3c32
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/915f3c32
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/915f3c32
Branch: refs/heads/master
Commit: 915f3c325d3dde66f8c8a891b3b0a04a165f7e54
Parents: d2feda5
Author: fmartelli <fa...@gmail.com>
Authored: Fri Feb 19 16:32:09 2016 +0100
Committer: fmartelli <fa...@gmail.com>
Committed: Fri Feb 19 16:32:26 2016 +0100
----------------------------------------------------------------------
.../syncope/common/lib/EntityTOUtils.java | 18 ++++++++++
.../core/misc/search/SearchCondVisitor.java | 16 ++-------
.../persistence/jpa/dao/JPAAnySearchDAO.java | 16 ++++++---
.../validation/entity/PlainSchemaValidator.java | 36 +++++++++++--------
.../test/resources/domains/MasterContent.xml | 14 ++++----
.../fit/console/AbstractConsoleITCase.java | 38 ++++++++++----------
.../syncope/fit/console/SchemasITCase.java | 4 +--
.../syncope/fit/core/PlainSchemaITCase.java | 8 ++++-
.../apache/syncope/fit/core/SearchITCase.java | 18 ++++++++++
.../apache/syncope/fit/core/SyncTaskITCase.java | 8 ++---
.../org/apache/syncope/fit/core/UserITCase.java | 16 ++++-----
11 files changed, 118 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/common/lib/src/main/java/org/apache/syncope/common/lib/EntityTOUtils.java
----------------------------------------------------------------------
diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/EntityTOUtils.java b/common/lib/src/main/java/org/apache/syncope/common/lib/EntityTOUtils.java
index b2d9c7e..17123b5 100644
--- a/common/lib/src/main/java/org/apache/syncope/common/lib/EntityTOUtils.java
+++ b/common/lib/src/main/java/org/apache/syncope/common/lib/EntityTOUtils.java
@@ -18,11 +18,29 @@
*/
package org.apache.syncope.common.lib;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import org.apache.commons.collections4.Transformer;
+import org.apache.syncope.common.lib.search.SearchableFields;
+import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.to.EntityTO;
+import org.apache.syncope.common.lib.to.GroupTO;
+import org.apache.syncope.common.lib.to.UserTO;
public final class EntityTOUtils {
+ public static final List<String> ANY_FIELDS;
+
+ static {
+ List<String> anyFields = new ArrayList<>();
+ anyFields.addAll(SearchableFields.get(UserTO.class));
+ anyFields.addAll(SearchableFields.get(GroupTO.class));
+ anyFields.addAll(SearchableFields.get(AnyObjectTO.class));
+
+ ANY_FIELDS = Collections.unmodifiableList(anyFields);
+ }
+
public static <KEY, E extends EntityTO<KEY>> Transformer<E, KEY> keyTransformer() {
return new Transformer<E, KEY>() {
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java b/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
index 402005b..2e281cf 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/search/SearchCondVisitor.java
@@ -25,11 +25,8 @@ import org.apache.cxf.jaxrs.ext.search.SearchBean;
import org.apache.cxf.jaxrs.ext.search.SearchCondition;
import org.apache.cxf.jaxrs.ext.search.SearchUtils;
import org.apache.cxf.jaxrs.ext.search.visitor.AbstractSearchConditionVisitor;
-import org.apache.syncope.common.lib.search.SearchableFields;
+import org.apache.syncope.common.lib.EntityTOUtils;
import org.apache.syncope.common.lib.search.SpecialAttr;
-import org.apache.syncope.common.lib.to.AnyObjectTO;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.to.UserTO;
import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
import org.apache.syncope.core.persistence.api.dao.search.MembershipCond;
import org.apache.syncope.core.persistence.api.dao.search.ResourceCond;
@@ -46,15 +43,6 @@ import org.apache.syncope.core.persistence.api.dao.search.RelationshipTypeCond;
*/
public class SearchCondVisitor extends AbstractSearchConditionVisitor<SearchBean, SearchCond> {
- private static final List<String> ANY_FIELDS;
-
- static {
- ANY_FIELDS = new ArrayList<>();
- ANY_FIELDS.addAll(SearchableFields.get(UserTO.class));
- ANY_FIELDS.addAll(SearchableFields.get(GroupTO.class));
- ANY_FIELDS.addAll(SearchableFields.get(AnyObjectTO.class));
- }
-
private String realm;
private SearchCond searchCond;
@@ -68,7 +56,7 @@ public class SearchCondVisitor extends AbstractSearchConditionVisitor<SearchBean
}
private AttributeCond createAttributeCond(final String schema) {
- AttributeCond attributeCond = ANY_FIELDS.contains(schema)
+ AttributeCond attributeCond = EntityTOUtils.ANY_FIELDS.contains(schema)
? new AnyCond()
: new AttributeCond();
attributeCond.setSchema(schema);
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index d414456..b0b1162 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -260,10 +260,18 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
return select;
}
- private StringBuilder buildWhere(final OrderBySupport orderBySupport) {
+ private StringBuilder buildWhere(final OrderBySupport orderBySupport, final AnyTypeKind typeKind) {
+ SearchSupport svs = new SearchSupport(typeKind);
final StringBuilder where = new StringBuilder(" u");
for (SearchSupport.SearchView searchView : orderBySupport.views) {
- where.append(',').append(searchView.name).append(' ').append(searchView.alias);
+ where.append(',');
+ if (searchView.name.equals(svs.attr().name)) {
+ where.append(" (SELECT * FROM ").append(searchView.name).append(" UNION ").
+ append("SELECT * FROM ").append(svs.nullAttr().name).append(')');
+ } else {
+ where.append(searchView.name);
+ }
+ where.append(' ').append(searchView.alias);
}
where.append(" WHERE ");
for (SearchSupport.SearchView searchView : orderBySupport.views) {
@@ -366,10 +374,10 @@ public class JPAAnySearchDAO extends AbstractDAO<Any<?>, Long> implements AnySea
OrderBySupport orderBySupport = parseOrderBy(typeKind, svs, orderBy);
if (queryString.charAt(0) == '(') {
queryString.insert(0, buildSelect(orderBySupport));
- queryString.append(buildWhere(orderBySupport));
+ queryString.append(buildWhere(orderBySupport, typeKind));
} else {
queryString.insert(0, buildSelect(orderBySupport).append('('));
- queryString.append(')').append(buildWhere(orderBySupport));
+ queryString.append(')').append(buildWhere(orderBySupport, typeKind));
}
queryString.
append(getAdminRealmsFilter(adminRealms, svs)).append(')').
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/PlainSchemaValidator.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/PlainSchemaValidator.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/PlainSchemaValidator.java
index 2817795..4bbb240 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/PlainSchemaValidator.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/validation/entity/PlainSchemaValidator.java
@@ -20,6 +20,7 @@ package org.apache.syncope.core.persistence.jpa.validation.entity;
import javax.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.common.lib.EntityTOUtils;
import org.apache.syncope.common.lib.types.AttrSchemaType;
import org.apache.syncope.common.lib.types.EntityViolationType;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
@@ -28,30 +29,37 @@ public class PlainSchemaValidator extends AbstractValidator<PlainSchemaCheck, Pl
@Override
public boolean isValid(final PlainSchema schema, final ConstraintValidatorContext context) {
- boolean isValid = schema.getType() != AttrSchemaType.Enum
- || StringUtils.isNotBlank(schema.getEnumerationValues());
+ boolean isValid = schema.getKey() != null && !EntityTOUtils.ANY_FIELDS.contains(schema.getKey());
if (!isValid) {
- context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(
- getTemplate(EntityViolationType.InvalidSchemaEnum, "Enumeration values missing")).
- addPropertyNode("enumerationValues").addConstraintViolation();
+ getTemplate(EntityViolationType.InvalidName, "Invalid PlainSchema name")).
+ addPropertyNode("name").addConstraintViolation();
} else {
- isValid = schema.getType() != AttrSchemaType.Encrypted
- || (schema.getSecretKey() != null && schema.getCipherAlgorithm() != null);
+ isValid = schema.getType() != AttrSchemaType.Enum
+ || StringUtils.isNotBlank(schema.getEnumerationValues());
if (!isValid) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(
- getTemplate(EntityViolationType.InvalidSchemaEncrypted,
- "SecretKey or CipherAlgorithm missing")).
- addPropertyNode("secretKey").addPropertyNode("cipherAlgorithm").addConstraintViolation();
+ getTemplate(EntityViolationType.InvalidSchemaEnum, "Enumeration values missing")).
+ addPropertyNode("enumerationValues").addConstraintViolation();
} else {
- isValid = !schema.isMultivalue() || !schema.isUniqueConstraint();
+ isValid = schema.getType() != AttrSchemaType.Encrypted
+ || (schema.getSecretKey() != null && schema.getCipherAlgorithm() != null);
if (!isValid) {
context.disableDefaultConstraintViolation();
context.buildConstraintViolationWithTemplate(
- getTemplate(EntityViolationType.InvalidSchemaMultivalueUnique,
- "Cannot contemporary be multivalue and have unique constraint")).
- addPropertyNode("multiValue").addConstraintViolation();
+ getTemplate(EntityViolationType.InvalidSchemaEncrypted,
+ "SecretKey or CipherAlgorithm missing")).
+ addPropertyNode("secretKey").addPropertyNode("cipherAlgorithm").addConstraintViolation();
+ } else {
+ isValid = !schema.isMultivalue() || !schema.isUniqueConstraint();
+ if (!isValid) {
+ context.disableDefaultConstraintViolation();
+ context.buildConstraintViolationWithTemplate(
+ getTemplate(EntityViolationType.InvalidSchemaMultivalueUnique,
+ "Cannot contemporary be multivalue and have unique constraint")).
+ addPropertyNode("multiValue").addConstraintViolation();
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
index fa890e6..84ad5eb 100644
--- a/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/test/resources/domains/MasterContent.xml
@@ -316,7 +316,7 @@ under the License.
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"/>
<PlainSchema name="surname" type="String" anyTypeClass_name="minimal user"
mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/>
- <PlainSchema name="type" type="String" anyTypeClass_name="other"
+ <PlainSchema name="ctype" type="String" anyTypeClass_name="other"
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"/>
<PlainSchema name="email" type="String" anyTypeClass_name="minimal user"
mandatoryCondition="false" multivalue="0" uniqueConstraint="0" readonly="0"
@@ -396,7 +396,7 @@ under the License.
<APlainAttr id="4" owner_id="2" schema_name="location"/>
<APlainAttrValue id="4" attribute_id="4" stringValue="2nd floor"/>
- <UPlainAttr id="99" owner_id="1" schema_name="type"/>
+ <UPlainAttr id="99" owner_id="1" schema_name="ctype"/>
<UPlainAttrValue id="9" attribute_id="99" stringValue="G"/>
<UPlainAttr id="100" owner_id="1" schema_name="fullname"/>
<UPlainAttrUniqueValue id="10" attribute_id="100" schema_name="fullname" stringValue="Gioacchino Rossini"/>
@@ -456,7 +456,7 @@ under the License.
<UPlainAttrValue id="35" attribute_id="124" stringValue="verdi@syncope.org"/>
<UPlainAttr id="125" owner_id="3" schema_name="email"/>
<UPlainAttrValue id="36" attribute_id="125" stringValue="vivaldi@syncope.org"/>
- <UPlainAttr id="126" owner_id="3" schema_name="type"/>
+ <UPlainAttr id="126" owner_id="3" schema_name="ctype"/>
<UPlainAttrValue id="37" attribute_id="126" stringValue="F"/>
<GPlainAttr id="600" owner_id="1" schema_name="icon"/>
@@ -729,7 +729,7 @@ under the License.
extAttrName="fullname" intAttrName="surname" intMappingType="UserPlainSchema" mandatoryCondition="true"
connObjectKey="0" password="0" purpose="PROPAGATION"/>
<MappingItem id="336" mapping_id="15"
- extAttrName="type" intAttrName="type" intMappingType="UserPlainSchema" mandatoryCondition="true"
+ extAttrName="type" intAttrName="ctype" intMappingType="UserPlainSchema" mandatoryCondition="true"
connObjectKey="0" password="0" purpose="PROPAGATION"/>
<MappingItem id="337" mapping_id="15"
extAttrName="name" intAttrName="firstname" intMappingType="UserPlainSchema" mandatoryCondition="false"
@@ -759,7 +759,7 @@ under the License.
extAttrName="__PASSWORD__" intMappingType="Password" mandatoryCondition="true"
connObjectKey="0" password="1" purpose="BOTH"/>
<MappingItem id="108" extAttrName="type" mapping_id="1"
- intAttrName="type" intMappingType="UserPlainSchema" mandatoryCondition="true"
+ intAttrName="ctype" intMappingType="UserPlainSchema" mandatoryCondition="true"
connObjectKey="0" password="0" purpose="BOTH"/>
<MappingItem id="109" extAttrName="surname" mapping_id="1"
intAttrName="surname" intMappingType="UserPlainSchema" mandatoryCondition="type == 'F'"
@@ -984,7 +984,7 @@ under the License.
destinationRealm_id="1" performCreate="1" performUpdate="1" performDelete="1" syncStatus="1"
syncMode="INCREMENTAL" unmatchingRule="ASSIGN" matchingRule="UPDATE" active="1"/>
<AnyTemplateSyncTask id="41" syncTask_id="4" anyType_name="USER"
- template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":["csv"],"derAttrs":[{"schema":"cn","readonly":false,"values":[""]}],"virAttrs":[],"resources":["resource-testdb"],"relationships":[],"memberships":[{"leftType":null,"leftKey":0,"rightType":"GROUP","rightKey":8,"groupName":null}],"dynGroups":[],"roles":[],"dynRoles":[],"plainAttrs":[{"schema":"type","readonly":false,"values":["email == 'test8@syncope.apache.org'? 'TYPE_8': 'TYPE_OTHER'"]}]}'/>
+ template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":["csv"],"derAttrs":[{"schema":"cn","readonly":false,"values":[""]}],"virAttrs":[],"resources":["resource-testdb"],"relationships":[],"memberships":[{"leftType":null,"leftKey":0,"rightType":"GROUP","rightKey":8,"groupName":null}],"dynGroups":[],"roles":[],"dynRoles":[],"plainAttrs":[{"schema":"ctype","readonly":false,"values":["email == 'test8@syncope.apache.org'? 'TYPE_8': 'TYPE_OTHER'"]}]}'/>
<AnyTemplateSyncTask id="42" syncTask_id="4" anyType_name="GROUP"
template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
<Task DTYPE="SchedTask" type="SCHEDULED" id="5" name="SampleJob Task" active="1"
@@ -997,7 +997,7 @@ under the License.
destinationRealm_id="1" performCreate="1" performUpdate="1" performDelete="0" syncStatus="1" syncMode="FULL_RECONCILIATION"
unmatchingRule="PROVISION" matchingRule="UPDATE" active="1"/>
<AnyTemplateSyncTask id="71" syncTask_id="7" anyType_name="USER"
- template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"relationships":[],"memberships":[],"dynGroups":[],"roles":[],"dynRoles":[],"plainAttrs":[{"schema":"type","readonly":false,"values":["'type a'"]},{"schema":"userId","readonly":false,"values":["'reconciled@syncope.apache.org'"]},{"schema":"fullname","readonly":false,"values":["'reconciled fullname'"]},{"schema":"surname","readonly":false,"values":["'surname'"]}]}'/>
+ template='{"@class":"org.apache.syncope.common.lib.to.UserTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"USER","realm":null,"status":null,"password":null,"token":null,"tokenExpireTime":null,"username":null,"lastLoginDate":null,"changePwdDate":null,"failedLogins":null,"securityQuestion":null,"securityAnswer":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"relationships":[],"memberships":[],"dynGroups":[],"roles":[],"dynRoles":[],"plainAttrs":[{"schema":"ctype","readonly":false,"values":["'type a'"]},{"schema":"userId","readonly":false,"values":["'reconciled@syncope.apache.org'"]},{"schema":"fullname","readonly":false,"values":["'reconciled fullname'"]},{"schema":"surname","readonly":false,"values":["'surname'"]}]}'/>
<AnyTemplateSyncTask id="72" syncTask_id="7" anyType_name="GROUP"
template='{"@class":"org.apache.syncope.common.lib.to.GroupTO","creator":null,"creationDate":null,"lastModifier":null,"lastChangeDate":null,"key":0,"type":"GROUP","realm":null,"status":null,"name":null,"userOwner":null,"groupOwner":null,"udynMembershipCond":null,"auxClasses":[],"derAttrs":[],"virAttrs":[],"resources":[],"plainAttrs":[]}'/>
<Task DTYPE="NotificationTask" type="NOTIFICATION" id="8" sender="admin@prova.org" subject="Notification for SYNCOPE-81"
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
index d81e029..9e54279 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/AbstractConsoleITCase.java
@@ -102,35 +102,33 @@ public abstract class AbstractConsoleITCase extends AbstractITCase {
}
protected Component findSuccessNotification(final Page page, final String searchPath, final String key) {
- Component result =
- page.visitChildren(NotificationPanel.class, new IVisitor<NotificationPanel, Component>() {
+ Component result = page.visitChildren(NotificationPanel.class, new IVisitor<NotificationPanel, Component>() {
- @Override
- public void component(final NotificationPanel object, final IVisit<Component> visit) {
+ @Override
+ public void component(final NotificationPanel object, final IVisit<Component> visit) {
- if (object.getDefaultModelObjectAsString().equals(Constants.OPERATION_SUCCEEDED)) {
- wicketTester.clickLink(object.getPageRelativePath());
- visit.stop(object);
- }
- }
- });
+ if (object.getDefaultModelObjectAsString().equals(Constants.OPERATION_SUCCEEDED)) {
+ wicketTester.clickLink(object.getPageRelativePath());
+ visit.stop(object);
+ }
+ }
+ });
return result;
}
protected Component findErrorNotification(final Page page, final String searchPath, final String key) {
- Component result =
- page.visitChildren(NotificationPanel.class, new IVisitor<NotificationPanel, Component>() {
+ Component result = page.visitChildren(NotificationPanel.class, new IVisitor<NotificationPanel, Component>() {
- @Override
- public void component(final NotificationPanel object, final IVisit<Component> visit) {
+ @Override
+ public void component(final NotificationPanel object, final IVisit<Component> visit) {
- if (!object.getDefaultModelObjectAsString().equals(Constants.OPERATION_SUCCEEDED)) {
- wicketTester.clickLink(object.getPageRelativePath());
- visit.stop(object);
- }
+ if (!object.getDefaultModelObjectAsString().equals(Constants.OPERATION_SUCCEEDED)) {
+ wicketTester.clickLink(object.getPageRelativePath());
+ visit.stop(object);
+ }
- }
- });
+ }
+ });
return result;
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SchemasITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SchemasITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SchemasITCase.java
index 59bf1dd..2175ad2 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SchemasITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/SchemasITCase.java
@@ -86,10 +86,10 @@ public class SchemasITCase extends AbstractTypesITCase {
public void updatePlainSchema() {
browsingToPlainSchemas();
- Component result = findComponentByProp(KEY, PLAIN_DATATABLE_PATH, "firstname");
+ Component result = findComponentByProp(KEY, PLAIN_DATATABLE_PATH, "ctype");
wicketTester.assertLabel(
- result.getPageRelativePath() + ":cells:1:cell", "firstname");
+ result.getPageRelativePath() + ":cells:1:cell", "ctype");
wicketTester.clickLink(
result.getPageRelativePath() + ":cells:7:cell:panelEdit:editLink");
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
index 973b09e..6b4fb58 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/PlainSchemaITCase.java
@@ -86,7 +86,13 @@ public class PlainSchemaITCase extends AbstractITCase {
fail("This should not be reacheable");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
- assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+ boolean entityViolationTypeCheck = false;
+ for (String element : e.getElements()) {
+ if (!entityViolationTypeCheck) {
+ entityViolationTypeCheck = element.contains(EntityViolationType.InvalidName.name());
+ }
+ }
+ assertTrue(entityViolationTypeCheck);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
index 5626612..6f15786 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
+import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.IterableUtils;
@@ -395,4 +396,21 @@ public class SearchITCase extends AbstractITCase {
assertNotNull(user);
}
}
+
+ @Test
+ public void issueSYNCOPE768() {
+ final List<UserTO> usersWithType = userService.search(
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
+ fiql(SyncopeClient.getUserSearchConditionBuilder().is("ctype").notNullValue().query()).build()).
+ getResult();
+
+ assertFalse(usersWithType.isEmpty());
+
+ final PagedResult<UserTO> matchedUsers = userService.search(
+ new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).
+ fiql(SyncopeClient.getUserSearchConditionBuilder().is("username").notNullValue().query()).
+ orderBy(SyncopeClient.getOrderByClauseBuilder().asc("ctype").build()).build());
+
+ assertTrue(matchedUsers.getResult().size() > usersWithType.size());
+ }
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SyncTaskITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SyncTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SyncTaskITCase.java
index d677571..b039776 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SyncTaskITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SyncTaskITCase.java
@@ -157,7 +157,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
inUserTO.setUsername(userName);
inUserTO.getPlainAttrs().add(attrTO("firstname", "nome9"));
inUserTO.getPlainAttrs().add(attrTO("surname", "cognome"));
- inUserTO.getPlainAttrs().add(attrTO("type", "a type"));
+ inUserTO.getPlainAttrs().add(attrTO("ctype", "a type"));
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"));
@@ -196,7 +196,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
// check for user template
userTO = readUser("test7");
assertNotNull(userTO);
- assertEquals("TYPE_OTHER", userTO.getPlainAttrMap().get("type").getValues().get(0));
+ assertEquals("TYPE_OTHER", userTO.getPlainAttrMap().get("ctype").getValues().get(0));
assertEquals(3, userTO.getResources().size());
assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
assertTrue(userTO.getResources().contains(RESOURCE_NAME_WS2));
@@ -215,7 +215,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
userTO = readUser("test8");
assertNotNull(userTO);
- assertEquals("TYPE_8", userTO.getPlainAttrMap().get("type").getValues().get(0));
+ assertEquals("TYPE_8", userTO.getPlainAttrMap().get("ctype").getValues().get(0));
// Check for ignored user - SYNCOPE-663
try {
@@ -513,7 +513,7 @@ public class SyncTaskITCase extends AbstractTaskITCase {
userTO.getPlainAttrs().add(attrTO("firstname", "testuser2"));
userTO.getPlainAttrs().add(attrTO("surname", "testuser2"));
- userTO.getPlainAttrs().add(attrTO("type", "a type"));
+ 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"));
http://git-wip-us.apache.org/repos/asf/syncope/blob/915f3c32/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
index bdd0fbf..1cccb74 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/UserITCase.java
@@ -131,7 +131,7 @@ public class UserITCase extends AbstractITCase {
userTO.getPlainAttrs().add(attrTO("fullname", email));
userTO.getPlainAttrs().add(attrTO("firstname", email));
userTO.getPlainAttrs().add(attrTO("surname", "surname"));
- userTO.getPlainAttrs().add(attrTO("type", "a type"));
+ userTO.getPlainAttrs().add(attrTO("ctype", "a type"));
userTO.getPlainAttrs().add(attrTO("userId", email));
userTO.getPlainAttrs().add(attrTO("email", email));
userTO.getPlainAttrs().add(attrTO("loginDate", DATE_FORMAT.format(new Date())));
@@ -235,7 +235,7 @@ public class UserITCase extends AbstractITCase {
AttrTO type = null;
for (AttrTO attr : userTO.getPlainAttrs()) {
- if ("type".equals(attr.getSchema())) {
+ if ("ctype".equals(attr.getSchema())) {
type = attr;
}
}
@@ -440,7 +440,7 @@ public class UserITCase extends AbstractITCase {
public void createWithRequiredValueMissing() {
UserTO userTO = getUniqueSampleTO("a.b@c.it");
- AttrTO type = userTO.getPlainAttrMap().get("type");
+ AttrTO type = userTO.getPlainAttrMap().get("ctype");
userTO.getPlainAttrs().remove(type);
userTO.getMemberships().add(new MembershipTO.Builder().group(8L).build());
@@ -453,7 +453,7 @@ public class UserITCase extends AbstractITCase {
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
- userTO.getPlainAttrs().add(attrTO("type", "F"));
+ userTO.getPlainAttrs().add(attrTO("ctype", "F"));
AttrTO surname = userTO.getPlainAttrMap().get("surname");
userTO.getPlainAttrs().remove(surname);
@@ -594,14 +594,14 @@ public class UserITCase extends AbstractITCase {
UserPatch userPatch = new UserPatch();
userPatch.setKey(userTO.getKey());
userPatch.getPlainAttrs().add(new AttrPatch.Builder().operation(PatchOperation.DELETE).
- attrTO(new AttrTO.Builder().schema("type").build()).
+ attrTO(new AttrTO.Builder().schema("ctype").build()).
build());
userTO = updateUser(userPatch).getAny();
assertNotNull(userTO);
assertNotNull(userTO.getDerAttrMap());
- assertFalse(userTO.getPlainAttrMap().containsKey("type"));
+ assertFalse(userTO.getPlainAttrMap().containsKey("ctype"));
}
@Test(expected = SyncopeClientException.class)
@@ -1551,11 +1551,11 @@ public class UserITCase extends AbstractITCase {
UserPatch userPatch = new UserPatch();
userPatch.setKey(key);
- userPatch.getPlainAttrs().add(attrAddReplacePatch("type", "a type"));
+ userPatch.getPlainAttrs().add(attrAddReplacePatch("ctype", "a type"));
UserTO userTO = updateUser(userPatch).getAny();
- assertEquals("a type", userTO.getPlainAttrMap().get("type").getValues().get(0));
+ assertEquals("a type", userTO.getPlainAttrMap().get("ctype").getValues().get(0));
}
}