mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Ticket refs #5755: icwmp: Add functiona test and update readme
This commit is contained in:
parent
6f27b50f11
commit
a9d8e076e2
7 changed files with 213 additions and 4 deletions
|
|
@ -37,7 +37,7 @@ echo "## Running script verification of functionalities ##"
|
|||
echo > ./funl-test-result.log
|
||||
echo > ./funl-test-debug.log
|
||||
test_num=0
|
||||
for test in `ls -I "common.sh" test/script/`; do
|
||||
for test in `ls -I "common.sh" -I "verify_custom_notifications.sh" test/script/`; do
|
||||
test_num=$(( test_num + 1 ))
|
||||
./test/script/${test}
|
||||
if [ "$?" -eq 0 ]; then
|
||||
|
|
@ -47,11 +47,23 @@ for test in `ls -I "common.sh" test/script/`; do
|
|||
fi
|
||||
done
|
||||
|
||||
echo "1..${test_num}" >> ./funl-test-result.log
|
||||
|
||||
echo "Stop all services"
|
||||
supervisorctl stop icwmpd
|
||||
|
||||
cp test/files/etc/config/users /etc/config/
|
||||
cp test/files/etc/config/wireless /etc/config/
|
||||
|
||||
echo "Verify Custom notifications"
|
||||
./test/script/verify_custom_notifications.sh
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "ok - verify_custom_notifications" >> ./funl-test-result.log
|
||||
else
|
||||
echo "not ok - verify_custom_notifications" >> ./funl-test-result.log
|
||||
fi
|
||||
|
||||
test_num=$(( test_num + 1 ))
|
||||
echo "1..${test_num}" >> ./funl-test-result.log
|
||||
|
||||
# Artefact
|
||||
gcovr -r . 2> /dev/null --xml -o ./funl-test-coverage.xml
|
||||
#GitLab-CI output
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ void load_json_custom_notify_file(struct cwmp *cwmp)
|
|||
continue;
|
||||
}
|
||||
if (strcmp(fault, "9009") == 0) {
|
||||
CWMP_LOG(WARNING, "This parameter %s is force notification parameter, can't be changed", blobmsg_get_string(tb[0]));
|
||||
CWMP_LOG(WARNING, "This parameter %s is forced notification parameter, can't be changed", blobmsg_get_string(tb[0]));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
test/files/etc/icwmpd/custom_notification_forced.json
Normal file
12
test/files/etc/icwmpd/custom_notification_forced.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"custom_notification": [
|
||||
{
|
||||
"parameter": "Device.Users.",
|
||||
"notify_type": "2"
|
||||
},
|
||||
{
|
||||
"parameter": "Device.DeviceInfo.ProvisioningCode",
|
||||
"notify_type": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
12
test/files/etc/icwmpd/custom_notification_invalid_json.json
Normal file
12
test/files/etc/icwmpd/custom_notification_invalid_json.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"custom_notification":
|
||||
{
|
||||
"parameter": "Device.Users.",
|
||||
"notify_type": "2"
|
||||
},
|
||||
{
|
||||
"parameter": "Device.WiFi.SSID.1.SSID",
|
||||
"notify_type": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"custom_notification": [
|
||||
{
|
||||
"parameter": "Device.Users.",
|
||||
"notify_type": "2"
|
||||
},
|
||||
{
|
||||
"parameter": "Device.WiFi.SSID.1.SD",
|
||||
"notify_type": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
12
test/files/etc/icwmpd/custom_notification_valid.json
Normal file
12
test/files/etc/icwmpd/custom_notification_valid.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"custom_notification": [
|
||||
{
|
||||
"parameter": "Device.Users.",
|
||||
"notify_type": "2"
|
||||
},
|
||||
{
|
||||
"parameter": "Device.WiFi.SSID.1.SSID",
|
||||
"notify_type": "1"
|
||||
}
|
||||
]
|
||||
}
|
||||
149
test/script/verify_custom_notifications.sh
Executable file
149
test/script/verify_custom_notifications.sh
Executable file
|
|
@ -0,0 +1,149 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ./test/script/common.sh
|
||||
source ./gitlab-ci/shared.sh
|
||||
|
||||
TEST_NAME="Custom Notifications"
|
||||
|
||||
echo "Running: $TEST_NAME"
|
||||
|
||||
echo "Install notification json files"
|
||||
exec_cmd mkdir -p /etc/icwmpd
|
||||
exec_cmd cp test/files/etc/icwmpd/custom_notification* /etc/icwmpd
|
||||
|
||||
#
|
||||
# Test a valid custom notification json file
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci delete cwmp.@notifications[0]
|
||||
uci commit cwmp
|
||||
|
||||
exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_valid.json"
|
||||
uci commit cwmp
|
||||
|
||||
touch /etc/icwmpd/.icwmpd_notify
|
||||
|
||||
supervisorctl start icwmpd
|
||||
sleep 5
|
||||
|
||||
notif1=`uci get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 != *"Device.Users."* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci get cwmp.@notifications[0].passive | grep "Device.WiFi.SSID.1.SSID"`
|
||||
if [[ $notif2 != *"Device.WiFi.SSID.1.SSID"* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.WiFi.SSID.1.SSID parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
supervisorctl stop icwmpd
|
||||
|
||||
echo "PASS test valid custom notification json file"
|
||||
|
||||
#
|
||||
# Test custom notification invalid json file
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci delete cwmp.@notifications[0]
|
||||
uci commit cwmp
|
||||
|
||||
exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_invalid_json.json"
|
||||
uci commit cwmp
|
||||
|
||||
touch /etc/icwmpd/.icwmpd_notify
|
||||
|
||||
supervisorctl start icwmpd
|
||||
sleep 5
|
||||
|
||||
notif1=`uci get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 == *"Device.Users."* ]]; then
|
||||
echo "FAIL: the json file is invalid, the active notifcation list shouldn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci get cwmp.@notifications[0].passive | grep "Device.WiFi.SSID.1.SSID"`
|
||||
if [[ $notif2 == *"Device.WiFi.SSID.1.SSID"* ]]; then
|
||||
echo "FAIL: the json file is invalid, the active notifcation list shouldn't contain Device.WiFi.SSID.1.SSID parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logfile=`cat /var/log/icwmpd.log`
|
||||
if [[ $logfile != *"[WARNING] The file /etc/icwmpd/custom_notification_invalid_json.json is not a valid JSON file"* ]]; then
|
||||
echo "FAIL: Log file doesn't contain a WARNING that the file /etc/icwmpd/custom_notification_invalid_json.json is not valid."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS test custom notification invalid json file"
|
||||
supervisorctl stop icwmpd
|
||||
|
||||
#
|
||||
# Test custom notification json file containing forced active notification
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci delete cwmp.@notifications[0]
|
||||
uci commit cwmp
|
||||
|
||||
exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_forced.json"
|
||||
uci commit cwmp
|
||||
|
||||
touch /etc/icwmpd/.icwmpd_notify
|
||||
|
||||
supervisorctl start icwmpd
|
||||
sleep 5
|
||||
|
||||
notif1=`uci get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 != *"Device.Users."* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci get cwmp.@notifications[0].passive | grep "Device.DeviceInfo.ProvisioningCode"`
|
||||
if [[ $notif2 == *"Device.DeviceInfo.ProvisioningCode"* ]]; then
|
||||
echo "FAIL: passive notifications list contains Device.DeviceInfo.ProvisioningCode while it's a forced active notification paramter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logfile=`cat /var/log/icwmpd.log`
|
||||
if [[ $logfile != *"[WARNING] This parameter Device.DeviceInfo.ProvisioningCode is forced notification parameter, can't be changed"* ]]; then
|
||||
echo "FAIL: Device.DeviceInfo.ProvisioningCode is forced notification parameter, can't be changed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS test custom notification json file containing forced active notification"
|
||||
supervisorctl stop icwmpd
|
||||
|
||||
#
|
||||
# Test custom notification json file containing invalid parameter path
|
||||
#
|
||||
rm /var/log/icwmpd.log
|
||||
uci delete cwmp.@notifications[0]
|
||||
uci commit cwmp
|
||||
|
||||
exec_cmd uci set cwmp.cpe.json_custom_notify_file="/etc/icwmpd/custom_notification_invalid_parameter.json"
|
||||
uci commit cwmp
|
||||
|
||||
touch /etc/icwmpd/.icwmpd_notify
|
||||
|
||||
supervisorctl start icwmpd
|
||||
sleep 5
|
||||
|
||||
notif1=`uci get cwmp.@notifications[0].active | grep "Device.Users."`
|
||||
if [[ $notif1 != *"Device.Users."* ]]; then
|
||||
echo "FAIL: active notifications list doesn't contain Device.Users. parameter"
|
||||
exit 1
|
||||
fi
|
||||
notif2=`uci get cwmp.@notifications[0].passive | grep "Device.WiFi.SSID.1.SD"`
|
||||
if [[ $notif2 == *"Device.WiFi.SSID.1.SD"* ]]; then
|
||||
echo "FAIL: passive notifications list contains Device.WiFi.SSID.1.SD while it's a wrong parameter path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
logfile=`cat /var/log/icwmpd.log`
|
||||
if [[ $logfile != *"[WARNING] The parameter Device.WiFi.SSID.1.SD is wrong path"* ]]; then
|
||||
echo "FAIL: Log file should contain WARNING that Device.WiFi.SSID.1.SD is wrong parameter path."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "PASS test custom notification json file containing invalid parameter path"
|
||||
supervisorctl stop icwmpd
|
||||
|
||||
echo "PASS: $TEST_NAME"
|
||||
Loading…
Add table
Reference in a new issue