changeset 1064:471eaf5420c8 Lakhnau-2020.2.x

moved tests to the proper class, added logging
author victory.bedrosova
date Thu, 11 Mar 2021 16:02:12 +0100
parents 4b6661db8a8a
children 5bc9d4871754
files mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java
diffstat 3 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java	Thu Mar 11 15:32:03 2021 +0100
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupport.java	Thu Mar 11 16:02:12 2021 +0100
@@ -81,6 +81,7 @@
         TestConnectionSupport testConnectionSupport = myVcsSupport.getTestConnectionSupport();
         testConnectionSupport.testConnection(new VcsRootImpl(-1, res));
       } catch (VcsException e) {
+        Loggers.VCS.infoAndDebugDetails("Failed to recognize " + fetchUrl + " as a Mercurial VCS root", e);
         return null;
       }
     }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java	Thu Mar 11 15:32:03 2021 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java	Thu Mar 11 16:02:12 2021 +0100
@@ -175,6 +175,28 @@
     assertEquals(customConfig, new HgVcsRoot(root).getCustomHgConfigServer());
   }
 
+  @TestFor(issues = "TW-70054")
+  public void exception_on_command_injection() throws Exception {
+    try {
+      new HgVcsRoot(vcsRoot().withUrl("--config=hooks.pre-identify=whoami>/tmp/JRNJRN").build());
+    } catch (IllegalArgumentException e) {
+      // expected
+      return;
+    }
+    fail("Expection not thrown ");
+  }
+
+  @TestFor(issues = "TW-70541")
+  public void exception_on_command_injection_cwd() throws Exception {
+    try {
+      new HgVcsRoot(vcsRoot().withUrl("--cwd=/home/user/.BuildServer/system/artifacts/Test/bad_artifact/411/").build());
+    } catch (IllegalArgumentException e) {
+      // expected
+      return;
+    }
+    fail("Expection not thrown ");
+  }
+
   private VcsRootImpl createVcsRoot(String url) {
     return createVcsRoot(url, "user", "pwd");
   }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java	Thu Mar 11 15:32:03 2021 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialUrlSupportTest.java	Thu Mar 11 16:02:12 2021 +0100
@@ -16,7 +16,6 @@
 
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
-import jetbrains.buildServer.util.TestFor;
 import jetbrains.buildServer.vcs.Credentials;
 import jetbrains.buildServer.vcs.VcsException;
 import jetbrains.buildServer.vcs.VcsUrl;
@@ -77,26 +76,4 @@
     Map<String, String> props = myUrlSupport.convertToVcsRootProperties(url);
     assertNull(props);
   }
-
-  @TestFor(issues = "TW-70054")
-  public void exception_on_command_injection() throws VcsException {
-    try {
-      myUrlSupport.convertToVcsRootProperties(new VcsUrl("--config=hooks.pre-identify=whoami>/tmp/JRNJRN"));
-    } catch (IllegalArgumentException e) {
-      // expected
-      return;
-    }
-    fail("Expection not thrown ");
-  }
-
-  @TestFor(issues = "TW-70541")
-  public void exception_on_command_injection_cwd() throws VcsException {
-    try {
-      myUrlSupport.convertToVcsRootProperties(new VcsUrl("--cwd=/home/user/.BuildServer/system/artifacts/Test/bad_artifact/411/"));
-    } catch (IllegalArgumentException e) {
-      // expected
-      return;
-    }
-    fail("Expection not thrown ");
-  }
 }