diff options
Diffstat (limited to 'test/ssh/sftp.exp')
-rwxr-xr-x | test/ssh/sftp.exp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/ssh/sftp.exp b/test/ssh/sftp.exp new file mode 100755 index 000000000..3b0124ec7 --- /dev/null +++ b/test/ssh/sftp.exp | |||
@@ -0,0 +1,87 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | send -- "ssh firejail-test@0\r" | ||
8 | expect { | ||
9 | timeout {puts "TESTING ERROR 0\n";exit} | ||
10 | "Child process initialized" {puts "OK\n"} | ||
11 | "an existing sandbox was detected" {puts "OK\n"} | ||
12 | } | ||
13 | sleep 1 | ||
14 | |||
15 | send -- "rm -f testfile\r" | ||
16 | after 100 | ||
17 | send -- "exit\r" | ||
18 | sleep 1 | ||
19 | |||
20 | send -- "echo 12345 > testfile\r" | ||
21 | after 100 | ||
22 | send -- "sftp firejail-test@0\r" | ||
23 | expect { | ||
24 | timeout {puts "TESTING ERROR 1\n";exit} | ||
25 | "Connected to 0" | ||
26 | } | ||
27 | expect { | ||
28 | timeout {puts "TESTING ERROR 2\n";exit} | ||
29 | "sftp>" | ||
30 | } | ||
31 | after 100 | ||
32 | send -- "put testfile\r" | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 3\n";exit} | ||
35 | "100%" | ||
36 | } | ||
37 | after 100 | ||
38 | send -- "exit\r" | ||
39 | sleep 1 | ||
40 | |||
41 | |||
42 | send -- "ssh firejail-test@0\r" | ||
43 | expect { | ||
44 | timeout {puts "TESTING ERROR 4\n";exit} | ||
45 | "Child process initialized" {puts "OK\n"} | ||
46 | "an existing sandbox was detected" {puts "OK\n"} | ||
47 | } | ||
48 | sleep 1 | ||
49 | send -- "cat testfile\r" | ||
50 | expect { | ||
51 | timeout {puts "TESTING ERROR 5\n";exit} | ||
52 | "12345" | ||
53 | } | ||
54 | after 100 | ||
55 | send -- "exit\r" | ||
56 | sleep 1 | ||
57 | |||
58 | send -- "rm testfile\r" | ||
59 | after 100 | ||
60 | send -- "sftp firejail-test@0\r" | ||
61 | expect { | ||
62 | timeout {puts "TESTING ERROR 6\n";exit} | ||
63 | "Connected to 0" | ||
64 | } | ||
65 | expect { | ||
66 | timeout {puts "TESTING ERROR 7\n";exit} | ||
67 | "sftp>" | ||
68 | } | ||
69 | after 100 | ||
70 | send -- "get testfile\r" | ||
71 | expect { | ||
72 | timeout {puts "TESTING ERROR 8\n";exit} | ||
73 | "100%" | ||
74 | } | ||
75 | after 100 | ||
76 | send -- "exit\r" | ||
77 | sleep 1 | ||
78 | send -- "cat testfile\r" | ||
79 | expect { | ||
80 | timeout {puts "TESTING ERROR 9\n";exit} | ||
81 | "12345" | ||
82 | } | ||
83 | after 100 | ||
84 | send -- "rm testfile\r" | ||
85 | sleep 1 | ||
86 | |||
87 | puts "\nall done\n" | ||