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 2013/09/20 15:10:26 UTC

svn commit: r1524988 [2/2] - in /syncope/branches/1_1_X: common/src/main/java/org/apache/syncope/common/types/ core/src/main/java/org/apache/syncope/core/persistence/beans/ core/src/main/java/org/apache/syncope/core/persistence/beans/user/ core/src/mai...

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/persistence/dao/VirSchemaTest.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/persistence/dao/VirSchemaTest.java?rev=1524988&r1=1524987&r2=1524988&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/persistence/dao/VirSchemaTest.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/persistence/dao/VirSchemaTest.java Fri Sep 20 13:10:25 2013
@@ -22,10 +22,13 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.List;
 import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.core.persistence.beans.user.UVirSchema;
+import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
 import org.apache.syncope.core.util.AttributableUtil;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -71,4 +74,17 @@ public class VirSchemaTest extends Abstr
         UVirSchema actual = virSchemaDAO.find("virtualdata", UVirSchema.class);
         assertNull("delete did not work", actual);
     }
+
+    @Test
+    public void issueSYNCOPE418() {
+        UVirSchema schema = new UVirSchema();
+        schema.setName("http://schemas.examples.org/security/authorization/organizationUnit");
+
+        try {
+            virSchemaDAO.save(schema);
+            fail();
+        } catch (InvalidEntityException e) {
+            assertTrue(e.hasViolation(EntityViolationType.InvalidName));
+        }
+    }
 }

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java?rev=1524988&r1=1524987&r2=1524988&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ConfigurationTestITCase.java Fri Sep 20 13:10:25 2013
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -34,6 +35,10 @@ import javax.ws.rs.core.Response;
 import org.apache.commons.io.IOUtils;
 import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.common.to.ConfigurationTO;
+import org.apache.syncope.common.types.EntityViolationType;
+import org.apache.syncope.common.types.SyncopeClientExceptionType;
+import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientException;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -127,4 +132,21 @@ public class ConfigurationTestITCase ext
         assertFalse(configExport.isEmpty());
         assertTrue(configExport.length() > 1000);
     }
+
+    @Test
+    public void issueSYNCOPE418() {
+        ConfigurationTO configurationTO = new ConfigurationTO();
+        configurationTO.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
+
+        try {
+            configurationService.create(configurationTO);
+            fail();
+        } catch (SyncopeClientCompositeErrorException scce) {
+            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidSyncopeConf);
+
+            assertNotNull(sce.getElements());
+            assertEquals(1, sce.getElements().size());
+            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+        }
+    }
 }

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java?rev=1524988&r1=1524987&r2=1524988&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/DerivedSchemaTestITCase.java Fri Sep 20 13:10:25 2013
@@ -28,9 +28,11 @@ import java.util.List;
 
 import org.apache.syncope.common.to.DerivedSchemaTO;
 import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.common.types.SchemaType;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientException;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -73,8 +75,7 @@ public class DerivedSchemaTestITCase ext
 
     @Test
     public void delete() {
-        DerivedSchemaTO schema = schemaService.read(AttributableType.ROLE, SchemaType.DERIVED,
-                "rderiveddata");
+        DerivedSchemaTO schema = schemaService.read(AttributableType.ROLE, SchemaType.DERIVED, "rderiveddata");
         assertNotNull(schema);
 
         schemaService.delete(AttributableType.ROLE, SchemaType.DERIVED,
@@ -139,4 +140,22 @@ public class DerivedSchemaTestITCase ext
             assertTrue(scce.hasException(SyncopeClientExceptionType.RequiredValuesMissing));
         }
     }
+
+    @Test
+    public void issueSYNCOPE418() {
+        DerivedSchemaTO schema = new DerivedSchemaTO();
+        schema.setName("http://schemas.examples.org/security/authorization/organizationUnit");
+        schema.setExpression("derived_sx + '_' + derived_dx");
+
+        try {
+            createSchema(AttributableType.ROLE, SchemaType.DERIVED, schema);
+            fail();
+        } catch (SyncopeClientCompositeErrorException scce) {
+            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRDerSchema);
+
+            assertNotNull(sce.getElements());
+            assertEquals(1, sce.getElements().size());
+            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+        }
+    }
 }

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1524988&r1=1524987&r2=1524988&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java Fri Sep 20 13:10:25 2013
@@ -18,12 +18,12 @@
  */
 package org.apache.syncope.core.rest;
 
-import static org.apache.syncope.core.rest.AbstractTest.getUUIDString;
-import static org.junit.Assert.*;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.util.Arrays;
 import java.util.Collection;
@@ -41,6 +41,7 @@ import org.apache.syncope.common.to.Prop
 import org.apache.syncope.common.to.ResourceTO;
 import org.apache.syncope.common.types.ConnConfPropSchema;
 import org.apache.syncope.common.types.ConnConfProperty;
+import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.MappingPurpose;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
@@ -481,13 +482,28 @@ public class ResourceTestITCase extends 
         mapping.addItem(item);
 
         resourceTO.setRmapping(mapping);
-        
+
         resourceTO = createResource(resourceTO);
         assertNotNull(resourceTO);
         assertEquals(2, resourceTO.getRmapping().getItems().size());
     }
 
-    private ResourceTO buildResourceTO(String resourceName) {
+    @Test
+    public void issueSYNCOPE418() {
+        try {
+            resourceService.create(
+                    buildResourceTO("http://schemas.examples.org/security/authorization/organizationUnit"));
+            fail();
+        } catch (SyncopeClientCompositeErrorException scce) {
+            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidExternalResource);
+
+            assertNotNull(sce.getElements());
+            assertEquals(1, sce.getElements().size());
+            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+        }
+    }
+
+    private ResourceTO buildResourceTO(final String resourceName) {
         ResourceTO resourceTO = new ResourceTO();
 
         resourceTO.setName(resourceName);

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java?rev=1524988&r1=1524987&r2=1524988&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java Fri Sep 20 13:10:25 2013
@@ -74,7 +74,7 @@ public class SchemaTestITCase extends Ab
 
             assertNotNull(sce.getElements());
             assertEquals(1, sce.getElements().size());
-            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidUSchema.name()));
+            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
         }
     }
 
@@ -93,7 +93,7 @@ public class SchemaTestITCase extends Ab
             assertNotNull(sce.getElements());
             assertEquals(1, sce.getElements().size());
             assertTrue(sce.getElements().iterator().next()
-                    .contains(EntityViolationType.InvalidSchemaTypeSpecification.name()));
+                    .contains(EntityViolationType.InvalidSchemaEnum.name()));
         }
     }
 
@@ -112,7 +112,7 @@ public class SchemaTestITCase extends Ab
             assertNotNull(sce.getElements());
             assertEquals(1, sce.getElements().size());
             assertTrue(sce.getElements().iterator().next()
-                    .contains(EntityViolationType.InvalidSchemaTypeSpecification.name()));
+                    .contains(EntityViolationType.InvalidSchemaEnum.name()));
         }
     }
 
@@ -269,6 +269,23 @@ public class SchemaTestITCase extends Ab
         }
     }
 
+    @Test
+    public void issueSYNCOPE418() {
+        SchemaTO schema = buildSchemaTO("http://schemas.examples.org/security/authorization/organizationUnit",
+                AttributeSchemaType.Double);
+
+        try {
+            createSchema(AttributableType.ROLE, SchemaType.NORMAL, schema);
+            fail();
+        } catch (SyncopeClientCompositeErrorException scce) {
+            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidRSchema);
+
+            assertNotNull(sce.getElements());
+            assertEquals(1, sce.getElements().size());
+            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+        }
+    }
+
     private SchemaTO buildSchemaTO(final String name, final AttributeSchemaType type) {
         SchemaTO schemaTO = new SchemaTO();
         schemaTO.setName(name + getUUIDString());

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java?rev=1524988&r1=1524987&r2=1524988&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/VirtualSchemaTestITCase.java Fri Sep 20 13:10:25 2013
@@ -28,9 +28,11 @@ import java.util.List;
 
 import org.apache.syncope.common.to.VirtualSchemaTO;
 import org.apache.syncope.common.types.AttributableType;
+import org.apache.syncope.common.types.EntityViolationType;
 import org.apache.syncope.common.types.SchemaType;
 import org.apache.syncope.common.types.SyncopeClientExceptionType;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
+import org.apache.syncope.common.validation.SyncopeClientException;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
@@ -110,4 +112,21 @@ public class VirtualSchemaTestITCase ext
             assertTrue(scce.hasException(SyncopeClientExceptionType.RequiredValuesMissing));
         }
     }
+
+    @Test
+    public void issueSYNCOPE418() {
+        VirtualSchemaTO schema = new VirtualSchemaTO();
+        schema.setName("http://schemas.examples.org/security/authorization/organizationUnit");
+
+        try {
+            createSchema(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL, schema);
+            fail();
+        } catch (SyncopeClientCompositeErrorException scce) {
+            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.InvalidMVirSchema);
+
+            assertNotNull(sce.getElements());
+            assertEquals(1, sce.getElements().size());
+            assertTrue(sce.getElements().iterator().next().contains(EntityViolationType.InvalidName.name()));
+        }
+    }
 }