Author: evenisse
Date: Thu Mar 22 13:46:37 2007
New Revision: 521451

URL: http://svn.apache.org/viewvc?view=rev&rev=521451
Log:
[SCM-263] Allow user:password in svn URLs

Modified:
    
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
    
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java

Modified: 
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
URL: 
http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java?view=diff&rev=521451&r1=521450&r2=521451
==============================================================================
--- 
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
 (original)
+++ 
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepository.java
 Thu Mar 22 13:46:37 2007
@@ -163,7 +163,16 @@
 
         if ( indexAt > 0 && !getProtocol().startsWith( "svn+" ) )
         {
-            setUser( urlPath.substring( 0, indexAt ) );
+            String userPassword = urlPath.substring( 0, indexAt );
+            if ( userPassword.indexOf( ":" ) < 0 )
+            {
+                setUser( userPassword );
+            }
+            else
+            {
+                setUser( userPassword.substring( 0, userPassword.indexOf( ":" 
) ) );
+                setPassword( userPassword.substring( userPassword.indexOf( ":" 
) + 1 ) );
+            }
 
             urlPath = urlPath.substring( indexAt + 1 );
 

Modified: 
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
URL: 
http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java?view=diff&rev=521451&r1=521450&r2=521451
==============================================================================
--- 
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
 (original)
+++ 
maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
 Thu Mar 22 13:46:37 2007
@@ -48,46 +48,82 @@
     public void testLegalFileURL()
         throws Exception
     {
-        testUrl( "scm:svn:file:///tmp/repo", "file:///tmp/repo", null, null );
+        testUrl( "scm:svn:file:///tmp/repo", "file:///tmp/repo", null, null, 
null );
     }
 
     public void testLegalLocalhostFileURL()
         throws Exception
     {
-        testUrl( "scm:svn:file://localhost/tmp/repo", 
"file://localhost/tmp/repo", null, null );
+        testUrl( "scm:svn:file://localhost/tmp/repo", 
"file://localhost/tmp/repo", null, null, null );
     }
 
     public void testLegalHttpURL()
         throws Exception
     {
-        testUrl( "scm:svn:http://subversion.tigris.org";, 
"http://subversion.tigris.org";, null,
+        testUrl( "scm:svn:http://subversion.tigris.org";, 
"http://subversion.tigris.org";, null, null,
                  "subversion.tigris.org" );
     }
 
+    public void testLegalHttpURLWithUser()
+        throws Exception
+    {
+        testUrl( "scm:svn:http://[EMAIL PROTECTED]", 
"http://subversion.tigris.org";, "user", null,
+                 "subversion.tigris.org" );
+    }
+
+    public void testLegalHttpURLWithUserPassword()
+        throws Exception
+    {
+        testUrl( "scm:svn:http://user:[EMAIL PROTECTED]", 
"http://subversion.tigris.org";, "user",
+                 "password", "subversion.tigris.org" );
+    }
+
     public void testLegalHttpsURL()
         throws Exception
     {
-        testUrl( "scm:svn:https://subversion.tigris.org";, 
"https://subversion.tigris.org";, null,
+        testUrl( "scm:svn:https://subversion.tigris.org";, 
"https://subversion.tigris.org";, null, null,
                  "subversion.tigris.org" );
     }
 
+    public void testLegalHttpsURLWithUser()
+        throws Exception
+    {
+        testUrl( "scm:svn:https://[EMAIL PROTECTED]", 
"https://subversion.tigris.org";, "user", null,
+                 "subversion.tigris.org" );
+    }
+
+    public void testLegalHttpsURLWithUserPassword()
+        throws Exception
+    {
+        testUrl( "scm:svn:https://user:[EMAIL PROTECTED]", 
"https://subversion.tigris.org";, "user",
+                 "password", "subversion.tigris.org" );
+    }
+
     public void testLegalSvnURL()
         throws Exception
     {
-        testUrl( "scm:svn:svn://subversion.tigris.org", 
"svn://subversion.tigris.org", null, "subversion.tigris.org" );
+        testUrl( "scm:svn:svn://subversion.tigris.org", 
"svn://subversion.tigris.org", null, null,
+                 "subversion.tigris.org" );
     }
 
     public void testLegalSvnPlusUsernameURL()
         throws Exception
     {
-        testUrl( "scm:svn:svn://[EMAIL PROTECTED]", 
"svn://subversion.tigris.org", "username",
+        testUrl( "scm:svn:svn://[EMAIL PROTECTED]", 
"svn://subversion.tigris.org", "username", null,
                  "subversion.tigris.org" );
     }
 
+    public void testLegalSvnPlusUsernamePasswordURL()
+        throws Exception
+    {
+        testUrl( "scm:svn:svn://username:[EMAIL PROTECTED]", 
"svn://subversion.tigris.org", "username",
+                 "password", "subversion.tigris.org" );
+    }
+
     public void testLegalSvnPlusSshURL()
         throws Exception
     {
-        testUrl( "scm:svn:svn+ssh://subversion.tigris.org", 
"svn+ssh://subversion.tigris.org", null,
+        testUrl( "scm:svn:svn+ssh://subversion.tigris.org", 
"svn+ssh://subversion.tigris.org", null, null,
                  "subversion.tigris.org" );
     }
 
@@ -103,7 +139,7 @@
         throws Exception
     {
         testUrl( "scm:svn:svn+ssh://[EMAIL PROTECTED]", "svn+ssh://[EMAIL 
PROTECTED]", null,
-                 "[EMAIL PROTECTED]" );
+                 null, "[EMAIL PROTECTED]" );
     }
 
     /* This test require a specific subversion config file
@@ -142,7 +178,8 @@
     //
     // ----------------------------------------------------------------------
 
-    private void testUrl( String scmUrl, String expectedUrl, String 
expectedUser, String expectedHost )
+    private void testUrl( String scmUrl, String expectedUrl, String 
expectedUser, String expectedPassword,
+                          String expectedHost )
         throws Exception
     {
         ScmRepository repository = scmManager.makeScmRepository( scmUrl );
@@ -162,6 +199,8 @@
 
         assertEquals( "User is incorrect", expectedUser, 
providerRepository.getUser() );
 
+        assertEquals( "Password is incorrect", expectedPassword, 
providerRepository.getPassword() );
+
         assertEquals( "Host is incorrect", expectedHost,
                       ( (SvnScmProviderRepository) 
repository.getProviderRepository() ).getHost() );
     }
@@ -170,7 +209,14 @@
                           int expectedPort )
         throws Exception
     {
-        testUrl( scmUrl, expectedUrl, expectedUser, expectedHost );
+        testUrl( scmUrl, expectedUrl, expectedUser, null, expectedHost );
+    }
+
+    private void testUrl( String scmUrl, String expectedUrl, String 
expectedUser, String expectedPassword,
+                          String expectedHost, int expectedPort )
+        throws Exception
+    {
+        testUrl( scmUrl, expectedUrl, expectedUser, expectedPassword, 
expectedHost );
 
         ScmRepository repository = scmManager.makeScmRepository( scmUrl );
 


Reply via email to