summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.jsch.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-06-15 00:05:14 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2021-06-15 00:05:14 +0200
commit6a8afeb9f210f92e17b6c525d989c6072984289f (patch)
tree130a880a22b83ebfe8bdf3aa7db80b29c510929a /org.eclipse.jgit.ssh.jsch.test
parent1aa3cf7f416658a4fafd592732ba70f5a1aee19e (diff)
parent01b2c4fc90849f43042ffb0bb40fa3ab69541245 (diff)
downloadjgit-6a8afeb9f210f92e17b6c525d989c6072984289f.tar.gz
jgit-6a8afeb9f210f92e17b6c525d989c6072984289f.zip
Merge branch 'master' into next
* master: (47 commits) Fix @since from commit 64d0aaa2 Prepare 5.13.0-SNAPSHOT builds Prepare 5.12.1-SNAPSHOT builds Teach independent negotiation (no pack file) using an option "wait-for-done" JGit v5.12.0.202106070339-r [license-check] Update list of project dependencies [errorprone] Fix warning InputStreamSlowMultibyteRead [errorprone] Make operator precedence explicit in OpenSshConfigFile Update jetty to 9.4.41.v20210516 Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r Update Orbit to R20210602031627 Prepare 5.12.0-SNAPSHOT builds Fixing visibility for HostEntry constructors. JGit v5.12.0.202106021050-rc1 Prepare 5.12.0-SNAPSHOT builds JGit v5.12.0.202106011439-rc1 Clarify operator precedence to fix errorprone error Prepare 5.12.0-SNAPSHOT builds Update Orbit to S20210518003616 and ant to 1.10.10.v20210426-1926 ... Change-Id: I76a1f155201648a62df11a41a9e02d97f522d00f
Diffstat (limited to 'org.eclipse.jgit.ssh.jsch.test')
-rw-r--r--org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java74
1 files changed, 73 insertions, 1 deletions
diff --git a/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java b/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
index 4be2271a8c..93d85e2e90 100644
--- a/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
+++ b/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/OpenSshConfigTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2017 Google Inc. and others
+ * Copyright (C) 2008, 2021 Google Inc. and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -517,4 +517,76 @@ public class OpenSshConfigTest extends RepositoryTestCase {
assertEquals("/tmp/${TST_VAR/bar",
c.getValue(SshConstants.IDENTITY_AGENT));
}
+
+ @Test
+ public void testNegativeMatch() throws Exception {
+ config("Host foo.bar !foobar.baz *.baz\n" + "Port 29418\n");
+ Host h = osc.lookup("foo.bar");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ h = osc.lookup("foobar.baz");
+ assertNotNull(h);
+ assertEquals(22, h.getPort());
+ h = osc.lookup("foo.baz");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ }
+
+ @Test
+ public void testNegativeMatch2() throws Exception {
+ // Negative match after the positive match.
+ config("Host foo.bar *.baz !foobar.baz\n" + "Port 29418\n");
+ Host h = osc.lookup("foo.bar");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ h = osc.lookup("foobar.baz");
+ assertNotNull(h);
+ assertEquals(22, h.getPort());
+ h = osc.lookup("foo.baz");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ }
+
+ @Test
+ public void testNoMatch() throws Exception {
+ config("Host !host1 !host2\n" + "Port 29418\n");
+ Host h = osc.lookup("host1");
+ assertNotNull(h);
+ assertEquals(22, h.getPort());
+ h = osc.lookup("host2");
+ assertNotNull(h);
+ assertEquals(22, h.getPort());
+ h = osc.lookup("host3");
+ assertNotNull(h);
+ assertEquals(22, h.getPort());
+ }
+
+ @Test
+ public void testMultipleMatch() throws Exception {
+ config("Host foo.bar\nPort 29418\nIdentityFile /foo\n\n"
+ + "Host *.bar\nPort 22\nIdentityFile /bar\n"
+ + "Host foo.bar\nPort 47\nIdentityFile /baz\n");
+ Host h = osc.lookup("foo.bar");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ assertArrayEquals(new Object[] { "/foo", "/bar", "/baz" },
+ h.getConfig().getValues("IdentityFile"));
+ }
+
+ @Test
+ public void testWhitespace() throws Exception {
+ config("Host foo \tbar baz\nPort 29418\n");
+ Host h = osc.lookup("foo");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ h = osc.lookup("bar");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ h = osc.lookup("baz");
+ assertNotNull(h);
+ assertEquals(29418, h.getPort());
+ h = osc.lookup("\tbar");
+ assertNotNull(h);
+ assertEquals(22, h.getPort());
+ }
}