Mercurial > hg > nginx-tests
annotate h2_proxy_ssl.t @ 886:af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
The test was broken with splitting h2.t due to missing ssl_certificate.
Break the test out into a separate file as it depends on openssl binary.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 25 Mar 2016 22:19:54 +0300 |
parents | |
children | 266e3b2e88f9 |
rev | line source |
---|---|
886
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/2 protocol with proxy to ssl backend. |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP2 qw/ :DEFAULT :frame /; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy/) |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has_daemon('openssl')->plan(1); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->todo_alerts(); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 $t->write_file_expand('nginx.conf', <<'EOF'); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 events { |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 http { |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS_HTTP%% |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 listen 127.0.0.1:8080 http2; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 listen 127.0.0.1:8081 ssl; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server_name localhost; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 ssl_certificate_key localhost.key; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 ssl_certificate localhost.crt; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 location / { } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 location /proxy_ssl/ { |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 proxy_pass https://127.0.0.1:8081/; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 EOF |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 $t->write_file('openssl.conf', <<EOF); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 [ req ] |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 default_bits = 2048 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 encrypt_key = no |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 distinguished_name = req_distinguished_name |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 [ req_distinguished_name ] |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 EOF |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 my $d = $t->testdir(); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 foreach my $name ('localhost') { |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 system('openssl req -x509 -new ' |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 . "-config '$d/openssl.conf' -subj '/CN=$name/' " |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 . "-out '$d/$name.crt' -keyout '$d/$name.key' " |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 . ">>$d/openssl.out 2>&1") == 0 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 or die "Can't create certificate for $name: $!\n"; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $t->write_file('index.html', ''); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 $t->run(); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 ############################################################################### |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 # request body with an empty DATA frame proxied to ssl backend |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 # "zero size buf in output" alerts seen |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 TODO: { |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 local $TODO = 'not yet'; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 my $sess = new_session(); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 my $sid = new_stream($sess, { path => '/proxy_ssl/', body_more => 1 }); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 h2_body($sess, ''); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 my $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 is($frame->{headers}->{':status'}, 200, 'empty request body'); |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 } |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
af2cd0ba6ca7
Tests: fixed HTTP/2 test for empty request body proxied with https.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 ############################################################################### |