diff options
author | Florian Zschocke <fzs@users.noreply.github.com> | 2019-11-10 17:56:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-10 17:56:56 +0100 |
commit | 4d7311ba9f65869b39c4e117ab6d45f7a6eb4adc (patch) | |
tree | d5200dd4a6f58dd00155fdbbaf8cda1d92df27fd /src/test/java/com/gitblit/tests/SshUnitTest.java | |
parent | 5784b125b676d5d19897c66144552afedc92c655 (diff) | |
parent | bca2cd21d1798eadbeef0a055f7d5bc8df78a846 (diff) | |
download | gitblit-4d7311ba9f65869b39c4e117ab6d45f7a6eb4adc.tar.gz gitblit-4d7311ba9f65869b39c4e117ab6d45f7a6eb4adc.zip |
Merge pull request #1322 from fzs/sshd_update
Update dependencies MINA to 2.0.21 and SSHD to 1.2.0
Update SSHD to fix an issue with hmac-sha2-512. This resolves problems with clients that prefer SHA-512 over SHA-256.
This also updates the dependency on SLF4J to the latest version, as the updated dependency on MINA did also bring in higher SLF4J versions.
Diffstat (limited to 'src/test/java/com/gitblit/tests/SshUnitTest.java')
-rw-r--r-- | src/test/java/com/gitblit/tests/SshUnitTest.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/test/java/com/gitblit/tests/SshUnitTest.java b/src/test/java/com/gitblit/tests/SshUnitTest.java index 27b4ec73..075ab43a 100644 --- a/src/test/java/com/gitblit/tests/SshUnitTest.java +++ b/src/test/java/com/gitblit/tests/SshUnitTest.java @@ -21,15 +21,21 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.Writer; import java.net.SocketAddress; +import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.PublicKey; +import java.util.EnumSet; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.sshd.client.ServerKeyVerifier; import org.apache.sshd.client.SshClient; import org.apache.sshd.client.channel.ClientChannel; +import org.apache.sshd.client.channel.ClientChannelEvent; +import org.apache.sshd.client.config.keys.ClientIdentityLoader; +import org.apache.sshd.client.future.AuthFuture; +import org.apache.sshd.client.keyverifier.ServerKeyVerifier; import org.apache.sshd.client.session.ClientSession; +import org.apache.sshd.common.config.keys.FilePasswordProvider; import org.apache.sshd.common.util.SecurityUtils; import org.junit.After; import org.junit.AfterClass; @@ -96,6 +102,16 @@ public abstract class SshUnitTest extends GitblitUnitTest { protected SshClient getClient() { SshClient client = SshClient.setUpDefaultClient(); + client.setClientIdentityLoader(new ClientIdentityLoader() { // Ignore the files under ~/.ssh + @Override + public boolean isValidLocation(String location) throws IOException { + return true; + } + @Override + public KeyPair loadClientIdentity(String location, FilePasswordProvider provider) throws IOException, GeneralSecurityException { + return null; + } + }); client.setServerKeyVerifier(new ServerKeyVerifier() { @Override public boolean verifyServerKey(ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) { @@ -112,9 +128,11 @@ public abstract class SshUnitTest extends GitblitUnitTest { protected String testSshCommand(String cmd, String stdin) throws IOException, InterruptedException { SshClient client = getClient(); - ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).await().getSession(); + ClientSession session = client.connect(username, "localhost", GitBlitSuite.sshPort).verify().getSession(); session.addPublicKeyIdentity(rwKeyPair); - assertTrue(session.auth().await().isSuccess()); + AuthFuture authFuture = session.auth(); + assertTrue(authFuture.await()); + assertTrue(authFuture.isSuccess()); ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, cmd); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -131,7 +149,7 @@ public abstract class SshUnitTest extends GitblitUnitTest { channel.setErr(err); channel.open(); - channel.waitFor(ClientChannel.CLOSED, 0); + channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.EOF), 0); String result = out.toString().trim(); channel.close(false); |