2020-05-04 00:30:41 +00:00
|
|
|
#!/bin/sh
|
2015-09-22 15:13:26 +00:00
|
|
|
# $Id: testupnppermissions.sh,v 1.2 2015/09/22 15:12:14 nanard Exp $
|
2015-09-22 14:02:19 +00:00
|
|
|
|
2020-05-04 00:30:41 +00:00
|
|
|
RULE_1="allow 1-20000 11.12.13.14/22 1234"
|
|
|
|
RULEA_1="allow 1-20000 0b0c0d0e/fffffc00 1234-1234"
|
|
|
|
RULEB_1="allow 1-20000 11.12.13.14/255.255.252.0 1234-1234"
|
|
|
|
RULE_2="deny 55 21.22.23.24/17 555-559"
|
|
|
|
RULEA_2="deny 55-55 15161718/ffff8000 555-559"
|
|
|
|
RULEB_2="deny 55-55 21.22.23.24/255.255.128.0 555-559"
|
2015-09-22 14:02:19 +00:00
|
|
|
|
|
|
|
i=1
|
|
|
|
s=1
|
2020-05-04 00:30:41 +00:00
|
|
|
./testupnppermissions "$RULE_1" "$RULE_2" | while read l;
|
2015-09-22 14:02:19 +00:00
|
|
|
do
|
|
|
|
if [ -z "$l" ]; then i=$(($i+1)); s=1; else
|
2015-09-22 15:13:26 +00:00
|
|
|
#echo "$i $s : checking '$l'"
|
2015-09-22 14:02:19 +00:00
|
|
|
case $s in
|
|
|
|
1)
|
2020-05-04 00:30:41 +00:00
|
|
|
val=$(eval echo "\${RULE_$i}")
|
|
|
|
if [ "$i '$val'" != "$l" ] ; then
|
2015-09-22 14:02:19 +00:00
|
|
|
exit $s
|
|
|
|
fi;;
|
|
|
|
2)
|
2020-05-04 00:30:41 +00:00
|
|
|
val=$(eval echo "\${RULEA_$i}")
|
2015-09-22 15:13:26 +00:00
|
|
|
if [ "Permission read successfully" = "$l" ] ; then
|
|
|
|
s=$(($s+1))
|
2020-05-04 00:30:41 +00:00
|
|
|
elif [ "perm rule added : $val" != "$l" ] ; then
|
2015-09-22 14:02:19 +00:00
|
|
|
exit $s
|
|
|
|
fi;;
|
|
|
|
3)
|
2015-09-22 15:13:26 +00:00
|
|
|
if [ "Permission read successfully" != "$l" ] ; then
|
2015-09-22 14:02:19 +00:00
|
|
|
exit $s
|
|
|
|
fi;;
|
|
|
|
4)
|
2020-05-04 00:30:41 +00:00
|
|
|
val=$(eval echo "\${RULEB_$i}")
|
|
|
|
if [ "$val" != "$l" ] ; then
|
2015-09-22 14:02:19 +00:00
|
|
|
exit $s
|
|
|
|
fi;;
|
|
|
|
*)
|
|
|
|
echo "$i $s : $l"
|
|
|
|
exit $s
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
s=$(($s+1))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# retrieve return status from subshell
|
|
|
|
r=$?
|
|
|
|
|
|
|
|
if [ $r -eq 0 ] ; then
|
|
|
|
echo "testupnppermissions tests OK"
|
|
|
|
else
|
|
|
|
echo "testupnppermissions tests FAILED"
|
|
|
|
fi
|
|
|
|
exit $r
|