annotate mirror.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 97c8280de681
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1208
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for http mirror module.
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
1381
97c8280de681 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1208
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http mirror/)->plan(8);
1208
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 $t->write_file_expand('nginx.conf', <<'EOF');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 daemon off;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 events {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 http {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 log_format test $uri;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 server {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 listen 127.0.0.1:8080;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 server_name localhost;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 location / {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 mirror /mirror;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 location /off {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 mirror off;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 location /many {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54 mirror /mirror/1;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 mirror /mirror/2;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 location /mirror {
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 log_subrequest on;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 access_log test$args.log test;
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 }
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 EOF
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 $t->write_file('index.html', '');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 $t->write_file('many', '');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 $t->write_file('off', '');
1381
97c8280de681 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1208
diff changeset
70 $t->run();
1208
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 ###############################################################################
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 like(http_get('/index.html?1'), qr/200 OK/, 'request');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 like(http_get('/?2'), qr/200 OK/, 'internal redirect');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 like(http_get('/off?3'), qr/200 OK/, 'mirror off');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 like(http_get('/many?4'), qr/200 OK/, 'mirror many');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 $t->stop();
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 is($t->read_file('test1.log'), "/mirror\n", 'log - request');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 is($t->read_file('test2.log'), "/mirror\n/mirror\n", 'log - redirect');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 ok(!-e $t->testdir() . '/test3.log', 'log - mirror off');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 is($t->read_file('test4.log'), "/mirror/1\n/mirror/2\n", 'log - mirror many');
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85
a6453cf5786a Tests: http mirror module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 ###############################################################################