annotate proxy_method.t @ 1571:1b4ceab9cb1c

Tests: fixed ssl_certificate.t with LibreSSL client. Net::SSLeay::connect() that manages TLS handshake could return unexpected error when receiving server alert, as seen in server certificate tests if it could not been selected. Typically, it returns the expected error -1, but with certain libssl implementations it can be 0, as explained below. The error is propagated from libssl's SSL_connect(), which is usually -1. In modern OpenSSL versions, it is the default error code used in the state machine returned when something went wrong with parsing TLS message header. In versions up to OpenSSL 1.0.2, with SSLv23_method() used by default, -1 is the only error code in the ssl_connect() method implementation which is used as well if receiving alert while parsing ServerHello. BoringSSL also seems to return -1. But it is not so with LibreSSL that returns zero. Previously, tests failed with client built with LibreSSL with SSLv3 removed. Here, the error is propagated directly from ssl_read_bytes() method, which is always implemented as ssl3_read_bytes() in all TLS methods. It could be also seen with OpenSSL up to 1.0.2 with non-default methods explicitly set.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 29 May 2020 23:10:20 +0300
parents 766bcbb632ee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1071
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
1 #!/usr/bin/perl
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
2
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
3 # (C) Dmitry Lazurkin
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
4
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
5 # Tests for proxy_method.
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
6
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
7 ###############################################################################
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
8
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
9 use warnings;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
10 use strict;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
11
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
12 use Test::More;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
13
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
15
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
16 use lib 'lib';
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
17 use Test::Nginx;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
18
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
19 ###############################################################################
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
20
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
21 select STDERR; $| = 1;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
22 select STDOUT; $| = 1;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
23
1075
5513b68493e7 Tests: added rewrite prerequisite in proxy_method.t.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1071
diff changeset
24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(4)
1076
4240cca68d1d Tests: whitespace fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 1075
diff changeset
25 ->write_file_expand('nginx.conf', <<'EOF');
1071
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
26
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
27 %%TEST_GLOBALS%%
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
28
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
29 daemon off;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
30
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
31 events {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
32 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
33
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
34 http {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
35 %%TEST_GLOBALS_HTTP%%
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
36
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
37 server {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
38 listen 127.0.0.1:8080;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
39 server_name localhost;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
40
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
41 location /preserve {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
42 proxy_pass http://127.0.0.1:8080/get-method;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
43 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
44
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
45 location /const {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
46 proxy_pass http://127.0.0.1:8080/get-method;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
47 proxy_method POST;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
48 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
49
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
50 location /var {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
51 proxy_pass http://127.0.0.1:8080/get-method;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
52 proxy_method $arg_method;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
53 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
54
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
55 location /parent {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
56 proxy_method POST;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
57 location /parent/child {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
58 proxy_pass http://127.0.0.1:8080/get-method;
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
59 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
60 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
61
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
62 location /get-method {
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
63 return 200 "request_method=$request_method";
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
64 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
65 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
66 }
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
67
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
68 EOF
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
69
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
70 $t->run();
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
71
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
72 ###############################################################################
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
73
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
74 like(http_get('/preserve'), qr/request_method=GET/,
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
75 'proxy_method from request');
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
76
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
77 like(http_get('/const'), qr/request_method=POST/,
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
78 'proxy_method from constant');
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
79
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
80 like(http_get('/var?method=POST'), qr/request_method=POST/,
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
81 'proxy_method from variable');
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
82
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
83 like(http_get('/parent/child'), qr/request_method=POST/,
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
84 'proxy_method from parent');
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
85
1dd57525de8b Tests: add tests for proxy_method directive.
Dmitry Lazurkin <dilaz03@gmail.com>
parents:
diff changeset
86 ###############################################################################