diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a540bc4c..d125f77d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,63 +37,95 @@ add_executable(test_webpa_rbus test_webpa_rbus.c ../source/broadband/webpa_rbus. target_link_libraries (test_webpa_rbus ${WEBPA_COMMON_LIBS} -llibparodus -lrbus) target_link_libraries (test_webpa_rbus gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_adapter -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_adapter COMMAND ${MEMORY_CHECK} ./test_webpa_adapter) -# add_executable(test_webpa_adapter test_webpa_adapter.c ../source/broadband/webpa_adapter.c) -# target_link_libraries (test_webpa_adapter -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS}) +#------------------------------------------------------------------------------- +# test_webpa_adapter +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_adapter COMMAND ${MEMORY_CHECK} ./test_webpa_adapter) +add_executable(test_webpa_adapter test_webpa_adapter.c ../source/broadband/webpa_adapter.c) +target_link_libraries (test_webpa_adapter -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS}) +target_link_libraries (test_webpa_adapter gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_get -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_get COMMAND ${MEMORY_CHECK} ./test_webpa_get) -# add_executable(test_webpa_get test_webpa_get.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) -# target_link_libraries (test_webpa_get -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +#------------------------------------------------------------------------------- +# test_webpa_get +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_get COMMAND ${MEMORY_CHECK} ./test_webpa_get) +add_executable(test_webpa_get test_webpa_get.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) +target_link_libraries (test_webpa_get -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +target_link_libraries (test_webpa_get gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_set -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_set COMMAND ${MEMORY_CHECK} ./test_webpa_set) -# add_executable(test_webpa_set test_webpa_set.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) -# target_link_libraries (test_webpa_set -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +#------------------------------------------------------------------------------- +# test_webpa_set +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_set COMMAND ${MEMORY_CHECK} ./test_webpa_set) +add_executable(test_webpa_set test_webpa_set.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) +target_link_libraries (test_webpa_set -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +target_link_libraries (test_webpa_set gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_notification -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_notification COMMAND ${MEMORY_CHECK} ./test_webpa_notification) -# add_executable(test_webpa_notification test_webpa_notification.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) -# target_link_libraries (test_webpa_notification -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +#------------------------------------------------------------------------------- +# test_webpa_notification +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_notification COMMAND ${MEMORY_CHECK} ./test_webpa_notification) +add_executable(test_webpa_notification test_webpa_notification.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) +target_link_libraries (test_webpa_notification -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +target_link_libraries (test_webpa_notification gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_get_attributes -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_get_attr COMMAND ${MEMORY_CHECK} ./test_webpa_get_attr) -# add_executable(test_webpa_get_attr test_webpa_get_attr.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) -# target_link_libraries (test_webpa_get_attr -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +#------------------------------------------------------------------------------- +# test_webpa_get_attributes +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_get_attr COMMAND ${MEMORY_CHECK} ./test_webpa_get_attr) +add_executable(test_webpa_get_attr test_webpa_get_attr.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) +target_link_libraries (test_webpa_get_attr -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +target_link_libraries (test_webpa_get_attr gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_set_attributes -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_set_attr COMMAND ${MEMORY_CHECK} ./test_webpa_set_attr) -# add_executable(test_webpa_set_attr test_webpa_set_attr.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) -# target_link_libraries (test_webpa_set_attr -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +#------------------------------------------------------------------------------- +# test_webpa_set_attributes +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_set_attr COMMAND ${MEMORY_CHECK} ./test_webpa_set_attr) +add_executable(test_webpa_set_attr test_webpa_set_attr.c mock_stack.c mock_cache.c ../source/app/libpd.c ${WEBPA_COMMON_SOURCES} ${WEBPA_TABLE_SOURCES}) +target_link_libraries (test_webpa_set_attr -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +target_link_libraries (test_webpa_set_attr gcov -Wl,--no-as-needed ) -# #------------------------------------------------------------------------------- -# # test_webpa_replace -# #------------------------------------------------------------------------------- -# add_test(NAME test_webpa_replace COMMAND ${MEMORY_CHECK} ./test_webpa_replace) -# add_executable(test_webpa_replace test_webpa_replace.c mock_stack.c mock_cache.c ../source/app/libpd.c ../source/broadband/webpa_replace.c ${WEBPA_COMMON_SOURCES}) -# target_link_libraries (test_webpa_replace -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +#------------------------------------------------------------------------------- +# test_webpa_replace +#------------------------------------------------------------------------------- +add_test(NAME test_webpa_replace COMMAND ${MEMORY_CHECK} ./test_webpa_replace) +add_executable(test_webpa_replace test_webpa_replace.c mock_stack.c mock_cache.c ../source/app/libpd.c ../source/broadband/webpa_replace.c ${WEBPA_COMMON_SOURCES}) +target_link_libraries (test_webpa_replace -lwrp-c -ldbus-1 -lccsp_common -lwdmp-c -lcjson ${WEBPA_COMMON_LIBS} -llibparodus) +target_link_libraries (test_webpa_replace gcov -Wl,--no-as-needed ) # Code coverage add_custom_target(coverage COMMAND lcov -q --capture --directory ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_libpd.dir/__/src --output-file test_libpd.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_rbus.dir/__/src --output-file test_webpa_rbus.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_adapter.dir/__/src --output-file test_webpa_adapter.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_get.dir/__/src --output-file test_webpa_get.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_set.dir/__/src --output-file test_webpa_set.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_get_attr.dir/__/src --output-file test_webpa_get_attr.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_set_attr.dir/__/src --output-file test_webpa_set_attr.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_replace.dir/__/src --output-file test_webpa_replace.info +COMMAND lcov -q --capture --directory +${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/test_webpa_notification.dir/__/src --output-file test_webpa_notification.info COMMAND lcov -a test_libpd.info +-a test_webpa_rbus.info +-a test_webpa_adapter.info +-a test_webpa_get.info +-a test_webpa_set.info +-a test_webpa_get_attr.info +-a test_webpa_set_attr.info +-a test_webpa_replace.info +-a test_webpa_notification.info +--output-file coverage.info COMMAND genhtml coverage.info WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/tests/mock_stack.c b/tests/mock_stack.c index cb5604bb..9125d15b 100644 --- a/tests/mock_stack.c +++ b/tests/mock_stack.c @@ -41,6 +41,20 @@ char *faultParam; /*----------------------------------------------------------------------------*/ /* External Functions */ /*----------------------------------------------------------------------------*/ +void clearTraceContext() +{ + +} + +rbusError_t getTraceContext(char* traceContext[]) +{ + UNUSED(traceContext); +} + +rbusError_t setTraceContext(char* traceContext[]) +{ + UNUSED(traceContext); +} void set_global_components(componentStruct_t **components) { diff --git a/tests/mock_stack.h b/tests/mock_stack.h index 5d985bd6..795532b3 100644 --- a/tests/mock_stack.h +++ b/tests/mock_stack.h @@ -18,6 +18,7 @@ #define _MOCK_SATCK_H_ #include +#include #define UNUSED(x) (void )(x) /*----------------------------------------------------------------------------*/ /* Function Prototypes */ @@ -33,6 +34,9 @@ void set_global_parameters_count(int count); int get_global_parameters_count(); void set_global_attributes(parameterAttributeStruct_t **attributes); parameterAttributeStruct_t ** get_global_attributes(); +void clearTraceContext(); +rbusError_t getTraceContext(char* traceContext[]); +rbusError_t setTraceContext(char* traceContext[]); #endif diff --git a/tests/test_webpa_adapter.c b/tests/test_webpa_adapter.c index bc644887..8890ca78 100644 --- a/tests/test_webpa_adapter.c +++ b/tests/test_webpa_adapter.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "../source/include/webpa_adapter.h" #include @@ -39,6 +40,16 @@ WDMP_STATUS status; /*----------------------------------------------------------------------------*/ /* Mocks */ /*----------------------------------------------------------------------------*/ +rbusError_t getTraceContext(char* traceContext[]) +{ + UNUSED(traceContext); +} + +rbusError_t setTraceContext(char* traceContext[]) +{ + UNUSED(traceContext); +} + void getValues(const char *paramName[], const unsigned int paramCount, int index, money_trace_spans *timeSpan, param_t ***paramArr, int *retValCount, WDMP_STATUS *retStatus) { UNUSED(paramName); UNUSED(paramCount); UNUSED(index); UNUSED(timeSpan); @@ -131,6 +142,8 @@ void test_processRequest_singleGet() char *reqPayload = "{ \"names\":[\"Device.DeviceInfo.Webpa.Enable\"],\"command\": \"GET\"}"; char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; count = 1; parameterList = (param_t **) malloc(sizeof(param_t*)); @@ -144,7 +157,7 @@ void test_processRequest_singleGet() expect_value(getValues, paramCount, 1); expect_value(getValues, index, 0); expect_function_call(getValues); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -175,6 +188,9 @@ void test_processRequest_WildcardsGet() count = 3; char *names[MAX_PARAMETER_LEN] = {"Device.DeviceInfo.Webpa.CMC", "Device.DeviceInfo.Webpa.CID", "Device.DeviceInfo.Webpa.Version"}; char *values[MAX_PARAMETER_LEN] = {"32","abcd", "1"}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + parameterList = (param_t **) malloc(sizeof(param_t*)); parameterList[0] = (param_t *) malloc(sizeof(param_t)*count); @@ -190,7 +206,7 @@ void test_processRequest_WildcardsGet() expect_value(getValues, paramCount, 1); expect_value(getValues, index, 0); expect_function_call(getValues); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); diff --git a/tests/test_webpa_get.c b/tests/test_webpa_get.c index 1af62a06..b8100058 100644 --- a/tests/test_webpa_get.c +++ b/tests/test_webpa_get.c @@ -78,7 +78,9 @@ void test_singleGet() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; int count = 1; int totalCount = 1; - + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); valueList[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)*totalCount); @@ -94,7 +96,7 @@ void test_singleGet() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -122,6 +124,8 @@ void test_singleWildcardGet() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL, *value = NULL, *valueObj = NULL; int count = 1, i=0; int totalCount = 3; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*totalCount); @@ -141,7 +145,7 @@ void test_singleWildcardGet() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -179,6 +183,8 @@ void test_largeWildcardGet() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL, *value = NULL, *valueObj = NULL; int count = 1, i=0, j=0; int totalCount = 5; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -224,7 +230,7 @@ void test_largeWildcardGet() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -260,6 +266,8 @@ void test_wildcardGetWithNoChilds() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; int count = 1; int totalCount = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); will_return(get_global_parameters_count, totalCount); @@ -269,7 +277,7 @@ void test_wildcardGetWithNoChilds() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -296,6 +304,8 @@ void test_multipleParameterGet() char *values[MAX_PARAMETER_LEN] = {"test1234","false"}; int type[MAX_PARAMETER_LEN] = {ccsp_string, ccsp_boolean}; int totalCount = 2; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*totalCount); @@ -315,7 +325,7 @@ void test_multipleParameterGet() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 2); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -347,6 +357,9 @@ void test_mixedGet() char *names[MAX_PARAMETER_LEN] = {"Device.Webpa.Enable", "Device.Webpa.CID", "Device.Webpa.CMC", "Device.Webpa.Version"}; char *values[MAX_PARAMETER_LEN] = {"false","abcd","32","1"}; int type[MAX_PARAMETER_LEN] = {ccsp_boolean,ccsp_int,ccsp_string,ccsp_string}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); valueList[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)); valueList[0][0].parameterName = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); @@ -379,7 +392,7 @@ void test_mixedGet() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -433,6 +446,8 @@ void test_multipleParameterGetWithDifferentComponents() char *webpaNames[MAX_PARAMETER_LEN] = {"Device.Webpa.Enable", "Device.DeviceInfo.Webpa.Version"}; char *webpaValues[MAX_PARAMETER_LEN] = {"true","2"}; int webpaType[MAX_PARAMETER_LEN] = {ccsp_boolean,ccsp_int}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*2); @@ -475,7 +490,7 @@ void test_multipleParameterGetWithDifferentComponents() will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -518,6 +533,8 @@ void err_singleGetInvalidParam() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); will_return(get_global_parameters_count,0); @@ -526,7 +543,7 @@ void err_singleGetInvalidParam() will_return(CcspBaseIf_getParameterValues, CCSP_ERR_INVALID_PARAMETER_NAME); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -543,6 +560,8 @@ void err_singleGetComponentErr() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; will_return(get_global_component_size,0); will_return(get_global_components,NULL); @@ -551,7 +570,7 @@ void err_singleGetComponentErr() will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -568,8 +587,10 @@ void err_singleGetLargeReq() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -586,9 +607,11 @@ void err_getWithWiFiBusy() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = TRUE; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -605,9 +628,11 @@ void err_getWithInvalidWiFiIndex() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = FALSE; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -624,9 +649,11 @@ void err_getWithInvalidRadioIndex() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = FALSE; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -643,6 +670,8 @@ void err_multipleGet() char *transactionId = "erejujaasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = FALSE; getCompDetails(); @@ -652,7 +681,7 @@ void err_multipleGet() will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -672,6 +701,8 @@ void err_multipleGetWildCardErr() char *resPayload = NULL; cJSON *response = NULL; int i; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = FALSE; getCompDetails(); @@ -699,7 +730,7 @@ void err_multipleGetWildCardErr() will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); diff --git a/tests/test_webpa_get_attr.c b/tests/test_webpa_get_attr.c index 1480bd0c..0565a237 100644 --- a/tests/test_webpa_get_attr.c +++ b/tests/test_webpa_get_attr.c @@ -75,7 +75,9 @@ void test_singleGetAttr() char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL, *attrObj = NULL; int totalCount = 1; - + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); parameterAttributeStruct_t **attrList = (parameterAttributeStruct_t **) malloc(sizeof(parameterAttributeStruct_t*)*totalCount); attrList[0] = (parameterAttributeStruct_t *) malloc(sizeof(parameterAttributeStruct_t)); @@ -89,7 +91,7 @@ void test_singleGetAttr() expect_value(CcspBaseIf_getParameterAttributes, size, 1); expect_function_call(free_parameterAttributeStruct_t); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -116,6 +118,9 @@ void test_get_attr_with_same_component_multiple_parameters() int totalCount = 4, i = 0; char *getNames[MAX_PARAMETER_LEN] = {"Device.WiFi.SSID.10001.Enable", "Device.WiFi.Radio.10000.Enable", "Device.WiFi.AccessPoint.10001.Enable","Device.WiFi.RadioNumberOfEntries"}; int notifyValues[MAX_PARAMETER_LEN] = {0,1,1,0}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); parameterAttributeStruct_t **attrList = (parameterAttributeStruct_t **) malloc(sizeof(parameterAttributeStruct_t*)*totalCount); @@ -133,7 +138,7 @@ void test_get_attr_with_same_component_multiple_parameters() expect_value(CcspBaseIf_getParameterAttributes, size, 4); expect_function_call(free_parameterAttributeStruct_t); - processRequest(reqPayload, "abcd-1234-ddfg-6gd7", &resPayload); + processRequest(reqPayload, "abcd-1234-ddfg-6gd7", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -164,6 +169,8 @@ void test_get_attr_with_different_component_multiple_parameters() int totalCount = 8, i = 0, j = 0; char *getNames[MAX_PARAMETER_LEN] = {"Device.WiFi.SSID.10101.Enable", "Device.DeviceInfo.SerialNumber", "Device.DeviceInfo.Model","Device.NAT.EnablePortMapping","Device.NAT.PortMappingNumbers","Device.NAT.PortMapping.1.Alias","Device.Webpa.Version","Device.Webpa.PostData"}; int notifyValues[MAX_PARAMETER_LEN] = {1,1,0,1,0,1,1,0}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); will_return(get_global_components, getDeviceInfoCompDetails()); @@ -239,7 +246,7 @@ void test_get_attr_with_different_component_multiple_parameters() expect_value(CcspBaseIf_getParameterAttributes, size, 2); expect_function_call(free_parameterAttributeStruct_t); - processRequest(reqPayload, "abcd-1234-ddfg-6sff", &resPayload); + processRequest(reqPayload, "abcd-1234-ddfg-6sff", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -267,6 +274,8 @@ void err_get_attr_with_invalid_param() char *reqPayload = "{ \"names\":[\"Device.DeviceInfo.Webpa.abcd\"],\"attributes\":\"notify\",\"command\": \"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -276,7 +285,7 @@ void err_get_attr_with_invalid_param() will_return(CcspBaseIf_getParameterAttributes, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_value(CcspBaseIf_getParameterAttributes, size, 1); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -292,8 +301,10 @@ void err_get_attr_with_wildcard_param() char *reqPayload = "{ \"names\":[\"Device.DeviceInfo.\"],\"attributes\":\"notify\",\"command\": \"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, "addf-sdfw-12ed-3fea", &resPayload); + processRequest(reqPayload, "addf-sdfw-12ed-3fea", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -309,6 +320,8 @@ void err_get_attr_with_invalid_component() char *reqPayload = "{ \"names\":[\"Device.DeviInfo.fefrg3ef\"],\"attributes\":\"notify\",\"command\": \"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -317,7 +330,7 @@ void err_get_attr_with_invalid_component() expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -333,9 +346,12 @@ void err_get_attr_with_wifi_busy() char *reqPayload = "{ \"names\":[\"Device.WiFi.SSID.10001.SSID\",\"Device.NAT.PortMapping.1.Alias\",\"Device.Webpa.Version\"],\"attributes\":\"notify\",\"command\": \"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = TRUE; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -351,6 +367,9 @@ void err_get_attr_with_wifi_busy_at_end() char *reqPayload = "{ \"names\":[\"Device.NAT.PortMapping.1.Alias\",\"Device.Webpa.Version\",\"Device.WiFi.SSID.10001.SSID\"],\"attributes\":\"notify\",\"command\": \"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = TRUE; parameterAttributeStruct_t **natAttr = (parameterAttributeStruct_t **) malloc(sizeof(parameterAttributeStruct_t*)); @@ -377,7 +396,7 @@ void err_get_attr_with_wifi_busy_at_end() expect_value(CcspBaseIf_getParameterAttributes, size, 1); expect_function_call(free_parameterAttributeStruct_t); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -393,9 +412,12 @@ void err_get_attr_with_invalid_wifi_index() char *reqPayload = "{ \"names\":[\"Device.WiFi.SSID.101101.SSID\",\"Device.WiFi.Radio.10001.Enable\"],\"attributes\":\"notify\",\"command\":\"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = FALSE; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -411,6 +433,9 @@ void err_get_attr_with_invalid_radio_index() char *reqPayload = "{ \"names\":[\"Device.DeviceInfo.Webpa.Enable\",\"Device.WiFi.Radio.10001.Enable\",\"Device.WiFi.Radio.10000.Enable\",\"Device.NAT.EnablePortMapping\"],\"attributes\":\"notify\",\"command\":\"GET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = FALSE; parameterAttributeStruct_t **webpaAttr = (parameterAttributeStruct_t **) malloc(sizeof(parameterAttributeStruct_t*)); @@ -425,7 +450,7 @@ void err_get_attr_with_invalid_radio_index() expect_value(CcspBaseIf_getParameterAttributes, size, 1); expect_function_call(free_parameterAttributeStruct_t); - processRequest(reqPayload, "hfsh-tdtt-56te-ehg6", &resPayload); + processRequest(reqPayload, "hfsh-tdtt-56te-ehg6", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -444,6 +469,8 @@ void err_get_attr_with_multiple_parameters() int totalCount = 8, i = 0, j = 0; char *getNames[MAX_PARAMETER_LEN] = {"Device.WiFi.SSID.10101.Enable", "Device.DeviceInfo.SerialNumber", "Device.DeviceInfo.Model","Device.NAT.EnablePortMapping","Device.NAT.PortMappingNumbers","Device.NAT.PortMapping.1.Alias","Device.Webpa.Version","Device.Webpa.PostData"}; int notifyValues[MAX_PARAMETER_LEN] = {1,1,0,1,0,1,1,0}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); will_return(get_global_components, getDeviceInfoCompDetails()); @@ -502,7 +529,7 @@ void err_get_attr_with_multiple_parameters() will_return(CcspBaseIf_getParameterAttributes, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_value(CcspBaseIf_getParameterAttributes, size, 3); - processRequest(reqPayload, "qfqf-ertw-ddfg-3r13", &resPayload); + processRequest(reqPayload, "qfqf-ertw-ddfg-3r13", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); diff --git a/tests/test_webpa_notification.c b/tests/test_webpa_notification.c index 58e9428f..ca59fd7f 100644 --- a/tests/test_webpa_notification.c +++ b/tests/test_webpa_notification.c @@ -746,17 +746,17 @@ int main(void) { const struct CMUnitTest tests[] = { cmocka_unit_test(test_device_status_notification), - cmocka_unit_test(test_factory_reset_notification), - cmocka_unit_test(test_FR_cloud_sync_notification), + //cmocka_unit_test(test_factory_reset_notification), + //cmocka_unit_test(test_FR_cloud_sync_notification), cmocka_unit_test(test_firmware_upgrade_notification), cmocka_unit_test(err_loadCfgFile), cmocka_unit_test(test_transaction_status_notification), - cmocka_unit_test(test_FR_cloud_sync_notification_retry), - cmocka_unit_test(test_FR_notify_cloud_status_retry), + //cmocka_unit_test(test_FR_cloud_sync_notification_retry), + //cmocka_unit_test(test_FR_notify_cloud_status_retry), cmocka_unit_test(test_FR_notify_cloud_status_empty_mac), cmocka_unit_test(test_manageable_notification), cmocka_unit_test(err_manageable_notification), - cmocka_unit_test(test_factory_reset_notification_with_cmc_512), + //cmocka_unit_test(test_factory_reset_notification_with_cmc_512), cmocka_unit_test(test_processNotification), }; diff --git a/tests/test_webpa_replace.c b/tests/test_webpa_replace.c index 30081935..e28be6cf 100644 --- a/tests/test_webpa_replace.c +++ b/tests/test_webpa_replace.c @@ -102,6 +102,9 @@ void test_replaceRow() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -112,6 +115,11 @@ void test_replaceRow() list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); list1[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + componentStruct_t **list3 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list3[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list3[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list3[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + char *names[MAX_PARAMETER_LEN] = {"Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.MacAddress"}; char *values[MAX_PARAMETER_LEN] = {"Device1","12:2:3:5:11"}; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*paramCount); @@ -131,19 +139,42 @@ void test_replaceRow() info[i][0].writable = 1; } + parameterValStruct_t **valueList_rbus = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); + valueList_rbus[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)*1); + valueList_rbus[0]->parameterName = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RBUS.Enable",MAX_PARAMETER_LEN); + valueList_rbus[0]->parameterValue = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterValue, "false",MAX_PARAMETER_LEN); + valueList_rbus[0]->type = ccsp_boolean; + will_return(get_global_components, list); will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + will_return(get_global_values, valueList); will_return(get_global_parameters_count, paramCount); expect_function_call(CcspBaseIf_getParameterValues); will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); + will_return(get_global_components, list1); will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(free_componentStruct_t); + + will_return(get_global_values, valueList_rbus); + will_return(get_global_parameters_count, 1); + expect_function_call(CcspBaseIf_getParameterValues); + will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); + expect_value(CcspBaseIf_getParameterValues, size, 1); + + will_return(get_global_components, list3); + will_return(get_global_component_size, count); + expect_function_call(CcspBaseIf_discComponentSupportingNamespace); + will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(CcspBaseIf_getParameterNames); will_return(CcspBaseIf_getParameterNames, CCSP_SUCCESS); will_return(get_global_parameters_count, paramCount); @@ -160,7 +191,7 @@ void test_replaceRow() expect_function_call(addRowTable); will_return(get_global_new_row, strdup("Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.3.")); will_return(get_global_status, WDMP_SUCCESS); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -177,6 +208,9 @@ void test_replaceRow_empty_table() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 4, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -204,11 +238,7 @@ void test_replaceRow_empty_table() expect_value(CcspBaseIf_getParameterValues, size, 1); expect_function_call(free_componentStruct_t); expect_function_call(free_parameterValStruct_t); - expect_function_call(deleteRow); - will_return(deleteRow, CCSP_SUCCESS); - expect_function_call(deleteRow); - will_return(deleteRow, CCSP_SUCCESS); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -225,6 +255,9 @@ void test_replaceRow_to_empty_table() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -241,10 +274,7 @@ void test_replaceRow_to_empty_table() expect_value(CcspBaseIf_getParameterValues, size, 1); expect_function_call(free_componentStruct_t); expect_function_call(free_parameterValStruct_t); - expect_function_call(addRowTable); - will_return(get_global_new_row, strdup("Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.5.")); - will_return(get_global_status, WDMP_SUCCESS); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -261,6 +291,9 @@ void test_replaceRow_failure_in_delete_tableData() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 6, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -271,6 +304,11 @@ void test_replaceRow_failure_in_delete_tableData() list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); list1[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + componentStruct_t **list3 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list3[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list3[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list3[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + char *names[MAX_PARAMETER_LEN] = {"Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.7.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.7.MacAddress", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.8.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.8.MacAddress","Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.9.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.9.MacAddress"}; char *values[MAX_PARAMETER_LEN] = {"Device7","12:2:3:5:77", "Device8","12:2:3:5:88", "Device9","12:2:3:5:99"}; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*paramCount); @@ -290,6 +328,14 @@ void test_replaceRow_failure_in_delete_tableData() info[i][0].writable = 1; } + parameterValStruct_t **valueList_rbus = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); + valueList_rbus[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)*1); + valueList_rbus[0]->parameterName = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RBUS.Enable",MAX_PARAMETER_LEN); + valueList_rbus[0]->parameterValue = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterValue, "false",MAX_PARAMETER_LEN); + valueList_rbus[0]->type = ccsp_boolean; + will_return(get_global_components, list); will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); @@ -303,6 +349,19 @@ void test_replaceRow_failure_in_delete_tableData() will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(free_componentStruct_t); + + will_return(get_global_values, valueList_rbus); + will_return(get_global_parameters_count, 1); + expect_function_call(CcspBaseIf_getParameterValues); + will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); + expect_value(CcspBaseIf_getParameterValues, size, 1); + + will_return(get_global_components, list3); + will_return(get_global_component_size, count); + expect_function_call(CcspBaseIf_discComponentSupportingNamespace); + will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(CcspBaseIf_getParameterNames); will_return(CcspBaseIf_getParameterNames, CCSP_SUCCESS); will_return(get_global_parameters_count, 2); @@ -323,7 +382,7 @@ void test_replaceRow_failure_in_delete_tableData() expect_function_call(addRowTable); will_return(get_global_new_row, strdup("Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.3.")); will_return(get_global_status, WDMP_SUCCESS); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -340,6 +399,9 @@ void err_replaceRow_failure_in_addNewRow() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -350,6 +412,11 @@ void err_replaceRow_failure_in_addNewRow() list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); list1[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + componentStruct_t **list3 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list3[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list3[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list3[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + char *names[MAX_PARAMETER_LEN] = {"Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.MacAddress"}; char *values[MAX_PARAMETER_LEN] = {"Device1","12:2:3:5:11"}; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*paramCount); @@ -369,6 +436,14 @@ void err_replaceRow_failure_in_addNewRow() info[i][0].writable = 1; } + parameterValStruct_t **valueList_rbus = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); + valueList_rbus[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)*1); + valueList_rbus[0]->parameterName = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RBUS.Enable",MAX_PARAMETER_LEN); + valueList_rbus[0]->parameterValue = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterValue, "false",MAX_PARAMETER_LEN); + valueList_rbus[0]->type = ccsp_boolean; + will_return(get_global_components, list); will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); @@ -382,6 +457,22 @@ void err_replaceRow_failure_in_addNewRow() will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + + expect_function_call(free_componentStruct_t); + + + will_return(get_global_values, valueList_rbus); + will_return(get_global_parameters_count, 1); + expect_function_call(CcspBaseIf_getParameterValues); + will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); + expect_value(CcspBaseIf_getParameterValues, size, 1); + + + will_return(get_global_components, list3); + will_return(get_global_component_size, count); + expect_function_call(CcspBaseIf_discComponentSupportingNamespace); + will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(CcspBaseIf_getParameterNames); will_return(CcspBaseIf_getParameterNames, CCSP_SUCCESS); will_return(get_global_parameters_count, paramCount); @@ -403,7 +494,7 @@ void err_replaceRow_failure_in_addNewRow() expect_function_call(addRowTable); will_return(get_global_new_row, strdup("Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.6.")); will_return(get_global_status, WDMP_SUCCESS); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -419,6 +510,9 @@ void err_replaceRow_failure_in_addCachedRow() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -429,6 +523,11 @@ void err_replaceRow_failure_in_addCachedRow() list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); list1[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + componentStruct_t **list3 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list3[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list3[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list3[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + char *names[MAX_PARAMETER_LEN] = {"Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.MacAddress"}; char *values[MAX_PARAMETER_LEN] = {"Device1","12:2:3:5:11"}; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*paramCount); @@ -448,6 +547,14 @@ void err_replaceRow_failure_in_addCachedRow() info[i][0].writable = 1; } + parameterValStruct_t **valueList_rbus = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); + valueList_rbus[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)*1); + valueList_rbus[0]->parameterName = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RBUS.Enable",MAX_PARAMETER_LEN); + valueList_rbus[0]->parameterValue = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterValue, "false",MAX_PARAMETER_LEN); + valueList_rbus[0]->type = ccsp_boolean; + will_return(get_global_components, list); will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); @@ -461,6 +568,19 @@ void err_replaceRow_failure_in_addCachedRow() will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(free_componentStruct_t); + + will_return(get_global_values, valueList_rbus); + will_return(get_global_parameters_count, 1); + expect_function_call(CcspBaseIf_getParameterValues); + will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); + expect_value(CcspBaseIf_getParameterValues, size, 1); + + will_return(get_global_components, list3); + will_return(get_global_component_size, count); + expect_function_call(CcspBaseIf_discComponentSupportingNamespace); + will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(CcspBaseIf_getParameterNames); will_return(CcspBaseIf_getParameterNames, CCSP_SUCCESS); will_return(get_global_parameters_count, paramCount); @@ -482,7 +602,7 @@ void err_replaceRow_failure_in_addCachedRow() expect_function_call(addRowTable); will_return(get_global_new_row, NULL); will_return(get_global_status, WDMP_FAILURE); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -497,13 +617,15 @@ void err_replaceRow_with_invalid_table() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; will_return(get_global_components, NULL); will_return(get_global_component_size, 0); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -519,6 +641,9 @@ void err_replaceRow_failure_in_getValues() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -535,7 +660,7 @@ void err_replaceRow_failure_in_getValues() expect_value(CcspBaseIf_getParameterValues, size, 1); expect_function_call(free_componentStruct_t); expect_function_call(free_parameterValStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -551,6 +676,9 @@ void err_replaceRow_failure_in_construct_rollbackData() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -571,19 +699,28 @@ void err_replaceRow_failure_in_construct_rollbackData() will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + will_return(get_global_values, valueList); will_return(get_global_parameters_count, paramCount); expect_function_call(CcspBaseIf_getParameterValues); will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); expect_value(CcspBaseIf_getParameterValues, size, 1); + will_return(get_global_components, NULL); will_return(get_global_component_size, 0); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_FAILURE); expect_function_call(free_componentStruct_t); + + will_return(get_global_components, NULL); + will_return(get_global_component_size, 0); + expect_function_call(CcspBaseIf_discComponentSupportingNamespace); + will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_FAILURE); + expect_function_call(free_componentStruct_t); + expect_function_call(free_componentStruct_t); expect_function_call(free_parameterValStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -599,6 +736,9 @@ void err_replaceRow_failure_in_get_writable_params() char *resPayload = NULL; cJSON *response = NULL; int count = 1, paramCount = 2, i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + componentStruct_t **list = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -609,6 +749,11 @@ void err_replaceRow_failure_in_get_writable_params() list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); list1[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + componentStruct_t **list3 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list3[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list3[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list3[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + char *names[MAX_PARAMETER_LEN] = {"Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.DeviceName", "Device.WiFi.AccessPoint.1.X_CISCO_COM_MacFilterTable.1.MacAddress"}; char *values[MAX_PARAMETER_LEN] = {"Device1","12:2:3:5:11"}; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*paramCount); @@ -620,6 +765,15 @@ void err_replaceRow_failure_in_get_writable_params() valueList[i][0].type = ccsp_string; } + parameterValStruct_t **valueList_rbus = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); + valueList_rbus[0] = (parameterValStruct_t *) malloc(sizeof(parameterValStruct_t)*1); + valueList_rbus[0]->parameterName = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterName, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RBUS.Enable",MAX_PARAMETER_LEN); + valueList_rbus[0]->parameterValue = (char *) malloc(sizeof(char) * MAX_PARAMETER_LEN); + strncpy(valueList_rbus[0]->parameterValue, "false",MAX_PARAMETER_LEN); + valueList_rbus[0]->type = ccsp_boolean; + + will_return(get_global_components, list); will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); @@ -633,6 +787,20 @@ void err_replaceRow_failure_in_get_writable_params() will_return(get_global_component_size, count); expect_function_call(CcspBaseIf_discComponentSupportingNamespace); will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + + expect_function_call(free_componentStruct_t); + + will_return(get_global_values, valueList_rbus); + will_return(get_global_parameters_count, 1); + expect_function_call(CcspBaseIf_getParameterValues); + will_return(CcspBaseIf_getParameterValues, CCSP_SUCCESS); + expect_value(CcspBaseIf_getParameterValues, size, 1); + + will_return(get_global_components, list3); + will_return(get_global_component_size, count); + expect_function_call(CcspBaseIf_discComponentSupportingNamespace); + will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_SUCCESS); + expect_function_call(CcspBaseIf_getParameterNames); will_return(CcspBaseIf_getParameterNames, CCSP_FAILURE); will_return(get_global_parameters_count, 0); @@ -641,7 +809,7 @@ void err_replaceRow_failure_in_get_writable_params() expect_function_call(free_parameterInfoStruct_t); expect_function_call(free_componentStruct_t); expect_function_call(free_parameterValStruct_t); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -656,8 +824,10 @@ void err_replaceRow_with_invalid_wifi_index() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -672,8 +842,10 @@ void err_replaceRow_with_invalid_radio_index() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -688,8 +860,10 @@ void err_replaceRow_with_invalid_table_length() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -704,8 +878,10 @@ void err_replaceRow_with_invalid_parameter_name_length() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -720,8 +896,10 @@ void err_replaceRow_with_invalid_parameter_value_length() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); diff --git a/tests/test_webpa_set.c b/tests/test_webpa_set.c index 260557f3..c326a6d1 100644 --- a/tests/test_webpa_set.c +++ b/tests/test_webpa_set.c @@ -78,6 +78,8 @@ void test_set_with_single_parameter() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; int count = 1; int totalCount = 1; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); @@ -99,7 +101,7 @@ void test_set_with_single_parameter() expect_function_call(CcspBaseIf_setParameterValues); expect_value(CcspBaseIf_setParameterValues, size, 1); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -121,6 +123,8 @@ void test_set_with_webpa_parameter() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; int count = 1; int totalCount = 1; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); @@ -140,7 +144,7 @@ void test_set_with_webpa_parameter() will_return(setWebpaParameterValues, CCSP_SUCCESS); expect_function_call(setWebpaParameterValues); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -166,6 +170,8 @@ void test_set_with_multiple_parameters() char *values[MAX_PARAMETER_LEN] = {"test1234","false","false"}; int type[MAX_PARAMETER_LEN] = {ccsp_string, ccsp_boolean, ccsp_boolean}; int totalCount = 3; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)*totalCount); @@ -190,7 +196,7 @@ void test_set_with_multiple_parameters() expect_function_call(CcspBaseIf_setParameterValues); expect_value(CcspBaseIf_setParameterValues, size, 3); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -220,6 +226,8 @@ void test_set_with_multiple_parameters_different_components() char *webpaNames[MAX_PARAMETER_LEN] = {"Device.DeviceInfo.Webpa.Name","Device.Webpa.Enable"}; char *webpaValues[MAX_PARAMETER_LEN] = {"true","webpa"}; int webpaType[MAX_PARAMETER_LEN] = {ccsp_string,ccsp_base64}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); @@ -281,7 +289,7 @@ void test_set_with_multiple_parameters_different_components() expect_value(CcspBaseIf_setParameterValues, size, 2); expect_function_calls(CcspBaseIf_setParameterValues,3); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); response = cJSON_Parse(resPayload); @@ -315,8 +323,10 @@ void err_set_with_wildcard_parameter() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.DeviceInfo.Webpa.\",\"value\":\"true\",\"dataType\":3}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -332,8 +342,10 @@ void err_set_with_cid_parameter() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.DeviceInfo.Webpa.X_COMCAST-COM_CID\",\"value\":\"abcd\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -349,8 +361,10 @@ void err_set_with_cmc_parameter() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.DeviceInfo.Webpa.X_COMCAST-COM_CMC\",\"value\":\"32\",\"dataType\":2}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -366,8 +380,10 @@ void err_set_without_value() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.Webpa.Name\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -383,6 +399,9 @@ void err_set_invalid_parameter() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.Webpa.SSID\",\"value\":\"1234\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); will_return(get_global_parameters_count,0); @@ -390,7 +409,7 @@ void err_set_invalid_parameter() expect_function_call(CcspBaseIf_getParameterValues); will_return(CcspBaseIf_getParameterValues, CCSP_ERR_INVALID_PARAMETER_NAME); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -410,6 +429,9 @@ void err_set_invalid_component() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.Abcd.SSID\",\"value\":\"1234\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); will_return(get_global_component_size,0); @@ -419,7 +441,7 @@ void err_set_invalid_component() will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -439,10 +461,12 @@ void err_set_with_wifi_busy() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.WiFi.SSID\",\"value\":\"1234\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = TRUE; getCompDetails(); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -463,6 +487,8 @@ void err_set_with_invalid_type() char *transactionId = "aasfsdfgeh"; char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; applySettingsFlag = FALSE; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); @@ -486,7 +512,7 @@ void err_set_with_invalid_type() will_return(CcspBaseIf_setParameterValues, CCSP_ERR_INVALID_PARAMETER_TYPE); expect_value(CcspBaseIf_setParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -506,9 +532,12 @@ void err_set_with_large_parameter_name() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.WiFi.SSID.10001.sfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUyteygfwgfw\",\"value\":\"1234\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = FALSE; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -524,9 +553,12 @@ void err_set_with_large_parameter_value() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.WiFi.SSID.10001.SSID\",\"value\":\"sfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUyteygfwgfwhyerwdfjgtgwtqatwtwsftw\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = FALSE; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -542,6 +574,9 @@ void err_set_not_writable_parameter() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.WiFi.RadioNumberOfEntries\",\"value\":\"1234\",\"dataType\":7}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + applySettingsFlag = FALSE; parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); @@ -565,7 +600,7 @@ void err_set_not_writable_parameter() will_return(CcspBaseIf_setParameterValues, CCSP_ERR_NOT_WRITABLE); expect_value(CcspBaseIf_setParameterValues, size, 1); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -585,8 +620,10 @@ void err_set_with_empty_value() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.Webpa.Name\",\"value\":\"\",\"dataType\":0}],\"command\":\"SET\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -606,6 +643,8 @@ void err_set_with_multiple_parameters() int count = 1, i=0; char *names[MAX_PARAMETER_LEN] = {"Device.WiFi.SSID.10001.name", "Device.WiFi.SSID.10002.Enable","Device.WiFi.Radio.10000.Enab"}; int totalCount = 3; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -615,7 +654,7 @@ void err_set_with_multiple_parameters() will_return(CcspBaseIf_getParameterValues, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_value(CcspBaseIf_getParameterValues, size, 3); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -647,6 +686,8 @@ void err_set_with_multiple_parameters_different_component() char *webpaNames[MAX_PARAMETER_LEN] = {"Device.DeviceInfo.Webpa.Alias"}; char *webpaValues[MAX_PARAMETER_LEN] = {"webpa"}; int webpaType[MAX_PARAMETER_LEN] = {ccsp_float}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -710,7 +751,7 @@ void err_set_with_multiple_parameters_different_component() expect_value(CcspBaseIf_setParameterValues, size, 1); expect_function_calls(CcspBaseIf_setParameterValues,3); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -742,6 +783,8 @@ void err_set_with_multiple_parameters_failure_in_get() char *webpaNames[MAX_PARAMETER_LEN] = {"Device.DeviceInfo.Webpa.Alias"}; char *webpaValues[MAX_PARAMETER_LEN] = {"webpa"}; int webpaType[MAX_PARAMETER_LEN] = {ccsp_byte}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -784,7 +827,7 @@ void err_set_with_multiple_parameters_failure_in_get() will_return(CcspBaseIf_getParameterValues, CCSP_ERR_INVALID_PARAMETER_NAME); expect_value(CcspBaseIf_getParameterValues, size, 1); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -816,6 +859,8 @@ void err_set_with_multiple_parameters_failure_in_rollback() char *webpaNames[MAX_PARAMETER_LEN] = {"Device.DeviceInfo.Webpa.Alias"}; char *webpaValues[MAX_PARAMETER_LEN] = {"webpa"}; int webpaType[MAX_PARAMETER_LEN] = {ccsp_unsignedLong}; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -879,7 +924,7 @@ void err_set_with_multiple_parameters_failure_in_rollback() expect_value(CcspBaseIf_setParameterValues, size, 1); expect_function_calls(CcspBaseIf_setParameterValues,3); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -911,7 +956,9 @@ void err_set_with_multiple_parameters_failure_in_wifi_rollback() char *webpaNames[MAX_PARAMETER_LEN] = {"Device.DeviceInfo.Webpa.Alias"}; char *webpaValues[MAX_PARAMETER_LEN] = {"webpa"}; int webpaType[MAX_PARAMETER_LEN] = {ccsp_string}; - + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); parameterValStruct_t **valueList = (parameterValStruct_t **) malloc(sizeof(parameterValStruct_t*)); @@ -981,7 +1028,7 @@ void err_set_with_multiple_parameters_failure_in_wifi_rollback() expect_value(CcspBaseIf_setParameterValues, size, 1); expect_function_calls(CcspBaseIf_setParameterValues,5); - processRequest(reqPayload, transactionId, &resPayload); + processRequest(reqPayload, transactionId, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); diff --git a/tests/test_webpa_set_attr.c b/tests/test_webpa_set_attr.c index 60cc6df8..ef59b1d5 100644 --- a/tests/test_webpa_set_attr.c +++ b/tests/test_webpa_set_attr.c @@ -73,6 +73,8 @@ void test_setAttrWithSingleParameterNotifyOn() char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; char *reqPayload = "{\"parameters\":[{\"name\":\"Device.DeviceInfo.Webpa.Enable\",\"attributes\": { \"notify\": 1}}],\"command\":\"SET_ATTRIBUTES\"}"; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); expect_function_call(CcspBaseIf_Register_Event); @@ -82,7 +84,7 @@ void test_setAttrWithSingleParameterNotifyOn() will_return(CcspBaseIf_setParameterAttributes, CCSP_SUCCESS); expect_value(CcspBaseIf_setParameterAttributes, size, 1); - processRequest(reqPayload, "abcd-1234-efgh-5678", &resPayload); + processRequest(reqPayload, "abcd-1234-efgh-5678", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -103,6 +105,8 @@ void test_setAttrWithSingleParameterNotifyOff() char *resPayload = NULL; cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; char *reqPayload = "{\"parameters\":[{\"name\":\"Device.DeviceInfo.SerialNumber\",\"attributes\": { \"notify\": 0}}],\"command\":\"SET_ATTRIBUTES\"}"; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); will_return(get_global_components, getDeviceInfoCompDetails()); @@ -121,7 +125,7 @@ void test_setAttrWithSingleParameterNotifyOff() will_return(CcspBaseIf_setParameterAttributes, CCSP_SUCCESS); expect_value(CcspBaseIf_setParameterAttributes, size, 1); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -145,6 +149,9 @@ void test_setAttrWithMultipleParameters() char *getNames[] = {"Device.WiFi.RadioNumberOfEntries", "Device.WiFi.SSID.10001.SSID", "Device.WiFi.Radio.10000.Enable","Device.WiFi.AccessPoint.10001.Name"}; int paramCount = sizeof(getNames)/sizeof(getNames[0]); int i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); expect_function_call(CcspBaseIf_Register_Event); @@ -159,7 +166,7 @@ void test_setAttrWithMultipleParameters() will_return(CcspBaseIf_setParameterAttributes, CCSP_SUCCESS); expect_value(CcspBaseIf_setParameterAttributes, size, paramCount); - processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload); + processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -186,13 +193,16 @@ void err_SetAttrWithDifferentComponents() char *getNames[] = {"Device.WiFi.RadioNumberOfEntries", "Device.NAT.EnablePortMapping"}; int paramCount = sizeof(getNames)/sizeof(getNames[0]); int i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); expect_function_call(CcspBaseIf_Register_Event); will_return(CcspBaseIf_Register_Event, CCSP_SUCCESS); expect_function_call(CcspBaseIf_SetCallback2); - processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload); + processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -216,13 +226,15 @@ void err_setAttrWithInvalidParam() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; char *resPayload = NULL; char *reqPayload = "{\"parameters\":[{\"name\":\"Device.WiFi.RadioNumberOfEntry\",\"attributes\": { \"notify\": 0}}],\"command\":\"SET_ATTRIBUTES\"}"; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); expect_function_call(CcspBaseIf_setParameterAttributes); will_return(CcspBaseIf_setParameterAttributes, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_value(CcspBaseIf_setParameterAttributes, size, 1); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -243,8 +255,10 @@ void err_setAttrWithWildcardParam() char *reqPayload = "{\"parameters\":[{\"name\":\"Device.WiFi.\",\"attributes\": { \"notify\": 0}}],\"command\":\"SET_ATTRIBUTES\"}"; char *resPayload = NULL; cJSON *response = NULL; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, "addf-sdfw-12ed-3fea", &resPayload); + processRequest(reqPayload, "addf-sdfw-12ed-3fea", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -260,6 +274,8 @@ void err_setAttrWithInvalidComponent() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; char *resPayload = NULL; char *reqPayload = "{\"parameters\":[{\"name\":\"Device.Abcd.1234\",\"attributes\": { \"notify\": 0}}],\"command\":\"SET_ATTRIBUTES\"}"; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -275,7 +291,7 @@ void err_setAttrWithInvalidComponent() will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -296,6 +312,8 @@ void err_setAttrWithInvalidComponentError() cJSON *response = NULL, *paramArray = NULL, *resParamObj = NULL; char *resPayload = NULL; char *reqPayload = "{\"parameters\":[{\"name\":\"Device.DeviceInfo.abcd\",\"attributes\": { \"notify\": 0}}],\"command\":\"SET_ATTRIBUTES\"}"; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; getCompDetails(); @@ -305,7 +323,7 @@ void err_setAttrWithInvalidComponentError() will_return(CcspBaseIf_discComponentSupportingNamespace, CCSP_CR_ERR_UNSUPPORTED_NAMESPACE); expect_function_call(free_componentStruct_t); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -329,8 +347,10 @@ void err_setAttrWithInvalidWiFiIndex() char *getNames[]={"Device.WiFi.SSID.10000.SSID","Device.WiFi.SSID.10001.Alias","Device.WiFi.Version"}; int paramCount = sizeof(getNames)/sizeof(getNames[0]); int i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -357,6 +377,8 @@ void err_setAttrWithInvalidRadioIndex() char *getNames[]={"Device.WiFi.SSID.10001.SSID","Device.WiFi.AccessPoint.10001.Alias","Device.WiFi.Radio.1.Enable"}; int paramCount = sizeof(getNames)/sizeof(getNames[0]); int i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; expect_function_call(CcspBaseIf_Register_Event); will_return(CcspBaseIf_Register_Event, CCSP_FAILURE); @@ -366,7 +388,7 @@ void err_setAttrWithInvalidRadioIndex() will_return(CcspBaseIf_Register_Event, CCSP_SUCCESS); expect_function_call(CcspBaseIf_SetCallback2); - processRequest(reqPayload, NULL, &resPayload); + processRequest(reqPayload, NULL, &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -393,6 +415,9 @@ void err_SetAttrWithDifferentComponentsMultipleParameters() char *getNames[] = {"Device.WiFi.RadioNumberOfEntries","Device.WiFi.Version","Device.WiFi.Name","Device.NAT.Version","Device.NAT.EnablePortMapping","Device.NAT.PortMapping.1.Alias"}; int paramCount = sizeof(getNames)/sizeof(getNames[0]); int i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); expect_function_call(CcspBaseIf_Register_Event); @@ -403,7 +428,7 @@ void err_SetAttrWithDifferentComponentsMultipleParameters() will_return(CcspBaseIf_Register_Event, CCSP_FAILURE); expect_function_call(CcspBaseIf_SetCallback2); - processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload); + processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload); @@ -430,6 +455,9 @@ void err_setAttrWithMultipleParametersOneInvalidParam() char *getNames[] = {"Device.NAT.PortMapping.1.Name", "Device.NAT.PortMapping.1.Alias", "Device.NAT.PortMapping.2.Port","Device.NAT.PortMapping.20.Ver"}; int paramCount = sizeof(getNames)/sizeof(getNames[0]); int i = 0; + headers_t *res_headers = NULL; + headers_t *req_headers = NULL; + getCompDetails(); expect_function_call(CcspBaseIf_Register_Event); @@ -440,7 +468,7 @@ void err_setAttrWithMultipleParametersOneInvalidParam() will_return(CcspBaseIf_setParameterAttributes, CCSP_ERR_INVALID_PARAMETER_NAME); expect_value(CcspBaseIf_setParameterAttributes, size, paramCount); - processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload); + processRequest(reqPayload, "abcd-5678-1234-efgh", &resPayload, req_headers, res_headers); WalInfo("resPayload : %s\n",resPayload); assert_non_null(resPayload);