Add a test for upstream bug SSHD-1028
SSHD-1028:[1] server doesn't close server-side sessions properly when client disconnects. [1] https://issues.apache.org/jira/projects/SSHD/issues/SSHD-1028 Change-Id: I0d67f49e35abe8375cb1370a494dc01d0fb2c9b1 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
8774f54190
commit
151f0cb82b
|
@ -22,6 +22,7 @@
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.sshd.common.NamedResource;
|
import org.apache.sshd.common.NamedResource;
|
||||||
import org.apache.sshd.common.PropertyResolverUtils;
|
import org.apache.sshd.common.PropertyResolverUtils;
|
||||||
|
@ -297,6 +298,17 @@ public void enableKeyboardInteractiveAuthentication() {
|
||||||
DefaultKeyboardInteractiveAuthenticator.INSTANCE);
|
DefaultKeyboardInteractiveAuthenticator.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the server's property map. This is a live map; changing it
|
||||||
|
* affects the server.
|
||||||
|
*
|
||||||
|
* @return a live map of the server's properties
|
||||||
|
* @since 5.9
|
||||||
|
*/
|
||||||
|
public Map<String, Object> getProperties() {
|
||||||
|
return server.getProperties();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the test server, listening on a random port.
|
* Starts the test server, listening on a random port.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,6 +15,8 @@ Import-Package: org.apache.sshd.client.config.hosts;version="[2.4.0,2.5.0)",
|
||||||
org.apache.sshd.common.session;version="[2.4.0,2.5.0)",
|
org.apache.sshd.common.session;version="[2.4.0,2.5.0)",
|
||||||
org.apache.sshd.common.util.net;version="[2.4.0,2.5.0)",
|
org.apache.sshd.common.util.net;version="[2.4.0,2.5.0)",
|
||||||
org.apache.sshd.common.util.security;version="[2.4.0,2.5.0)",
|
org.apache.sshd.common.util.security;version="[2.4.0,2.5.0)",
|
||||||
|
org.apache.sshd.server;version="[2.4.0,2.5.0)",
|
||||||
|
org.eclipse.jgit.api;version="[5.9.0,5.10.0)",
|
||||||
org.eclipse.jgit.api.errors;version="[5.9.0,5.10.0)",
|
org.eclipse.jgit.api.errors;version="[5.9.0,5.10.0)",
|
||||||
org.eclipse.jgit.internal.transport.sshd.proxy;version="[5.9.0,5.10.0)",
|
org.eclipse.jgit.internal.transport.sshd.proxy;version="[5.9.0,5.10.0)",
|
||||||
org.eclipse.jgit.junit;version="[5.9.0,5.10.0)",
|
org.eclipse.jgit.junit;version="[5.9.0,5.10.0)",
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.sshd.client.config.hosts.KnownHostEntry;
|
import org.apache.sshd.client.config.hosts.KnownHostEntry;
|
||||||
|
import org.apache.sshd.server.ServerFactoryManager;
|
||||||
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.errors.TransportException;
|
import org.eclipse.jgit.api.errors.TransportException;
|
||||||
import org.eclipse.jgit.junit.ssh.SshTestBase;
|
import org.eclipse.jgit.junit.ssh.SshTestBase;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
|
@ -175,4 +177,31 @@ public void testHugePreamble() throws Exception {
|
||||||
defaultCloneDir, null,
|
defaultCloneDir, null,
|
||||||
"IdentityFile " + privateKey1.getAbsolutePath());
|
"IdentityFile " + privateKey1.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for SSHD-1028. If the server doesn't close sessions, the second
|
||||||
|
* fetch will fail. Occurs on sshd 2.5.[01].
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
* on errors
|
||||||
|
* @see <a href=
|
||||||
|
* "https://issues.apache.org/jira/projects/SSHD/issues/SSHD-1028">SSHD-1028</a>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPushWithSessionLimit() throws Exception {
|
||||||
|
server.getProperties().put(ServerFactoryManager.MAX_CONCURRENT_SESSIONS,
|
||||||
|
Integer.valueOf(2));
|
||||||
|
File localClone = cloneWith("ssh://localhost/doesntmatter",
|
||||||
|
defaultCloneDir, null, //
|
||||||
|
"Host localhost", //
|
||||||
|
"HostName localhost", //
|
||||||
|
"Port " + testPort, //
|
||||||
|
"User " + TEST_USER, //
|
||||||
|
"IdentityFile " + privateKey1.getAbsolutePath());
|
||||||
|
// Fetch a couple of times
|
||||||
|
try (Git git = Git.open(localClone)) {
|
||||||
|
git.fetch().call();
|
||||||
|
git.fetch().call();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue