channel.setOut(new NoCloseOutputStream(System.out)); channel.setErr(new NoCloseOutputStream(System.err)); WaitableFuture wf = channel.open(); wf.await();
channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
channel.setOut( AnsiConsole.wrapOutputStream(sout)); channel.setErr( AnsiConsole.wrapOutputStream(serr)); channel.open(); channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
OpenFuture openFuture = channel.open(); openFuture.await(configuration.getTimeout()); SshResult result = null;
channel.setOut(channelOut); channel.setErr(channelErr); channel.open().await(); // TODO use verify and a configurable timeout
channel.setOut(channelOut); channel.setErr(channelErr); channel.open().await(); // TODO use verify and a configurable timeout
@Test public void testShellClosedOnClientTimeout() throws Exception { TestEchoShell.latch = new CountDownLatch(1); SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(err); channel.open().verify(9L, TimeUnit.SECONDS); assertTrue("Latch time out", TestEchoShell.latch.await(10L, TimeUnit.SECONDS)); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll( EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.OPENED))); } } finally { TestEchoShell.latch = null; client.stop(); } }
channel.open().verify(9L, TimeUnit.SECONDS); try (OutputStream pipedIn = channel.getInvertedIn()) { msg += "\nexit\n";
channel.open().verify(9L, TimeUnit.SECONDS); try (OutputStream pipedIn = channel.getInvertedIn()) { msg += "\nexit\n";
channel.open().verify(9L, TimeUnit.SECONDS); try (OutputStream pipedIn = channel.getInvertedIn()) { msg += "\nexit\n";
@Test public void testShellClosedOnClientTimeout() throws Exception { TestEchoShell.latch = new CountDownLatch(1); SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(err); channel.open().verify(9L, TimeUnit.SECONDS); assertTrue("Latch time out", TestEchoShell.latch.await(10L, TimeUnit.SECONDS)); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll( EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.OPENED))); } } finally { TestEchoShell.latch = null; client.stop(); } }
@Test public void testShellClosedOnClientTimeout() throws Exception { TestEchoShell.latch = new CountDownLatch(1); SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream()) { channel.setOut(out); channel.setErr(err); channel.open().verify(9L, TimeUnit.SECONDS); assertTrue("Latch time out", TestEchoShell.latch.await(10L, TimeUnit.SECONDS)); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll( EnumSet.of(ClientChannelEvent.CLOSED, ClientChannelEvent.OPENED))); } } finally { TestEchoShell.latch = null; client.stop(); } }
@Test(timeout = 6L * 60L * 1000L) public void testTrafficHeavyLoad() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (final ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); try (final ClientChannel channel = session.createShellChannel()) { channel.setOut(new VerifyingOutputStream(channel, END_FILE)); channel.setErr(new NoCloseOutputStream(System.err)); channel.open().verify(15L, TimeUnit.SECONDS); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.MINUTES.toMillis(2L)); assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } } finally { client.stop(); } } }
@Test(timeout = 6L * 60L * 1000L) public void testTrafficHeavyLoad() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (final ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); try (final ClientChannel channel = session.createShellChannel()) { channel.setOut(new VerifyingOutputStream(channel, END_FILE)); channel.setErr(new NoCloseOutputStream(System.err)); channel.open().verify(15L, TimeUnit.SECONDS); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.MINUTES.toMillis(2L)); assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } } finally { client.stop(); } } }
@Test(timeout = 6L * 60L * 1000L) public void testTrafficHeavyLoad() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (final ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); try (final ClientChannel channel = session.createShellChannel()) { channel.setOut(new VerifyingOutputStream(channel, END_FILE)); channel.setErr(new NoCloseOutputStream(System.err)); channel.open().verify(15L, TimeUnit.SECONDS); Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.MINUTES.toMillis(2L)); assertFalse("Timeout while waiting for channel closure", result.contains(ClientChannelEvent.TIMEOUT)); } } finally { client.stop(); } } }
@Test public void testSwitchToNoneCipher() throws Exception { setUp(0L, 0L, 0L); sshd.getCipherFactories().add(BuiltinCiphers.none); try (SshClient client = setupTestClient()) { client.getCipherFactories().add(BuiltinCiphers.none); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); outputDebugMessage("Request switch to none cipher for %s", session); KeyExchangeFuture switchFuture = session.switchToNoneCipher(); switchFuture.verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createSubsystemChannel(SftpConstants.SFTP_SUBSYSTEM_NAME)) { channel.open().verify(5L, TimeUnit.SECONDS); } } finally { client.stop(); } } }
@Test public void testSwitchToNoneCipher() throws Exception { setUp(0L, 0L, 0L); sshd.getCipherFactories().add(BuiltinCiphers.none); try (SshClient client = setupTestClient()) { client.getCipherFactories().add(BuiltinCiphers.none); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); outputDebugMessage("Request switch to none cipher for %s", session); KeyExchangeFuture switchFuture = session.switchToNoneCipher(); switchFuture.verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createSubsystemChannel(SftpConstants.SFTP_SUBSYSTEM_NAME)) { channel.open().verify(5L, TimeUnit.SECONDS); } } finally { client.stop(); } } }
@Test public void testSwitchToNoneCipher() throws Exception { setUp(0L, 0L, 0L); sshd.getCipherFactories().add(BuiltinCiphers.none); try (SshClient client = setupTestClient()) { client.getCipherFactories().add(BuiltinCiphers.none); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); outputDebugMessage("Request switch to none cipher for %s", session); KeyExchangeFuture switchFuture = session.switchToNoneCipher(); switchFuture.verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createSubsystemChannel(SftpConstants.SFTP_SUBSYSTEM_NAME)) { channel.open().verify(5L, TimeUnit.SECONDS); } } finally { client.stop(); } } }