From b59c8ffafa2467286ad9bb4cf84bee55d859c390 Mon Sep 17 00:00:00 2001 From: Rangaiah Date: Tue, 17 Sep 2024 19:14:13 +0530 Subject: [PATCH] Added unit test cases for pk12 certs --- .vscode/settings.json | 5 +++++ src/CMakeLists.txt | 2 ++ tests/CMakeLists.txt | 30 +++++++++++++++++++++++++++--- tests/test_token.c | 4 +++- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..fb2cacfc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "rdkconfig_generic.h": "c" + } +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 031e55b8..cd74d7f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,7 +70,9 @@ if (ENABLE_WEBCFGBIN) target_link_libraries (parodus -lrbus) endif (ENABLE_WEBCFGBIN) +if (BUILD_YOCTO) if (PARODUS_SECERT_ENABLE) target_link_libraries (parodus -lrdkconfig -lsecure_wrapper) endif (PARODUS_SECERT_ENABLE) +endif (BUILD_YOCTO) install (TARGETS parodus DESTINATION bin) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7a081072..70ddd6ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -131,6 +131,10 @@ set (CONN_SRC ../src/connection.c ../src/string_helpers.c ../src/mutex.c ../src/time.c ../src/config.c ../src/auth_token.c ../src/spin_thread.c ../src/heartBeat.c ../src/close_retry.c) #set(CONN_SRC ../src/connection.c ${PARODUS_COMMON_SRC}) +if (NOT BUILD_YOCTO) +set(CONN_SRC ${CONN_SRC} ../src/rdkconfig_generic.c) +endif (NOT BUILD_YOCTO) + add_executable(test_connection test_connection.c ${CONN_SRC}) target_link_libraries (test_connection ${PARODUS_COMMON_LIBS} -lcmocka -lcurl -luuid) @@ -166,6 +170,10 @@ if (ENABLE_WEBCFGBIN) set(CLIST_SRC ${CLIST_SRC} ../src/upstream_rbus.c ../src/xmidtsend_rbus.c) endif (ENABLE_WEBCFGBIN) +if (NOT BUILD_YOCTO) +set(CLIST_SRC ${CLIST_SRC} ../src/rdkconfig_generic.c) +endif (NOT BUILD_YOCTO) + add_executable(test_client_list ${CLIST_SRC}) #target_link_libraries (test_client_list ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS}) target_link_libraries (test_client_list ${PARODUS_COMMON_LIBS} -lcurl -luuid) @@ -187,6 +195,10 @@ if (ENABLE_WEBCFGBIN) set(SVA_SRC ${SVA_SRC} ../src/upstream_rbus.c ../src/xmidtsend_rbus.c) endif (ENABLE_WEBCFGBIN) +if (NOT BUILD_YOCTO) +set(SVA_SRC ${SVA_SRC} ../src/rdkconfig_generic.c) +endif (NOT BUILD_YOCTO) + add_executable(test_service_alive ${SVA_SRC}) #target_link_libraries (test_service_alive ${PARODUS_CONN_LIBS} ${PARODUS_COMMON_LIBS}) target_link_libraries (test_service_alive ${PARODUS_COMMON_LIBS} -lcurl -luuid) @@ -195,7 +207,10 @@ target_link_libraries (test_service_alive ${PARODUS_COMMON_LIBS} -lcurl -luuid) # test_config #------------------------------------------------------------------------------- add_test(NAME test_config COMMAND ${MEMORY_CHECK} ./test_config) -add_executable(test_config test_config.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c) +if (NOT BUILD_YOCTO) +set(CON_SRC ${CON_SRC} ../src/rdkconfig_generic.c) +endif (NOT BUILD_YOCTO) +add_executable(test_config test_config.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c ${CON_SRC}) target_link_libraries (test_config -lcmocka -Wl,--no-as-needed -lcimplog -lcjson -lcjwt -ltrower-base64 -lssl -lcrypto -lrt -lm -lcurl -luuid @@ -205,17 +220,22 @@ target_link_libraries (test_config -lcmocka # test_auth_token #------------------------------------------------------------------------------- add_test(NAME test_auth_token COMMAND ${MEMORY_CHECK} ./test_auth_token) -add_executable(test_auth_token test_auth_token.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c) +if (NOT BUILD_YOCTO) +set(AUTH_SRC ${AUTH_SRC} ../src/rdkconfig_generic.c) +endif (NOT BUILD_YOCTO) + +add_executable(test_auth_token test_auth_token.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c ${AUTH_SRC}) target_link_libraries (test_auth_token -lcmocka -Wl,--no-as-needed -lcimplog -lcjson -lcjwt -ltrower-base64 -lssl -lcrypto -lrt -lm -lcurl -luuid ) + #------------------------------------------------------------------------------- # test_auth_token_more #------------------------------------------------------------------------------- add_test(NAME test_auth_token_more COMMAND ${MEMORY_CHECK} ./test_auth_token_more) -add_executable(test_auth_token_more test_auth_token_more.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c ../src/config.c) +add_executable(test_auth_token_more test_auth_token_more.c ../src/config.c ../src/auth_token.c ../src/string_helpers.c ../src/config.c ${AUTH_SRC}) target_link_libraries (test_auth_token_more -lcmocka -Wl,--no-as-needed -lcimplog -lcjson -lcjwt -ltrower-base64 -lssl -lcrypto -lrt -lm -lcurl -luuid @@ -376,6 +396,10 @@ if (ENABLE_WEBCFGBIN) set(TOKEN_SRC ${TOKEN_SRC} ../src/upstream_rbus.c ../src/xmidtsend_rbus.c) endif (ENABLE_WEBCFGBIN) +if (NOT BUILD_YOCTO) +set(TOKEN_SRC ${TOKEN_SRC} ../src/rdkconfig_generic.c) +endif (NOT BUILD_YOCTO) + add_executable(test_token ${TOKEN_SRC} ) #target_link_libraries (test_token ${PARODUS_COMMON_LIBS} ${PARODUS_JWT_LIBS} -lcmocka ) target_link_libraries (test_token ${PARODUS_COMMON_LIBS} -lcmocka -lcurl -luuid) diff --git a/tests/test_token.c b/tests/test_token.c index ac055519..f5b7b2f7 100644 --- a/tests/test_token.c +++ b/tests/test_token.c @@ -630,7 +630,9 @@ void test_allow_insecure_conn () char *server_addr; unsigned int port; ParodusCfg *cfg = get_parodus_cfg(); - +#ifdef FEATURE_DNS_QUERY + cfg->record_jwt_file = NULL; +#endif parStrncpy (cfg->hw_mac, "aabbccddeeff", sizeof(cfg->hw_mac)); parStrncpy (cfg->dns_txt_url, "test.mydns.mycom.net", sizeof(cfg->dns_txt_url)); cfg->jwt_algo = 1025;