diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c index f91112a9..3a5a74bf 100644 --- a/tests/unittests/torture_config.c +++ b/tests/unittests/torture_config.c @@ -671,6 +671,32 @@ static void torture_config_proxyjump(void **state) { assert_string_equal(session->opts.ProxyCommand, "ssh -W [%h]:%p 2620:52:0::fed"); + /* Multiple @ is allowed in second jump */ + torture_write_file(LIBSSH_TESTCONFIG11, + "Host allowed-hostname\n" + "\tProxyJump localhost,user@principal.com@jumpbox:22\n" + ""); + torture_reset_config(session); + ssh_options_set(session, SSH_OPTIONS_HOST, "allowed-hostname"); + ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG11); + assert_ssh_return_code(session, ret); + assert_string_equal(session->opts.ProxyCommand, + "ssh -J user@principal.com@jumpbox:22 -W [%h]:%p localhost"); + + /* Multiple @ is allowed */ + torture_write_file(LIBSSH_TESTCONFIG11, + "Host allowed-hostname\n" + "\tProxyJump user@principal.com@jumpbox:22\n" + ""); + torture_reset_config(session); + ssh_options_set(session, SSH_OPTIONS_HOST, "allowed-hostname"); + ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG11); + assert_ssh_return_code(session, ret); + assert_string_equal(session->opts.ProxyCommand, + "ssh -l user@principal.com -p 22 -W [%h]:%p jumpbox"); + + /* In this part, we try various other config files and strings. */ + /* Try to create some invalid configurations */ /* Non-numeric port */ torture_write_file(LIBSSH_TESTCONFIG11, @@ -682,16 +708,6 @@ static void torture_config_proxyjump(void **state) { ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG11); assert_ssh_return_code_equal(session, ret, SSH_ERROR); - /* Too many @ */ - torture_write_file(LIBSSH_TESTCONFIG11, - "Host bad-hostname\n" - "\tProxyJump user@principal.com@jumpbox:22\n" - ""); - torture_reset_config(session); - ssh_options_set(session, SSH_OPTIONS_HOST, "bad-hostname"); - ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG11); - assert_ssh_return_code_equal(session, ret, SSH_ERROR); - /* Braces mismatch in hostname */ torture_write_file(LIBSSH_TESTCONFIG11, "Host mismatch\n" @@ -752,16 +768,6 @@ static void torture_config_proxyjump(void **state) { ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG11); assert_ssh_return_code_equal(session, ret, SSH_ERROR); - /* Too many @ in second jump */ - torture_write_file(LIBSSH_TESTCONFIG11, - "Host bad-hostname\n" - "\tProxyJump localhost,user@principal.com@jumpbox:22\n" - ""); - torture_reset_config(session); - ssh_options_set(session, SSH_OPTIONS_HOST, "bad-hostname"); - ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG11); - assert_ssh_return_code_equal(session, ret, SSH_ERROR); - /* Braces mismatch in second jump */ torture_write_file(LIBSSH_TESTCONFIG11, "Host mismatch\n"