Skip to content

Commit

Permalink
Make all tests runnable on Windows (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
kegelh committed Sep 16, 2022
1 parent ec467a3 commit 430cbfc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.bat text eol=crlf
src/itest/docker-image/** eol=lf
4 changes: 3 additions & 1 deletion src/test/java/com/hierynomus/sshj/test/SshFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.util.gss.BogusGSSAuthenticator;
import org.apache.sshd.common.keyprovider.ClassLoadableResourceKeyPairProvider;
import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.scp.server.ScpCommandFactory;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.shell.ProcessShellFactory;
Expand All @@ -38,6 +39,7 @@
public class SshFixture extends ExternalResource {
public static final String hostkey = "hostkey.pem";
public static final String fingerprint = "ce:a7:c1:cf:17:3f:96:49:6a:53:1a:05:0b:ba:90:db";
public static final String listCommand = OsUtils.isWin32() ? "cmd.exe /C dir" : "ls";

private final SshServer server = defaultSshServer();
private SSHClient client = null;
Expand Down Expand Up @@ -110,7 +112,7 @@ private SshServer defaultSshServer() {
ScpCommandFactory commandFactory = new ScpCommandFactory();
commandFactory.setDelegateCommandFactory((session, command) -> new ProcessShellFactory(command, command.split(" ")).createShell(session));
sshServer.setCommandFactory(commandFactory);
sshServer.setShellFactory(new ProcessShellFactory("ls", "ls"));
sshServer.setShellFactory(new ProcessShellFactory(listCommand, listCommand.split(" ")));
return sshServer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/schmizz/sshj/LoadsOfConnects.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void loadsOfConnects() {
SSHClient client = fixture.setupConnectedDefaultClient();
client.authPassword("test", "test");
Session s = client.startSession();
Session.Command c = s.exec("ls");
Session.Command c = s.exec(SshFixture.listCommand);
IOUtils.readFully(c.getErrorStream());
IOUtils.readFully(c.getInputStream());
c.close();
Expand Down

0 comments on commit 430cbfc

Please sign in to comment.