summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/src
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/src')
-rw-r--r--org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java132
1 files changed, 132 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 86dbc4edcd..92a2fbd275 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
@@ -54,6 +54,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
+import java.util.Locale;
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.transport.CredentialItem;
@@ -668,6 +669,137 @@ public abstract class SshTestBase extends SshTestHarness {
"IdentityFile " + privateKey1.getAbsolutePath());
}
+ @Test
+ public void testPasswordAuth() throws Exception {
+ server.enablePasswordAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ TEST_USER.toUpperCase(Locale.ROOT));
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications password");
+ }
+
+ @Test
+ public void testPasswordAuthSeveralTimes() throws Exception {
+ server.enablePasswordAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ "wrongpass", "wrongpass", TEST_USER.toUpperCase(Locale.ROOT));
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications password");
+ }
+
+ @Test(expected = TransportException.class)
+ public void testPasswordAuthWrongPassword() throws Exception {
+ server.enablePasswordAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ "wrongpass");
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications password");
+ }
+
+ @Test(expected = TransportException.class)
+ public void testPasswordAuthNoPassword() throws Exception {
+ server.enablePasswordAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider();
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications password");
+ }
+
+ @Test(expected = TransportException.class)
+ public void testPasswordAuthCorrectPasswordTooLate() throws Exception {
+ server.enablePasswordAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ "wrongpass", "wrongpass", "wrongpass",
+ TEST_USER.toUpperCase(Locale.ROOT));
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications password");
+ }
+
+ @Test
+ public void testKeyboardInteractiveAuth() throws Exception {
+ server.enableKeyboardInteractiveAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ TEST_USER.toUpperCase(Locale.ROOT));
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications keyboard-interactive");
+ }
+
+ @Test
+ public void testKeyboardInteractiveAuthSeveralTimes() throws Exception {
+ server.enableKeyboardInteractiveAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ "wrongpass", "wrongpass", TEST_USER.toUpperCase(Locale.ROOT));
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications keyboard-interactive");
+ }
+
+ @Test(expected = TransportException.class)
+ public void testKeyboardInteractiveAuthWrongPassword() throws Exception {
+ server.enableKeyboardInteractiveAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ "wrongpass");
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications keyboard-interactive");
+ }
+
+ @Test(expected = TransportException.class)
+ public void testKeyboardInteractiveAuthNoPassword() throws Exception {
+ server.enableKeyboardInteractiveAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider();
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications keyboard-interactive");
+ }
+
+ @Test(expected = TransportException.class)
+ public void testKeyboardInteractiveAuthCorrectPasswordTooLate()
+ throws Exception {
+ server.enableKeyboardInteractiveAuthentication();
+ TestCredentialsProvider provider = new TestCredentialsProvider(
+ "wrongpass", "wrongpass", "wrongpass",
+ TEST_USER.toUpperCase(Locale.ROOT));
+ cloneWith("ssh://git/doesntmatter", defaultCloneDir, provider, //
+ "Host git", //
+ "HostName localhost", //
+ "Port " + testPort, //
+ "User " + TEST_USER, //
+ "PreferredAuthentications keyboard-interactive");
+ }
+
@Theory
public void testSshKeys(String keyName) throws Exception {
// JSch fails on ECDSA 384/521 keys. Compare