diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-10-01 23:27:10 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-11-13 10:49:26 -0800 |
commit | 06387d4bfdddf96e0d590649cdc6b7f89a53e341 (patch) | |
tree | 5f092cef7d0ea110d7658906198ff06e3d22bcfe /org.eclipse.jgit.test/src/org | |
parent | 9b31969f3c8b10747ee4af4fff83e9f45c6b41b0 (diff) | |
download | jgit-06387d4bfdddf96e0d590649cdc6b7f89a53e341.tar.gz jgit-06387d4bfdddf96e0d590649cdc6b7f89a53e341.zip |
Add ssh tests for PreferredAuthentications
Tests that it works with unknown authentications in the list, and
fails if there are no common authentications between server and
client. The latter also tests that the ssh config setting is taken
into account at all.
And promptly the JGit sshd client didn't. Add a fix for this. It's
a tiny bit hacky: Apache MINA looks up a custom property set on a
hierarchy of "PropertyResolver"s starting with the session. On the
session itself this property can never be set since it's read
already in the session constructor before anyone had any chance
to set it. The next element in the resolver hierarchy is the sshd
SshClient, and so we set that property there. Since we use one
SshClient and one ClientSession per JGit SshdSession, this is OK.
Bug: 520927
Change-Id: I62446fc1fffde125a8965c030240f0918ae234b7
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test/src/org')
-rw-r--r-- | org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java index 2f623e3305..3b5aa5adb7 100644 --- a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java +++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java @@ -572,6 +572,29 @@ public abstract class SshTestBase extends SshTestHarness { "HostKeyAlgorithms ssh-rsa,ssh-dss"); } + @Test + public void testSshWithUnknownAuthInConfig() throws Exception { + cloneWith("ssh://git/doesntmatter", defaultCloneDir, null, // + "Host git", // + "HostName localhost", // + "Port " + testPort, // + "User " + TEST_USER, // + "IdentityFile " + privateKey1.getAbsolutePath(), // + "PreferredAuthentications gssapi-with-mic,hostbased,publickey,keyboard-interactive,password"); + } + + @Test(expected = TransportException.class) + public void testSshWithNoMatchingAuthInConfig() throws Exception { + // Server doesn't do password, and anyway we set no password. + cloneWith("ssh://git/doesntmatter", defaultCloneDir, null, // + "Host git", // + "HostName localhost", // + "Port " + testPort, // + "User " + TEST_USER, // + "IdentityFile " + privateKey1.getAbsolutePath(), // + "PreferredAuthentications password"); + } + @Theory public void testSshKeys(String keyName) throws Exception { // JSch fails on ECDSA 384/521 keys. Compare |