maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r723478 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/command/login/ test/java/org/apache/maven/scm/provider/perforce/command/login/
Date Thu, 04 Dec 2008 22:49:48 GMT
Author: carlos
Date: Thu Dec  4 14:49:48 2008
New Revision: 723478

URL: http://svn.apache.org/viewvc?rev=723478&view=rev
Log:
[SCM-415] Perforce scm requires password breaking Perforce setup for external authentication

Submitted By: ajbanck, Peter Janes

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommandTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java?rev=723478&r1=723477&r2=723478&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommand.java
Thu Dec  4 14:49:48 2008
@@ -51,27 +51,34 @@
     {
         Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir()
);
         PerforceLoginConsumer consumer = new PerforceLoginConsumer();
+        boolean isSuccess = false;
 
         try
         {
             String password = repo.getPassword();
             if ( StringUtils.isEmpty( password ) )
             {
-                throw new ScmException( "password is required for the perforce scm plugin."
);
+                if ( getLogger().isInfoEnabled() )
+                {
+                    getLogger().info( "No password found, proceeding without it." );
+                }
+                isSuccess = true;
             }
+            else {
+                CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+                int exitCode = CommandLineUtils.executeCommandLine( cl, new StringBufferInputStream(password),
consumer, err );
+                isSuccess = consumer.isSuccess();
+
+                if ( isSuccess )
+                {
+                    String cmdLine = CommandLineUtils.toString( cl.getCommandline() );
+
+                    StringBuffer msg = new StringBuffer( "Exit code: " + exitCode + " - "
+ err.getOutput() );
+                    msg.append( '\n' );
+                    msg.append( "Command line was:" + cmdLine );
 
-            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
-            int exitCode = CommandLineUtils.executeCommandLine( cl, new StringBufferInputStream(password),
consumer, err );
-
-            if ( exitCode != 0 )
-            {
-                String cmdLine = CommandLineUtils.toString( cl.getCommandline() );
-
-                StringBuffer msg = new StringBuffer( "Exit code: " + exitCode + " - " + err.getOutput()
);
-                msg.append( '\n' );
-                msg.append( "Command line was:" + cmdLine );
-
-                throw new CommandLineException( msg.toString() );
+                    throw new CommandLineException( msg.toString() );
+                }
             }
         }
         catch ( CommandLineException e )
@@ -79,8 +86,8 @@
             throw new ScmException( "", e );
         }
 
-        return new LoginScmResult( cl.toString(), consumer.isSuccess() ? "Login successful"
: "Login failed",
-                        consumer.getOutput(), consumer.isSuccess() );
+        return new LoginScmResult( cl.toString(), isSuccess ? "Login successful" : "Login
failed",
+                        consumer.getOutput(), isSuccess );
     }
 
     public static Commandline createCommandLine( PerforceScmProviderRepository repo, File
workingDir )

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommandTest.java?rev=723478&r1=723477&r2=723478&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommandTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/login/PerforceLoginCommandTest.java
Thu Dec  4 14:49:48 2008
@@ -19,7 +19,10 @@
  * under the License.
  */
 
+import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -44,6 +47,26 @@
         testCommandLine( cmdPrefix + " login" );
     }
 
+    /**
+     * This test requires P4 installed
+     * 
+     * @throws Exception
+     */
+    public void disabledTestLoginWithoutPassword()
+        throws Exception
+    {
+        ScmRepository repository = getScmManager().makeScmRepository( "scm:perforce://depot/projects/pathname"
);
+        PerforceScmProviderRepository scmRepository =
+            (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet fileSet = new ScmFileSet( new File( "." ) );
+
+        PerforceLoginCommand command = new PerforceLoginCommand();
+        ScmLogger logger = new DefaultLog();
+        command.setLogger( logger );
+
+        command.executeLoginCommand( scmRepository, fileSet, null );
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -52,10 +75,10 @@
         throws Exception
     {
         ScmRepository repository = getScmManager().makeScmRepository( "scm:perforce://depot/projects/pathname"
);
-        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository
+        PerforceScmProviderRepository scmRepository = (PerforceScmProviderRepository) repository
             .getProviderRepository();
         //CommandParameters params = new CommandParameters();
-        Commandline cl = PerforceLoginCommand.createCommandLine( svnRepository, workingDirectory
);
+        Commandline cl = PerforceLoginCommand.createCommandLine( scmRepository, workingDirectory
);
 
         assertCommandLine( commandLine, null, cl );
     }



Mime
View raw message