continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1412367 - in /continuum/trunk: continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apach...
Date Wed, 21 Nov 2012 23:59:22 GMT
Author: brett
Date: Wed Nov 21 23:59:20 2012
New Revision: 1412367

URL: http://svn.apache.org/viewvc?rev=1412367&view=rev
Log:
[CONTINUUM-2620] adjust validation to allow commonly used punctuation

Modified:
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectGroupAction-addProjectGroup-validation.xml
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ProjectGroupAction-saveProjectGroup-validation.xml
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java?rev=1412367&r1=1412366&r2=1412367&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java
Wed Nov 21 23:59:20 2012
@@ -74,6 +74,26 @@ public class ProjectGroupTest
         assertTextPresent( "Id contains invalid characters." );
     }
 
+    public void testAddProjectGroupWithDashedGroupId()
+        throws Exception
+    {
+        String name = "Test Project Group with Dashes";
+        String groupId = "com.example.this-is-a-long-group-id";
+        String description = "";
+
+        addProjectGroup( name, groupId, description, true );
+    }
+
+    public void testAddProjectGroupWithPunctuation()
+        throws Exception
+    {
+        String name = "Test :: Test Project Group (with Punctuation)";
+        String groupId = "com.example.test";
+        String description = "";
+
+        addProjectGroup( name, groupId, description, true );
+    }
+
     public void testAddProjectGroupWithEmptyString()
         throws Exception
     {
@@ -94,7 +114,7 @@ public class ProjectGroupTest
     public void testEditProjectGroupWithValidValues()
         throws Exception
     {
-        final String newName = "New Project Group Name";
+        final String newName = "Test :: New Project Group Name (with valid values)";
         final String newDescription = "New Project Group Description";
 
         editProjectGroup( projectGroupName, projectGroupId, projectGroupDescription, newName,
newDescription );

Modified: continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectGroupAction-addProjectGroup-validation.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectGroupAction-addProjectGroup-validation.xml?rev=1412367&r1=1412366&r2=1412367&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectGroupAction-addProjectGroup-validation.xml
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectGroupAction-addProjectGroup-validation.xml
Wed Nov 21 23:59:20 2012
@@ -27,7 +27,7 @@
       <message key="addProjectGroup.name.required"/>
     </field-validator>
     <field-validator type="regex">
-      <param name="expression"><![CDATA[[A-Za-z0-9_.\s\-]*]]></param>
+      <param name="expression"><![CDATA[[A-Za-z0-9_.\s\-():]*]]></param>
       <message key="addProjectGroup.name.invalid"/>
     </field-validator>
   </field>
@@ -36,7 +36,7 @@
       <message key="addProjectGroup.groupId.required"/>
     </field-validator>
     <field-validator type="regex">
-      <param name="expression"><![CDATA[[a-zA-Z0-9_.\s]*]]></param>
+      <param name="expression"><![CDATA[[a-zA-Z0-9_.\s\-]*]]></param>
       <message key="addProjectGroup.groupId.invalid"/>
     </field-validator>
   </field>

Modified: continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ProjectGroupAction-saveProjectGroup-validation.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ProjectGroupAction-saveProjectGroup-validation.xml?rev=1412367&r1=1412366&r2=1412367&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ProjectGroupAction-saveProjectGroup-validation.xml
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/ProjectGroupAction-saveProjectGroup-validation.xml
Wed Nov 21 23:59:20 2012
@@ -27,7 +27,7 @@
       <message key="projectGroup.name.required"/>
     </field-validator>
     <field-validator type="regex">
-      <param name="expression"><![CDATA[[A-Za-z0-9_.\s\-]*]]></param>
+      <param name="expression"><![CDATA[[A-Za-z0-9_.\s\-():]*]]></param>
       <message key="projectGroup.name.invalid"/>
     </field-validator>
   </field>

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?rev=1412367&r1=1412366&r2=1412367&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Wed Nov 21 23:59:20 2012
@@ -98,7 +98,7 @@ import java.util.Set;
 public class ContinuumServiceImpl
     extends AbstractContinuumSecureService
 {
-    private static final String NAME_VALID_EXPRESSION = "[a-zA-Z0-9_.\\s\\-]*";
+    private static final String NAME_VALID_EXPRESSION = "[A-Za-z0-9_.\\s\\-():]*";
 
     private static final String DIRECTORY_VALID_EXPRESSION = "[A-Za-z0-9_/\\s:.\\\\-]*";
 
@@ -116,7 +116,7 @@ public class ContinuumServiceImpl
 
     private static final String SCHEDULE_CRON_VALID_EXPRESSION = "[A-Z0-9\\s*/,-?#]*";
 
-    private static final String PROJECTGROUP_ID_VALID_EXPRESSION = "[a-zA-Z0-9_.\\s]*";
+    private static final String PROJECTGROUP_ID_VALID_EXPRESSION = "[a-zA-Z0-9_.\\s\\-]*";
 
     private static final String REPOSITORY_LAYOUT_VALID_EXPRESSION = "default|legacy";
 
@@ -3342,8 +3342,7 @@ public class ContinuumServiceImpl
         throws Exception
     {
         return serializeObject( this.addBuildDefinitionToProjectGroup( projectGroupId,
-                                                                       (BuildDefinition)
unserializeObject(
-                                                                           buildDef ) ) );
+                                                                       (BuildDefinition)
unserializeObject( buildDef ) ) );
     }
 
     public Map<String, Object> addBuildDefinitionToProjectRPC( int projectId, Map<String,
Object> buildDef )
@@ -4156,4 +4155,9 @@ public class ContinuumServiceImpl
     {
         this.distributedBuildManager = distributedBuildManager;
     }
+
+    public void setRoleManager( RoleManager roleManager )
+    {
+        this.roleManager = roleManager;
+    }
 }

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java?rev=1412367&r1=1412366&r2=1412367&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplStub.java
Wed Nov 21 23:59:20 2012
@@ -24,20 +24,16 @@ import org.apache.maven.continuum.Contin
 import org.apache.maven.continuum.profile.ProfileException;
 import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
 import org.apache.maven.continuum.xmlrpc.server.ContinuumServiceImpl;
+import org.codehaus.plexus.redback.authorization.AuthorizationException;
 
 public class ContinuumServiceImplStub
     extends ContinuumServiceImpl
 {
-    protected void checkBuildProjectInGroupAuthorization( String resource )
-        throws ContinuumException
-    {
-        // do nothing
-    }
-
-    protected void checkViewProjectGroupAuthorization( String resource )
-        throws ContinuumException
+    @Override
+    protected boolean isAuthorized( String role, String resource, boolean requiredResource
)
+        throws AuthorizationException
     {
-        // do nothing
+        return true;
     }
 
     protected void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId,
BuildTrigger buildTrigger )
@@ -47,7 +43,7 @@ public class ContinuumServiceImplStub
 
     public org.apache.maven.continuum.model.project.BuildDefinition getBuildDefinition( BuildDefinition
buildDef,
                                                                                         org.apache.maven.continuum.model.project.BuildDefinition
buildDefinition )
-        throws ProfileException, ContinuumException
+        throws ContinuumException
     {
         return populateBuildDefinition( buildDef, buildDefinition );
     }

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java?rev=1412367&r1=1412366&r2=1412367&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/test/java/org/apache/continuum/xmlrpc/server/ContinuumServiceImplTest.java
Wed Nov 21 23:59:20 2012
@@ -33,8 +33,10 @@ import org.apache.maven.continuum.releas
 import org.apache.maven.continuum.xmlrpc.project.BuildAgentConfiguration;
 import org.apache.maven.continuum.xmlrpc.project.BuildDefinition;
 import org.apache.maven.continuum.xmlrpc.project.ContinuumProjectState;
+import org.apache.maven.continuum.xmlrpc.project.ProjectGroupSummary;
 import org.apache.maven.continuum.xmlrpc.project.ReleaseListenerSummary;
 import org.apache.maven.continuum.xmlrpc.server.ContinuumServiceImpl;
+import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -68,6 +70,8 @@ public class ContinuumServiceImplTest
 
     private Map<String, Object> params;
 
+    private RoleManager roleManager;
+
     @Override
     public void setUp()
         throws Exception
@@ -81,11 +85,13 @@ public class ContinuumServiceImplTest
         releaseManager = context.mock( ContinuumReleaseManager.class );
         configurationService = context.mock( ConfigurationService.class );
         distributedBuildManager = context.mock( DistributedBuildManager.class );
+        roleManager = context.mock( RoleManager.class );
 
         continuumService = new ContinuumServiceImplStub();
         continuum = context.mock( Continuum.class );
         continuumService.setContinuum( continuum );
         continuumService.setDistributedBuildManager( distributedBuildManager );
+        continuumService.setRoleManager( roleManager );
 
         ProjectGroup projectGroup = new ProjectGroup();
         projectGroup.setName( "test-group" );
@@ -329,12 +335,12 @@ public class ContinuumServiceImplTest
 
         try
         {
-            String buildAgentUrl = continuumService.getBuildAgentUrl( 1, 1 );
+            continuumService.getBuildAgentUrl( 1, 1 );
             fail( "ContinuumException is expected to occur here." );
         }
         catch ( ContinuumException e )
         {
-            ; //pass
+            //pass
         }
         context.assertIsSatisfied();
     }
@@ -435,6 +441,104 @@ public class ContinuumServiceImplTest
         context.assertIsSatisfied();
     }
 
+    public void testAddProjectGroupWithPunctuation()
+        throws Exception
+    {
+        final String name = "Test :: Group Name (with punctuation)";
+        final String groupId = "com.example.long-group-id";
+        final String description = "Description";
+
+        context.checking( new Expectations()
+        {
+            {
+                ProjectGroup group = createProjectGroup( name, groupId, description );
+                one( continuum ).addProjectGroup( group );
+
+                group = createProjectGroup( name, groupId, description );
+                one( continuum ).getProjectGroupByGroupId( groupId );
+                will( returnValue( group ) );
+//
+//                one( continuum ).getProjectGroup( projectGroupId );
+//                will( returnValue( group ) );
+            }
+        } );
+
+        ProjectGroupSummary group = continuumService.addProjectGroup( name, groupId, description
);
+        assertEquals( name, group.getName() );
+        assertEquals( groupId, group.getGroupId() );
+        assertEquals( description, group.getDescription() );
+
+        context.assertIsSatisfied();
+    }
+
+    public void testEditProjectGroupWithPunctuation()
+        throws Exception
+    {
+        final String newName = "Test :: Group Name (with punctuation)";
+        final String newGroupId = "com.example.long-group-id";
+        final String newDescription = "Description";
+        final int projectGroupId = 1;
+
+        context.checking( new Expectations()
+        {
+            {
+                ProjectGroup group = createProjectGroup( "name", "groupId", "description"
);
+
+                one( continuum ).addProjectGroup( group );
+
+                group = createProjectGroup( projectGroupId );
+                one( continuum ).getProjectGroupByGroupId( "groupId" );
+                will( returnValue( group ) );
+
+                one( continuum ).getProjectGroupWithProjects( projectGroupId );
+                will( returnValue( group ) );
+
+                for ( String role : Arrays.asList( "project-administrator", "project-developer",
"project-user" ) )
+                {
+                    one( roleManager ).updateRole( role, "name", newName );
+                }
+
+                ProjectGroup newProjectGroup = createProjectGroup( projectGroupId, newName,
newGroupId,
+                                                                   newDescription );
+                one( continuum ).updateProjectGroup( newProjectGroup );
+
+                exactly( 3 ).of( continuum ).getProjectGroup( projectGroupId );
+                onConsecutiveCalls( returnValue( group ), returnValue( group ), returnValue(
newProjectGroup ) );
+            }
+        } );
+
+        ProjectGroupSummary group = continuumService.addProjectGroup( "name", "groupId",
"description" );
+        group.setName( newName );
+        group.setGroupId( newGroupId );
+        group.setDescription( newDescription );
+
+        continuumService.updateProjectGroup( group );
+
+        context.assertIsSatisfied();
+    }
+
+    private static ProjectGroup createProjectGroup( String name, String groupId, String description
)
+    {
+        ProjectGroup group = new ProjectGroup();
+        group.setName( name );
+        group.setGroupId( groupId );
+        group.setDescription( description );
+        return group;
+    }
+
+    private static ProjectGroup createProjectGroup( int projectGroupId, String name, String
groupId,
+                                                    String description )
+    {
+        ProjectGroup group = createProjectGroup( name, groupId, description );
+        group.setId( projectGroupId );
+        return group;
+    }
+
+    private static ProjectGroup createProjectGroup( int projectGroupId )
+    {
+        return createProjectGroup( projectGroupId, "name", "groupId", "description" );
+    }
+
     private BuildDefinition createBuildDefinition()
     {
         BuildDefinition buildDef = new BuildDefinition();
@@ -462,8 +566,6 @@ public class ContinuumServiceImplTest
     public class ProjectGroupStub
         extends ProjectGroup
     {
-        private static final long serialVersionUID = 1L;
-
         @Override
         public List<Project> getProjects()
         {



Mime
View raw message