summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit.ssh/src
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-04-26 16:43:28 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2020-05-23 16:46:22 +0200
commit5a5d85a4a3407df5f9693ab36287e72726c512f6 (patch)
tree0774117236e7f3d38f72390da908dedb5eb064ed /org.eclipse.jgit.junit.ssh/src
parent3a499606b1d8f18cb129cd47e63dd17f54e80def (diff)
downloadjgit-5a5d85a4a3407df5f9693ab36287e72726c512f6.tar.gz
jgit-5a5d85a4a3407df5f9693ab36287e72726c512f6.zip
In-memory SSH keys for the "no files" sshd tests
Avoid using a key written to a file. This makes it clearer that the test does not rely on files being present. Change-Id: I31cf4f404aab5b891c32fc4bda906b7f8fe03777 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.junit.ssh/src')
-rw-r--r--org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
index 883ff0b8b5..03e2855829 100644
--- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
+++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2018, Thomas Wolf <thomas.wolf@paranor.ch> and others
+ * Copyright (C) 2018, 2020 Thomas Wolf <thomas.wolf@paranor.ch> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -252,11 +252,24 @@ public class SshTestGitServer {
.loadKeyPairIdentities(null,
NamedResource.ofName(key.toString()), in, null)
.iterator().next();
- if (inFront) {
- hostKeys.add(0, pair);
- } else {
- hostKeys.add(pair);
- }
+ addHostKey(pair, inFront);
+ }
+ }
+
+ /**
+ * Adds an additional host key to the server.
+ *
+ * @param key
+ * {@link KeyPair} to add
+ * @param inFront
+ * whether to add the new key before other existing keys
+ * @since 5.8
+ */
+ public void addHostKey(@NonNull KeyPair key, boolean inFront) {
+ if (inFront) {
+ hostKeys.add(0, key);
+ } else {
+ hostKeys.add(key);
}
}
@@ -323,6 +336,18 @@ public class SshTestGitServer {
}
/**
+ * Sets the test user's public key on the server.
+ *
+ * @param key
+ * to set
+ *
+ * @since 5.8
+ */
+ public void setTestUserPublicKey(@NonNull PublicKey key) {
+ this.testKey = key;
+ }
+
+ /**
* Sets the lines the server sends before its server identification in the
* initial protocol version exchange.
*