Mercurial > hg > nginx-tests
comparison post_action.t @ 453:baae3ed4ad09
Tests: post_action tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 28 Aug 2014 04:48:18 +0400 |
parents | |
children | 5baf4b01cae4 |
comparison
equal
deleted
inserted
replaced
452:4465c1cf6f75 | 453:baae3ed4ad09 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for nginx post_action directive. | |
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 proxy/)->plan(6); | |
26 | |
27 $t->write_file_expand('nginx.conf', <<'EOF'); | |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen 127.0.0.1:8080; | |
41 server_name localhost; | |
42 | |
43 location / { | |
44 post_action /post.html; | |
45 } | |
46 | |
47 location /post.html { | |
48 # static | |
49 } | |
50 | |
51 location /remote { | |
52 post_action /post.remote; | |
53 } | |
54 | |
55 location /post.remote { | |
56 proxy_pass http://127.0.0.1:8080/post.html; | |
57 } | |
58 } | |
59 } | |
60 | |
61 EOF | |
62 | |
63 $t->write_file('index.html', 'SEE-THIS'); | |
64 $t->write_file('post.html', 'HIDDEN'); | |
65 $t->write_file('remote', 'SEE-THIS'); | |
66 | |
67 $t->run(); | |
68 | |
69 ############################################################################### | |
70 | |
71 like(http_get('/'), qr/SEE-THIS/m, 'post action'); | |
72 unlike(http_get('/'), qr/HIDDEN/m, 'no additional body'); | |
73 | |
74 like(http_get('/remote'), qr/SEE-THIS/m, 'post action proxy'); | |
75 unlike(http_get('/remote'), qr/HIDDEN/m, 'no additional body proxy'); | |
76 | |
77 $t->stop(); | |
78 | |
79 like(`cat ${\($t->testdir())}/access.log`, qr/post/, 'post action in logs'); | |
80 | |
81 TODO: { | |
82 local $TODO = 'broken in 1.5.4'; | |
83 | |
84 # the r->header_sent check in 1.5.4+ results in | |
85 # "header already sent" alerts | |
86 | |
87 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); | |
88 | |
89 } | |
90 | |
91 ############################################################################### |