-
Notifications
You must be signed in to change notification settings - Fork 0
/
50file-config.t
57 lines (50 loc) · 1.32 KB
/
50file-config.t
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
use strict;
use warnings;
use Test::More;
use t::Util;
plan skip_all => 'curl not found'
unless prog_exists('curl');
subtest 'etag' => sub {
my $fetch = sub {
my $extra_conf = shift;
my $server = spawn_h2o(<< "EOT");
hosts:
default:
paths:
/:
file.dir: examples/doc_root
$extra_conf
EOT
return `curl --silent --dump-header /dev/stderr http://127.0.0.1:$server->{port}/ 2>&1 > /dev/null`;
};
my $etag_re = qr/^etag: /im;
my $resp = $fetch->('');
like $resp, $etag_re, "default is on";
$resp = $fetch->('file.etag: off');
unlike $resp, $etag_re, "off";
$resp = $fetch->('file.etag: on');
like $resp, $etag_re, "on";
};
subtest 'dir-listing' => sub {
my $server = spawn_h2o(<< 'EOT');
hosts:
default:
paths:
/off:
file.dir: examples/doc_root
file.dirlisting: off
/on:
file.dir: examples/doc_root
file.dirlisting: on
file.index: []
EOT
my $fetch = sub {
my $path = shift;
return `curl --silent --dump-header /dev/stderr http://127.0.0.1:$server->{port}$path 2>&1 > /dev/null`;
};
my $resp = $fetch->("/on/");
like $resp, qr{^HTTP/1\.[0-9]+ 200 }s, "ON returns 200";
$resp = $fetch->("/off/");
like $resp, qr{^HTTP/1\.[0-9]+ 403 }s, "OFF returns 403";
};
done_testing();