comparison h2_proxy_protocol.t @ 952:e9064d691790

Tests: converted tests to run in parallel.
author Andrey Zelenkov <zelenkov@nginx.com>
date Tue, 21 Jun 2016 16:39:13 +0300
parents 4dc302d8e04f
children 882267679006
comparison
equal deleted inserted replaced
951:9361c7eddfc1 952:e9064d691790
37 37
38 http { 38 http {
39 %%TEST_GLOBALS_HTTP%% 39 %%TEST_GLOBALS_HTTP%%
40 40
41 server { 41 server {
42 listen 127.0.0.1:8081 proxy_protocol http2; 42 listen 127.0.0.1:%%PORT_0%% proxy_protocol http2;
43 server_name localhost; 43 server_name localhost;
44 44
45 location /pp { 45 location /pp {
46 set_real_ip_from 127.0.0.1/32; 46 set_real_ip_from 127.0.0.1/32;
47 real_ip_header proxy_protocol; 47 real_ip_header proxy_protocol;
57 $t->run(); 57 $t->run();
58 58
59 ############################################################################### 59 ###############################################################################
60 60
61 my $proxy = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; 61 my $proxy = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF;
62 my $s = Test::Nginx::HTTP2->new(8081, proxy => $proxy); 62 my $s = Test::Nginx::HTTP2->new(port(0), proxy => $proxy);
63 my $sid = $s->new_stream({ path => '/pp' }); 63 my $sid = $s->new_stream({ path => '/pp' });
64 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); 64 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
65 65
66 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 66 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
67 ok($frame, 'PROXY HEADERS frame'); 67 ok($frame, 'PROXY HEADERS frame');
68 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr'); 68 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr');
69 69
70 # invalid PROXY protocol string 70 # invalid PROXY protocol string
71 71
72 $proxy = 'BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; 72 $proxy = 'BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF;
73 $s = Test::Nginx::HTTP2->new(8081, preface => $proxy, pure => 1); 73 $s = Test::Nginx::HTTP2->new(port(0), preface => $proxy, pure => 1);
74 $frames = $s->read(all => [{ type => 'GOAWAY' }]); 74 $frames = $s->read(all => [{ type => 'GOAWAY' }]);
75 75
76 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; 76 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
77 ok($frame, 'invalid PROXY - GOAWAY frame'); 77 ok($frame, 'invalid PROXY - GOAWAY frame');
78 is($frame->{code}, 1, 'invalid PROXY - error code'); 78 is($frame->{code}, 1, 'invalid PROXY - error code');