summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2018-09-21 22:43:34 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2018-11-06 13:17:22 +0100
commitcc000f93a84b22e692a9c234486978703fdb8f30 (patch)
treea56762ee000562a1a5753ade93c113231a5bf14d /org.eclipse.jgit.test/tst
parent08b0a8632d54a24d92075b94d0b0134b69146ba2 (diff)
downloadjgit-cc000f93a84b22e692a9c234486978703fdb8f30.tar.gz
jgit-cc000f93a84b22e692a9c234486978703fdb8f30.zip
Factor out a JSch-independent ssh config parser
Move the bulk of the basic parsing and host entry handling into a new class OpenSshConfigFile that has no dependencies on any concrete ssh implementation. Make the existing OpenSshConfig use the new parser. Introduce a new class SshConstants collecting all the various ssh- related string literals. Also use TreeMaps with a case-insensitive key comparator instead of converting keys to uppercase. Add a test to verify that keys are matched case-insensitively. Most of the parsing code was simply moved, except that the new parser supports looking up entries given host name, port, and user name, and can thus handle more %-substitutions correctly. This feature is not yet used and cannot be used with JSch since JSch only has a ConfigRepository.getConfig(String) interface. The split is still worth the trouble as it opens the way to using another ssh client altogether. Apache MINA sshd, for instance, resolves host entries giving host name, port, and user name. (Apache MINA has a built-in ssh config handling, but that has problems, too: its pattern matching is case-insensitive, and its merging of host entries if several match is not the same as in OpenSsh. But with this refactoring, it will be possible to plug in OpenSshConfigFile into an Apache MINA sshd client without dragging along JSch.) One test case that doesn't make sense anymore has been removed. It tested that repeatedly querying for a host entry returned the same object. That is no longer true since the caching has been moved to a deeper level. Bug: 520927 Change-Id: I6381d52b29099595e6eaf8b05c786aeeaefbf9cc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java16
1 files changed, 0 insertions, 16 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
index 0760585761..1a22e10f4c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
@@ -50,7 +50,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -349,21 +348,6 @@ public class OpenSshConfigTest extends RepositoryTestCase {
}
@Test
- public void testRepeatedLookups() throws Exception {
- config("Host orcz\n" + "\tConnectionAttempts 5\n");
- final Host h1 = osc.lookup("orcz");
- final Host h2 = osc.lookup("orcz");
- assertNotNull(h1);
- assertSame(h1, h2);
- assertEquals(5, h1.getConnectionAttempts());
- assertEquals(h1.getConnectionAttempts(), h2.getConnectionAttempts());
- final ConfigRepository.Config c = osc.getConfig("orcz");
- assertNotNull(c);
- assertSame(c, h1.getConfig());
- assertSame(c, h2.getConfig());
- }
-
- @Test
public void testRepeatedLookupsWithModification() throws Exception {
config("Host orcz\n" + "\tConnectionAttempts -1\n");
final Host h1 = osc.lookup("orcz");