maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From micha...@apache.org
Subject [2/2] maven-scm git commit: [SCM-874] ScmResult output password masking does not handle multiline text
Date Sat, 17 Mar 2018 23:54:06 GMT
[SCM-874] ScmResult output password masking does not handle multiline text


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/302ccb48
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/302ccb48
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/302ccb48

Branch: refs/heads/master
Commit: 302ccb4854af613b5818c4187e5d8fd537484bf9
Parents: 609c4bd
Author: Michael Osipov <michaelo@apache.org>
Authored: Sun Mar 18 00:53:26 2018 +0100
Committer: Michael Osipov <michaelo@apache.org>
Committed: Sun Mar 18 00:53:26 2018 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/maven/scm/ScmResult.java   |  2 +-
 .../test/java/org/apache/maven/scm/ScmResultTest.java   | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-scm/blob/302ccb48/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
----------------------------------------------------------------------
diff --git a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
index ace98d9..ae1ef0e 100644
--- a/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
+++ b/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
@@ -44,7 +44,7 @@ public class ScmResult
     public static final String PASSWORD_PLACE_HOLDER = "********";
 
     //works for SVN and git
-    private Pattern patternForUserColonPasswordAtHost = Pattern.compile( "^.*:(.*)@.*$" );
+    private Pattern patternForUserColonPasswordAtHost = Pattern.compile( "^.*:(.*)@.*$",
Pattern.DOTALL );
 
     /**
      * Copy constructor.

http://git-wip-us.apache.org/repos/asf/maven-scm/blob/302ccb48/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
----------------------------------------------------------------------
diff --git a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
index 7db262e..621f4ea 100644
--- a/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
+++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java
@@ -30,14 +30,20 @@ public class ScmResultTest
 
     private static final String SCM_URL_GIT_COLON = "scm:git:https://username:" + PASSWORD
+ "@github.com/username/repo.git";
 
-    private static final String MOCK_ERROR_OUTPUT = "fatal repository " + SCM_URL_GIT_COLON
+ "does not exist";
+    private static final String MOCK_ERROR_OUTPUT = "fatal: repository '" + SCM_URL_GIT_COLON
+ "' not found";
+
+    private static final String MOCK_ERROR_MULTILINE_OUTPUT = "remote: Invalid username or
password." + System.lineSeparator() + "fatal: Authentication failed for '" + SCM_URL_GIT_COLON
+ "'";
 
     public void testPasswordsAreMaskedInOutput()
         throws Exception
     {
         ScmResult result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_OUTPUT,
false );
-        assertNotSame( "Command Output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput()
);
-        assertTrue( "Command Output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER
) );
+        assertNotSame( "Command output contains password", MOCK_ERROR_OUTPUT, result.getCommandOutput()
);
+        assertTrue( "Command output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER
) );
+
+        result = new ScmResult( "git push", "git-push failed", MOCK_ERROR_MULTILINE_OUTPUT,
false );
+        assertNotSame( "Command output contains password", MOCK_ERROR_MULTILINE_OUTPUT, result.getCommandOutput()
);
+        assertTrue( "Command output not masked", result.getCommandOutput().contains( ScmResult.PASSWORD_PLACE_HOLDER
) );
     }
 
 }


Mime
View raw message