Mercurial > hg > nginx-tests
annotate autoindex_win32.t @ 1938:e1059682aeef
Tests: fixed ClientHello with resending Initial QUIC packets.
Previously it was rebuilt each time using distinct ClientHello.random
resulting in different CRYPTO payload. As such, it led to TLS digest
hash and derived secrets mismatch when resending Initial packet. Now
ClientHello is built once and reused when resending Initial packets.
Additionally, this required to preserve a generated secret value used
in shared secret calculation as part of TLS key schedule. Previously
it was regenerated when receiving a Retry packet, but this won't work
with reused ClientHello as the resulting shared secrets won't match.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 30 Aug 2023 02:22:58 +0400 |
parents | 1b53142f7fdc |
children |
rev | line source |
---|---|
1827
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for autoindex module on win32. |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use Encode qw/ encode /; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 eval { require Win32API::File; }; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 plan(skip_all => 'Win32API::File not installed') if $@; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 my $t = Test::Nginx->new()->has(qw/http autoindex charset/)->plan(9) |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 ->write_file_expand('nginx.conf', <<'EOF'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 events { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 http { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS_HTTP%% |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 listen 127.0.0.1:8080; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location / { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 autoindex on; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 charset utf-8; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 EOF |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 my $d = $t->testdir(); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 mkdir("$d/test-dir"); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 $t->write_file('test-file', ''); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 my $file = "$d/test-file-" . ("\x{043c}\x{0438}") x 3; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 win32_write_file($file, ''); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 my $dir = "$d/test-dir-" . ("\x{043c}\x{0438}") x 3; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 win32_mkdir($dir); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 my $subfile = "$dir/test-subfile-" . ("\x{043c}\x{0438}") x 3; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 win32_write_file($subfile, ''); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 $t->run(); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 ############################################################################### |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 my $r = http_get('/'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 like($r, qr!href="test-file"!ms, 'file'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 like($r, qr!href="test-dir/"!ms, 'directory'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 TODO: { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 local $TODO = 'not yet' unless $t->has_version('1.23.4'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 like($r, qr!href="test-file-(%d0%bc%d0%b8){3}"!msi, 'utf file link'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 like($r, qr!test-file-(\xd0\xbc\xd0\xb8){3}</a>!ms, 'utf file name'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 like($r, qr!href="test-dir-(%d0%bc%d0%b8){3}/"!msi, 'utf dir link'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 like($r, qr!test-dir-(\xd0\xbc\xd0\xb8){3}/</a>!ms, 'utf dir name'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 $r = http_get('/test-dir-' . "\xd0\xbc\xd0\xb8" x 3 . '/'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 like($r, qr!Index of /test-dir-(\xd0\xbc\xd0\xb8){3}/!msi, 'utf subdir index'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 like($r, qr!href="test-subfile-(%d0%bc%d0%b8){3}"!msi, 'utf subdir link'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 like($r, qr!test-subfile-(\xd0\xbc\xd0\xb8){3}</a>!msi, 'utf subdir name'); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 ############################################################################### |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 sub win32_mkdir { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 my ($name) = @_; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 mkdir("$d/test-dir-tmp"); |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 Win32API::File::MoveFileW(encode("UTF-16LE","$d/test-dir-tmp\0"), |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 encode("UTF-16LE", $name . "\0")) or die "$^E"; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 sub win32_write_file { |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 my ($name, $data) = @_; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 my $h = Win32API::File::CreateFileW(encode("UTF-16LE", $name . "\0"), |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 Win32API::File::FILE_READ_DATA() |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 | Win32API::File::FILE_WRITE_DATA(), 0, [], |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 Win32API::File::CREATE_NEW(), 0, []) or die $^E; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 Win32API::File::WriteFile($h, $data, 0, [], []) or die $^E; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 Win32API::File::CloseHandle($h) or die $^E; |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 } |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
1b53142f7fdc
Tests: win32 autoindex tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 ############################################################################### |