Mercurial > hg > nginx-tests
annotate charset.t @ 1974:b5036a0f9ae0 default tip
Tests: improved compatibility when using recent "openssl" app.
Starting with OpenSSL 3.0, "openssl genrsa" generates encrypted keys
in PKCS#8 format instead of previously used PKCS#1 format. Further,
since OpenSSL 1.1.0 such keys are using PBKDF2 hmacWithSHA256.
Such keys are not supported by old SSL libraries, notably by OpenSSL
before 1.0.0 (OpenSSL 0.9.8 only supports hmacWithSHA1) and by BoringSSL
before May 21, 2019 (support for hmacWithSHA256 was added in 302a4dee6c),
and trying to load such keys into nginx compiled with an old SSL library
results in "unsupported prf" errors.
To facilitate testing with old SSL libraries, keys are now generated
with "openssl genrsa -traditional" if the flag is available.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 06 May 2024 00:04:26 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
399 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for charset filter. | |
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/http charset proxy/)->plan(7) | |
26 ->write_file_expand('nginx.conf', <<'EOF')->run(); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
30 daemon off; | |
31 | |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 types { | |
39 text/html html; | |
40 text/foo foo; | |
41 } | |
42 | |
43 charset_map B A { | |
44 58 59; # X -> Y | |
45 } | |
46 | |
47 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
48 listen 127.0.0.1:8080; |
399 | 49 server_name localhost; |
50 | |
51 location / { | |
52 charset utf-8; | |
53 } | |
54 | |
55 location /t3.foo { | |
56 charset utf-8; | |
57 charset_types text/foo; | |
58 } | |
59 | |
60 location /t4.any { | |
61 charset utf-8; | |
62 charset_types *; | |
63 } | |
64 | |
65 location /t5.html { | |
66 charset $arg_c; | |
67 } | |
68 | |
69 location /t.html { | |
70 charset A; | |
71 source_charset B; | |
72 } | |
73 | |
74 location /proxy/ { | |
75 charset B; | |
76 override_charset on; | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 proxy_pass http://127.0.0.1:8080/; |
399 | 78 } |
79 } | |
80 } | |
81 | |
82 EOF | |
83 | |
84 $t->write_file('t1.html', ''); | |
85 $t->write_file('t2.foo', ''); | |
86 $t->write_file('t3.foo', ''); | |
87 $t->write_file('t4.any', ''); | |
88 $t->write_file('t5.html', ''); | |
89 $t->write_file('t.html', 'X' x 99); | |
90 | |
91 ############################################################################### | |
92 | |
93 like(http_get('/t1.html'), qr!text/html; charset=utf-8!, 'charset indicated'); | |
94 like(http_get('/t2.foo'), qr!text/foo\x0d!, 'wrong type'); | |
95 like(http_get('/t3.foo'), qr!text/foo; charset=utf-8!, 'charset_types'); | |
96 like(http_get('/t4.any'), qr!text/plain; charset=utf-8!, 'charset_types any'); | |
97 like(http_get('/t5.html?c=utf-8'), qr!text/html; charset=utf-8!, 'variables'); | |
98 | |
99 like(http_get('/t.html'), qr!Y{99}!, 'recode'); | |
100 like(http_get('/proxy/t.html'), qr!X{99}!, 'override charset'); | |
101 | |
102 ############################################################################### |