Simple test for SCM-811 ensures ouptut is masked
Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/9d009e8f Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/9d009e8f Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/9d009e8f Branch: refs/heads/master Commit: 9d009e8f14c0dff99c377b8991bdd59b519f0d33 Parents: 8785b85 Author: EDWARD WEBB <edward.w...@libertymutual.com> Authored: Sat Feb 6 10:15:41 2016 -0500 Committer: EDWARD WEBB <edward.w...@libertymutual.com> Committed: Sat Feb 6 10:15:41 2016 -0500 ---------------------------------------------------------------------- .../org/apache/maven/scm/ScmResultTest.java | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-scm/blob/9d009e8f/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 new file mode 100644 index 0000000..d27fc62 --- /dev/null +++ b/maven-scm-api/src/test/java/org/apache/maven/scm/ScmResultTest.java @@ -0,0 +1,47 @@ +package org.apache.maven.scm; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; +import org.apache.maven.scm.provider.ScmUrlUtils; + +/** + * @author <a href="mailto:denn...@apache.org">Dennis Lundberg</a> + * + */ +public class ScmResultTest + extends TestCase +{ + + private static final String PASSWORD = "secr$t"; + + 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"; + + 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 ) ); + } + +}