-
Notifications
You must be signed in to change notification settings - Fork 0
/
eggdrop_chanset_inputvalidation.bats
86 lines (76 loc) · 3.25 KB
/
eggdrop_chanset_inputvalidation.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@test "Eggdrop setup" {
run cp $WORK_DIR/tests/eggdrop_chanset_inputvalidation* $HOME/eggdrop/
[ $status -eq 0 ]
run cp $WORK_DIR/tests/cmd_accept.tcl $HOME/eggdrop/scripts/
[ $status -eq 0 ]
cd $HOME/eggdrop
run ./eggdrop -m eggdrop_chanset_inputvalidation.conf 3>&-
echo $output
[ $status -eq 0 ]
echo {channel add \#eggtest} |nc localhost 45678
}
@test "Flood* accepts valid inputs" {
# Accepts X:X input
echo {channel set \#eggtest flood-deop 253:42} |nc localhost 45678
run bash -c 'echo "{channel info #eggtest}" |nc localhost 45678'
[[ $output == *"253:42"* ]]
}
@test "Flood* settings prevent non-integer input" {
# Denies X:D, D:X inputs
run bash -c 'echo {channel set \#eggtest flood-deop 4:D} |nc localhost 45678'
[[ $output == *"values must be integers"* ]]
run bash -c 'echo {channel set \#eggtest flood-deop 2a:4} |nc localhost 45678'
[[ $output == *"values must be integers >= 0"* ]]
run bash -c 'echo {channel set \#eggtest flood-deop 2:4a} |nc localhost 45678'
[[ $output == *"values must be integers >= 0"* ]]
}
@test "Flood* settings prevent single (non-zero) entry" {
# Denies just '4' as input
run bash -c 'echo {channel set \#eggtest flood-deop 4} |nc localhost 45678'
[[ $output == *"flood value must be in X:Y format"* ]]
}
@test "Flood* settings prevent invalid input format" {
# Denies entries like ':X' 'X:' '3:4:5', '3a:4'
run bash -c 'echo {channel set \#eggtest flood-deop :3} |nc localhost 45678'
[[ $output == *"flood value must be in X:Y format"* ]]
run bash -c 'echo {channel set \#eggtest flood-deop 3:} |nc localhost 45678'
[[ $output == *"flood value must be in X:Y format"* ]]
run bash -c 'echo {channel set \#eggtest flood-deop 53:75:86} |nc localhost 45678'
[[ $output == *"flood value must be in X:Y format"* ]]
}
@test "Flood* settings prevent negative numbers" {
run bash -c 'echo {channel set \#eggtest flood-deop -1:8} |nc localhost 45678'
[[ $output == *"values must be integers >= 0"* ]]
}
@test "Flood* set to 0 clears flood setting" {
# 0, 0:0, 4:0, 0:4
echo {channel set \#eggtest flood-deop 6:9} |nc localhost 45678
bash -c 'echo {channel set \#eggtest flood-deop 0} |nc localhost 45678'
run bash -c 'echo {channel info \#eggtest} |nc localhost 45678'
FOO=$(echo $output| cut -d " " -f 15)
[ $FOO == "0:0" ]
echo {channel set \#eggtest flood-deop 6:9} |nc localhost 45678
bash -c 'echo {channel set \#eggtest flood-deop 0:0} |nc localhost 45678'
run bash -c 'echo {channel info \#eggtest} |nc localhost 45678'
FOO=$(echo $output| cut -d " " -f 15)
[ $FOO == "0:0" ]
echo {channel set \#eggtest flood-deop 6:9} |nc localhost 45678
bash -c 'echo {channel set \#eggtest flood-deop 9:0} |nc localhost 45678'
run bash -c 'echo {channel info \#eggtest} |nc localhost 45678'
FOO=$(echo $output| cut -d " " -f 15)
[ $FOO == "9:0" ]
echo {channel set \#eggtest flood-deop 6:9} |nc localhost 45678
bash -c 'echo {channel set \#eggtest flood-deop 0:8} |nc localhost 45678'
run bash -c 'echo {channel info \#eggtest} |nc localhost 45678'
FOO=$(echo $output| cut -d " " -f 15)
[ $FOO == "0:8" ]
}
@test "Kill Eggdrop" {
ps x|grep "[e]ggdrop "
if [ $? -eq 0 ]; then
pkill eggdrop
fi
if [ -e $HOME/eggdrop/tempuser.user ]; then
rm $HOME/eggdrop/tempsuer.user
fi
}