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