comparison h2_proxy_protocol.t @ 948:4dc302d8e04f

Tests: changed HTTP2 package to act as a class. Stopped exporting any subroutines. A subset of them now act as class methods.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 17 Jun 2016 11:36:33 +0300
parents e3df9c2100de
children e9064d691790
comparison
equal deleted inserted replaced
947:b9e42c554ba7 948:4dc302d8e04f
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 $sess = new_session(8081, proxy => $proxy); 62 my $s = Test::Nginx::HTTP2->new(8081, proxy => $proxy);
63 my $sid = new_stream($sess, { path => '/pp' }); 63 my $sid = $s->new_stream({ path => '/pp' });
64 my $frames = h2_read($sess, 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 $sess = new_session(8081, preface => $proxy, pure => 1); 73 $s = Test::Nginx::HTTP2->new(8081, preface => $proxy, pure => 1);
74 $frames = h2_read($sess, 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');
79 79