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