Mercurial > hg > nginx-tests
annotate gunzip_perl.t @ 1858:cdcd75657e52
Tests: added has_feature() tests for IO::Socket::SSL.
The following distinct features supported:
- "socket_ssl", which requires IO::Socket::SSL and also implies
existance of the IO::Socket::SSL::SSL_VERIFY_NONE() symbol.
It is used by most of the tests.
- "socket_ssl_sni", which requires IO::Socket::SSL with the can_client_sni()
function (1.84), and SNI support available in Net::SSLeay and the OpenSSL
library being used. Used by ssl_sni.t, ssl_sni_sessions.t,
stream_ssl_preread.t. Additional Net::SSLeay testing is believed to be
unneeded and was removed.
- "socket_ssl_alpn", which requires IO::Socket::SSL with ALPN support (2.009),
and ALPN support in Net::SSLeay and the OpenSSL library being used.
Used by h2_ssl.t, h2_ssl_verify_client.t, stream_ssl_alpn.t,
stream_ssl_preread_alpn.t.
- "socket_ssl_sslversion", which requires IO::Socket::SSL with
the get_sslversion() and get_sslversion_int() methods (1.964).
Used by mail_imap_ssl.t.
- "socket_ssl_reused", which requires IO::Socket::SSL with
the get_session_reused() method (2.057). To be used in the following
patches.
This makes it possible to simplify and unify various SSL tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:02 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for gunzip filter module with perl module. |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 BEGIN { use FindBin; chdir($FindBin::Bin); } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 use lib 'lib'; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use Test::Nginx qw/ :DEFAULT :gzip /; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 ############################################################################### |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 select STDERR; $| = 1; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 select STDOUT; $| = 1; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 eval { require IO::Compress::Gzip; }; |
773 | 25 plan(skip_all => "IO::Compress::Gzip not found") if $@; |
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http gunzip perl/)->plan(2) |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
231
diff
changeset
|
32 daemon off; |
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 events { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 http { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8080; |
231
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 server_name localhost; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 gunzip on; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 location / { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 perl 'sub { |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 my $r = shift; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 $r->header_out("Content-Encoding", "gzip"); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 $r->send_http_header("text/plain"); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 return OK if $r->header_only; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 use IO::Compress::Gzip; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 my $in = "TEST"; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 my $out; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 IO::Compress::Gzip::gzip(\\$in => \\$out); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 $r->print($out); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 return OK; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 }'; |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 } |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 EOF |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 $t->run(); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 ############################################################################### |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 http_gzip_like(http_gzip_request('/'), qr/TEST/, 'perl response gzipped'); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 like(http_get('/'), qr/TEST/, 'perl response gunzipped'); |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 |
bc1861122d0c
Tests: gunzip filter tests import.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 ############################################################################### |