continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r915748 - in /continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/ main/java/org/apache/maven/continuum/core/action/ test/java/org/apache/maven/continuum/ test/resources/org/apache/maven/continuum/
Date Wed, 24 Feb 2010 10:56:15 GMT
Author: oching
Date: Wed Feb 24 10:56:15 2010
New Revision: 915748

URL: http://svn.apache.org/viewvc?rev=915748&view=rev
Log:
[CONTINUUM-2466] authorization failed when building ant / shell projects
merge from 1.3.x branch -r915747

Added:
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectToCheckoutQueueStub.java
      - copied unchanged from r915747, continuum/branches/continuum-1.3.x/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectToCheckoutQueueStub.java
Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
    continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/AddProjectTest.xml

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=915748&r1=915747&r2=915748&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Wed Feb 24 10:56:15 2010
@@ -1454,6 +1454,22 @@
         AbstractContinuumAction.setUnvalidatedProjectGroup( context, projectGroup );
 
         AbstractContinuumAction.setProjectGroupId( context, projectGroup.getId() );
+        
+        StoreProjectAction.setUseScmCredentialsCache( context, project.isScmUseCache() );
+        
+        // set for initial checkout
+        String scmUsername = project.getScmUsername();
+        String scmPassword = project.getScmPassword();
+        
+        if( scmUsername != null && !StringUtils.isEmpty( scmUsername ) )
+        {
+            CheckoutProjectContinuumAction.setScmUsername( context, scmUsername );
+        }
+        
+        if( scmPassword != null && !StringUtils.isEmpty( scmPassword ) )
+        {
+            CheckoutProjectContinuumAction.setScmPassword( context, scmPassword );
+        }
 
         executeAction( "validate-project", context );
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java?rev=915748&r1=915747&r2=915748&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
Wed Feb 24 10:56:15 2010
@@ -21,6 +21,7 @@
 
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -61,10 +62,22 @@
             project = projectDao.getProject( getProjectId( context ) );
         }
 
+        String scmUsername = project.getScmUsername();
+        String scmPassword = project.getScmPassword();
+        
+        if( scmUsername == null || StringUtils.isEmpty( scmUsername ) )
+        {
+            scmUsername = CheckoutProjectContinuumAction.getScmUsername( context, null );
+        }
+        
+        if( scmPassword == null || StringUtils.isEmpty( scmPassword ) )
+        {
+            scmPassword = CheckoutProjectContinuumAction.getScmPassword( context, null );
+        }
+        
         BuildDefinition defaultBuildDefinition = getBuildDefinition( context );
         parallelBuildsManager.checkoutProject( project.getId(), project.getName(),
                                                workingDirectoryService.getWorkingDirectory(
project ),
-                                               project.getScmUsername(), project.getScmPassword(),
-                                               defaultBuildDefinition );
+                                               scmUsername, scmPassword, defaultBuildDefinition
);
     }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java?rev=915748&r1=915747&r2=915748&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
Wed Feb 24 10:56:15 2010
@@ -56,11 +56,11 @@
 
         boolean useCredentialsCache = isUseScmCredentialsCache( context, false );
         // CONTINUUM-1605 don't store username/password
-        if ( !useCredentialsCache )
+        if ( useCredentialsCache )
         {
             project.setScmUsername( null );
             project.setScmPassword( null );
-            project.setScmUseCache( false );
+            project.setScmUseCache( true );
         }
 
         projectGroup.addProject( project );

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java?rev=915748&r1=915747&r2=915748&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AddProjectTest.java
Wed Feb 24 10:56:15 2010
@@ -18,6 +18,8 @@
  */
 package org.apache.maven.continuum;
 
+import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.project.builder.maven.MavenTwoContinuumProjectBuilder;
@@ -30,6 +32,10 @@
 public class AddProjectTest
     extends AbstractContinuumTest
 {
+    static final String SCM_USERNAME = "test";
+    
+    static final String SCM_PASSWORD = ";password";
+    
     public void testScmUserNamePasswordNotStoring()
         throws Exception
     {
@@ -61,8 +67,67 @@
 
         // read the project from store
         Project project = continuum.getProject( result.getProjects().get( 0 ).getId() );
-        assertEquals( "test", project.getScmUsername() );
-        assertEquals( ";password", project.getScmPassword() );
+        assertEquals( SCM_USERNAME, project.getScmUsername() );
+        assertEquals( SCM_PASSWORD, project.getScmPassword() );
         assertFalse( project.isScmUseCache() );
     }    
+    
+    public void testAntProjectScmUserNamePasswordNotStoring()
+        throws Exception
+    {
+        // use same url since we're just going to add the project, not build it
+        String scmUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
+        DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
+        
+        Project project = new Project();
+        project.setName( "Sample Ant Project" );
+        project.setVersion( "1.0" );
+        project.setScmUsername( SCM_USERNAME );
+        project.setScmPassword( SCM_PASSWORD );
+        project.setScmUrl( scmUrl );        
+        project.setScmUseCache( true );
+        
+        BuildDefinitionService bdService = ( BuildDefinitionService )lookup( BuildDefinitionService.class.getName()
);
+        
+        int projectId =
+            continuum.addProject( project, ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR,
+                                  getDefaultProjectGroup().getId(),
+                                  bdService.getDefaultAntBuildDefinitionTemplate().getId()
);
+                
+        // read the project from store
+        Project retrievedProject = continuum.getProject( projectId );
+        assertNull(  retrievedProject.getScmUsername() );
+        assertNull( retrievedProject.getScmPassword() );
+        assertTrue( retrievedProject.isScmUseCache() );
+    }
+    
+    public void testAntProjectScmUserNamePasswordStoring()
+        throws Exception
+    {
+        // use same url since we're just going to add the project, not build it
+        String scmUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
+        DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
+        
+        Project project = new Project();
+        project.setName( "Sample Ant Project" );
+        project.setVersion( "1.0" );
+        project.setScmUsername( SCM_USERNAME );
+        project.setScmPassword( SCM_PASSWORD );
+        project.setScmUrl( scmUrl );        
+        project.setScmUseCache( false );
+        
+        BuildDefinitionService bdService = ( BuildDefinitionService )lookup( BuildDefinitionService.class.getName()
);
+        
+        int projectId =
+            continuum.addProject( project, ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR,
+                                  getDefaultProjectGroup().getId(),
+                                  bdService.getDefaultAntBuildDefinitionTemplate().getId()
);
+               
+        // read the project from store
+        Project retrievedProject = continuum.getProject( projectId );
+        assertEquals( SCM_USERNAME, retrievedProject.getScmUsername() );
+        assertEquals( SCM_PASSWORD, retrievedProject.getScmPassword() );
+        assertFalse( retrievedProject.isScmUseCache() );
+    }
+    
 }

Modified: continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/AddProjectTest.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/AddProjectTest.xml?rev=915748&r1=915747&r2=915748&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/AddProjectTest.xml
(original)
+++ continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/AddProjectTest.xml
Wed Feb 24 10:56:15 2010
@@ -24,5 +24,10 @@
       <role-hint>continuumUrl</role-hint>
       <implementation>org.apache.maven.continuum.utils.ContinuumUrlValidator</implementation>
     </component>
+    <component>
+      <role>org.codehaus.plexus.action.Action</role>
+      <role-hint>add-project-to-checkout-queue</role-hint>
+      <implementation>org.apache.maven.continuum.AddProjectToCheckoutQueueStub</implementation>
+    </component>
   </components>
 </plexus>



Mime
View raw message