Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-06-23 18:12:51 -0400
committerMatthias Sohn2016-12-23 08:01:54 -0500
commitf19f61427fd4e6aad44b8851e7661fc814074c50 (patch)
tree09213b5852f59707a23b4db2b228eaa2133dd388 /org.eclipse.egit.core.test/src
parentfdf10f1325b4133eba2f31a3e073cee517097611 (diff)
downloadegit-f19f61427fd4e6aad44b8851e7661fc814074c50.tar.gz
egit-f19f61427fd4e6aad44b8851e7661fc814074c50.tar.xz
egit-f19f61427fd4e6aad44b8851e7661fc814074c50.zip
Validate target repository path entered by the user
Validate the repository path entered in NewRepositoryWizard or GitImportWizard to prevent we hit an InvalidPathException in JGit. Since it seems many users try to paste a git clone command or a URL instead of a local path raise a dedicated error messages for these cases. Bug: 496688 Change-Id: I7c40f2d47f5b37ce50d873dbd02e6365097d7110 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/util/RepositoryPathCheckerTest.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/util/RepositoryPathCheckerTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/util/RepositoryPathCheckerTest.java
new file mode 100644
index 000000000..1b8060d56
--- /dev/null
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/util/RepositoryPathCheckerTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (C) 2016, Matthias Sohn <matthias.sohn@sap.com> and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.egit.core.internal.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.jgit.util.SystemReader;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RepositoryPathCheckerTest {
+
+ private RepositoryPathChecker checker;
+
+ @Before
+ public void setup() {
+ checker = new RepositoryPathChecker();
+ }
+
+ @Test
+ public void testLocalAbsoluteFileUnix() {
+ assertTrue(checker.check("/a/b"));
+ }
+
+ @Test
+ public void testLocalAbsoluteFileWindows() {
+ Assume.assumeTrue(SystemReader.getInstance().isWindows());
+ assertTrue(checker.check("C:/a/b"));
+ }
+
+ @Test
+ public void testLocalRelativePath() {
+ assertFalse(checker.check("a/b"));
+ }
+
+ @Test
+ public void testSSH() {
+ assertFalse(checker.check("ssh://a.test:/a/b"));
+ assertFalse(checker.check("joe@a.test:/a/b"));
+ }
+
+ @Test
+ public void testHTTP() {
+ assertFalse(checker.check("https://a.test/a/b"));
+ }
+
+ @Test
+ public void testFile() {
+ assertFalse(checker.check("file://a.test/a/b"));
+ }
+
+ @Test
+ public void testFooBar() {
+ assertFalse(checker.check("foobar://a.test/a/b"));
+ }
+}

Back to the top