Mercurial > hg > nginx-tests
annotate xslt.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 | 829467f8d696 |
children | b4014b3e8495 |
rev | line source |
---|---|
208 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for nginx xslt filter module. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
15 | |
16 use lib 'lib'; | |
17 use Test::Nginx; | |
18 | |
19 ############################################################################### | |
20 | |
21 select STDERR; $| = 1; | |
22 select STDOUT; $| = 1; | |
23 | |
1493
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http xslt/)->plan(6); |
208 | 25 |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | |
27 | |
28 %%TEST_GLOBALS%% | |
29 | |
249
6a0d934950bc
Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents:
224
diff
changeset
|
30 daemon off; |
208 | 31 |
32 events { | |
33 } | |
34 | |
35 http { | |
36 %%TEST_GLOBALS_HTTP%% | |
37 | |
38 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
39 listen 127.0.0.1:8080; |
208 | 40 server_name localhost; |
41 | |
42 default_type text/xml; | |
43 | |
44 location /x1 { | |
45 xslt_stylesheet %%TESTDIR%%/test.xslt; | |
46 } | |
47 location /x2 { | |
48 xslt_stylesheet %%TESTDIR%%/test.xslt | |
211
ee8fee3c4ae8
Tests: fix xslt tests for CentOS 5.
Maxim Dounin <mdounin@mdounin.ru>
parents:
208
diff
changeset
|
49 param1='value1':param2=/root param3='value%33'; |
208 | 50 } |
51 location /x3 { | |
52 xml_entities %%TESTDIR%%/entities.dtd; | |
53 xslt_stylesheet %%TESTDIR%%/test.xslt; | |
54 } | |
55 location /x4 { | |
56 xslt_stylesheet %%TESTDIR%%/first.xslt; | |
57 xslt_stylesheet %%TESTDIR%%/test.xslt; | |
58 } | |
1493
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
59 location /x5 { |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
60 xslt_stylesheet %%TESTDIR%%/test.xslt |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
61 param1='$server_name'; |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
62 } |
208 | 63 } |
64 } | |
65 | |
66 EOF | |
67 | |
68 $t->write_file('test.xslt', <<'EOF'); | |
69 | |
70 <xsl:stylesheet version="1.0" | |
71 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
72 | |
73 <xsl:output method="html"/> | |
74 | |
75 <xsl:param name="param1"/> | |
76 <xsl:param name="param2"/> | |
77 <xsl:param name="param3"/> | |
78 | |
79 <xsl:template match="/"> | |
80 test xslt result | |
81 param1=<xsl:value-of select="$param1"/> | |
82 param2=<xsl:value-of select="$param2"/> | |
83 param3=<xsl:value-of select="$param3"/> | |
211
ee8fee3c4ae8
Tests: fix xslt tests for CentOS 5.
Maxim Dounin <mdounin@mdounin.ru>
parents:
208
diff
changeset
|
84 data=<xsl:value-of select="/root"/> |
208 | 85 </xsl:template> |
86 | |
87 </xsl:stylesheet> | |
88 | |
89 EOF | |
90 | |
91 $t->write_file('first.xslt', <<'EOF'); | |
92 | |
93 <xsl:stylesheet version="1.0" | |
94 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
95 | |
96 <xsl:template match="/"> | |
211
ee8fee3c4ae8
Tests: fix xslt tests for CentOS 5.
Maxim Dounin <mdounin@mdounin.ru>
parents:
208
diff
changeset
|
97 <root>other <xsl:value-of select="/root"/></root> |
208 | 98 </xsl:template> |
99 | |
100 </xsl:stylesheet> | |
101 | |
102 EOF | |
103 | |
104 $t->write_file('entities.dtd', '<!ENTITY test "test entity">' . "\n"); | |
105 $t->write_file('x1', '<empty/>'); | |
106 $t->write_file('x2', '<root>data</root>'); | |
107 $t->write_file('x3', '<!DOCTYPE root><root>&test;</root>'); | |
108 $t->write_file('x4', '<root>data</root>'); | |
1493
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
109 $t->write_file('x5', '<root>data</root>'); |
208 | 110 |
111 $t->run(); | |
112 | |
113 ############################################################################### | |
114 | |
115 like(http_get("/x1"), qr!200 OK.*test xslt result!ms, 'simple'); | |
116 like(http_get("/x1"), qr!200 OK.*Content-Type: text/html!ms, 'content type'); | |
117 like(http_get("/x2"), qr!200 OK.*param1=value1.*param2=data.*param3=value3!ms, | |
118 'params'); | |
119 like(http_get("/x3"), qr!200 OK.*data=test entity!ms, 'entities'); | |
120 like(http_get("/x4"), qr!200 OK.*data=other data!ms, 'several stylesheets'); | |
121 | |
1493
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
122 TODO: { |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
123 todo_skip 'heap-buffer-overflow', 1 unless $t->has_version('1.17.2') |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
124 or $ENV{TEST_NGINX_UNSAFE}; |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
125 |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
126 like(http_get("/x5"), qr!200 OK.*param1=localhost!ms, 'params variable'); |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
127 |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
128 } |
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
129 |
208 | 130 ############################################################################### |