Mercurial > hg > nginx-tests
annotate stream_ssl_preread_protocol.t @ 1357:2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 17 Jul 2018 21:23:20 +0300 |
parents | |
children | 71f964c077bf |
rev | line source |
---|---|
1357
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for stream_ssl_preread module, protocol preread. |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/stream stream_ssl_preread stream_return/) |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 stream { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 server { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 listen 127.0.0.1:8080; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 ssl_preread on; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 return $ssl_preread_protocol; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 EOF |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 $t->try_run('no ssl_preread_protocol')->plan(6); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 ############################################################################### |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 is(get('SSLv3'), 'SSLv3', 'client hello SSLv3'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 is(get('TLSv1'), 'TLSv1', 'client hello TLSv1'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 is(get('TLSv1.1'), 'TLSv1.1', 'client hello TLSv1.1'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 is(get('TLSv1.2'), 'TLSv1.2', 'client hello TLSv1.2'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 is(get_tls13(), 'TLSv1.3', 'client hello supported_versions'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 TODO: { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 local $TODO = 'not yet'; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 is(get_ssl2(), 'SSLv2', 'client hello version 2'); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 ############################################################################### |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 sub get { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 my $v = shift; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 my ($re, $ch); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 $re = 0x0300, $ch = 0x0300 if $v eq 'SSLv3'; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 $re = 0x0301, $ch = 0x0301 if $v eq 'TLSv1'; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $re = 0x0301, $ch = 0x0302 if $v eq 'TLSv1.1'; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 $re = 0x0301, $ch = 0x0303 if $v eq 'TLSv1.2'; |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 my $r = pack("CnNn2C", 0x16, $re, 0x00380100, 0x0034, $ch, 0xeb); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 $r .= pack("N*", 0x6357cdba, 0xa6b8d853, 0xf1f6ac0f); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 $r .= pack("N*", 0xdf03178c, 0x0ae41824, 0xe7643682); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 $r .= pack("N*", 0x3c1b273f, 0xbfde4b00, 0x00000000); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $r .= pack("CN3", 0x0c, 0x00000008, 0x00060000, 0x03666f6f); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 http($r); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 sub get_tls13 { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 my $r = pack("N*", 0x16030100, 0x33010000, 0x2f0303eb); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 $r .= pack("N*", 0x6357cdba, 0xa6b8d853, 0xf1f6ac0f); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 $r .= pack("N*", 0xdf03178c, 0x0ae41824, 0xe7643682); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 $r .= pack("N*", 0x3c1b273f, 0xbfde4b00, 0x00000000); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 $r .= pack("CNCn", 0x07, 0x002b0007, 0x02, 0x7f1c); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 http($r); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 sub get_ssl2 { |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 my $r = pack("nCn4", 0x801c, 0x01, 0x0002, 0x0003, 0x0000, 0x0010); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 $r .= pack("C3", 0x01, 0x00, 0x80); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 $r .= pack("N4", 0x322dd95c, 0x4749ef17, 0x3d5f0916, 0xf0b730f8); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 http($r); |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 } |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
2415ef05a282
Tests: stream_ssl_preread module tests, protocol preread.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 ############################################################################### |