Mercurial > hg > nginx-tests
annotate rewrite_if.t @ 1866:a797d7428fa5
Tests: simplified http SSL tests with IO::Socket::SSL.
The http SSL tests which previously used IO::Socket::SSL were converted
to use improved IO::Socket::SSL infrastructure in Test::Nginx.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 May 2023 18:07:19 +0300 |
parents | 7787498b3ceb |
children |
rev | line source |
---|---|
1395
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for rewrite "if" condition. |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(33) |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 http { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 server { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 listen 127.0.0.1:8080; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 server_name localhost; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 location / { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 if ($arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location /sp { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 if ( $arg_c ) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 location /eq { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 if ($arg_c = 1) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location /not { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 if ($arg_c != 2) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 location /pos { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 if ($arg_c ~ foo) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 location /cpos { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 if ($arg_c ~* foo) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 location /neg { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 if ($arg_c !~ foo) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 location /cneg { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 if ($arg_c !~* foo) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 location /plain { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 if (-f %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 location /dir { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 if (-d %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 location /exist { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 if (-e %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 location /exec { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 if (-x %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 location /not_plain { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 if (!-f %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 location /not_dir { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 if (!-d %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 location /not_exist { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 if (!-e %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 location /not_exec { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 if (!-x %%TESTDIR%%/$arg_c) { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 return 204; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 EOF |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 $t->write_file('file', ''); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 mkdir($t->testdir() . '/dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 $t->run(); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 ############################################################################### |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 like(http_get('/?c=1'), qr/ 204 /, 'var'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 unlike(http_get('/?c=0'), qr/ 204 /, 'false'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 like(http_get('/sp?c=1'), qr/ 204 /, 'spaces'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 like(http_get('/eq?c=1'), qr/ 204 /, 'equal'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 unlike(http_get('/eq?c=2'), qr/ 204 /, 'equal false'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 like(http_get('/not?c=1'), qr/ 204 /, 'not equal'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 unlike(http_get('/not?c=2'), qr/ 204 /, 'not equal false'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 like(http_get('/pos?c=food'), qr/ 204 /, 'match'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 like(http_get('/cpos?c=FooD'), qr/ 204 /, 'match case'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 like(http_get('/neg?c=FooD'), qr/ 204 /, 'match negative'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 like(http_get('/cneg?c=bar'), qr/ 204 /, 'match negative case'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 unlike(http_get('/pos?c=FooD'), qr/ 204 /, 'mismatch'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 unlike(http_get('/cpos?c=bar'), qr/ 204 /, 'mismatch case'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 unlike(http_get('/neg?c=food'), qr/ 204 /, 'mismatch negative'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 unlike(http_get('/cneg?c=FooD'), qr/ 204 /, 'mismatch negative case'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 like(http_get('/plain?c=file'), qr/ 204 /, 'plain file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 unlike(http_get('/plain?c=dir'), qr/ 204 /, 'plain dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 unlike(http_get('/not_plain?c=file'), qr/ 204 /, 'not plain file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 like(http_get('/not_plain?c=dir'), qr/ 204 /, 'not plain dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 unlike(http_get('/dir/?c=file'), qr/ 204 /, 'directory file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 like(http_get('/dir?c=dir'), qr/ 204 /, 'directory dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 like(http_get('/not_dir?c=file'), qr/ 204 /, 'not directory file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 unlike(http_get('/not_dir?c=dir'), qr/ 204 /, 'not directory dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 like(http_get('/exist?c=file'), qr/ 204 /, 'exist file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 like(http_get('/exist?c=dir'), qr/ 204 /, 'exist dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 unlike(http_get('/exist?c=nx'), qr/ 204 /, 'exist non-existent'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 unlike(http_get('/not_exist?c=file'), qr/ 204 /, 'not exist file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 unlike(http_get('/not_exist?c=dir'), qr/ 204 /, 'not exist dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 like(http_get('/not_exist?c=nx'), qr/ 204 /, 'not exist non-existent'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 SKIP: { |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 skip 'no exec on win32', 4 if $^O eq 'MSWin32'; |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 unlike(http_get('/exec?c=file'), qr/ 204 /, 'executable file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 like(http_get('/exec?c=dir'), qr/ 204 /, 'executable dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 like(http_get('/not_exec?c=file'), qr/ 204 /, 'not executable file'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 unlike(http_get('/not_exec?c=dir'), qr/ 204 /, 'not executable dir'); |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 } |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 |
7787498b3ceb
Tests: rewrite module tests, the "if" directive.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 ############################################################################### |