comparison 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
comparison
equal deleted inserted replaced
885:a1e76cca714c 886:af2cd0ba6ca7
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Tests for HTTP/2 protocol with proxy to ssl backend.
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 use Test::Nginx::HTTP2 qw/ :DEFAULT :frame /;
20
21 ###############################################################################
22
23 select STDERR; $| = 1;
24 select STDOUT; $| = 1;
25
26 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy/)
27 ->has_daemon('openssl')->plan(1);
28
29 $t->todo_alerts();
30
31 $t->write_file_expand('nginx.conf', <<'EOF');
32
33 %%TEST_GLOBALS%%
34
35 daemon off;
36
37 events {
38 }
39
40 http {
41 %%TEST_GLOBALS_HTTP%%
42
43 server {
44 listen 127.0.0.1:8080 http2;
45 listen 127.0.0.1:8081 ssl;
46 server_name localhost;
47
48 ssl_certificate_key localhost.key;
49 ssl_certificate localhost.crt;
50
51 location / { }
52 location /proxy_ssl/ {
53 proxy_pass https://127.0.0.1:8081/;
54 }
55 }
56 }
57
58 EOF
59
60 $t->write_file('openssl.conf', <<EOF);
61 [ req ]
62 default_bits = 2048
63 encrypt_key = no
64 distinguished_name = req_distinguished_name
65 [ req_distinguished_name ]
66 EOF
67
68 my $d = $t->testdir();
69
70 foreach my $name ('localhost') {
71 system('openssl req -x509 -new '
72 . "-config '$d/openssl.conf' -subj '/CN=$name/' "
73 . "-out '$d/$name.crt' -keyout '$d/$name.key' "
74 . ">>$d/openssl.out 2>&1") == 0
75 or die "Can't create certificate for $name: $!\n";
76 }
77
78 $t->write_file('index.html', '');
79 $t->run();
80
81 ###############################################################################
82
83 # request body with an empty DATA frame proxied to ssl backend
84 # "zero size buf in output" alerts seen
85
86 TODO: {
87 local $TODO = 'not yet';
88
89 my $sess = new_session();
90 my $sid = new_stream($sess, { path => '/proxy_ssl/', body_more => 1 });
91 h2_body($sess, '');
92 my $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
93
94 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
95 is($frame->{headers}->{':status'}, 200, 'empty request body');
96
97 }
98
99 ###############################################################################