aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2019-06-27 19:55:29 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-06-28 08:06:35 +0200
commitc7edda1dd3554ff634f61cbf194a1379bbad1443 (patch)
treebc372808218b832c24c08cbd3b5f1096648204ca
parent17999bb7b5d965851ed3d8f306c88588474e1a27 (diff)
downloadlibssh-c7edda1dd3554ff634f61cbf194a1379bbad1443.tar.gz
libssh-c7edda1dd3554ff634f61cbf194a1379bbad1443.tar.xz
libssh-c7edda1dd3554ff634f61cbf194a1379bbad1443.zip
tests: Added a check for unaccessible global known_hosts
Verify that the check process will not fail if the global known_hosts file is not accessible and the local known_hosts file contain the host. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 8e42ed82201f4c42dcbc0726a2304d8ab69179dc)
-rw-r--r--tests/unittests/torture_knownhosts_parsing.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/unittests/torture_knownhosts_parsing.c b/tests/unittests/torture_knownhosts_parsing.c
index c80bdbca..ac8d7f31 100644
--- a/tests/unittests/torture_knownhosts_parsing.c
+++ b/tests/unittests/torture_knownhosts_parsing.c
@@ -381,6 +381,7 @@ static void torture_knownhosts_host_exists(void **state)
ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
ssh_options_set(session, SSH_OPTIONS_KNOWNHOSTS, knownhosts_file);
+
/* This makes sure the system's known_hosts are not used */
ssh_options_set(session, SSH_OPTIONS_GLOBAL_KNOWNHOSTS, "/dev/null");
@@ -388,6 +389,14 @@ static void torture_knownhosts_host_exists(void **state)
assert_int_equal(found, SSH_KNOWN_HOSTS_OK);
assert_true(found == SSH_KNOWN_HOSTS_OK);
+ /* This makes sure the check will not fail when the system's known_hosts is
+ * not accessible*/
+ ssh_options_set(session, SSH_OPTIONS_GLOBAL_KNOWNHOSTS, "./unaccessible");
+
+ found = ssh_session_has_known_hosts_entry(session);
+ assert_int_equal(found, SSH_KNOWN_HOSTS_OK);
+ assert_true(found == SSH_KNOWN_HOSTS_OK);
+
ssh_options_set(session, SSH_OPTIONS_HOST, "wurstbrot");
found = ssh_session_has_known_hosts_entry(session);
assert_true(found == SSH_KNOWN_HOSTS_UNKNOWN);