From 9b1852f7281e9ccf4e06fe855d42aa6db5ad6577 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 3 Dec 2018 16:45:25 +0100 Subject: [PATCH] tests: Verify ProxyCommand works with ssh Signed-off-by: Jakub Jelen Reviewed-by: Andreas Schneider --- tests/client/torture_proxycommand.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/client/torture_proxycommand.c b/tests/client/torture_proxycommand.c index a72a2eb6..a1fb35c2 100644 --- a/tests/client/torture_proxycommand.c +++ b/tests/client/torture_proxycommand.c @@ -93,6 +93,28 @@ static void torture_options_set_proxycommand_notexist(void **state) { assert_ssh_return_code_equal(session, rc, SSH_ERROR); } +static void torture_options_set_proxycommand_ssh(void **state) +{ + struct torture_state *s = *state; + ssh_session session = s->ssh.session; + const char *address = torture_server_address(AF_INET); + char command[255] = {0}; + int rc; + socket_t fd; + + rc = snprintf(command, sizeof(command), "ssh -W [%%h]:%%p alice@%s", address); + assert_true((size_t)rc < sizeof(command)); + + rc = ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, command); + assert_int_equal(rc, 0); + rc = ssh_connect(session); + assert_ssh_return_code(session, rc); + fd = ssh_get_fd(session); + assert_true(fd != SSH_INVALID_SOCKET); + rc = fcntl(fd, F_GETFL); + assert_int_equal(rc & O_RDWR, O_RDWR); +} + int torture_run_tests(void) { int rc; struct CMUnitTest tests[] = { @@ -102,6 +124,9 @@ int torture_run_tests(void) { cmocka_unit_test_setup_teardown(torture_options_set_proxycommand_notexist, session_setup, session_teardown), + cmocka_unit_test_setup_teardown(torture_options_set_proxycommand_ssh, + session_setup, + session_teardown), };