aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-04-01 13:45:12 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2018-04-01 13:45:12 -0400
commit17b8cfa97fb2fbf819eac53900bf9d0fd5225f73 (patch)
tree32159b1426ba5ed7c778567ded94423d45378d5d /test
parenttesting (diff)
downloadfirejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.tar.gz
firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.tar.zst
firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.zip
testing ssh
Diffstat (limited to 'test')
-rwxr-xr-xtest/login_ssh.exp59
-rwxr-xr-xtest/root/root.sh2
-rwxr-xr-xtest/ssh/login.exp49
-rwxr-xr-xtest/ssh/scp.exp63
-rwxr-xr-xtest/ssh/sftp.exp87
-rwxr-xr-xtest/ssh/ssh.sh16
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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "ssh bingo@0\r"
8expect {
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}
23sleep 1
24
25# test default gw
26send -- "bash\r"
27sleep 1
28send -- "ps aux; pwd\r"
29expect {
30 timeout {puts "TESTING ERROR 1\n";exit}
31 "/bin/bash"
32}
33expect {
34 timeout {puts "TESTING ERROR 2\n";exit}
35 "bash"
36}
37expect {
38 timeout {puts "TESTING ERROR 3\n";exit}
39 "ps aux"
40}
41expect {
42 timeout {puts "TESTING ERROR 4\n";exit}
43 "home"
44}
45sleep 1
46
47
48send -- "ps aux |wc -l; pwd\r"
49expect {
50 timeout {puts "TESTING ERROR 5\n";exit}
51 "6"
52}
53expect {
54 timeout {puts "TESTING ERROR 6\n";exit}
55 "home"
56}
57sleep 1
58
59puts "\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
11if [ "$?" -eq 0 ]; 11if [ "$?" -eq 0 ];
12then 12then
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
19else 17else
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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "ssh firejail-test@0\r"
8expect {
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}
13sleep 1
14
15send -- "ps aux | wc -l\r"
16expect {
17 timeout {puts "TESTING ERROR 1\n";exit}
18 "5"
19}
20after 100
21
22send -- "ls -l /home | grep drw | wc -l\r"
23expect {
24 timeout {puts "TESTING ERROR 2\n";exit}
25 "1"
26}
27after 100
28
29send -- "cat /proc/self/status | grep Seccomp\r"
30expect {
31 timeout {puts "TESTING ERROR 3\n";exit}
32 "2"
33}
34after 100
35
36send -- "cat /proc/self/status | grep CapBnd\r"
37expect {
38 timeout {puts "TESTING ERROR 4\n";exit}
39 "0000000000000000"
40}
41after 100
42
43# preparing scp/sftp tests
44send -- "rm testfile\r"
45
46send -- "exit\r"
47sleep 1
48
49puts "\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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "ssh firejail-test@0\r"
8expect {
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}
13sleep 1
14
15send -- "rm -f testfile\r"
16after 100
17send -- "exit\r"
18sleep 1
19
20send -- "echo 12345 > testfile\r"
21after 100
22send -- "scp testfile firejail-test@0:~/testfile\r"
23expect {
24 timeout {puts "TESTING ERROR 1\n";exit}
25 "100%"
26}
27sleep 1
28
29
30send -- "ssh firejail-test@0\r"
31expect {
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}
36sleep 1
37send -- "cat testfile\r"
38expect {
39 timeout {puts "TESTING ERROR 3\n";exit}
40 "12345"
41}
42after 100
43send -- "exit\r"
44sleep 1
45
46send -- "rm testfile\r"
47after 100
48send -- "scp firejail-test@0:~/testfile testfile\r"
49expect {
50 timeout {puts "TESTING ERROR 4\n";exit}
51 "100%"
52}
53sleep 1
54send -- "cat testfile\r"
55expect {
56 timeout {puts "TESTING ERROR 5\n";exit}
57 "12345"
58}
59after 100
60send -- "rm testfile\r"
61sleep 1
62
63puts "\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
3set timeout 10
4spawn $env(SHELL)
5match_max 100000
6
7send -- "ssh firejail-test@0\r"
8expect {
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}
13sleep 1
14
15send -- "rm -f testfile\r"
16after 100
17send -- "exit\r"
18sleep 1
19
20send -- "echo 12345 > testfile\r"
21after 100
22send -- "sftp firejail-test@0\r"
23expect {
24 timeout {puts "TESTING ERROR 0\n";exit}
25 "Connected to 0"
26}
27expect {
28 timeout {puts "TESTING ERROR 0\n";exit}
29 "sftp>"
30}
31after 100
32send -- "put testfile\r"
33expect {
34 timeout {puts "TESTING ERROR 0\n";exit}
35 "100%"
36}
37after 100
38send -- "exit\r"
39sleep 1
40
41
42send -- "ssh firejail-test@0\r"
43expect {
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}
48sleep 1
49send -- "cat testfile\r"
50expect {
51 timeout {puts "TESTING ERROR 0\n";exit}
52 "12345"
53}
54after 100
55send -- "exit\r"
56sleep 1
57
58send -- "rm testfile\r"
59after 100
60send -- "sftp firejail-test@0\r"
61expect {
62 timeout {puts "TESTING ERROR 0\n";exit}
63 "Connected to 0"
64}
65expect {
66 timeout {puts "TESTING ERROR 0\n";exit}
67 "sftp>"
68}
69after 100
70send -- "get testfile\r"
71expect {
72 timeout {puts "TESTING ERROR 0\n";exit}
73 "100%"
74}
75after 100
76send -- "exit\r"
77sleep 1
78send -- "cat testfile\r"
79expect {
80 timeout {puts "TESTING ERROR 0\n";exit}
81 "12345"
82}
83after 100
84send -- "rm testfile\r"
85sleep 1
86
87puts "\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
6export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8
9echo "TESTING: ssh login (test/ssh/login.exp)"
10./login.exp
11
12echo "TESTING: sftp (test/ssh/sftp.exp)"
13./sftp.exp
14
15echo "TESTING: scp (test/ssh/scp.exp)"
16./scp.exp