aboutsummaryrefslogtreecommitdiffstats
path: root/test/fnetfilter/template.exp
blob: eb57313bd502e9aeadd8bb1caff525de144055ad (plain) (blame)
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
#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2017 Firejail Authors
# License GPL v2

set timeout 10
spawn $env(SHELL)
match_max 100000

send -- "rm outfile\r"
after 100

send -- "fnetfilter test2.net,icmp-type,destination-unreachable,time-exceeded,echo-request,3478,3479 outfile\r"
after 100

send -- "cat outfile\r"
expect {
	timeout {puts "TESTING ERROR 1\n";exit}
	"*filter"
}
expect {
	timeout {puts "TESTING ERROR 2\n";exit}
	"INPUT -m state --state RELATED,ESTABLISHED"
}
expect {
	timeout {puts "TESTING ERROR 3\n";exit}
	"icmp-type echo-reply"
}
expect {
	timeout {puts "TESTING ERROR 4\n";exit}
	"icmp-type destination-unreachable"
}
expect {
	timeout {puts "TESTING ERROR 5\n";exit}
	"icmp-type time-exceeded"
}
expect {
	timeout {puts "TESTING ERROR 6\n";exit}
	"icmp-type echo-request"
}
expect {
	timeout {puts "TESTING ERROR 7\n";exit}
	"dport 3478"
}
expect {
	timeout {puts "TESTING ERROR 8\n";exit}
	"dport 3479"
}
expect {
	timeout {puts "TESTING ERROR 8\n";exit}
	"dport 3478"
}
expect {
	timeout {puts "TESTING ERROR 10\n";exit}
	"dport 3479"
}
after 100

send -- "fnetfilter test2.net,icmp-type,destination-unreachable,time-exceeded,echo-request outfile\r"
expect {
	timeout {puts "TESTING ERROR 11\n";exit}
	"ARG5 on line 14 was not defined"
}
after 100

send -- "fnetfilter test2.net,icmp-type,destination-unreachable,time-exceeded,echo-request\r"
expect {
	timeout {puts "TESTING ERROR 12\n";exit}
	"invalid destination file in netfilter command"
}
after 100

send -- "fnetfilter test3.net,44 outfile\r"
expect {
	timeout {puts "TESTING ERROR 13\n";exit}
	"invalid template argument on line 1"
}
after 100
send -- "rm outfile\r"
after 100

puts "\nall done\n"