diff options
author | netblue30 <netblue30@yahoo.com> | 2018-04-01 13:45:12 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2018-04-01 13:45:12 -0400 |
commit | 17b8cfa97fb2fbf819eac53900bf9d0fd5225f73 (patch) | |
tree | 32159b1426ba5ed7c778567ded94423d45378d5d /test | |
parent | testing (diff) | |
download | firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.tar.gz firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.tar.zst firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.zip |
testing ssh
Diffstat (limited to 'test')
-rwxr-xr-x | test/login_ssh.exp | 59 | ||||
-rwxr-xr-x | test/root/root.sh | 2 | ||||
-rwxr-xr-x | test/ssh/login.exp | 49 | ||||
-rwxr-xr-x | test/ssh/scp.exp | 63 | ||||
-rwxr-xr-x | test/ssh/sftp.exp | 87 | ||||
-rwxr-xr-x | test/ssh/ssh.sh | 16 |
6 files changed, 215 insertions, 61 deletions
diff --git a/test/login_ssh.exp b/test/login_ssh.exp deleted file mode 100755 index db0721d25..000000000 --- a/test/login_ssh.exp +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | |||
3 | set timeout 10 | ||
4 | spawn $env(SHELL) | ||
5 | match_max 100000 | ||
6 | |||
7 | send -- "ssh bingo@0\r" | ||
8 | expect { | ||
9 | timeout {puts "TESTING ERROR 0\n";exit} | ||
10 | "password:" { | ||
11 | puts "\nTESTING: please enter SSH password" | ||
12 | set oldmode [stty -echo -raw] | ||
13 | expect_user -re "(.*)\n" | ||
14 | send_user "\n" | ||
15 | eval stty $oldmode | ||
16 | # stty echo | ||
17 | set pass $expect_out(1,string) | ||
18 | send -- "$pass\r" | ||
19 | puts "TESTING: password sent to the server" | ||
20 | } | ||
21 | "Child process initialized" | ||
22 | } | ||
23 | sleep 1 | ||
24 | |||
25 | # test default gw | ||
26 | send -- "bash\r" | ||
27 | sleep 1 | ||
28 | send -- "ps aux; pwd\r" | ||
29 | expect { | ||
30 | timeout {puts "TESTING ERROR 1\n";exit} | ||
31 | "/bin/bash" | ||
32 | } | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 2\n";exit} | ||
35 | "bash" | ||
36 | } | ||
37 | expect { | ||
38 | timeout {puts "TESTING ERROR 3\n";exit} | ||
39 | "ps aux" | ||
40 | } | ||
41 | expect { | ||
42 | timeout {puts "TESTING ERROR 4\n";exit} | ||
43 | "home" | ||
44 | } | ||
45 | sleep 1 | ||
46 | |||
47 | |||
48 | send -- "ps aux |wc -l; pwd\r" | ||
49 | expect { | ||
50 | timeout {puts "TESTING ERROR 5\n";exit} | ||
51 | "6" | ||
52 | } | ||
53 | expect { | ||
54 | timeout {puts "TESTING ERROR 6\n";exit} | ||
55 | "home" | ||
56 | } | ||
57 | sleep 1 | ||
58 | |||
59 | puts "\nall done\n" | ||
diff --git a/test/root/root.sh b/test/root/root.sh index d77982993..3a20e4ba4 100755 --- a/test/root/root.sh +++ b/test/root/root.sh | |||
@@ -11,10 +11,8 @@ which less | |||
11 | if [ "$?" -eq 0 ]; | 11 | if [ "$?" -eq 0 ]; |
12 | then | 12 | then |
13 | echo "TESTING: firecfg (test/root/firecfg.exp)" | 13 | echo "TESTING: firecfg (test/root/firecfg.exp)" |
14 | rm -fr /home/netblue/.local/share/applications-store | ||
15 | mv /home/netblue/.local/share/applications /home/netblue/.local/share/applications-store | 14 | mv /home/netblue/.local/share/applications /home/netblue/.local/share/applications-store |
16 | ./firecfg.exp | 15 | ./firecfg.exp |
17 | rm -fr /home/netblue/.local/share/applications | ||
18 | mv /home/netblue/.local/share/applications-store /home/netblue/.local/share/applications | 16 | mv /home/netblue/.local/share/applications-store /home/netblue/.local/share/applications |
19 | else | 17 | else |
20 | echo "TESTING SKIP: firecfg, less not found" | 18 | echo "TESTING SKIP: firecfg, less not found" |
diff --git a/test/ssh/login.exp b/test/ssh/login.exp new file mode 100755 index 000000000..479292c91 --- /dev/null +++ b/test/ssh/login.exp | |||
@@ -0,0 +1,49 @@ | |||
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 -- "ps aux | wc -l\r" | ||
16 | expect { | ||
17 | timeout {puts "TESTING ERROR 1\n";exit} | ||
18 | "5" | ||
19 | } | ||
20 | after 100 | ||
21 | |||
22 | send -- "ls -l /home | grep drw | wc -l\r" | ||
23 | expect { | ||
24 | timeout {puts "TESTING ERROR 2\n";exit} | ||
25 | "1" | ||
26 | } | ||
27 | after 100 | ||
28 | |||
29 | send -- "cat /proc/self/status | grep Seccomp\r" | ||
30 | expect { | ||
31 | timeout {puts "TESTING ERROR 3\n";exit} | ||
32 | "2" | ||
33 | } | ||
34 | after 100 | ||
35 | |||
36 | send -- "cat /proc/self/status | grep CapBnd\r" | ||
37 | expect { | ||
38 | timeout {puts "TESTING ERROR 4\n";exit} | ||
39 | "0000000000000000" | ||
40 | } | ||
41 | after 100 | ||
42 | |||
43 | # preparing scp/sftp tests | ||
44 | send -- "rm testfile\r" | ||
45 | |||
46 | send -- "exit\r" | ||
47 | sleep 1 | ||
48 | |||
49 | puts "\nall done\n" | ||
diff --git a/test/ssh/scp.exp b/test/ssh/scp.exp new file mode 100755 index 000000000..355125751 --- /dev/null +++ b/test/ssh/scp.exp | |||
@@ -0,0 +1,63 @@ | |||
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 -- "scp testfile firejail-test@0:~/testfile\r" | ||
23 | expect { | ||
24 | timeout {puts "TESTING ERROR 1\n";exit} | ||
25 | "100%" | ||
26 | } | ||
27 | sleep 1 | ||
28 | |||
29 | |||
30 | send -- "ssh firejail-test@0\r" | ||
31 | expect { | ||
32 | timeout {puts "TESTING ERROR 2\n";exit} | ||
33 | "Child process initialized" {puts "OK\n"} | ||
34 | "an existing sandbox was detected" {puts "OK\n"} | ||
35 | } | ||
36 | sleep 1 | ||
37 | send -- "cat testfile\r" | ||
38 | expect { | ||
39 | timeout {puts "TESTING ERROR 3\n";exit} | ||
40 | "12345" | ||
41 | } | ||
42 | after 100 | ||
43 | send -- "exit\r" | ||
44 | sleep 1 | ||
45 | |||
46 | send -- "rm testfile\r" | ||
47 | after 100 | ||
48 | send -- "scp firejail-test@0:~/testfile testfile\r" | ||
49 | expect { | ||
50 | timeout {puts "TESTING ERROR 4\n";exit} | ||
51 | "100%" | ||
52 | } | ||
53 | sleep 1 | ||
54 | send -- "cat testfile\r" | ||
55 | expect { | ||
56 | timeout {puts "TESTING ERROR 5\n";exit} | ||
57 | "12345" | ||
58 | } | ||
59 | after 100 | ||
60 | send -- "rm testfile\r" | ||
61 | sleep 1 | ||
62 | |||
63 | puts "\nall done\n" | ||
diff --git a/test/ssh/sftp.exp b/test/ssh/sftp.exp new file mode 100755 index 000000000..72c858f05 --- /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 0\n";exit} | ||
25 | "Connected to 0" | ||
26 | } | ||
27 | expect { | ||
28 | timeout {puts "TESTING ERROR 0\n";exit} | ||
29 | "sftp>" | ||
30 | } | ||
31 | after 100 | ||
32 | send -- "put testfile\r" | ||
33 | expect { | ||
34 | timeout {puts "TESTING ERROR 0\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 0\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 0\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 0\n";exit} | ||
63 | "Connected to 0" | ||
64 | } | ||
65 | expect { | ||
66 | timeout {puts "TESTING ERROR 0\n";exit} | ||
67 | "sftp>" | ||
68 | } | ||
69 | after 100 | ||
70 | send -- "get testfile\r" | ||
71 | expect { | ||
72 | timeout {puts "TESTING ERROR 0\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 0\n";exit} | ||
81 | "12345" | ||
82 | } | ||
83 | after 100 | ||
84 | send -- "rm testfile\r" | ||
85 | sleep 1 | ||
86 | |||
87 | puts "\nall done\n" | ||
diff --git a/test/ssh/ssh.sh b/test/ssh/ssh.sh new file mode 100755 index 000000000..20a70b1b6 --- /dev/null +++ b/test/ssh/ssh.sh | |||
@@ -0,0 +1,16 @@ | |||
1 | #!/bin/bash | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2018 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | export MALLOC_CHECK_=3 | ||
7 | export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) | ||
8 | |||
9 | echo "TESTING: ssh login (test/ssh/login.exp)" | ||
10 | ./login.exp | ||
11 | |||
12 | echo "TESTING: sftp (test/ssh/sftp.exp)" | ||
13 | ./sftp.exp | ||
14 | |||
15 | echo "TESTING: scp (test/ssh/scp.exp)" | ||
16 | ./scp.exp | ||