use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.
the class SshProxyTest method initializeClass.
@BeforeClass
public static void initializeClass() {
try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
Assume.assumeNotNull(inputStream);
properties = new NonBlockingProperties();
properties.load(inputStream);
} catch (final IOException e) {
LOGGER.warn("cant find properties file (tests will be skipped)", e);
properties = null;
return;
}
final String knownHosts = properties.getProperty("ssh.knownHosts");
final String privateKey = properties.getProperty("ssh.privateKey");
username = properties.getProperty("scp.out.test.username");
hostname = "localhost";
port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
sessionFactory = new DefaultSessionFactory(username, hostname, port);
try {
sessionFactory.setKnownHosts(knownHosts);
sessionFactory.setIdentityFromPrivateKey(privateKey);
} catch (final JSchException e) {
Assume.assumeNoException(e);
}
}
use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.
the class TunnelConnectionManagerTest method testGetTunnel.
@Test
public void testGetTunnel() {
try (final TunnelConnectionManager manager = new TunnelConnectionManager(new DefaultSessionFactory())) {
assertNotNull(manager);
final List<String> pathAndSpecList = new ArrayList<>();
pathAndSpecList.add("joe@crabshack|crab:10:imitationcrab:20");
pathAndSpecList.add("bob@redlobster|lobster:15:tail:20");
try {
manager.setTunnelConnections(pathAndSpecList);
} catch (final JSchException e) {
LOGGER.info("unable to set pathAndSpecList: ", e);
fail("unable to setPathAndSpecList: " + e.getMessage());
}
Tunnel tunnel = manager.getTunnel("imitationcrab", 20);
assertEquals("crab", tunnel.getLocalAlias());
assertEquals(10, tunnel.getLocalPort());
tunnel = manager.getTunnel("tail", 20);
assertEquals("lobster", tunnel.getLocalAlias());
assertEquals(15, tunnel.getLocalPort());
} catch (final JSchException e) {
LOGGER.info("unable to create TunnelConnectionManager: ", e);
fail("unable to create TunnelConnectionManager: " + e.getMessage());
}
}
Aggregations