Blame


1 5c2e310e 2021-01-22 op #!/bin/sh
2 5c2e310e 2021-01-22 op
3 5c2e310e 2021-01-22 op set -e
4 5c2e310e 2021-01-22 op
5 a82d4dfa 2021-07-10 op if [ "${SKIP_RUNTIME_TESTS:-0}" -eq 1 ]; then
6 bffa7daa 2021-07-08 op echo
7 bffa7daa 2021-07-08 op echo "======================"
8 bffa7daa 2021-07-08 op echo "runtime tests skipped!"
9 bffa7daa 2021-07-08 op echo "======================"
10 bffa7daa 2021-07-08 op echo
11 bffa7daa 2021-07-08 op exit 0
12 bffa7daa 2021-07-08 op fi
13 bffa7daa 2021-07-08 op
14 02be96c6 2021-02-09 op ggflags=
15 02be96c6 2021-02-09 op
16 fb4102a5 2021-07-06 op config_common='
17 fb4102a5 2021-07-06 op ipv6 off
18 fb4102a5 2021-07-06 op port 10965
19 fb4102a5 2021-07-06 op '
20 fb4102a5 2021-07-06 op
21 5c2e310e 2021-01-22 op # usage: config <global config> <stuff for localhost>
22 5c2e310e 2021-01-22 op # generates a configuration file reg.conf
23 5c2e310e 2021-01-22 op config() {
24 5c2e310e 2021-01-22 op cat <<EOF > reg.conf
25 fb4102a5 2021-07-06 op $config_common
26 5c2e310e 2021-01-22 op $1
27 5c2e310e 2021-01-22 op server "localhost" {
28 6ff23c67 2021-02-01 op cert "$PWD/cert.pem"
29 6ff23c67 2021-02-01 op key "$PWD/key.pem"
30 6ff23c67 2021-02-01 op root "$PWD/testdata"
31 5c2e310e 2021-01-22 op $2
32 5c2e310e 2021-01-22 op }
33 5c2e310e 2021-01-22 op EOF
34 5c2e310e 2021-01-22 op }
35 5c2e310e 2021-01-22 op
36 5c2e310e 2021-01-22 op checkconf() {
37 5c2e310e 2021-01-22 op ./../gmid -n -c reg.conf
38 5c2e310e 2021-01-22 op }
39 5c2e310e 2021-01-22 op
40 5c2e310e 2021-01-22 op # usage: get <path>
41 5c2e310e 2021-01-22 op # return the body of the request on stdout
42 5c2e310e 2021-01-22 op get() {
43 321341f6 2021-07-06 op ./gg -T30 -b $ggflags "gemini://localhost:10965/$1"
44 5c2e310e 2021-01-22 op }
45 5c2e310e 2021-01-22 op
46 5c2e310e 2021-01-22 op # usage: head <path>
47 5c2e310e 2021-01-22 op # return the meta response line on stdout
48 5c2e310e 2021-01-22 op head() {
49 321341f6 2021-07-06 op ./gg -T30 -h $ggflags "gemini://localhost:10965/$1"
50 5c2e310e 2021-01-22 op }
51 5c2e310e 2021-01-22 op
52 31a4993a 2021-01-23 op # usage: raw <path>
53 31a4993a 2021-01-23 op # return both header and body
54 31a4993a 2021-01-23 op raw() {
55 321341f6 2021-07-06 op ./gg -T30 $ggflags "gemini://localhost:10965/$1"
56 31a4993a 2021-01-23 op }
57 31a4993a 2021-01-23 op
58 5c2e310e 2021-01-22 op run() {
59 ca3f6756 2021-07-06 op ./../gmid -f -c reg.conf &
60 5c2e310e 2021-01-22 op pid=$!
61 31a4993a 2021-01-23 op # give gmid time to bind the port, otherwise we end up
62 31a4993a 2021-01-23 op # executing gg when gmid isn't ready yet.
63 31a4993a 2021-01-23 op sleep 1
64 5c2e310e 2021-01-22 op }
65 5c2e310e 2021-01-22 op
66 5c2e310e 2021-01-22 op # usage: check [exit-message]
67 5c2e310e 2021-01-22 op # check if gmid is still running
68 5c2e310e 2021-01-22 op check() {
69 5c2e310e 2021-01-22 op if ! ps $pid >/dev/null; then
70 5c2e310e 2021-01-22 op echo ${1:-"gmid crashed?"}
71 5c2e310e 2021-01-22 op exit 1
72 5c2e310e 2021-01-22 op fi
73 5c2e310e 2021-01-22 op }
74 5c2e310e 2021-01-22 op
75 afc025ff 2021-02-06 op restart() {
76 052c9d24 2021-03-20 op kill -HUP $pid
77 afc025ff 2021-02-06 op sleep 1
78 afc025ff 2021-02-06 op }
79 afc025ff 2021-02-06 op
80 5c2e310e 2021-01-22 op # quit gmid
81 5c2e310e 2021-01-22 op quit() {
82 052c9d24 2021-03-20 op kill $pid || true
83 5c2e310e 2021-01-22 op wait || true
84 5c2e310e 2021-01-22 op }
85 5c2e310e 2021-01-22 op
86 9f006a21 2021-02-07 op count() {
87 9f006a21 2021-02-07 op wc -l | xargs
88 9f006a21 2021-02-07 op }
89 9f006a21 2021-02-07 op
90 5c2e310e 2021-01-22 op # usage: eq a b errmsg
91 5c2e310e 2021-01-22 op # if a and b aren't equal strings, exit with errmsg
92 5c2e310e 2021-01-22 op eq() {
93 5c2e310e 2021-01-22 op if ! [ "$1" = "$2" ]; then
94 5c2e310e 2021-01-22 op echo "$3: \"$1\" not equal \"$2\""
95 5c2e310e 2021-01-22 op exit 1
96 5c2e310e 2021-01-22 op fi
97 5c2e310e 2021-01-22 op }
98 5c2e310e 2021-01-22 op
99 5c2e310e 2021-01-22 op onexit() {
100 5c2e310e 2021-01-22 op rm -f bigfile bigfile.sha
101 5c2e310e 2021-01-22 op quit
102 5c2e310e 2021-01-22 op }
103 5c2e310e 2021-01-22 op
104 5c2e310e 2021-01-22 op # tests
105 5c2e310e 2021-01-22 op
106 5c2e310e 2021-01-22 op trap 'onexit' INT TERM EXIT
107 5c2e310e 2021-01-22 op
108 5c2e310e 2021-01-22 op endl=`printf "\r\n"`
109 5c2e310e 2021-01-22 op lf=`echo`
110 5c2e310e 2021-01-22 op
111 5c2e310e 2021-01-22 op config "" ""
112 5c2e310e 2021-01-22 op checkconf
113 5c2e310e 2021-01-22 op run
114 5c2e310e 2021-01-22 op
115 5c2e310e 2021-01-22 op eq "$(head /)" "20 text/gemini" "Unexpected head for /"
116 5c2e310e 2021-01-22 op eq "$(get /)" "# hello world$ln" "Unexpected body for /"
117 5c2e310e 2021-01-22 op echo OK GET /
118 5c2e310e 2021-01-22 op
119 5c2e310e 2021-01-22 op eq "$(head /foo)" "51 not found" "Unexpected head /foo"
120 5c2e310e 2021-01-22 op eq "$(get /foo)" "" "Unexpected body /foo"
121 5c2e310e 2021-01-22 op echo OK GET /foo
122 5c2e310e 2021-01-22 op
123 5c2e310e 2021-01-22 op # should redirect if asked for a directory but without the trailing /
124 5c2e310e 2021-01-22 op eq "$(head /dir)" "30 /dir/" "Unexpected redirect for /dir"
125 5c2e310e 2021-01-22 op eq "$(get /dir)" "" "Unexpected body for redirect"
126 5c2e310e 2021-01-22 op echo OK GET /dir
127 5c2e310e 2021-01-22 op
128 5c2e310e 2021-01-22 op # 51 for a directory without index.gmi
129 5c2e310e 2021-01-22 op eq "$(head /dir/)" "51 not found" "Unexpected head for /"
130 5c2e310e 2021-01-22 op eq "$(get /dir/)" "" "Unexpected body for error"
131 5c2e310e 2021-01-22 op echo OK GET /dir/
132 5c2e310e 2021-01-22 op
133 5c2e310e 2021-01-22 op eq "$(head /dir/foo.gmi)" "20 text/gemini" "Unexpected head for /dir/foo.gmi"
134 5c2e310e 2021-01-22 op eq "$(get /dir/foo.gmi)" "# hello world$ln" "Unexpected body for /dir/foo.gmi"
135 5c2e310e 2021-01-22 op echo OK GET /dir/foo.gmi
136 5c2e310e 2021-01-22 op
137 5c2e310e 2021-01-22 op # try a big file
138 5c2e310e 2021-01-22 op eq "$(head /bigfile)" "20 application/octet-stream" "Unexpected head for /bigfile"
139 5c2e310e 2021-01-22 op get /bigfile > bigfile
140 5c2e310e 2021-01-22 op ./sha bigfile bigfile.sha
141 5c2e310e 2021-01-22 op eq "$(cat bigfile.sha)" "$(cat testdata/bigfile.sha)" "Unexpected sha for /bigfile"
142 5c2e310e 2021-01-22 op echo OK GET /bigfile
143 5c2e310e 2021-01-22 op
144 5c2e310e 2021-01-22 op # shouldn't be executing cgi scripts
145 5c2e310e 2021-01-22 op eq "$(head /hello)" "20 application/octet-stream" "Unexpected head for /hello"
146 5c2e310e 2021-01-22 op echo OK GET /hello
147 5c2e310e 2021-01-22 op
148 5c2e310e 2021-01-22 op check "should be running"
149 5c2e310e 2021-01-22 op
150 5c2e310e 2021-01-22 op # try with custom mime
151 d19951cf 2021-07-09 op config 'map "text/x-funny-text" to-ext "gmi"' 'default type "application/x-trash"'
152 5c2e310e 2021-01-22 op checkconf
153 afc025ff 2021-02-06 op restart
154 5c2e310e 2021-01-22 op
155 5c2e310e 2021-01-22 op eq "$(head /)" "20 text/x-funny-text" "Unexpected head for /"
156 5c2e310e 2021-01-22 op echo OK GET / with custom mime
157 5c2e310e 2021-01-22 op
158 5c2e310e 2021-01-22 op eq "$(head /hello)" "20 application/x-trash" "Unexpected head for /hello"
159 5c2e310e 2021-01-22 op echo OK GET /hello with custom mime
160 5c2e310e 2021-01-22 op
161 5c2e310e 2021-01-22 op check "should be running"
162 5c2e310e 2021-01-22 op
163 5c2e310e 2021-01-22 op # try with custom lang
164 5c2e310e 2021-01-22 op config '' 'lang "it"'
165 5c2e310e 2021-01-22 op checkconf
166 afc025ff 2021-02-06 op restart
167 5c2e310e 2021-01-22 op
168 5c2e310e 2021-01-22 op eq "$(head /)" "20 text/gemini; lang=it" "Unexpected head for /"
169 5c2e310e 2021-01-22 op echo OK GET / with custom lang
170 5c2e310e 2021-01-22 op
171 5c2e310e 2021-01-22 op check "should be running"
172 5c2e310e 2021-01-22 op
173 49b73ba1 2021-02-10 op # make sure we can use different lang in different location rules
174 49b73ba1 2021-02-10 op config '' 'lang "it" location "/en/*" { lang "en" } location "/de/*" { lang "de" }'
175 49b73ba1 2021-02-10 op checkconf
176 a4188b78 2021-02-12 op echo OK parse multiple locations correctly
177 49b73ba1 2021-02-10 op restart
178 49b73ba1 2021-02-10 op
179 9f006a21 2021-02-07 op # try with CGI scripts
180 87f2b68b 2021-02-02 op config '' 'cgi "*"'
181 5c2e310e 2021-01-22 op checkconf
182 afc025ff 2021-02-06 op restart
183 5c2e310e 2021-01-22 op
184 5c2e310e 2021-01-22 op eq "$(head /hello)" "20 text/gemini" "Unexpected head for /hello"
185 5c2e310e 2021-01-22 op eq "$(get /hello)" "# hello world$ln" "Unexpected body for /hello"
186 5c2e310e 2021-01-22 op echo OK GET /hello with cgi
187 5c2e310e 2021-01-22 op
188 5c2e310e 2021-01-22 op eq "$(head /slow)" "20 text/gemini" "Unexpected head for /slow"
189 5c2e310e 2021-01-22 op eq "$(get /slow)" "# hello world$ln" "Unexpected body for /slow"
190 5c2e310e 2021-01-22 op echo OK GET /slow with cgi
191 5c2e310e 2021-01-22 op
192 35744950 2021-02-01 op eq "$(head /err)" "42 CGI error" "Unexpected head for /err"
193 5c2e310e 2021-01-22 op eq "$(get /err)" "" "Unexpected body for /err"
194 5c2e310e 2021-01-22 op echo OK GET /err with cgi
195 5c2e310e 2021-01-22 op
196 6cdecad8 2021-01-23 op eq "$(raw /invalid | wc -c | xargs)" 2048 "Unexpected body for /invalid"
197 3309ef97 2021-01-23 op echo OK GET /invalid with cgi
198 3309ef97 2021-01-23 op
199 c836cdfa 2021-03-29 op eq "$(raw /max-length-reply | wc -c | xargs)" 1029 "Unexpected header for /max-length-reply"
200 c836cdfa 2021-03-29 op echo OK GET /max-length-reply with cgi
201 c836cdfa 2021-03-29 op
202 7b31a638 2021-01-24 op # try a big file
203 7b31a638 2021-01-24 op eq "$(head /serve-bigfile)" "20 application/octet-stream" "Unexpected head for /serve-bigfile"
204 7b31a638 2021-01-24 op get /bigfile > bigfile
205 7b31a638 2021-01-24 op ./sha bigfile bigfile.sha
206 7b31a638 2021-01-24 op eq "$(cat bigfile.sha)" "$(cat testdata/bigfile.sha)" "Unexpected sha for /serve-bigfile"
207 7b31a638 2021-01-24 op echo OK GET /serve-bigfile with cgi
208 7b31a638 2021-01-24 op
209 9f006a21 2021-02-07 op # ensure we split the query correctly
210 9f006a21 2021-02-07 op eq "$(get /env | awk /^-/ | count)" 1 "Unexpected number of arguments"
211 9f006a21 2021-02-07 op eq "$(get /env?foo | awk /^-/ | count)" 2 "Unexpected number of arguments"
212 9f006a21 2021-02-07 op eq "$(get /env?foo+bar | awk /^-/ | count)" 3 "Unexpected number of arguments"
213 9f006a21 2021-02-07 op eq "$(get /env?foo+bar=5 | awk /^-/ | count)" 1 "Unexpected number of arguments"
214 9f006a21 2021-02-07 op eq "$(get /env?foo+bar%3d5 | awk /^-/ | count)" 3 "Unexpected number of arguments"
215 9f006a21 2021-02-07 op
216 5c2e310e 2021-01-22 op check "should be running"
217 e7a2a99b 2021-01-24 op
218 e7a2a99b 2021-01-24 op config '' 'index "foo.gmi"'
219 e7a2a99b 2021-01-24 op checkconf
220 afc025ff 2021-02-06 op restart
221 e7a2a99b 2021-01-24 op
222 e7a2a99b 2021-01-24 op eq "$(head /dir/)" "20 text/gemini" "Unexpected head for /"
223 e7a2a99b 2021-01-24 op eq "$(get /dir/)" "# hello world$ln" "Unexpected body for error"
224 e7a2a99b 2021-01-24 op echo OK GET /dir/ with custom index
225 e7a2a99b 2021-01-24 op
226 e7a2a99b 2021-01-24 op check "should be running"
227 c8b74339 2021-01-24 op
228 49b73ba1 2021-02-10 op config '' 'location "/dir/*" { default type "text/plain" index "hello" }'
229 c8b74339 2021-01-24 op checkconf
230 afc025ff 2021-02-06 op restart
231 c8b74339 2021-01-24 op
232 c8b74339 2021-01-24 op eq "$(head /dir/hello)" "20 text/plain" "Unexpected head for /"
233 c8b74339 2021-01-24 op echo OK GET /dir/hello with location and default type
234 c8b74339 2021-01-24 op
235 252908e6 2021-01-24 op eq "$(head /dir/)" "20 text/plain" "Unexpected head for /dir/"
236 c8b74339 2021-01-24 op eq "$(get /dir/|tail -1)" 'echo "# hello world"' "Unexpected body for /dir/"
237 c8b74339 2021-01-24 op echo OK GET /dir/ with location and custom index
238 c8b74339 2021-01-24 op
239 c8b74339 2021-01-24 op check "should be running"
240 252908e6 2021-01-24 op
241 49b73ba1 2021-02-10 op config '' 'location "/dir/*" { auto index on }'
242 252908e6 2021-01-24 op checkconf
243 afc025ff 2021-02-06 op restart
244 252908e6 2021-01-24 op
245 252908e6 2021-01-24 op eq "$(head /)" "20 text/gemini" "Unexpected head for /"
246 252908e6 2021-01-24 op eq "$(get /)" "# hello world$ln" "Unexpected body for /"
247 252908e6 2021-01-24 op echo OK GET / with auto index
248 252908e6 2021-01-24 op
249 252908e6 2021-01-24 op eq "$(head /dir)" "30 /dir/" "Unexpected head for /dir"
250 252908e6 2021-01-24 op eq "$(head /dir/)" "20 text/gemini" "Unexpected head for /dir/"
251 5f715ce4 2021-02-02 op eq "$(get /dir/|wc -l|xargs)" "5" "Unexpected body for /dir/"
252 252908e6 2021-01-24 op echo OK GET /dir/ with auto index on
253 252908e6 2021-01-24 op
254 252908e6 2021-01-24 op check "should be running"
255 6abda252 2021-02-06 op
256 6abda252 2021-02-06 op # test block return and strip
257 6abda252 2021-02-06 op
258 6abda252 2021-02-06 op config '' 'location "*" { block }'
259 6abda252 2021-02-06 op checkconf
260 afc025ff 2021-02-06 op restart
261 6abda252 2021-02-06 op
262 6abda252 2021-02-06 op eq "$(head /)" "40 temporary failure" "Unexpected head for /"
263 6abda252 2021-02-06 op eq "$(get /)" "" "Unexpected body for /"
264 6abda252 2021-02-06 op echo OK GET / with block
265 6abda252 2021-02-06 op
266 6abda252 2021-02-06 op eq "$(head /nonexists)" "40 temporary failure" "Unexpected head for /nonexists"
267 6abda252 2021-02-06 op eq "$(get /nonexists)" "" "Unexpected body for /nonexists"
268 6abda252 2021-02-06 op echo OK GET /nonexists with block
269 6abda252 2021-02-06 op
270 6abda252 2021-02-06 op check "should be running"
271 6abda252 2021-02-06 op
272 6abda252 2021-02-06 op config '' '
273 6abda252 2021-02-06 op location "/dir" {
274 6abda252 2021-02-06 op strip 1
275 6abda252 2021-02-06 op block return 40 "%% %p %q %P %N test"
276 6abda252 2021-02-06 op }
277 6abda252 2021-02-06 op location "*" {
278 6abda252 2021-02-06 op strip 99
279 6abda252 2021-02-06 op block return 40 "%% %p %q %P %N test"
280 6abda252 2021-02-06 op }'
281 6abda252 2021-02-06 op checkconf
282 afc025ff 2021-02-06 op restart
283 6abda252 2021-02-06 op
284 6abda252 2021-02-06 op eq "$(head /dir/foo.gmi)" "40 % /foo.gmi 10965 localhost test"
285 6abda252 2021-02-06 op echo OK GET /dir/foo.gmi with strip and block
286 6abda252 2021-02-06 op
287 737a6b50 2021-04-30 op eq "$(head /bigfile)" "40 % / 10965 localhost test"
288 6abda252 2021-02-06 op echo OK GET /bigfile with strip and block
289 6abda252 2021-02-06 op
290 6abda252 2021-02-06 op check "should be running"
291 e3ddf390 2021-02-06 op
292 e3ddf390 2021-02-06 op # test the entrypoint
293 e3ddf390 2021-02-06 op
294 e3ddf390 2021-02-06 op config '' 'entrypoint "/env"'
295 e3ddf390 2021-02-06 op checkconf
296 e3ddf390 2021-02-06 op restart
297 afc025ff 2021-02-06 op
298 e3ddf390 2021-02-06 op eq "$(head /foo/bar)" "20 text/plain; lang=en" "Unknown head for /foo/bar"
299 e3ddf390 2021-02-06 op eq "$(get /foo/bar|grep PATH_INFO)" "PATH_INFO=/foo/bar" "Unexpected PATH_INFO"
300 e3ddf390 2021-02-06 op echo OK GET /foo/bar with entrypoint
301 e3ddf390 2021-02-06 op
302 02be96c6 2021-02-09 op # test with require ca
303 02be96c6 2021-02-09 op
304 02be96c6 2021-02-09 op config '' 'require client ca "'$PWD'/testca.pem"'
305 02be96c6 2021-02-09 op checkconf
306 02be96c6 2021-02-09 op restart
307 02be96c6 2021-02-09 op
308 02be96c6 2021-02-09 op eq "$(head /)" "60 client certificate required" "Unexpected head for /"
309 02be96c6 2021-02-09 op echo OK GET / without client certificate
310 02be96c6 2021-02-09 op
311 02be96c6 2021-02-09 op ggflags="-C valid.crt -K valid.key"
312 02be96c6 2021-02-09 op eq "$(head /)" "20 text/gemini" "Unexpected head for /"
313 02be96c6 2021-02-09 op echo OK GET / with valid client certificate
314 02be96c6 2021-02-09 op
315 02be96c6 2021-02-09 op ggflags="-C invalid.cert.pem -K invalid.key.pem"
316 02be96c6 2021-02-09 op eq "$(head /)" "61 certificate not authorised" "Unexpected head for /"
317 02be96c6 2021-02-09 op echo OK GET / with invalid client certificate
318 02be96c6 2021-02-09 op
319 02be96c6 2021-02-09 op ggflags=''
320 fdea6aa0 2021-04-30 op
321 fdea6aa0 2021-04-30 op
322 fdea6aa0 2021-04-30 op # test with root inside a location
323 fdea6aa0 2021-04-30 op
324 fdea6aa0 2021-04-30 op config '' 'location "/foo/*" { root "'$PWD'/testdata" strip 1 }'
325 fdea6aa0 2021-04-30 op checkconf
326 fdea6aa0 2021-04-30 op restart
327 fdea6aa0 2021-04-30 op
328 7aa92586 2021-04-30 op eq "$(head /foo)" "51 not found" "Unexpected head for /foo"
329 7aa92586 2021-04-30 op eq "$(head /foo/)" "20 text/gemini" "Unexpected head for /foo/"
330 0f2124e2 2021-06-12 op echo OK /foo and /foo/ with root inside location
331 7aa92586 2021-04-30 op
332 7aa92586 2021-04-30 op # how to match both /foo and /foo/*
333 7aa92586 2021-04-30 op config '' '
334 7aa92586 2021-04-30 op location "/foo" { block return 31 "%p/" }
335 7aa92586 2021-04-30 op location "/foo/*" { root "'$PWD'/testdata" strip 1 }
336 7aa92586 2021-04-30 op '
337 7aa92586 2021-04-30 op checkconf
338 7aa92586 2021-04-30 op restart
339 fdea6aa0 2021-04-30 op
340 7aa92586 2021-04-30 op eq "$(head /foo)" "31 /foo/" "Unexpected head for /foo"
341 fdea6aa0 2021-04-30 op eq "$(head /foo/)" "20 text/gemini" "Unexpected head for /foo/"
342 0f2124e2 2021-06-12 op echo OK /foo and /foo/ with root inside location
343 0f2124e2 2021-06-12 op
344 0f2124e2 2021-06-12 op # test with fastcgi
345 0f2124e2 2021-06-12 op
346 0f2124e2 2021-06-12 op # NB: the fcgi spawn is NOT supported outside of this test suite
347 0f2124e2 2021-06-12 op
348 0f2124e2 2021-06-12 op config 'prefork 1' 'fastcgi spawn "'$PWD'/fcgi-test"'
349 0f2124e2 2021-06-12 op checkconf
350 0f2124e2 2021-06-12 op restart
351 0f2124e2 2021-06-12 op
352 0f2124e2 2021-06-12 op eq "$(head /)" "20 text/gemini" "Unexpected head for /"
353 0f2124e2 2021-06-12 op eq "$(get /)" "# Hello, world!" "Unexpected body for /"
354 0f2124e2 2021-06-12 op echo OK GET / with fastcgi
355 fb4102a5 2021-07-06 op
356 fb4102a5 2021-07-06 op # test macro expansion
357 fb4102a5 2021-07-06 op
358 fb4102a5 2021-07-06 op cat <<EOF > reg.conf
359 fb4102a5 2021-07-06 op pwd = "$PWD"
360 fb4102a5 2021-07-06 op $config_common
361 fb4102a5 2021-07-06 op
362 fb4102a5 2021-07-06 op server "localhost" {
363 fb4102a5 2021-07-06 op # the quoting of \$ is for sh
364 fb4102a5 2021-07-06 op cert \$pwd "/cert.pem"
365 fb4102a5 2021-07-06 op key \$pwd "/key.pem"
366 fb4102a5 2021-07-06 op root \$pwd "/testdata"
367 fb4102a5 2021-07-06 op }
368 fb4102a5 2021-07-06 op EOF
369 fb4102a5 2021-07-06 op checkconf
370 fb4102a5 2021-07-06 op restart
371 fb4102a5 2021-07-06 op
372 fb4102a5 2021-07-06 op eq "$(head /)" "20 text/gemini" "Unexpected head for /"
373 fb4102a5 2021-07-06 op eq "$(get /)" "# hello world$ln" "Unexpected body for /"
374 fb4102a5 2021-07-06 op echo OK GET / with macro expansion