You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tw...@apache.org on 2022/04/15 17:50:26 UTC
[mina-sshd] 02/03: Fix ClientTest
This is an automated email from the ASF dual-hosted git repository.
twolf pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
commit 1e4265c8ca6d9d9530a8712a3fd6b0c9e34ae183
Author: Thomas Wolf <tw...@apache.org>
AuthorDate: Fri Apr 15 17:51:05 2022 +0200
Fix ClientTest
Don't use `PublicKey.equals()` to check two `PublicKey` instances for
equality. This may fail depending on the implementation class. Use our
own `KeyUtils.compareKeys()` instead.
---
sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
index ad40b463e..2f196eab1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
@@ -75,6 +75,7 @@ import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.channel.ChannelListener;
import org.apache.sshd.common.channel.StreamingChannel;
import org.apache.sshd.common.channel.exception.SshChannelClosedException;
+import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoInputStream;
@@ -1063,7 +1064,7 @@ public class ClientTest extends BaseTestSupport {
KeyPairProvider keys = createTestHostKeyProvider();
KeyPair pair = keys.loadKey(null, CommonTestSupportUtils.DEFAULT_TEST_HOST_KEY_TYPE);
- sshd.setPublickeyAuthenticator((username, key, session) -> key.equals(pair.getPublic()));
+ sshd.setPublickeyAuthenticator((username, key, session) -> KeyUtils.compareKeys(key, pair.getPublic()));
client.setUserAuthFactories(Collections.singletonList(UserAuthPublicKeyFactory.INSTANCE));
client.start();