icwmp/test/script/verify_delete_method.sh
2022-12-07 20:58:46 +05:30

45 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
source ./test/script/common.sh
source ./gitlab-ci/shared.sh
TEST_NAME="DELETE RPC Method"
echo "Running: $TEST_NAME"
remove_icwmp_log
curl $connection_request_path -X POST --data '{"name": "deleteObject","objectName":"Device.Users.User.2"}' >/dev/null 2>&1
check_ret $?
sleep 2
check_session "DeleteObject"
status=$(print_tag_value "cwmp:DeleteObjectResponse" "Status")
if [ "$status" != "1" ]; then
echo "Error: Delete Object Method doesn't work correctly, current_value($status) expected_value(1)" >> ./funl-test-debug.log
exit 1
fi
# Since user object is deleted by init script so, delete the user from uci here
del_list=$(uci show users | grep -E "^users\.[A-Za-z0-9_]+\.deleted='1'$")
if [ -n $del_list ]; then
for line in $del_list;
do
sec=$(echo $line | cut -d. -f2)
sec_type=$(uci get users.$sec)
if [ "${sec_type}" == "user" ]; then
uci delete users.${sec}
uci commit users
fi
done
fi
remove_icwmp_log
curl $connection_request_path -X POST --data '{"name": "getParameterValues", "parameterNames": ["Device.Users.User"] }' >/dev/null 2>&1
check_ret $?
sleep 2
check_session "GetParameterValues"
if grep -q "Device.Users.User.2" "$icwmp_log_file"; then
echo "Error: 'Device.Users.User.2' object is not really deleted" >> ./funl-test-debug.log
exit 1
fi
echo "PASS: $TEST_NAME"