aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/unittests/torture_config.c44
-rw-r--r--tests/unittests/torture_options.c21
2 files changed, 61 insertions, 4 deletions
diff --git a/tests/unittests/torture_config.c b/tests/unittests/torture_config.c
index beb1ce79..7efa32db 100644
--- a/tests/unittests/torture_config.c
+++ b/tests/unittests/torture_config.c
@@ -547,6 +547,48 @@ static void torture_config_match(void **state)
assert_ssh_return_code(session, ret);
assert_string_equal(session->opts.host, "otherhost");
+ torture_write_file(LIBSSH_TESTCONFIG10,
+ "Match exec /bin/true\n"
+ "\tHostName execed-true.com\n"
+ "");
+ torture_reset_config(session);
+ ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
+ assert_ssh_return_code(session, ret);
+#ifdef _WIN32
+ /* The match exec is not supported on windows at this moment */
+ assert_string_equal(session->opts.host, "otherhost");
+#else
+ assert_string_equal(session->opts.host, "execed-true.com");
+#endif
+
+ torture_write_file(LIBSSH_TESTCONFIG10,
+ "Match !exec /bin/false\n"
+ "\tHostName execed-false.com\n"
+ "");
+ torture_reset_config(session);
+ ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
+ assert_ssh_return_code(session, ret);
+#ifdef _WIN32
+ /* The match exec is not supported on windows at this moment */
+ assert_string_equal(session->opts.host, "otherhost");
+#else
+ assert_string_equal(session->opts.host, "execed-false.com");
+#endif
+
+ torture_write_file(LIBSSH_TESTCONFIG10,
+ "Match exec \"test -f /bin/true\"\n"
+ "\tHostName execed-arguments.com\n"
+ "");
+ torture_reset_config(session);
+ ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
+ assert_ssh_return_code(session, ret);
+#ifdef _WIN32
+ /* The match exec is not supported on windows at this moment */
+ assert_string_equal(session->opts.host, "otherhost");
+#else
+ assert_string_equal(session->opts.host, "execed-arguments.com");
+#endif
+
/* Try to create some invalid configurations */
/* Missing argument to Match*/
torture_write_file(LIBSSH_TESTCONFIG10,
@@ -593,7 +635,7 @@ static void torture_config_match(void **state)
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
assert_ssh_return_code_equal(session, ret, SSH_ERROR);
- /* Missing argument to unsupported option exec */
+ /* Missing argument to option exec */
torture_write_file(LIBSSH_TESTCONFIG10,
"Match exec\n"
"\tUser exec\n"
diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c
index 396772d8..f33ada20 100644
--- a/tests/unittests/torture_options.c
+++ b/tests/unittests/torture_options.c
@@ -688,7 +688,7 @@ static void torture_options_config_match(void **state)
session->opts.port = 0;
- /* The Match exec keyword is ignored */
+ /* The Match exec keyword */
torture_reset_config(session);
config = fopen("test_config", "w");
assert_non_null(config);
@@ -701,15 +701,20 @@ static void torture_options_config_match(void **state)
rv = ssh_options_parse_config(session, "test_config");
assert_ssh_return_code(session, rv);
+#ifdef _WIN32
+ /* The match exec is not supported on windows at this moment */
assert_int_equal(session->opts.port, 34);
+#else
+ assert_int_equal(session->opts.port, 33);
+#endif
session->opts.port = 0;
- /* The Match exec keyword can accept more arguments */
+ /* Commands containing whitespace characters must be quoted. */
torture_reset_config(session);
config = fopen("test_config", "w");
assert_non_null(config);
- fputs("Match exec /bin/true 1 \n"
+ fputs("Match exec \"/bin/true 1\"\n"
"\tPort 33\n"
"Match all\n"
"\tPort 34\n",
@@ -718,7 +723,12 @@ static void torture_options_config_match(void **state)
rv = ssh_options_parse_config(session, "test_config");
assert_ssh_return_code(session, rv);
+#ifdef _WIN32
+ /* The match exec is not supported on windows at this moment */
assert_int_equal(session->opts.port, 34);
+#else
+ assert_int_equal(session->opts.port, 33);
+#endif
session->opts.port = 0;
@@ -735,7 +745,12 @@ static void torture_options_config_match(void **state)
rv = ssh_options_parse_config(session, "test_config");
assert_ssh_return_code(session, rv);
+#ifdef _WIN32
+ /* The match exec is not supported on windows at this moment */
assert_int_equal(session->opts.port, 34);
+#else
+ assert_int_equal(session->opts.port, 33);
+#endif
session->opts.port = 0;