changeset 1898:26252394dd58

Tests: updated HTTP/2 tests with invalid connection preface. HTTP/1.x 400 is now expected instead of HTTP/2 GOAWAY due to HTTP/2 auto-detection fallback to HTTP/1.x.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 30 May 2023 05:35:40 +0400
parents 38f1fd9ca3e6
children a0ee073760c5
files h2.t
diffstat 1 files changed, 7 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/h2.t
+++ b/h2.t
@@ -26,7 +26,7 @@ select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite charset gzip/)
-	->plan(144);
+	->plan(142);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -1017,20 +1017,14 @@ is($frame->{headers}->{':status'}, 200, 
 
 # invalid connection preface
 
-$s = Test::Nginx::HTTP2->new(port(8080), preface => 'x' x 16, pure => 1);
-$frames = $s->read(all => [{ type => 'GOAWAY' }]);
-
-($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
-ok($frame, 'invalid preface - GOAWAY frame');
-is($frame->{code}, 1, 'invalid preface - error code');
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.25.1');
 
-my $preface = 'PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8;
-$s = Test::Nginx::HTTP2->new(port(8080), preface => $preface, pure => 1);
-$frames = $s->read(all => [{ type => 'GOAWAY' }]);
+like(http('x' x 16), qr/400 Bad Request/, 'invalid preface');
+like(http('PRI * HTTP/2.0' . CRLF . CRLF . 'x' x 8), qr/400 Bad Request/,
+	'invalid preface 2');
 
-($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
-ok($frame, 'invalid preface 2 - GOAWAY frame');
-is($frame->{code}, 1, 'invalid preface 2 - error code');
+}
 
 # GOAWAY on SYN_STREAM with even StreamID