tests: Adjust test that require complete config re-parsing
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
de7405f1c7
Коммит
9aa47fef99
@ -287,6 +287,7 @@ static void torture_config_auth_methods(void **state) {
|
|||||||
assert_int_equal(session->opts.flags, 0);
|
assert_int_equal(session->opts.flags, 0);
|
||||||
|
|
||||||
/* gradually enable them again */
|
/* gradually enable them again */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "gss");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "gss");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG8);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG8);
|
||||||
assert_true(ret == 0);
|
assert_true(ret == 0);
|
||||||
@ -341,29 +342,34 @@ static void torture_config_match(void **state)
|
|||||||
assert_string_equal(session->opts.host, "all-matched.com");
|
assert_string_equal(session->opts.host, "all-matched.com");
|
||||||
|
|
||||||
/* Hostname example does simple hostname matching */
|
/* Hostname example does simple hostname matching */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "example");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "example");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
||||||
assert_true(ret == 0);
|
assert_true(ret == 0);
|
||||||
assert_string_equal(session->opts.host, "example.com");
|
assert_string_equal(session->opts.host, "example.com");
|
||||||
|
|
||||||
/* We can match also both hosts from a comma separated list */
|
/* We can match also both hosts from a comma separated list */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "example1");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "example1");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
||||||
assert_true(ret == 0);
|
assert_true(ret == 0);
|
||||||
assert_string_equal(session->opts.host, "exampleN");
|
assert_string_equal(session->opts.host, "exampleN");
|
||||||
|
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "example2");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "example2");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
||||||
assert_true(ret == 0);
|
assert_true(ret == 0);
|
||||||
assert_string_equal(session->opts.host, "exampleN");
|
assert_string_equal(session->opts.host, "exampleN");
|
||||||
|
|
||||||
/* We can match by user */
|
/* We can match by user */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_USER, "guest");
|
ssh_options_set(session, SSH_OPTIONS_USER, "guest");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
||||||
assert_true(ret == 0);
|
assert_true(ret == 0);
|
||||||
assert_string_equal(session->opts.host, "guest.com");
|
assert_string_equal(session->opts.host, "guest.com");
|
||||||
|
|
||||||
/* We can combine two options on a single line to match both of them */
|
/* We can combine two options on a single line to match both of them */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_USER, "tester");
|
ssh_options_set(session, SSH_OPTIONS_USER, "tester");
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
||||||
@ -371,6 +377,7 @@ static void torture_config_match(void **state)
|
|||||||
assert_string_equal(session->opts.host, "testhost.com");
|
assert_string_equal(session->opts.host, "testhost.com");
|
||||||
|
|
||||||
/* We can also negate conditions */
|
/* We can also negate conditions */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_USER, "not-tester");
|
ssh_options_set(session, SSH_OPTIONS_USER, "not-tester");
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost");
|
||||||
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
ret = ssh_config_parse_file(session, LIBSSH_TESTCONFIG10);
|
||||||
|
@ -451,22 +451,26 @@ static void torture_options_config_host(void **state) {
|
|||||||
|
|
||||||
assert_int_equal(session->opts.port, 42);
|
assert_int_equal(session->opts.port, 42);
|
||||||
|
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost2");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost2");
|
||||||
ssh_options_parse_config(session, "test_config");
|
ssh_options_parse_config(session, "test_config");
|
||||||
assert_int_equal(session->opts.port, 43);
|
assert_int_equal(session->opts.port, 43);
|
||||||
|
|
||||||
session->opts.port = 0;
|
session->opts.port = 0;
|
||||||
|
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost3");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost3");
|
||||||
ssh_options_parse_config(session, "test_config");
|
ssh_options_parse_config(session, "test_config");
|
||||||
assert_int_equal(session->opts.port, 43);
|
assert_int_equal(session->opts.port, 43);
|
||||||
|
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost4");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost4");
|
||||||
ssh_options_parse_config(session, "test_config");
|
ssh_options_parse_config(session, "test_config");
|
||||||
assert_int_equal(session->opts.port, 44);
|
assert_int_equal(session->opts.port, 44);
|
||||||
|
|
||||||
session->opts.port = 0;
|
session->opts.port = 0;
|
||||||
|
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost5");
|
ssh_options_set(session, SSH_OPTIONS_HOST, "testhost5");
|
||||||
ssh_options_parse_config(session, "test_config");
|
ssh_options_parse_config(session, "test_config");
|
||||||
assert_int_equal(session->opts.port, 44);
|
assert_int_equal(session->opts.port, 44);
|
||||||
@ -494,6 +498,7 @@ static void torture_options_config_match(void **state)
|
|||||||
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
||||||
|
|
||||||
/* The Match all keyword needs to be the only one (start) */
|
/* The Match all keyword needs to be the only one (start) */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match all host local\n",
|
fputs("Match all host local\n",
|
||||||
@ -504,6 +509,7 @@ static void torture_options_config_match(void **state)
|
|||||||
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
||||||
|
|
||||||
/* The Match all keyword needs to be the only one (end) */
|
/* The Match all keyword needs to be the only one (end) */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match host local all\n",
|
fputs("Match host local all\n",
|
||||||
@ -514,6 +520,7 @@ static void torture_options_config_match(void **state)
|
|||||||
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
||||||
|
|
||||||
/* The Match host keyword requires an argument */
|
/* The Match host keyword requires an argument */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match host\n",
|
fputs("Match host\n",
|
||||||
@ -524,6 +531,7 @@ static void torture_options_config_match(void **state)
|
|||||||
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
||||||
|
|
||||||
/* The Match user keyword requires an argument */
|
/* The Match user keyword requires an argument */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match user\n",
|
fputs("Match user\n",
|
||||||
@ -534,6 +542,7 @@ static void torture_options_config_match(void **state)
|
|||||||
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
assert_ssh_return_code_equal(session, rv, SSH_ERROR);
|
||||||
|
|
||||||
/* The Match canonical keyword is ignored */
|
/* The Match canonical keyword is ignored */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match canonical\n"
|
fputs("Match canonical\n"
|
||||||
@ -550,6 +559,7 @@ static void torture_options_config_match(void **state)
|
|||||||
session->opts.port = 0;
|
session->opts.port = 0;
|
||||||
|
|
||||||
/* The Match originalhost keyword is ignored */
|
/* The Match originalhost keyword is ignored */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match originalhost origin\n"
|
fputs("Match originalhost origin\n"
|
||||||
@ -566,6 +576,7 @@ static void torture_options_config_match(void **state)
|
|||||||
session->opts.port = 0;
|
session->opts.port = 0;
|
||||||
|
|
||||||
/* The Match localuser keyword is ignored */
|
/* The Match localuser keyword is ignored */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match originalhost origin\n"
|
fputs("Match originalhost origin\n"
|
||||||
@ -582,6 +593,7 @@ static void torture_options_config_match(void **state)
|
|||||||
session->opts.port = 0;
|
session->opts.port = 0;
|
||||||
|
|
||||||
/* The Match exec keyword is ignored */
|
/* The Match exec keyword is ignored */
|
||||||
|
SAFE_FREE(session->opts.options_seen);
|
||||||
config = fopen("test_config", "w");
|
config = fopen("test_config", "w");
|
||||||
assert_non_null(config);
|
assert_non_null(config);
|
||||||
fputs("Match exec /bin/true\n"
|
fputs("Match exec /bin/true\n"
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user