public abstract class SshTestHarness extends RepositoryTestCase
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.| Modifier and Type | Class and Description |
|---|---|
protected static class |
SshTestHarness.LogEntry |
protected static class |
SshTestHarness.TestCredentialsProvider |
| Modifier and Type | Field and Description |
|---|---|
private SshSessionFactory |
factory |
private java.io.File |
homeDir |
protected java.io.File |
knownHosts |
protected java.io.File |
privateKey1 |
protected java.io.File |
privateKey2 |
protected java.io.File |
publicKey1 |
protected SshTestGitServer |
server |
protected java.io.File |
sshDir |
protected static java.lang.String |
TEST_USER |
protected int |
testPort |
db, trashASSUME_UNCHANGED, author, committer, CONTENT, CONTENT_ID, LENGTH, mockSystemReader, MOD_TIME, SMUDGE| Constructor and Description |
|---|
SshTestHarness() |
| Modifier and Type | Method and Description |
|---|---|
protected java.io.File |
cloneWith(java.lang.String uri,
java.io.File to,
CredentialsProvider provider,
java.lang.String... config) |
protected void |
copyTestResource(java.lang.Class<?> loader,
java.lang.String resourceName,
java.io.File to)
Copies a test data file contained in the test bundle to the given file,
using
Class.getResourceAsStream(String) to get the test resource. |
protected void |
copyTestResource(java.lang.String resourceName,
java.io.File to)
Copies a test data file contained in the test bundle to the given file.
|
private static byte[] |
createHostKey(java.io.OutputStream publicKey) |
private static java.io.File |
createKeyPair(java.io.File privateKeyFile) |
protected static java.lang.String |
createKnownHostsFile(java.io.File file,
java.lang.String host,
int port,
java.io.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 SshSessionFactory |
createSessionFactory() |
protected SshSessionFactory |
getSessionFactory() |
protected boolean |
hasHostKey(java.lang.String host,
int port,
java.lang.String keyPart,
java.util.List<java.lang.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 void |
installConfig(java.lang.String... config) |
protected void |
pushTo(CredentialsProvider provider,
java.io.File localClone) |
protected void |
pushTo(java.io.File localClone) |
void |
setUp()
Setup test
|
void |
shutdownServer() |
assertEqualsFile, check, checkFile, checkoutBranch, commitFile, copyFile, createBranch, createEntry, createEntry, createEntry, deleteTrashFile, fsTick, indexState, lookup, read, resetIndex, slashify, writeLink, writeTrashFile, writeTrashFile, writeTrashFilesaddRepoToClose, createBareRepository, createRepository, createRepository, createTempDirectory, createTempFile, createUniqueTestGitDir, createWorkRepository, getCeilings, getTemporaryDirectory, indexState, read, recursiveDelete, runHook, tearDown, tick, write, writeprotected static final java.lang.String TEST_USER
protected java.io.File sshDir
protected java.io.File privateKey1
protected java.io.File privateKey2
protected java.io.File publicKey1
protected SshTestGitServer server
private SshSessionFactory factory
protected int testPort
protected java.io.File knownHosts
private java.io.File homeDir
public void setUp()
throws java.lang.Exception
RepositoryTestCasesetUp in class RepositoryTestCasejava.lang.Exceptionprivate static java.io.File createKeyPair(java.io.File privateKeyFile)
throws java.lang.Exception
java.lang.Exceptionprivate static byte[] createHostKey(java.io.OutputStream publicKey)
throws java.lang.Exception
java.lang.Exceptionprotected static java.lang.String createKnownHostsFile(java.io.File file,
java.lang.String host,
int port,
java.io.File publicKey)
throws java.io.IOException
file - to write the known_hosts file tohost - for the entryport - for the entrypublicKey - to usejava.io.IOExceptionprotected boolean hasHostKey(java.lang.String host,
int port,
java.lang.String keyPart,
java.util.List<java.lang.String> lines)
host - to look forport - to look forkeyPart - to look forlines - to look intrue if found, false otherwisepublic void shutdownServer()
throws java.lang.Exception
java.lang.Exceptionprotected abstract SshSessionFactory createSessionFactory()
protected SshSessionFactory getSessionFactory()
protected abstract void installConfig(java.lang.String... config)
protected void copyTestResource(java.lang.String resourceName,
java.io.File to)
throws java.io.IOException
copyTestResource(Class, String, File) with
SshTestHarness.class as first parameter.resourceName - of the test resource to copyto - file to copy the resource tojava.io.IOException - if the resource cannot be copiedprotected void copyTestResource(java.lang.Class<?> loader,
java.lang.String resourceName,
java.io.File to)
throws java.io.IOException
Class.getResourceAsStream(String) to get the test resource.loader - Class to use to load the resourceresourceName - of the test resource to copyto - file to copy the resource tojava.io.IOException - if the resource cannot be copiedprotected java.io.File cloneWith(java.lang.String uri,
java.io.File to,
CredentialsProvider provider,
java.lang.String... config)
throws java.lang.Exception
java.lang.Exceptionprotected void pushTo(java.io.File localClone)
throws java.lang.Exception
java.lang.Exceptionprotected void pushTo(CredentialsProvider provider, java.io.File localClone) throws java.lang.Exception
java.lang.Exception