public class SshTestGitServer extends Object
Supports only a single repository. Authenticates only the given test user against his given test public key. Supports fetch and push.
Modifier and Type | Field and Description |
---|---|
static String |
ECHO_COMMAND
Simple echo test command.
|
protected List<KeyPair> |
hostKeys |
protected Repository |
repository |
protected org.apache.sshd.server.SshServer |
server |
protected PublicKey |
testKey |
protected String |
testUser |
Constructor and Description |
---|
SshTestGitServer(String testUser,
Path testKey,
Repository repository,
byte[] hostKey)
Creates a ssh git test server.
|
SshTestGitServer(String testUser,
Path testKey,
Repository repository,
KeyPair hostKey)
Creates a ssh git test server.
|
SshTestGitServer(String testUser,
PublicKey testKey,
Repository repository,
KeyPair hostKey)
Creates a ssh git test server.
|
Modifier and Type | Method and Description |
---|---|
void |
addHostKey(KeyPair key,
boolean inFront)
Adds an additional host key to the server.
|
void |
addHostKey(Path key,
boolean inFront)
Adds an additional host key to the server.
|
protected void |
configureAuthentication()
Configures the authentication mechanisms of this test server.
|
protected void |
configureShell()
Configures shell access for the test server.
|
protected List<org.apache.sshd.server.subsystem.SubsystemFactory> |
configureSubsystems()
Configures the test server's subsystems (sftp, scp).
|
void |
enableKeyboardInteractiveAuthentication()
Enable keyboard-interactive authentication.
|
void |
enablePasswordAuthentication()
Enable password authentication.
|
org.apache.sshd.common.PropertyResolver |
getPropertyResolver()
Retrieves the server's
PropertyResolver , giving access to server
properties. |
void |
setPreamble(String... lines)
Sets the lines the server sends before its server identification in the
initial protocol version exchange.
|
void |
setTestUserPublicKey(Path key)
Sets the test user's public key on the server.
|
void |
setTestUserPublicKey(PublicKey key)
Sets the test user's public key on the server.
|
int |
start()
Starts the test server, listening on a random port.
|
void |
stop()
Stops the test server.
|
public static final String ECHO_COMMAND
@NonNull protected final Repository repository
protected final org.apache.sshd.server.SshServer server
public SshTestGitServer(@NonNull String testUser, @NonNull Path testKey, @NonNull Repository repository, @NonNull byte[] hostKey) throws IOException, GeneralSecurityException
testUser
- user name of the test usertestKey
- public key file of the test userrepository
- to servehostKey
- the unencrypted private key to use as host keyIOException
GeneralSecurityException
public SshTestGitServer(@NonNull String testUser, @NonNull Path testKey, @NonNull Repository repository, @NonNull KeyPair hostKey) throws IOException, GeneralSecurityException
testUser
- user name of the test usertestKey
- public key file of the test userrepository
- to servehostKey
- the unencrypted private key to use as host keyIOException
GeneralSecurityException
protected void configureAuthentication()
@NonNull protected List<org.apache.sshd.server.subsystem.SubsystemFactory> configureSubsystems()
protected void configureShell()
public void addHostKey(@NonNull Path key, boolean inFront) throws IOException, GeneralSecurityException
key
- path to the private key file; should not be encryptedinFront
- whether to add the new key before other existing keysIOException
- if the file denoted by the Path
key
cannot be
readGeneralSecurityException
- if the key contained in the file cannot be readpublic void addHostKey(@NonNull KeyPair key, boolean inFront)
key
- KeyPair
to addinFront
- whether to add the new key before other existing keyspublic void enablePasswordAuthentication()
public void enableKeyboardInteractiveAuthentication()
public org.apache.sshd.common.PropertyResolver getPropertyResolver()
PropertyResolver
, giving access to server
properties.PropertyResolver
public int start() throws IOException
IOException
public void stop() throws IOException
IOException
public void setTestUserPublicKey(Path key) throws IOException, GeneralSecurityException
key
- to setIOException
- if the file cannot be readGeneralSecurityException
- if the public key cannot be extracted from the filepublic void setTestUserPublicKey(@NonNull PublicKey key)
key
- to setpublic void setPreamble(String... lines)
lines
- to sendCopyright © 2020 Eclipse JGit Project. All rights reserved.