From 08298404af816c812c9cf8ca74b8afa32e72c605 Mon Sep 17 00:00:00 2001 From: roman Date: Thu, 26 Oct 2023 14:51:44 +0200 Subject: [PATCH] tests UPDATE add back client tests --- tests/CMakeLists.txt | 19 +-- tests/client/test_client.c | 141 ------------------ tests/{client => }/test_client_messages.c | 0 tests/{client => }/test_client_ssh.c | 168 ++-------------------- tests/{client => }/test_client_tls.c | 0 5 files changed, 12 insertions(+), 316 deletions(-) delete mode 100644 tests/client/test_client.c rename tests/{client => }/test_client_messages.c (100%) rename tests/{client => }/test_client_ssh.c (65%) rename tests/{client => }/test_client_tls.c (100%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b3e75485..3b3a4088 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,15 +8,14 @@ if(${SOURCE_FORMAT_ENABLED}) endif() # list of all the tests that don't require SSH and TLS -set(tests test_unix_socket test_client_thread test_fd_comm test_init_destroy_client test_init_destroy_server test_io test_thread_messages) +set(tests test_unix_socket test_client_thread test_fd_comm test_init_destroy_client test_init_destroy_server + test_io test_thread_messages test_client_messages test_client_ssh test_client_tls) # only enable PAM tests if the version of PAM is greater than 1.4 if(LIBPAM_HAVE_CONFDIR) list(APPEND tests test_auth) endif() -# set(client_tests test_client test_client_messages) - # add -Wl,--wrap flags set(test test_client_ssh) set(${test}_mock_funcs connect ssh_connect ssh_userauth_none ssh_userauth_kbdint ssh_is_connected @@ -55,31 +54,17 @@ foreach(test_name IN LISTS tests) add_test(NAME ${test_name} COMMAND $) endforeach() -# foreach(test_name IN LISTS client_tests) -# add_executable(${test_name} $ ./client/${test_name}.c) -# target_link_libraries(${test_name} ${CMOCKA_LIBRARIES} ${LIBYANG_LIBRARIES} netconf2) -# target_include_directories(${test_name} PRIVATE ${CMOCKA_INCLUDE_DIR}) -# set_target_properties(${test_name} PROPERTIES LINK_FLAGS "${${test_name}_wrap_link_flags}") -# add_test(NAME ${test_name} COMMAND $) -# endforeach() - if(ENABLE_VALGRIND_TESTS) foreach(test_name IN LISTS tests) add_test(${test_name}_valgrind valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 --suppressions=${PROJECT_SOURCE_DIR}/tests/library_valgrind.supp ${CMAKE_BINARY_DIR}/tests/${test_name}) endforeach() - - # foreach(test_name IN LISTS client_tests) - # add_test(${test_name}_valgrind valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 - # --suppressions=${PROJECT_SOURCE_DIR}/tests/library_valgrind.supp ${CMAKE_BINARY_DIR}/tests/${test_name}) - # endforeach() endif() include_directories(${CMAKE_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}) configure_file("${PROJECT_SOURCE_DIR}/tests/config.h.in" "${PROJECT_BINARY_DIR}/tests/config.h" ESCAPE_QUOTES @ONLY) if(LIBPAM_HAVE_CONFDIR) - #compile PAM test module add_library(pam_netconf SHARED ${CMAKE_SOURCE_DIR}/tests/pam/pam_netconf.c) set_target_properties(pam_netconf PROPERTIES PREFIX "") diff --git a/tests/client/test_client.c b/tests/client/test_client.c deleted file mode 100644 index 722d0bf1..00000000 --- a/tests/client/test_client.c +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file test_client.c - * @author David Sedlák - * @brief client test - * - * Copyright (c) 2018 CESNET, z.s.p.o. - * - * This source code is licensed under BSD 3-Clause License (the "License"). - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "tests/config.h" - -static int -setup_f(void **state) -{ - (void)state; - - nc_verbosity(NC_VERB_VERBOSE); - - return 0; -} - -static int -teardown_f(void **state) -{ - (void)state; - - return 0; -} - -static void -test_nc_client_setting_schema_searchpath(void **state) -{ - (void)state; - const char *path; - int ret; - - /* initiate client */ - nc_client_init(); - - path = nc_client_get_schema_searchpath(); - assert_null(path); - - ret = nc_client_set_schema_searchpath("path"); - assert_int_equal(ret, 0); - path = nc_client_get_schema_searchpath(); - assert_string_equal(path, "path"); - - ret = nc_client_set_schema_searchpath("path1"); - assert_int_equal(ret, 0); - path = nc_client_get_schema_searchpath(); - assert_string_equal(path, "path1"); -} - -LY_ERR -test_clb(const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data, - LYS_INFORMAT *format, const char **model_data, void (**free_module_data)(void *model_data, void *user_data)) -{ - (void)mod_name; - (void)mod_rev; - (void)submod_name; - (void)sub_rev; - (void)user_data; - (void)format; - (void)model_data; - (void)free_module_data; - - return LY_SUCCESS; -} - -LY_ERR -test_clb1(const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data, - LYS_INFORMAT *format, const char **model_data, void (**free_module_data)(void *model_data, void *user_data)) -{ - (void)mod_name; - (void)mod_rev; - (void)submod_name; - (void)sub_rev; - (void)user_data; - (void)format; - (void)model_data; - (void)free_module_data; - - return LY_SUCCESS; -} - -static void -test_nc_client_setting_schema_callback(void **state) -{ - (void)state; - ly_module_imp_clb ret_f; - char *data_ret; - int ret; - - ret_f = nc_client_get_schema_callback((void **)&data_ret); - assert_null(ret_f); - assert_null(data_ret); - - ret = nc_client_set_schema_callback(test_clb, "DATA"); - assert_int_equal(ret, 0); - ret_f = nc_client_get_schema_callback((void **)&data_ret); - assert_ptr_equal(test_clb, ret_f); - assert_string_equal("DATA", data_ret); - - ret = nc_client_set_schema_callback(test_clb1, "DATA1"); - assert_int_equal(ret, 0); - ret_f = nc_client_get_schema_callback((void **)&data_ret); - assert_ptr_equal(test_clb1, ret_f); - assert_string_equal("DATA1", data_ret); - - /* destroy client */ - nc_client_destroy(); -} - -int -main(void) -{ - const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(test_nc_client_setting_schema_searchpath, setup_f, teardown_f), - cmocka_unit_test_setup_teardown(test_nc_client_setting_schema_callback, setup_f, teardown_f), - }; - - return cmocka_run_group_tests(tests, NULL, NULL); -} diff --git a/tests/client/test_client_messages.c b/tests/test_client_messages.c similarity index 100% rename from tests/client/test_client_messages.c rename to tests/test_client_messages.c diff --git a/tests/client/test_client_ssh.c b/tests/test_client_ssh.c similarity index 65% rename from tests/client/test_client_ssh.c rename to tests/test_client_ssh.c index 0a66e597..b8fa940f 100644 --- a/tests/client/test_client_ssh.c +++ b/tests/test_client_ssh.c @@ -25,78 +25,15 @@ #include #include #include -#include #include #include #include -#include #include "tests/config.h" #include #include #include -const char *data = - "\n" - " \n" - " 10\n" - " \n" - " default-ssh\n" - " \n" - " \n" - " 127.0.0.1\n" - " 10005\n" - " \n" - " \n" - " \n" - " \n" - " key\n" - " \n" - " \n" - " ct:ssh-public-key-format\n" - " MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA6ojtjfDmvyQP1ZkIwBpr97eKDuebvpoglRHRdvVuTpf/gU1VArAQmwGh05i6lm8TkVl1noMlIxLJDcWslaeVn6KyvsX0HhsQtXwqPqwka5UCv6alwf/ivAvcNpcX1j0t/uIGCI4dSiKnzQCyf0FTirzQkjrDZUd3meDhNQTruCalGV4gfNWIq3e1oGuwAn1tLlu9oTrE4HzMpgbNEU6wNmsSqpwGxUhYLoSaM7b0dLmqP+ZczSS0Uac0PFNkehGQ2CYIT80f580o4XGtoLCUUGkp6YCTL4Z2CeBEaJABWjDIDH+dKYIUBqUpz4Th12gXAP+h+3qI6+9eppeHrfrzARDsfLjwUNxQJse1QSArjAytf0FKtGHrORc7W0TiCFvR0zaoUNLTKk7enTiRQ9rfWZOAu44fUvPCaXDE6zXXeaVgoKCo4VHlho36erUcjlEBM+jk28IykbZGtBb6igKvYa1tPSgeYm/zJoFVjQcnr14uci/ft1+Na+hOIEoEEiKxcAPk2b2vBKNlRIW7WLJ3u7ZiuQEJTNm6+3cE4+lfwaBCBqBToE+dpzvoUXoMyFFReUFd1O5axu4fXgt00jMaOQxmE0v9OmR/pL/PWIflVF4Zz5yVONYaDVc7l+veY0oEZruEPJ0hlEgxuCzLrcMhjufl2qE2Q7fQIaav/1NqBVkCAw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2nDcOjF4GhbtHum15yCPaw5QVs/33nuPWze4ZLXReKk9p0mTh5V0p+N3IvGlXl+uzEVu5d55eI7LIw5sLymHmwjWjxvimiMtrzLbCHSPHGc5JU9NLUH9/bBY/JxGpy+NzcsHHOOQTwTdRIjviIOAo7fgQn2RyX0k+zXE8/7zqjqvji9zyemdNu8we4uJICSntyvJwkbj/hrufTKEnBrwXpzfVn1EsH+6w32ZPBGLUhT75txJ8r56SRq7l1XPU9vxovmT+lSMFF/Y0j1MbHWnds5H1shoFPNtYTvWBL/gfPHjIc+H23zsiu3XlZAoIBAC2xB/Pnpoi9vOUMiqFH36AXtYa1DURy+AqCFlYlClMvb7YgvQ1w1eJvnwrHSLk7HdKhnwGsLPduuRRH8q0n/osnoOutSQroE0n41UyIv2ZNccRwNmSzQcairBu2dSz02hlsh2otNl5IuGpOqXyPjXBpW4qGD6n2tH7THALnLC0BHtTSQVQsJsRM3gX39LoiWvLDp2qJvplm6rTpi8Rgap6rZSqHe1yNKIxxD2vlr/WY9SMgLXYASO4SSBz9wfGOmQIPk6KXNJkdV4kC7nNjIi75iwLLCgjHgUiHTrDq5sWekpeNnUoWsinbTsdsjnv3zHG9GyiClyLGxMbs4M5eyYECggEBAKuC8ZMpdIrjk6tERYB6g0LnQ7mW8XYbDFAmLYMLs9yfG2jcjVbsW9Kugsr+3poUUv/q+hNO3jfY4HazhZDa0MalgNPoSwr/VNRnkck40x2ovFb989J7yl++zTrnIrax9XRH1V0cNu+Kj7OMwZ2RRfbNv5JBdOZPvkfqyIKFmbQgYbtD66rHuzNOfJpzqr/WVLO57/zzW8245NKG2B6B0oXkei/KqDY0DAbHR3i3EOj1NPtVI1FC/xX8R9BREaid458bqoHJKuInrGcBjaUI9Cvymv8TbstUgD6NPbJR4Sm6vrLeUqzjWZP3t1+Z6DjXmnpR2vvhMU/FWb//21p/88o=\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " test\n" - " \n" - " \n" - " \n" - " client\n" - " ct:ssh-public-key-format\n" - " AAAAB3NzaC1yc2EAAAADAQABAAABAQDPavVALiM7QwTIUAndO8E9GOkSDQWjuEwkzbJ3kOBPa7kkq71UOZFeecDjFb9eipkljfFys/JYHGQaYVF8/svT0KV5h7HlutRdF6yvqSEbjpbTORb27pdHX3iFEyDCwCIoq9vMeX+wyXnteyn01GpIL0ig0WAnvkqX/SPjuplX5ZItUSr0MhXM7fNSX50BD6G8IO0/djUcdMUcjTjGv73SxB9ZzLvxnhXuUJbzEJJJLj6qajyEIVaJSa73vA33JCD8qzarrsuITojVLPDFmeHwSAoB5dP86yop6e6ypuXzKxxef6yNXcE8oTj8UFYBIXsgIP2nBvWk41EaK0Vk3YFl\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " sshpka:rsa-sha2-512\n" - " \n" - " \n" - " sshkea:curve25519-sha256\n" - " \n" - " \n" - " sshea:aes256-ctr\n" - " \n" - " \n" - " sshma:hmac-sha2-512\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n"; - static int setup_f(void **state) { @@ -105,10 +42,15 @@ setup_f(void **state) nc_verbosity(NC_VERB_VERBOSE); + /* init client */ + nc_client_init(); + ret = nc_client_ssh_set_username("username"); assert_int_equal(ret, 0); ret = nc_client_ssh_ch_set_username("ch_username"); assert_int_equal(ret, 0); + /* skip all hostkey and known_hosts checks */ + nc_client_ssh_set_knownhosts_mode(NC_SSH_KNOWNHOSTS_SKIP); return 0; } @@ -117,6 +59,7 @@ static int teardown_f(void **state) { (void)state; + /* destroy client */ nc_client_destroy(); return 0; } @@ -269,10 +212,11 @@ __wrap_nc_sock_listen_inet(const char *address, uint16_t port, struct nc_keepali } MOCK int -__wrap_nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, int timeout, char **host, uint16_t *port, uint16_t *idx) +__wrap_nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, pthread_mutex_t *bind_lock, int timeout, char **host, uint16_t *port, uint16_t *idx) { (void)binds; (void)bind_count; + (void)bind_lock; (void)timeout; (void)host; (void)port; @@ -293,25 +237,6 @@ __wrap_nc_accept_callhome_ssh_sock(int sock, const char *host, uint16_t port, st return mock_ptr_type(struct nc_session *); } -static void -test_nc_client_ssh_setting_auth_hostkey_check_clb(void **state) -{ - (void)state; - // int (*ret_f)(const char *hostname, ssh_session session, void *priv); - // char *priv_data_ret; - - /// * ssh_hostkey_check_clb is set in setup_f */ - // nc_client_ssh_get_auth_hostkey_check_clb(&ret_f, (void **)&priv_data_ret); - // assert_ptr_equal(ret_f, ssh_hostkey_check_clb); - // assert_null(priv_data_ret); - - /// * set different callback and private data */ - // nc_client_ssh_set_auth_hostkey_check_clb(test_hostkey_clb, "DATA"); - // nc_client_ssh_get_auth_hostkey_check_clb(&ret_f, (void **)&priv_data_ret); - // assert_ptr_equal(ret_f, test_hostkey_clb); - // assert_string_equal(priv_data_ret, "DATA"); -} - char * test_pwd_clb1(const char *username, const char *hostname, void *priv) { @@ -501,9 +426,6 @@ test_nc_client_ssh_setting_auth_pref(void **state) (void)state; int ret; - /* initiate client, must be called in first test */ - nc_client_init(); - /* check default prefference settings according to documentation */ ret = nc_client_ssh_get_auth_pref(NC_SSH_AUTH_INTERACTIVE); assert_int_equal(ret, 1); @@ -638,57 +560,11 @@ test_nc_connect_ssh_password_succesfull(void **state) nc_session_free(session, NULL); } -static void -test_nc_connect_ssh_pubkey_ecdsa_succesfull(void **state) -{ - (void)state; - struct nc_session *session; - int ret = 0; - - /* set authentication method to use password authentication */ - nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PASSWORD, -1); - nc_client_ssh_set_auth_pref(NC_SSH_AUTH_PUBLICKEY, 1); - nc_client_ssh_set_auth_pref(NC_SSH_AUTH_INTERACTIVE, -1); - - /* add keypair for authentication */ - ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_ecdsa.pub", TESTS_DIR "/data/key_ecdsa"); - assert_int_equal(ret, 0); - - /* fake succesfull connection */ - will_return(__wrap_connect, 0); - will_return(__wrap_ssh_connect, 0); - /* do not authenticate using no authentication method */ - will_return(__wrap_ssh_userauth_none, 1); - will_return(__wrap_ssh_userauth_try_publickey, 0); - will_return(__wrap_ssh_userauth_publickey, 0); - will_return(__wrap_ssh_is_connected, 1); - will_return(__wrap_ssh_channel_open_session, 0); - will_return(__wrap_ssh_channel_request_subsystem, 0); - - /* fake ssh function for recieving hello message */ - will_return(__wrap_ssh_is_connected, 1); - - will_return(__wrap_nc_handshake_io, 3); - will_return(__wrap_nc_ctx_check_and_fill, 0); - session = nc_connect_ssh("127.0.0.1", 8080, NULL); - assert_non_null(session); - - /* disconnect */ - will_return(__wrap_ssh_channel_poll_timeout, 0); - nc_session_free(session, NULL); - - /* delete the keypair */ - ret = nc_client_ssh_del_keypair(0); - assert_int_equal(ret, 0); -} - static void test_nc_connect_ssh_pubkey_succesfull(void **state) { (void)state; struct nc_session *session; - struct ly_ctx *ctx; - struct lyd_node *tree; int ret = 0; /* set authentication method to use password authentication */ @@ -697,13 +573,12 @@ test_nc_connect_ssh_pubkey_succesfull(void **state) nc_client_ssh_set_auth_pref(NC_SSH_AUTH_INTERACTIVE, -1); /* add keypair for authentication */ - ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_rsa.pub", TESTS_DIR "/data/key_rsa"); + ret = nc_client_ssh_add_keypair(TESTS_DIR "/data/key_ecdsa.pub", TESTS_DIR "/data/key_ecdsa"); assert_int_equal(ret, 0); /* fake succesfull connection */ will_return(__wrap_connect, 0); will_return(__wrap_ssh_connect, 0); - will_return(__wrap_nc_sock_listen_inet, 0); /* do not authenticate using no authentication method */ will_return(__wrap_ssh_userauth_none, 1); will_return(__wrap_ssh_userauth_try_publickey, 0); @@ -717,30 +592,12 @@ test_nc_connect_ssh_pubkey_succesfull(void **state) will_return(__wrap_nc_handshake_io, 3); will_return(__wrap_nc_ctx_check_and_fill, 0); - - ret = ly_ctx_new(MODULES_DIR, 0, &ctx); - assert_int_equal(ret, 0); - - ret = nc_server_config_load_modules(&ctx); - assert_int_equal(ret, 0); - - ret = lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_NO_STATE | LYD_PARSE_STRICT, LYD_VALIDATE_NO_STATE, &tree); - assert_int_equal(ret, 0); - - ret = nc_server_config_setup(tree); - assert_int_equal(ret, 0); - session = nc_connect_ssh("127.0.0.1", 8080, NULL); assert_non_null(session); /* disconnect */ will_return(__wrap_ssh_channel_poll_timeout, 0); - - /* free everything used */ nc_session_free(session, NULL); - lyd_free_all(tree); - nc_server_destroy(); - ly_ctx_destroy(ctx); } static void @@ -784,9 +641,6 @@ test_nc_connect_ssh_bad_hello(void **state) session = nc_connect_ssh("127.0.0.1", 8080, NULL); assert_null(session); - - /* destroy client, must be called in last test */ - nc_client_destroy(); } static void @@ -824,7 +678,7 @@ test_nc_client_ssh_ch_add_bind_listen(void **state) assert_int_equal(ret, -1); /* fake a successful CH ssh listening socket */ - will_return(__wrap_nc_sock_listen_inet, 1); + will_return(__wrap_nc_sock_listen_inet, 5); ret = nc_client_ssh_ch_add_bind_listen("127.0.0.1", 4334); assert_int_equal(ret, 0); @@ -916,7 +770,6 @@ main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test_setup_teardown(test_nc_client_ssh_setting_auth_pref, setup_f, teardown_f), - cmocka_unit_test_setup_teardown(test_nc_client_ssh_setting_auth_hostkey_check_clb, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_client_ssh_setting_auth_password_clb, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_client_ssh_setting_auth_interactive_clb, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_client_ssh_setting_auth_privkey_passphrase_clb, setup_f, teardown_f), @@ -924,7 +777,6 @@ main(void) cmocka_unit_test_setup_teardown(test_nc_client_ssh_setting_username, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_connect_ssh_interactive_succesfull, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_connect_ssh_password_succesfull, setup_f, teardown_f), - cmocka_unit_test_setup_teardown(test_nc_connect_ssh_pubkey_ecdsa_succesfull, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_connect_ssh_pubkey_succesfull, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_connect_connection_failed, setup_f, teardown_f), cmocka_unit_test_setup_teardown(test_nc_connect_ssh_bad_hello, setup_f, teardown_f), diff --git a/tests/client/test_client_tls.c b/tests/test_client_tls.c similarity index 100% rename from tests/client/test_client_tls.c rename to tests/test_client_tls.c