Mercurial > hg > nginx-tests
comparison quic_key_update.t @ 1930:0e8b5b442b1d
Tests: basic QUIC key update tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 18 Aug 2023 17:03:34 +0400 |
parents | |
children | afe4af958e53 |
comparison
equal
deleted
inserted
replaced
1929:3408c20d2f24 | 1930:0e8b5b442b1d |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for QUIC key update. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::HTTP3; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/) | |
27 ->has_daemon('openssl')->plan(3); | |
28 | |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | |
30 | |
31 %%TEST_GLOBALS%% | |
32 | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 ssl_certificate_key localhost.key; | |
42 ssl_certificate localhost.crt; | |
43 | |
44 server { | |
45 listen 127.0.0.1:%%PORT_8980_UDP%% quic; | |
46 server_name localhost; | |
47 | |
48 location / { } | |
49 } | |
50 } | |
51 | |
52 EOF | |
53 | |
54 $t->write_file('openssl.conf', <<EOF); | |
55 [ req ] | |
56 default_bits = 2048 | |
57 encrypt_key = no | |
58 distinguished_name = req_distinguished_name | |
59 [ req_distinguished_name ] | |
60 EOF | |
61 | |
62 my $d = $t->testdir(); | |
63 | |
64 foreach my $name ('localhost') { | |
65 system('openssl req -x509 -new ' | |
66 . "-config $d/openssl.conf -subj /CN=$name/ " | |
67 . "-out $d/$name.crt -keyout $d/$name.key " | |
68 . ">>$d/openssl.out 2>&1") == 0 | |
69 or die "Can't create certificate for $name: $!\n"; | |
70 } | |
71 | |
72 $t->run(); | |
73 | |
74 ############################################################################### | |
75 | |
76 my ($s, $sid, $frames, $frame); | |
77 | |
78 $s = Test::Nginx::HTTP3->new(); | |
79 ok(get($s), 'request'); | |
80 | |
81 # sets the Key Phase bit | |
82 | |
83 $s->key_update(); | |
84 ok(get($s), 'key update 1'); | |
85 | |
86 # clears the Key Phase bit | |
87 | |
88 $s->key_update(); | |
89 ok(get($s), 'key update 2'); | |
90 | |
91 ############################################################################### | |
92 | |
93 sub get { | |
94 my ($s) = @_; | |
95 my $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 1 }]); | |
96 grep { $_->{type} eq "HEADERS" } @$frames; | |
97 } | |
98 | |
99 ############################################################################### |