summaryrefslogtreecommitdiffstats
path: root/debian/vendor-h2o/t/50config-tag.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:12:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 21:12:02 +0000
commit77e50caaf2ef81cd91075cf836fed0e75718ffb4 (patch)
tree53b7b411290b63192fc9e924a3b6b65cdf67e9d0 /debian/vendor-h2o/t/50config-tag.t
parentAdding upstream version 1.8.3. (diff)
downloaddnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.tar.xz
dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.zip
Adding debian version 1.8.3-2.debian/1.8.3-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--debian/vendor-h2o/t/50config-tag.t111
1 files changed, 111 insertions, 0 deletions
diff --git a/debian/vendor-h2o/t/50config-tag.t b/debian/vendor-h2o/t/50config-tag.t
new file mode 100644
index 0000000..dd37f99
--- /dev/null
+++ b/debian/vendor-h2o/t/50config-tag.t
@@ -0,0 +1,111 @@
+use strict;
+use warnings;
+use File::Temp qw(tempfile);
+use Test::More;
+use t::Util;
+
+plan skip_all => 'curl not found'
+ unless prog_exists('curl');
+
+my $curl = "curl --silent --show-error --dump-header /dev/stderr";
+
+subtest 'basic' => sub {
+ my $included = temp_config_file(<< "EOT");
+header.add: &marked "foo: FOO"
+file.dir: @{[DOC_ROOT]}
+EOT
+
+ my $server = spawn_h2o(<< "EOT");
+hosts:
+ default:
+ paths:
+ /: !file $included
+EOT
+
+ my ($stderr, $stdout) = run_prog("$curl http://127.0.0.1:@{[$server->{port}]}/");
+ like $stderr, qr{^HTTP/[^ ]+ 200\s}s;
+ like $stderr, qr{^foo: ?FOO\r$}im;
+};
+
+subtest 'multi-hop' => sub {
+ my $included2 = temp_config_file(<< "EOT");
+header.add: &marked "foo: FOO"
+file.dir: @{[DOC_ROOT]}
+EOT
+ my $included1 = temp_config_file(<< "EOT");
+!file $included2
+EOT
+
+ my $server = spawn_h2o(<< "EOT");
+hosts:
+ default:
+ paths:
+ /: !file $included1
+EOT
+
+ my ($stderr, $stdout) = run_prog("$curl http://127.0.0.1:@{[$server->{port}]}/");
+ like $stderr, qr{^HTTP/[^ ]+ 200\s}s;
+ like $stderr, qr{^foo: ?FOO\r$}im;
+};
+
+subtest 'with-alias' => sub {
+ my $included = temp_config_file(<< "EOT");
+header.add: &marked "foo: FOO"
+file.dir: @{[DOC_ROOT]}
+EOT
+
+ my $server = spawn_h2o(<< "EOT");
+hosts:
+ default:
+ paths:
+ /: !file $included
+ /another:
+ header.add: *marked
+ file.dir: @{[DOC_ROOT]}
+EOT
+
+ subtest 'with_merge' => sub {
+ my ($stderr, $stdout) = run_prog("$curl http://127.0.0.1:@{[$server->{port}]}/");
+ like $stderr, qr{^HTTP/[^ ]+ 200\s}s;
+ like $stderr, qr{^foo: ?FOO\r$}im;
+ };
+
+ subtest 'with_alias' => sub {
+ my ($stderr, $stdout) = run_prog("$curl http://127.0.0.1:@{[$server->{port}]}/another/");
+ like $stderr, qr{^HTTP/[^ ]+ 200\s}s;
+ like $stderr, qr{^foo: ?FOO\r$}im;
+ };
+};
+
+subtest 'with-merge' => sub {
+ my $included2 = temp_config_file(<< "EOT");
+header.add: "foo: FOO"
+EOT
+ my $included1 = temp_config_file(<< "EOT");
+<<: !file $included2
+header.append: "bar: BAR"
+EOT
+
+ my $server = spawn_h2o(<< "EOT");
+hosts:
+ default:
+ paths:
+ /:
+ <<: !file $included1
+ file.dir: @{[ DOC_ROOT ]}
+EOT
+
+ my ($stderr, $stdout) = run_prog("$curl http://127.0.0.1:@{[$server->{port}]}/");
+ like $stderr, qr{^HTTP/[^ ]+ 200\s}s;
+ like $stderr, qr{^foo: ?FOO\r$}im;
+ like $stderr, qr{^bar: ?BAR\r$}im;
+};
+
+done_testing();
+
+sub temp_config_file {
+ my ($content) = @_;
+ my ($fh, $fn) = tempfile(UNLINK => 1);
+ print $fh $content;
+ return $fn;
+}