java.lang.Object
org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
org.eclipse.jgit.junit.RepositoryTestCase
org.eclipse.jgit.junit.ssh.SshTestHarness
- Direct Known Subclasses:
SshBasicTestBase
public abstract class SshTestHarness
extends org.eclipse.jgit.junit.RepositoryTestCase
Root class for ssh tests. Sets up the ssh test server. A set of pre-computed
keys for testing is provided in the bundle and can be used in test cases via
copyTestResource(String, File). These test key files names have four
components, separated by a single underscore: "id", the algorithm, the bits
(if variable), and the password if the private key is encrypted. For instance
"id_ecdsa_384_testpass" is an encrypted ECDSA-384 key. The passphrase
to decrypt is "testpass". The key "id_ecdsa_384" is the same but
unencrypted. All keys were generated and encrypted via ssh-keygen. Note that
DSA and ec25519 have no "bits" component. Available keys are listed in
SshTestBase.KEY_RESOURCES.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Fileprotected Fileprotected Fileprotected Fileprotected Fileprotected SshTestGitServerprotected Fileprotected static final Stringprotected intFields inherited from class org.eclipse.jgit.junit.RepositoryTestCase
db, trashFields inherited from class org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
ASSUME_UNCHANGED, author, committer, CONTENT, CONTENT_ID, currentTest, LENGTH, mockSystemReader, MOD_TIME, SMUDGE, testRoot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected FilecloneWith(String uri, File to, org.eclipse.jgit.transport.CredentialsProvider provider, String... config) protected voidcopyTestResource(Class<?> loader, String resourceName, File to) Copies a test data file contained in the test bundle to the given file, usingClass.getResourceAsStream(String)to get the test resource.protected voidcopyTestResource(String resourceName, File to) Copies a test data file contained in the test bundle to the given file.protected static StringcreateKnownHostsFile(File file, String host, int port, File publicKey) Creates a new known_hosts file with one entry for the given host and port taken from the given public key file.protected abstract org.eclipse.jgit.transport.SshSessionFactoryprotected org.eclipse.jgit.transport.SshSessionFactoryprotected booleanhasHostKey(String host, int port, String keyPart, List<String> lines) Checks whether there is a line for the given host and port that also matches the given key part in the list of lines.protected abstract voidinstallConfig(String... config) protected voidprotected voidvoidsetUp()voidMethods inherited from class org.eclipse.jgit.junit.RepositoryTestCase
assertEqualsFile, check, checkFile, checkoutBranch, commitFile, copyFile, createBranch, createEntry, createEntry, createEntry, createGitLink, deleteTrashFile, fsTick, getRefs, indexState, lookup, read, resetIndex, slashify, tearDown, writeLink, writeTrashFile, writeTrashFile, writeTrashFilesMethods inherited from class org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
addRepoToClose, createBareRepository, createRepository, createRepository, createTempDirectory, createTempFile, createUniqueTestGitDir, createWorkRepository, getCeilings, getTemporaryDirectory, indexState, read, recursiveDelete, runHook, tick, write, write
-
Field Details
-
TEST_USER
- See Also:
-
sshDir
-
privateKey1
-
privateKey2
-
publicKey1
-
publicKey2
- Since:
- 5.10
-
server
-
testPort
protected int testPort -
knownHosts
-
-
Constructor Details
-
SshTestHarness
public SshTestHarness()
-
-
Method Details
-
setUp
- Overrides:
setUpin classorg.eclipse.jgit.junit.RepositoryTestCase- Throws:
Exception
-
createKnownHostsFile
protected static String createKnownHostsFile(File file, String host, int port, File publicKey) throws IOException Creates a new known_hosts file with one entry for the given host and port taken from the given public key file.- Parameters:
file- to write the known_hosts file tohost- for the entryport- for the entrypublicKey- to use- Returns:
- the public-key part of the line
- Throws:
IOException- if an IO error occurred
-
hasHostKey
Checks whether there is a line for the given host and port that also matches the given key part in the list of lines.- Parameters:
host- to look forport- to look forkeyPart- to look forlines- to look in- Returns:
trueif found,falseotherwise
-
shutdownServer
- Throws:
Exception
-
createSessionFactory
protected abstract org.eclipse.jgit.transport.SshSessionFactory createSessionFactory() -
getSessionFactory
protected org.eclipse.jgit.transport.SshSessionFactory getSessionFactory() -
installConfig
-
copyTestResource
Copies a test data file contained in the test bundle to the given file. Equivalent tocopyTestResource(Class, String, File)withSshTestHarness.classas first parameter.- Parameters:
resourceName- of the test resource to copyto- file to copy the resource to- Throws:
IOException- if the resource cannot be copied
-
copyTestResource
Copies a test data file contained in the test bundle to the given file, usingClass.getResourceAsStream(String)to get the test resource.- Parameters:
loader-Classto use to load the resourceresourceName- of the test resource to copyto- file to copy the resource to- Throws:
IOException- if the resource cannot be copied
-
cloneWith
protected File cloneWith(String uri, File to, org.eclipse.jgit.transport.CredentialsProvider provider, String... config) throws Exception - Throws:
Exception
-
pushTo
- Throws:
Exception
-
pushTo
protected void pushTo(org.eclipse.jgit.transport.CredentialsProvider provider, File localClone) throws Exception - Throws:
Exception
-