Mercurial > hg > nginx-tests
annotate xslt.t @ 1888:cc13f7b098db
Tests: avoid premature stream reset in h3_limit_req.t.
STREAM and RESET_STREAM frames could be batched, which prevents the stream
from being processed and changes the status code. The fix is to wait for
the stream acknowledgment. Here we just look at the largest acknowledged,
this should be enough for simple cases.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 04 Apr 2023 00:33:54 +0400 |
parents | 5ac6efbe5552 |
children |
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 | |
1584
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
24 my $t = Test::Nginx->new()->has(qw/http xslt/)->plan(8); |
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'); | |
1493
829467f8d696
Tests: xslt_stylesheet parameter from variable.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
121 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
|
122 |
1584
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
123 # xslt and ranges |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
124 |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
125 unlike(http_get("/x1"), qr!Accept-Ranges!, 'no Accept-Ranges'); |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
126 like(http(<<EOF), qr!200 OK.*test xslt result!ms, 'no ranges'); |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
127 GET /x1 HTTP/1.1 |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
128 Host: localhost |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
129 Connection: close |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
130 Range: bytes=-10 |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
131 |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
132 EOF |
b4014b3e8495
Tests: added xslt filter tests with ranges.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1493
diff
changeset
|
133 |
208 | 134 ############################################################################### |