annotate http_uri.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 eb33558f731d
children 7b80c8e0479a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1515
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for URI normalization.
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20 ###############################################################################
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22 select STDERR; $| = 1;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDOUT; $| = 1;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(8)
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 ->write_file_expand('nginx.conf', <<'EOF')->run();
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 %%TEST_GLOBALS%%
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 daemon off;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 events {
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 }
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 http {
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 %%TEST_GLOBALS_HTTP%%
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 server {
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 listen 127.0.0.1:8080;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 server_name localhost;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 location / {
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 add_header X-URI "x $uri x";
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 return 204;
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 }
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 }
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 }
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 EOF
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 ###############################################################################
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 local $TODO = 'not yet' unless $t->has_version('1.17.5');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 like(http_get('/foo/bar%'), qr/400 Bad/, 'percent');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 like(http_get('/foo/bar%1'), qr/400 Bad/, 'percent digit');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 like(http_get('/foo/bar/.?args'), qr!x /foo/bar/ x!, 'dot args');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 like(http_get('/foo/bar/.#frag'), qr!x /foo/bar/ x!, 'dot frag');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 like(http_get('/foo/bar/..?args'), qr!x /foo/ x!, 'dot dot args');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 like(http_get('/foo/bar/..#frag'), qr!x /foo/ x!, 'dot dot frag');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 like(http_get('/foo/bar/.'), qr!x /foo/bar/ x!, 'trailing dot');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 like(http_get('/foo/bar/..'), qr!x /foo/ x!, 'trailing dot dot');
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64
eb33558f731d Tests: URI normalization tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 ###############################################################################