diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
commit | 77e50caaf2ef81cd91075cf836fed0e75718ffb4 (patch) | |
tree | 53b7b411290b63192fc9e924a3b6b65cdf67e9d0 /debian/vendor-h2o/t/40session-ticket | |
parent | Adding upstream version 1.8.3. (diff) | |
download | dnsdist-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/40session-ticket.t | 133 | ||||
-rw-r--r-- | debian/vendor-h2o/t/40session-ticket/forever_ticket.yaml | 6 |
2 files changed, 139 insertions, 0 deletions
diff --git a/debian/vendor-h2o/t/40session-ticket.t b/debian/vendor-h2o/t/40session-ticket.t new file mode 100644 index 0000000..2e5d5e4 --- /dev/null +++ b/debian/vendor-h2o/t/40session-ticket.t @@ -0,0 +1,133 @@ +use strict; +use warnings; +use File::Temp qw(tempdir); +use Net::EmptyPort qw(check_port empty_port); +use Test::More; +use t::Util; + +plan skip_all => "could not find openssl" + unless prog_exists("openssl"); +#plan skip_all => "openssl 1.0.2 or above is required" +# unless `openssl version` =~ /^OpenSSL 1\.(?:0\.[2-9][^0-9]|[1-9])/s; + +my $tempdir = tempdir(CLEANUP => 1); + +subtest "internal" => sub { + spawn_with(<< "EOT", + mode: ticket +EOT + sub { + is test(), "New"; + test(); # openssl 0.9.8 seems to return "New" (maybe because in the first run we did not specify -sess_in) + is test(), "Reused"; + is test(), "Reused"; + }); + spawn_with(<< "EOT", + mode: ticket +EOT + sub { + is test(), "New"; + }); +}; + +subtest "file" => sub { + my $tickets_file = "t/40session-ticket/forever_ticket.yaml"; + spawn_with(<< "EOT", + mode: ticket + ticket-store: file + ticket-file: $tickets_file +EOT + sub { + is test(), "New"; + is test(), "Reused"; + is test(), "Reused"; + }); + spawn_with(<< "EOT", + mode: ticket + ticket-store: file + ticket-file: $tickets_file +EOT + sub { + sleep 1; + is test(), "Reused"; + }); +}; + +subtest "no-tickets-in-file" => sub { + my $tickets_file = "t/40session-ticket/nonexistent"; + spawn_with(<< "EOT", + mode: ticket + ticket-store: file + ticket-file: $tickets_file +EOT + sub { + is test(), "New"; + is test(), "New"; + is test(), "New"; + }); +}; + +subtest "memcached" => sub { + plan skip_all => "memcached not found" + unless prog_exists("memcached"); + my $memc_port = empty_port(); + my $doit = sub { + my $memc_proto = shift; + my $memc_guard = spawn_server( + argv => [ qw(memcached -l 127.0.0.1 -p), $memc_port, "-B", $memc_proto ], + is_ready => sub { + check_port($memc_port); + }, + ); + my $conf =<< "EOT"; + mode: ticket + ticket-store: memcached + memcached: + host: 127.0.0.1 + port: $memc_port + protocol: $memc_proto +EOT + spawn_with($conf, sub { + is test(), "New"; + is test(), "Reused"; + is test(), "Reused"; + }); + spawn_with($conf, sub { + sleep 1; + is test(), "Reused"; + }); + }; + $doit->("binary"); + $doit->("ascii"); +}; + +done_testing; + +my $server; + +sub spawn_with { + my ($opts, $cb) = @_; + $server = spawn_h2o(<< "EOT"); +ssl-session-resumption: +$opts +hosts: + default: + paths: + /: + file.dir: @{[ DOC_ROOT ]} +EOT + $cb->(); +} + +sub test { + my $lines = do { + my $cmd_opts = (-e "$tempdir/session" ? "-sess_in $tempdir/session" : "") . " -sess_out $tempdir/session"; + open my $fh, "-|", "openssl s_client $cmd_opts -connect 127.0.0.1:$server->{tls_port} 2>&1 < /dev/null" + or die "failed to open pipe:$!"; + local $/; + <$fh>; + }; + $lines =~ m{---\n(New|Reused),}s + or die "failed to parse the output of s_client:{{{$lines}}}"; + $1; +} diff --git a/debian/vendor-h2o/t/40session-ticket/forever_ticket.yaml b/debian/vendor-h2o/t/40session-ticket/forever_ticket.yaml new file mode 100644 index 0000000..0d71578 --- /dev/null +++ b/debian/vendor-h2o/t/40session-ticket/forever_ticket.yaml @@ -0,0 +1,6 @@ +- name: a397b6b7fab929366203f16fc81ffbed + cipher: aes-128-cbc + hash: sha1 + key: f1ed89cde68763630e80d2be827cfb98e3fe72644f64315a4a8ad63769a3577ccec4dd13b20eaf8c008886e5458db10e658cf2a83f04403ac4e98035d2422a75806730eb4f2fee12faff954895bc65d1 + not_before: 0 + not_after: 18446744073709551615 |