aboutsummaryrefslogtreecommitdiffstats
path: root/test/ssh
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/ssh
parenttesting (diff)
downloadfirejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.tar.gz
firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.tar.zst
firejail-17b8cfa97fb2fbf819eac53900bf9d0fd5225f73.zip
testing ssh
Diffstat (limited to 'test/ssh')
-rwxr-xr-xtest/ssh/login.exp49
-rwxr-xr-xtest/ssh/scp.exp63
-rwxr-xr-xtest/ssh/sftp.exp87
-rwxr-xr-xtest/ssh/ssh.sh16
4 files changed, 215 insertions, 0 deletions
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