# HG changeset patch # User Dmitry Neverov # Date 1357838694 -14400 # Node ID b58a75b12b7b894aecb1ddfe1477fc68b9498120 # Parent a827c3756535f0583da63e34237f8f9a426d9fad# Parent 81fa236998d41230ded69cac70c428352f5e81f5 Merge branch Faradi-7.1.x diff -r a827c3756535 -r b58a75b12b7b mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactory.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactory.java Sat Dec 29 18:35:09 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactory.java Thu Jan 10 21:24:54 2013 +0400 @@ -28,7 +28,7 @@ createClonedRepositoryParentDir(parentDir); // take last part of repository path - String repPath = hgRoot.getRepositoryUrlWithCredentials(); + String repPath = hgRoot.getRepository(); String[] splitted = repPath.split("[/\\\\]"); if (splitted.length > 0) { repPath = splitted[splitted.length-1]; diff -r a827c3756535 -r b58a75b12b7b mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactoryTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactoryTest.java Thu Jan 10 21:24:54 2013 +0400 @@ -0,0 +1,46 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import jetbrains.buildServer.TempFiles; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; +import jetbrains.buildServer.util.TestFor; +import jetbrains.buildServer.vcs.VcsRoot; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerPluginConfigBuilder.serverPluginConfig; +import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; +import static org.testng.AssertJUnit.assertFalse; + +@Test +public class HgVcsRootFactoryTest { + + private TempFiles myTempFiles; + + @BeforeMethod(alwaysRun = true) + public void setUp() { + myTempFiles = new TempFiles(); + } + + @AfterMethod(alwaysRun = true) + public void tearDown() { + myTempFiles.cleanup(); + } + + @TestFor(issues = "TW-25057") + public void vcs_root_custom_clone_dir_should_not_contain_password() throws Exception { + TempFiles tmp = new TempFiles(); + String urlWithoutPath = "http://only.host/"; + String password = "pwd"; + VcsRoot root = vcsRoot() + .withUrl(urlWithoutPath) + .withUserName("user") + .withPassword(password) + .withCloneRepositoryTo(tmp.createTempDir()) + .build(); + + HgVcsRoot hgRoot = new HgVcsRootFactory(serverPluginConfig().cachesDir(tmp.createTempDir()).build()).createHgRoot(root); + assertFalse("Custom clone dir contains password", hgRoot.getCustomWorkingDir().getName().contains(password)); + } + +} diff -r a827c3756535 -r b58a75b12b7b mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/VcsRootBuilder.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/VcsRootBuilder.java Sat Dec 29 18:35:09 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/VcsRootBuilder.java Thu Jan 10 21:24:54 2013 +0400 @@ -6,6 +6,7 @@ import org.jmock.Expectations; import org.jmock.Mockery; +import java.io.File; import java.io.IOException; /** @@ -21,6 +22,7 @@ private String myHgPath; private String myUserForTag; private boolean myUncompressed = true; + private File myCloneRepositoryTo; public static VcsRootBuilder vcsRoot() { return new VcsRootBuilder(); @@ -35,6 +37,8 @@ vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, myBranch); vcsRoot.addProperty(Constants.USER_FOR_TAG, myUserForTag); vcsRoot.addProperty(Constants.UNCOMPRESSED_TRANSFER, String.valueOf(myUncompressed)); + if (myCloneRepositoryTo != null) + vcsRoot.addProperty(Constants.SERVER_CLONE_PATH_PROP, String.valueOf(myCloneRepositoryTo.getAbsolutePath())); return vcsRoot; } @@ -52,6 +56,11 @@ allowing(root).getProperty(with(Constants.UNCOMPRESSED_TRANSFER)); will(returnValue(null)); allowing(root).getProperty(with(Constants.USER_FOR_TAG)); will(returnValue(myUserForTag)); }}); + if (myCloneRepositoryTo != null) { + context.checking(new Expectations() {{ + allowing(root).getProperty(with(Constants.SERVER_CLONE_PATH_PROP)); will(returnValue(myCloneRepositoryTo.getAbsolutePath())); + }}); + } return root; } @@ -96,4 +105,10 @@ myUserForTag = username; return this; } + + + public VcsRootBuilder withCloneRepositoryTo(File cloneTo) { + myCloneRepositoryTo = cloneTo; + return this; + } } diff -r a827c3756535 -r b58a75b12b7b mercurial-tests/src/testng.xml --- a/mercurial-tests/src/testng.xml Sat Dec 29 18:35:09 2012 +0400 +++ b/mercurial-tests/src/testng.xml Thu Jan 10 21:24:54 2013 +0400 @@ -29,6 +29,7 @@ +