summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.apache.test
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-08-03 16:22:37 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2020-08-10 10:20:06 +0200
commitcc9975ff68158a602fde8fb1c396e164081262ab (patch)
tree7562d0884d49d779d6b772e060fe0bba9a215613 /org.eclipse.jgit.ssh.apache.test
parent76f79bc36c7c9130550459ace957703f1511b08d (diff)
downloadjgit-cc9975ff68158a602fde8fb1c396e164081262ab.tar.gz
jgit-cc9975ff68158a602fde8fb1c396e164081262ab.zip
sshd: work around a race condition in Apache MINA sshd 2.4.0/2.5.x
When exceptions occur very early in the SSH connection setup, it's possible that an exception gets lost. A subsequent authentication attempt may then never be notified of the failure, and then wait indefinitely or until its timeout expires. This is caused by race conditions in sshd. The issue has been reported upstream as SSHD-1050,[1] but will be fixed at the earliest in sshd 2.6.0. [1] https://issues.apache.org/jira/projects/SSHD/issues/SSHD-1050 Bug: 565394 Change-Id: If9b62839db38f9e59a5e1137c2257039ba82de98 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.ssh.apache.test')
-rw-r--r--org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java b/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java
index f27af6e196..651ae7dec1 100644
--- a/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java
+++ b/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java
@@ -11,6 +11,7 @@ package org.eclipse.jgit.transport.sshd;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -159,7 +160,7 @@ public class ApacheSshTest extends SshTestBase {
"IdentityFile " + privateKey1.getAbsolutePath());
}
- @Test (expected = TransportException.class)
+ @Test
public void testHugePreamble() throws Exception {
// Test that the connection fails when the preamble is longer than 64k.
StringBuilder b = new StringBuilder();
@@ -172,11 +173,16 @@ public class ApacheSshTest extends SshTestBase {
lines[i] = line;
}
server.setPreamble(lines);
- cloneWith(
- "ssh://" + TEST_USER + "@localhost:" + testPort
- + "/doesntmatter",
- defaultCloneDir, null,
- "IdentityFile " + privateKey1.getAbsolutePath());
+ TransportException e = assertThrows(TransportException.class,
+ () -> cloneWith(
+ "ssh://" + TEST_USER + "@localhost:" + testPort
+ + "/doesntmatter",
+ defaultCloneDir, null,
+ "IdentityFile " + privateKey1.getAbsolutePath()));
+ // The assertions test that we don't run into bug 565394 / SSHD-1050
+ assertFalse(e.getMessage().contains("timeout"));
+ assertTrue(e.getMessage().contains("65536")
+ || e.getMessage().contains("closed"));
}
/**