diff --git a/tests/test_webpa_replace.c b/tests/test_webpa_replace.c index 1e278423..4b96db3e 100644 --- a/tests/test_webpa_replace.c +++ b/tests/test_webpa_replace.c @@ -73,6 +73,11 @@ void addRowTable(char *objectName, TableData *list,char **retObject, money_trace void deleteRowTable(char *object, money_trace_spans *timeSpan, WDMP_STATUS *retStatus) { UNUSED(object); UNUSED(timeSpan); UNUSED(retStatus); + (*timeSpan).count = 1; + (*timeSpan).spans = (money_trace_span *)malloc(sizeof(money_trace_span)); + (*timeSpan).spans[0].name = strdup("component name"); + (*timeSpan).spans[0].duration = 23; + *retStatus = get_global_status(); function_called(); } @@ -103,7 +108,7 @@ void test_replaceRow() list[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); list[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); - + componentStruct_t **list1 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); list1[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); @@ -261,6 +266,530 @@ void test_replaceRow_to_empty_table() cJSON_Delete(response); } +void test_replaceRow_failure_in_delete_tableData() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTable.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + int count = 1, paramCount = 6, i = 0; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + 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); + list[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + + componentStruct_t **list1 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list1[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list1[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); + for(i = 0; i 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_string_equal("Success", cJSON_GetObjectItem(response, "message")->valuestring); + assert_int_equal(200, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_failure_in_addNewRow() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTable.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + int count = 1, paramCount = 2, i = 0; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + 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); + list[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + + componentStruct_t **list1 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list1[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list1[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); + for(i = 0; i 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_failure_in_addCachedRow() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTable.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + int count = 1, paramCount = 2, i = 0; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + 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); + list[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + + componentStruct_t **list1 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list1[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list1[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); + for(i = 0; i 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_with_invalid_table() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTab.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + + 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, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_failure_in_getValues() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTable.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + int count = 1, paramCount = 2, i = 0; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + 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); + list[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + + 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, NULL); + will_return(get_global_parameters_count, 0); + expect_function_call(CcspBaseIf_getParameterValues); + will_return(CcspBaseIf_getParameterValues, CCSP_CR_ERR_INVALID_PARAM); + expect_value(CcspBaseIf_getParameterValues, size, 1); + expect_function_call(free_componentStruct_t); + expect_function_call(free_parameterValStruct_t); + processRequest(reqPayload, transactionId, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_failure_in_construct_rollbackData() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTable.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + int count = 1, paramCount = 2, i = 0; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + 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); + list[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); + for(i = 0; i 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_failure_in_get_writable_params() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10001.X_CISCO_COM_MacFilterTable.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + int count = 1, paramCount = 2, i = 0; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + 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); + list[0]->dbusPath = strdup(RDKB_WIFI_DBUS_PATH); + + componentStruct_t **list1 = (componentStruct_t **) malloc(sizeof(componentStruct_t *)*count); + list1[0] = (componentStruct_t *) malloc(sizeof(componentStruct_t)); + list1[0]->componentName = strdup(RDKB_WIFI_FULL_COMPONENT_NAME); + list1[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); + for(i = 0; i 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_with_invalid_wifi_index() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.AccessPoint.10021.X_CISCO_COM_MacFilterTab.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + + processRequest(reqPayload, transactionId, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_with_invalid_radio_index() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.Radio.10021.X_CISCO_COM_MacFilterTab.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + + processRequest(reqPayload, transactionId, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_with_invalid_table_length() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.Radio.10021.X_CISCO_COM_MacFilterTabDevice1DeviceNamesfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdferfddfffddfgffdddff.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + + processRequest(reqPayload, transactionId, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_with_invalid_parameter_name_length() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceNamefdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdferfddfffddfgffdddff\":\"Device1\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.Radio.10021.X_CISCO_COM_MacFilterTab.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + + processRequest(reqPayload, transactionId, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + +void err_replaceRow_with_invalid_parameter_value_length() +{ + char *reqPayload = "{\"rows\":{\"0\":{\"DeviceName\":\"Device1fdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGsfdgfgherejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdfosFYQWPIYRSDAWIEUFTGJVHEDFKWJESDFWEGFWEGFGAQWWEGYTEHERHAEGTWERHTBQR4WYTRejrehigeiruwegwegwiegfuwgfegfwegfwefegaugdferfddfffddfgffdddff\",\"MacAddress\":\"12:2:3:5:11\"},\"1\":{\"DeviceName\":\"Device2\",\"MacAddress\":\"2:1:3:5:7\"} },\"table\" : \"Device.WiFi.Radio.10021.X_CISCO_COM_MacFilterTab.\",\"command\":\"REPLACE_ROWS\"}"; + char *transactionId = "aasfsdfgeh"; + char *resPayload = NULL; + cJSON *response = NULL; + money_trace_spans timeSpan; + memset(&timeSpan, 0, sizeof(money_trace_spans)); + + processRequest(reqPayload, transactionId, true, &resPayload, &timeSpan); + WalInfo("resPayload : %s\n",resPayload); + assert_true(timeSpan.count > 0); + assert_non_null(timeSpan.spans); + assert_non_null(resPayload); + response = cJSON_Parse(resPayload); + assert_int_equal(520, cJSON_GetObjectItem(response, "statusCode")->valueint); + assert_non_null(response); + cJSON_Delete(response); +} + /*----------------------------------------------------------------------------*/ /* External Functions */ /*----------------------------------------------------------------------------*/ @@ -271,6 +800,18 @@ int main(void) cmocka_unit_test(test_replaceRow), cmocka_unit_test(test_replaceRow_empty_table), cmocka_unit_test(test_replaceRow_to_empty_table), + cmocka_unit_test(test_replaceRow_failure_in_delete_tableData), + cmocka_unit_test(err_replaceRow_failure_in_addNewRow), + cmocka_unit_test(err_replaceRow_failure_in_addCachedRow), + cmocka_unit_test(err_replaceRow_with_invalid_table), + cmocka_unit_test(err_replaceRow_failure_in_getValues), + cmocka_unit_test(err_replaceRow_failure_in_construct_rollbackData), + cmocka_unit_test(err_replaceRow_failure_in_get_writable_params), + cmocka_unit_test(err_replaceRow_with_invalid_wifi_index), + cmocka_unit_test(err_replaceRow_with_invalid_radio_index), + cmocka_unit_test(err_replaceRow_with_invalid_table_length), + cmocka_unit_test(err_replaceRow_with_invalid_parameter_name_length), + cmocka_unit_test(err_replaceRow_with_invalid_parameter_value_length) }; return cmocka_run_group_tests(tests, NULL, NULL);