8a94acb128170c8d521f9d500a597b0c01a35b7d
- Author
- Andrii Kostenko <andrey@kostenko.name>
- Committer
- Andrii Kostenko <andrey@kostenko.name>
- Date
Message
Added more tests for security check
Diff
1diff --git a/tests/test_check_venv.zunit b/tests/test_check_venv.zunit
2index c312bd9ad0d4960849cd1e3af4648fb36728d57d..31f7bf8ede74bb4f36927b8c7f7506a69eb4fccb 100644
3--- a/tests/test_check_venv.zunit
4+++ b/tests/test_check_venv.zunit
5@@ -25,7 +25,7 @@
6 }
7
8
9-@test 'check_venv - Security warning for weak permissions' {
10+@test 'check_venv - Security warning for weak writeable by group permissions' {
11 PWD="$TARGET"
12
13 echo "foobar" > "$TARGET/.venv"
14@@ -41,6 +41,66 @@
15 assert "$lines[4]" same_as "Run the following command to fix this: \"chmod 600 $TARGET/.venv\""
16 }
17
18+@test 'check_venv - Security warning for weak writeable by everyone permissions' {
19+ PWD="$TARGET"
20+
21+ echo "foobar" > "$TARGET/.venv"
22+ chmod 600 "$TARGET/.venv"
23+ chmod a+w "$TARGET/.venv"
24+
25+ run check_venv
26+
27+ assert $status equals 0
28+ assert "$lines[1]" same_as "AUTOSWITCH WARNING: Virtualenv will not be activated"
29+ assert "$lines[2]" is_empty
30+ assert "$lines[3]" same_as "Reason: Found a .venv file with weak permission settings (622)."
31+ assert "$lines[4]" same_as "Run the following command to fix this: \"chmod 600 $TARGET/.venv\""
32+}
33+
34+@test 'check_venv - No security warning for readable by everyone permission' {
35+ PWD="$TARGET"
36+
37+ echo "foobar" > "$TARGET/.venv"
38+ chmod 600 "$TARGET/.venv"
39+ chmod a+r "$TARGET/.venv"
40+ MYOLDPWD="$(dirname $TARGET)"
41+ AUTOSWITCH_DEFAULTENV="foodefault"
42+
43+ run check_venv
44+
45+ assert $status equals 0
46+ assert "$output" same_as "Switching virtualenv: foobar [$PYTHON_VERSION]"
47+}
48+
49+@test 'check_venv - No security warning for readable by group permission' {
50+ PWD="$TARGET"
51+
52+ echo "foobar" > "$TARGET/.venv"
53+ chmod 600 "$TARGET/.venv"
54+ chmod g+r "$TARGET/.venv"
55+ MYOLDPWD="$(dirname $TARGET)"
56+ AUTOSWITCH_DEFAULTENV="foodefault"
57+
58+ run check_venv
59+
60+ assert $status equals 0
61+ assert "$output" same_as "Switching virtualenv: foobar [$PYTHON_VERSION]"
62+}
63+
64+@test 'check_venv - No security warning for readable only by owner permission' {
65+ PWD="$TARGET"
66+
67+ echo "foobar" > "$TARGET/.venv"
68+ chmod 600 "$TARGET/.venv"
69+ MYOLDPWD="$(dirname $TARGET)"
70+ AUTOSWITCH_DEFAULTENV="foodefault"
71+
72+ run check_venv
73+
74+ assert $status equals 0
75+ assert "$output" same_as "Switching virtualenv: foobar [$PYTHON_VERSION]"
76+}
77+
78
79 @test 'check_venv - does not change if MYOLDPWD=PWD' {
80 PWD="$TARGET"