Mercurial > hg > nginx-tests
annotate stream_udp_stream.t @ 1829:a78c32419f02
Tests: separate SSL session reuse tests.
Instead of being mixed with generic SSL tests, session reuse variants
are now tested in a separate file.
In the generic SSL tests only basic session reuse is now tested,
notably with session tickets enabled and a shared SSL session cache.
This should make it possible to reuse sessions in all cases (except
when it's not supported, such as with LibreSSL with TLSv1.3).
Note that session reuse with tickets implies that $ssl_session_id
is selected by the client and therefore is not available on the
initial connection. Relevant test is modified to handle this.
Further, BoringSSL does not use legacy session ID with TLSv1.3 even
if it is sent by the client. In contrast, OpenSSL always generates
an unique legacy session id, so it is available with TLSv1.3 even if
session resumption does not work (such as with old Net::SSLeay and
IO::Socket::SSL modules).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 23 Mar 2023 19:49:47 +0300 |
parents | f3ba4c74de31 |
children |
rev | line source |
---|---|
1335 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Nginx, Inc. | |
4 | |
5 # Tests for UDP stream. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 use Test::Nginx::Stream qw/ dgram /; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/stream stream_return udp/)->plan(8) | |
26 ->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 stream { | |
1609
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1535
diff
changeset
|
36 %%TEST_GLOBALS_STREAM%% |
f3ba4c74de31
Tests: added TEST_GLOBALS_STREAM variable support.
Andrei Belov <defan@nginx.com>
parents:
1535
diff
changeset
|
37 |
1437
2fc21bdd6f0d
Tests: adjusted stream_udp_stream.t for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1372
diff
changeset
|
38 proxy_timeout 1s; |
1335 | 39 |
40 server { | |
41 listen 127.0.0.1:%%PORT_8980_UDP%% udp; | |
42 proxy_pass 127.0.0.1:%%PORT_8981_UDP%%; | |
43 } | |
44 | |
45 server { | |
46 listen 127.0.0.1:%%PORT_8981_UDP%% udp; | |
47 return $remote_port; | |
48 } | |
49 } | |
50 | |
51 EOF | |
52 | |
53 $t->run(); | |
54 | |
55 ############################################################################### | |
56 | |
57 my $s = dgram('127.0.0.1:' . port(8980)); | |
58 my $data = $s->io('1', read_timeout => 0.5); | |
59 isnt($data, '', 'udp_stream response 1'); | |
60 | |
61 my $s2 = dgram('127.0.0.1:' . port(8980)); | |
62 my $data2 = $s2->io('1', read_timeout => 0.5); | |
63 isnt($data2, '', 'udp_stream response 2'); | |
64 | |
65 isnt($data, $data2, 'udp_stream two sessions'); | |
66 | |
67 is($s->io('1'), $data, 'udp_stream session 1'); | |
68 is($s->io('1'), $data, 'udp_stream session 2'); | |
69 | |
70 is($s2->io('1'), $data2, 'udp_stream another session 1'); | |
71 is($s2->io('1'), $data2, 'udp_stream another session 2'); | |
72 | |
1437
2fc21bdd6f0d
Tests: adjusted stream_udp_stream.t for slow hosts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1372
diff
changeset
|
73 select undef, undef, undef, 1.1; |
1335 | 74 |
75 isnt($s->io('1'), $data, 'udp_stream new session'); | |
1372 | 76 |
77 ############################################################################### |