aboutsummaryrefslogtreecommitdiffstats
path: root/test/network/iprange.exp
diff options
context:
space:
mode:
Diffstat (limited to 'test/network/iprange.exp')
-rwxr-xr-xtest/network/iprange.exp103
1 files changed, 103 insertions, 0 deletions
diff --git a/test/network/iprange.exp b/test/network/iprange.exp
new file mode 100755
index 000000000..a1b2ccab4
--- /dev/null
+++ b/test/network/iprange.exp
@@ -0,0 +1,103 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2016 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --net=br1 --iprange=10.10.30.50,10.10.30.55\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "eth0"
14}
15expect {
16 timeout {puts "TESTING ERROR 1\n";exit}
17 "10.10.30.50" {puts "10.10.30.50\n"}
18 "10.10.30.51" {puts "10.10.30.51\n"}
19 "10.10.30.52" {puts "10.10.30.52\n"}
20 "10.10.30.53" {puts "10.10.30.53\n"}
21 "10.10.30.54" {puts "10.10.30.54\n"}
22 "10.10.30.55" {puts "10.10.30.55\n"}
23}
24expect {
25 timeout {puts "TESTING ERROR 2\n";exit}
26 "255.255.255.0"
27}
28expect {
29 timeout {puts "TESTING ERROR 3\n";exit}
30 "Child process initialized"
31}
32sleep 1
33send -- "exit\r"
34sleep 2
35
36send -- "firejail --profile=iprange.profile\r"
37expect {
38 timeout {puts "TESTING ERROR 5\n";exit}
39 "eth0"
40}
41expect {
42 timeout {puts "TESTING ERROR 6\n";exit}
43 "10.10.30.50" {puts "10.10.30.50\n"}
44 "10.10.30.51" {puts "10.10.30.51\n"}
45 "10.10.30.52" {puts "10.10.30.52\n"}
46 "10.10.30.53" {puts "10.10.30.53\n"}
47 "10.10.30.54" {puts "10.10.30.54\n"}
48 "10.10.30.55" {puts "10.10.30.55\n"}
49}
50expect {
51 timeout {puts "TESTING ERROR 7\n";exit}
52 "255.255.255.0"
53}
54expect {
55 timeout {puts "TESTING ERROR 8\n";exit}
56 "Child process initialized"
57}
58sleep 1
59send -- "exit\r"
60sleep 2
61
62
63
64send -- "firejail --iprange=10.10.30.50,10.10.30.55\r"
65expect {
66 timeout {puts "TESTING ERROR 9\n";exit}
67 "no network device configured"
68}
69after 100
70
71send -- "firejail --net=br1 --iprange=10.10.30.50,10.10.30.55 --iprange=10.10.30.50,10.10.30.55\r"
72expect {
73 timeout {puts "TESTING ERROR 10\n";exit}
74 "cannot configure the IP range twice for the same interface"
75}
76after 100
77
78send -- "firejail --net=br1 --iprange=10.10.30.50\r"
79expect {
80 timeout {puts "TESTING ERROR 11\n";exit}
81 "invalid IP range"
82}
83after 100
84
85send -- "firejail --net=br0 --iprange=10.10.30.50,10.10.30.55\r"
86expect {
87 timeout {puts "TESTING ERROR 12\n";exit}
88 "IP range addresses not in network range"
89}
90after 100
91
92send -- "firejail --net=br1 --iprange=10.10.30.55,10.10.30.50\r"
93expect {
94 timeout {puts "TESTING ERROR 12\n";exit}
95 "invalid IP range"
96}
97after 100
98
99
100after 100
101
102puts "\nall done\n"
103