comparison h2_proxy_protocol.t @ 1899:a0ee073760c5

Tests: updated HTTP/2 tests with invalid PROXY protocol. Connection close is now expected prior to sending any HTTP/2 frames from the upper layer, similar to existing behaviour over HTTPS.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 31 May 2023 13:29:31 +0400
parents 882267679006
children 236d038dc04a
comparison
equal deleted inserted replaced
1898:26252394dd58 1899:a0ee073760c5
23 ############################################################################### 23 ###############################################################################
24 24
25 select STDERR; $| = 1; 25 select STDERR; $| = 1;
26 select STDOUT; $| = 1; 26 select STDOUT; $| = 1;
27 27
28 my $t = Test::Nginx->new()->has(qw/http http_v2 realip/)->plan(4) 28 my $t = Test::Nginx->new()->has(qw/http http_v2 realip/)->plan(3)
29 ->write_file_expand('nginx.conf', <<'EOF'); 29 ->write_file_expand('nginx.conf', <<'EOF');
30 30
31 %%TEST_GLOBALS%% 31 %%TEST_GLOBALS%%
32 32
33 daemon off; 33 daemon off;
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 TODO: {
73 local $TODO = 'not yet' unless $t->has_version('1.25.1');
74
72 $proxy = 'BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; 75 $proxy = 'BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF;
73 $s = Test::Nginx::HTTP2->new(port(8080), preface => $proxy, pure => 1); 76 ok(!http($proxy), 'PROXY invalid protocol');
74 $frames = $s->read(all => [{ type => 'GOAWAY' }]);
75 77
76 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; 78 }
77 ok($frame, 'invalid PROXY - GOAWAY frame');
78 is($frame->{code}, 1, 'invalid PROXY - error code');
79 79
80 ############################################################################### 80 ###############################################################################