blob: 4a3d20944a87616a928f589fdbf410dc4b3a3c8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#!/bin/sh -e
#
# Run 'test/main security' for security checks.
# Note that these require root access and iteraction with the test script.
if [ "$1" = security ]; then
test_security=1
else
test_security=0
fi
store_file="/tmp/envstore-test-$$"
testdir=$(mktemp -d /tmp/envstore.XXXXXX)
export ENVSTORE_FILE=$store_file
PATH=./bin:$PATH
trap "envstore clear" INT
echo "# make"
make -s -B
echo "# make install"
make -s install prefix=$testdir
echo "# make uninstall"
make -s uninstall prefix=$testdir
rm -r $testdir
echo "# envstore clear"
envstore clear
echo "# envstore save var"
export hello=world
envstore save hello
unset hello
echo "# envstore eval"
eval $(envstore eval)
test "$hello" = world
unset hello
echo "# envstore rm"
envstore rm hello
eval $(envstore eval)
test -z "$hello"
echo "# envstore save var value"
envstore save hello world
echo "# envstore eval"
eval $(envstore eval)
test "$hello" = world
unset hello
echo "# envstore clear"
envstore clear
eval $(envstore eval)
test -z "$hello"
echo "# envstore save + eval (spaces in value), save var"
export hello='your mom'
envstore save hello
unset hello
eval $(envstore eval)
test "$hello" = 'your mom'
unset hello
envstore clear
echo "# envstore save + eval (spaces in value), save var value"
envstore save hello 'your mom'
eval $(envstore eval)
test "$hello" = 'your mom'
unset hello
echo "# envstore save (overwrite)"
envstore save hello world
eval $(envstore eval)
test "$hello" = world
envstore clear
echo "# envstore save (' in value)"
envstore save hello "the ' dude"
eval $(envstore eval)
test "$hello" = "the ' dude"
unset hello
echo "# envstore save (multiple 's in value)"
envstore save hello "the '' ' dude ' moose"
eval $(envstore eval)
test "$hello" = "the '' ' dude ' moose"
unset hello
echo "# envstore save (UTF-8)"
export hello='mÿde Rentner… und so'
envstore save hello
unset hello
eval $(envstore eval)
test "$hello" = 'mÿde Rentner… und so'
unset hello
envstore clear
# former --extended tests
echo "# invalid invocations"
! envstore save > /dev/null 2>&1
unset nonexistent
! envstore save nonexistent > /dev/null 2>&1
! envstore rm > /dev/null 2>&1
echo "# other invocations"
envstore list
envstore eval
envstore rm nonexistent
envstore clear
echo "# envify"
envstore save oaei lalala
test "$(bin/envify sh test/envify)" = lalala
envstore clear
if [ "$test_security" = 1 ]; then
echo "# world-writable store file"
envstore save fucked yes
chmod 777 $store_file
test "$(envstore eval)" != "export fucked='yes'"
rm $store_file
envstore save fucked yes
echo "Now, enter the following as root:"
echo " chown root $store_file"
echo -n "[press return when done] "
read wayne
test "$(envstore eval)" != "export fucked='yes'"
echo "Looking good, you may remove the file now"
echo " rm $store_file"
echo -n "[press return when done] "
read wayne
fi
|