Skip to content

Commit

Permalink
Added unit test cases for pk12 certs
Browse files Browse the repository at this point in the history
  • Loading branch information
nlrcomcast committed Sep 18, 2024
1 parent efc7a02 commit 23bb55c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: CMake
working-directory: build
run: |
cmake .. -DBUILD_GIT:BOOL=true -DENABLE_WEBCFGBIN:BOOL=true -DINTEGRATION_TESTING:BOOL=false -DDISABLE_VALGRIND:BOOL=${DISABLE_VALGRIND} -DENABLE_SESHAT:BOOL=true -DFEATURE_DNS_QUERY:BOOL=true
cmake .. -DBUILD_GIT:BOOL=true -DENABLE_WEBCFGBIN:BOOL=true -DINTEGRATION_TESTING:BOOL=false -DDISABLE_VALGRIND:BOOL=${DISABLE_VALGRIND} -DENABLE_SESHAT:BOOL=true -DFEATURE_DNS_QUERY:BOOL=true -DPARODUS_SECERT_ENABLE:BOOL=true
- name: Get rtrouted Binary
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"rdkconfig_generic.h": "c"
}
}
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
30 changes: 27 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion tests/test_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 23bb55c

Please sign in to comment.