summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2018-11-08 10:49:44 -0500
committerLibravatar netblue30 <netblue30@yahoo.com>2018-11-08 10:49:44 -0500
commit2acc910daf73c284965ca96bc70b4eb980c865cf (patch)
tree7b5733a8ccacba4089a7a9c067b12355372c8dc9 /test
parentMerge pull request #2251 from glitsj16/sort (diff)
downloadfirejail-2acc910daf73c284965ca96bc70b4eb980c865cf.tar.gz
firejail-2acc910daf73c284965ca96bc70b4eb980c865cf.tar.zst
firejail-2acc910daf73c284965ca96bc70b4eb980c865cf.zip
profile parser testing
Diffstat (limited to 'test')
-rwxr-xr-xtest/profiles/profile_appname.exp25
-rwxr-xr-xtest/profiles/profile_noperm.exp2
-rwxr-xr-xtest/profiles/profile_recursivity.exp25
-rwxr-xr-xtest/profiles/profile_syntax2.exp27
-rwxr-xr-xtest/profiles/profiles.sh27
-rw-r--r--test/profiles/test2.profile4
-rw-r--r--test/profiles/test3.profile1
7 files changed, 85 insertions, 26 deletions
diff --git a/test/profiles/profile_appname.exp b/test/profiles/profile_appname.exp
new file mode 100755
index 000000000..c70e7ad57
--- /dev/null
+++ b/test/profiles/profile_appname.exp
@@ -0,0 +1,25 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2018 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --profile=firefox\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Reading profile /etc/firejail/firefox.profile"
14}
15expect {
16 timeout {puts "TESTING ERROR 1\n";exit}
17 "Reading profile /etc/firejail/firefox-common.profile"
18}
19expect {
20 timeout {puts "TESTING ERROR 2\n";exit}
21 "shell=none configured, but no program specified"
22}
23
24after 100
25puts "\nall done\n"
diff --git a/test/profiles/profile_noperm.exp b/test/profiles/profile_noperm.exp
index b3b031cb2..9f8cb54e2 100755
--- a/test/profiles/profile_noperm.exp
+++ b/test/profiles/profile_noperm.exp
@@ -7,7 +7,7 @@ match_max 100000
7send -- "firejail --profile=/etc/shadow\r" 7send -- "firejail --profile=/etc/shadow\r"
8expect { 8expect {
9 timeout {puts "TESTING ERROR 0\n";exit} 9 timeout {puts "TESTING ERROR 0\n";exit}
10 "cannot access profile" 10 "inaccessible profile file"
11} 11}
12after 100 12after 100
13puts "\nall done\n" 13puts "\nall done\n"
diff --git a/test/profiles/profile_recursivity.exp b/test/profiles/profile_recursivity.exp
new file mode 100755
index 000000000..66e4510bf
--- /dev/null
+++ b/test/profiles/profile_recursivity.exp
@@ -0,0 +1,25 @@
1#!/usr/bin/expect -f
2# This file is part of Firejail project
3# Copyright (C) 2014-2018 Firejail Authors
4# License GPL v2
5
6set timeout 10
7spawn $env(SHELL)
8match_max 100000
9
10send -- "firejail --profile=test3.profile\r"
11expect {
12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Reading profile test3.profile"
14}
15expect {
16 timeout {puts "TESTING ERROR 1\n";exit}
17 "Reading profile test3.profile"
18}
19expect {
20 timeout {puts "TESTING ERROR 2\n";exit}
21 "maximum profile include level was reached"
22}
23
24after 100
25puts "\nall done\n"
diff --git a/test/profiles/profile_syntax2.exp b/test/profiles/profile_syntax2.exp
index 4d621f3ec..da34b67e8 100755
--- a/test/profiles/profile_syntax2.exp
+++ b/test/profiles/profile_syntax2.exp
@@ -7,7 +7,7 @@ set timeout 10
7spawn $env(SHELL) 7spawn $env(SHELL)
8match_max 100000 8match_max 100000
9 9
10send -- "firejail --debug --profile=test2.profile\r" 10send -- "firejail --profile=test2.profile\r"
11expect { 11expect {
12 timeout {puts "TESTING ERROR 0\n";exit} 12 timeout {puts "TESTING ERROR 0\n";exit}
13 "Reading profile test2.profile" 13 "Reading profile test2.profile"
@@ -18,29 +18,8 @@ expect {
18} 18}
19expect { 19expect {
20 timeout {puts "TESTING ERROR 2\n";exit} 20 timeout {puts "TESTING ERROR 2\n";exit}
21 "Mounting a new /home directory" 21 "cannot access profile file"
22} 22}
23expect { 23
24 timeout {puts "TESTING ERROR 3\n";exit}
25 "Disable /bin/rmdir" {puts "Most Linux platforms\n"}
26 "Disable /usr/bin/rmdir" { puts "OpenSUSE platform\n"}
27}
28expect {
29 timeout {puts "TESTING ERROR 4\n";exit}
30 "Drop CAP_SYS_MODULE"
31}
32expect {
33 timeout {puts "TESTING ERROR 5\n";exit}
34 "seccomp entries in /run/firejail/mnt/seccomp"
35}
36expect {
37 timeout {puts "TESTING ERROR 7\n";exit}
38 "jeq mount"
39}
40expect {
41 timeout {puts "TESTING ERROR 8\n";exit}
42 "Child process initialized"
43}
44send -- "exit\r"
45after 100 24after 100
46puts "\nall done\n" 25puts "\nall done\n"
diff --git a/test/profiles/profiles.sh b/test/profiles/profiles.sh
index 7c3549aea..a3d24ac0c 100755
--- a/test/profiles/profiles.sh
+++ b/test/profiles/profiles.sh
@@ -6,6 +6,33 @@
6export MALLOC_CHECK_=3 6export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) 7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8 8
9echo "TESTING: profile recursivity (test/profiles/profile_recursivity.exp)"
10./profile_recursivity.exp
11
12echo "TESTING: profile application name (test/profiles/profile_appname.exp)"
13./profile_appname.exp
14
15echo "TESTING: profile syntax (test/profiles/profile_syntax.exp)"
16./profile_syntax.exp
17
18echo "TESTING: profile syntax 2 (test/profiles/profile_syntax2.exp)"
19./profile_syntax2.exp
20
21echo "TESTING: ignore command (test/profiles/ignore.exp)"
22./ignore.exp
23
24echo "TESTING: profile read-only (test/profiles/profile_readonly.exp)"
25./profile_readonly.exp
26
27echo "TESTING: profile read-only links (test/profiles/profile_readonly.exp)"
28./profile_followlnk.exp
29
30echo "TESTING: profile no permissions (test/profiles/profile_noperm.exp)"
31./profile_noperm.exp
32
33
34
35
9echo "TESTING: default profiles installed in /etc" 36echo "TESTING: default profiles installed in /etc"
10PROFILES=`ls /etc/firejail/*.profile` 37PROFILES=`ls /etc/firejail/*.profile`
11for PROFILE in $PROFILES 38for PROFILE in $PROFILES
diff --git a/test/profiles/test2.profile b/test/profiles/test2.profile
index e219d800d..9fbd5219a 100644
--- a/test/profiles/test2.profile
+++ b/test/profiles/test2.profile
@@ -1,4 +1,6 @@
1caps 1caps
2seccomp 2seccomp
3 private 3 private
4 include test.profile 4 include test.profile
5 include test.local
6 include test25.profile
diff --git a/test/profiles/test3.profile b/test/profiles/test3.profile
new file mode 100644
index 000000000..c28ddadb5
--- /dev/null
+++ b/test/profiles/test3.profile
@@ -0,0 +1 @@
include test3.profile \ No newline at end of file