# HG changeset patch # User Sergey Kandaurov # Date 1466763742 -10800 # Node ID 508ee7ea97065ecfad040b2f96f88bcaa405c9a5 # Parent 0a87d9bcfb26a18cf4047e5f37aa4b0738ef5a25 Tests: avoid unexpected substring match in proxy_protocol_port.t. The client's ephemeral port number could be a string superset of the $proxy_protocol_port variable testing value. diff --git a/proxy_protocol_port.t b/proxy_protocol_port.t --- a/proxy_protocol_port.t +++ b/proxy_protocol_port.t @@ -68,22 +68,22 @@ EOF ############################################################################### -my $tcp4 = 'PROXY TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; -my $tcp6 = 'PROXY TCP6 2001:Db8::1 2001:Db8::2 1234 5678' . CRLF; +my $tcp4 = 'PROXY TCP4 192.0.2.1 192.0.2.2 12345 5678' . CRLF; +my $tcp6 = 'PROXY TCP6 2001:Db8::1 2001:Db8::2 12345 5678' . CRLF; my $unk = 'PROXY UNKNOWN 1 2 3 4 5 6' . CRLF; # realip -like(pp_get('/pp', $tcp4), qr/X-PP-Port: 1234/, 'pp port tcp4'); -like(pp_get('/pp', $tcp6), qr/X-PP-Port: 1234/, 'pp port tcp6'); +like(pp_get('/pp', $tcp4), qr/X-PP-Port: 12345/, 'pp port tcp4'); +like(pp_get('/pp', $tcp6), qr/X-PP-Port: 12345/, 'pp port tcp6'); unlike(pp_get('/pp', $unk), qr/X-PP-Port/, 'pp port unknown'); # remote_port -like(pp_get('/pp/real', $tcp4), qr/X-Remote-Port: 1234/, 'remote port tcp4'); -unlike(pp_get('/pp', $tcp4), qr/X-Remote-Port: 1234/, 'no remote port tcp4'); -like(pp_get('/pp/real', $tcp6), qr/X-Remote-Port: 1234/, 'remote port tcp6'); -unlike(pp_get('/pp', $tcp6), qr/X-Remote-Port: 1234/, 'no remote port tcp6'); +like(pp_get('/pp/real', $tcp4), qr/X-Remote-Port: 12345/, 'remote port tcp4'); +unlike(pp_get('/pp', $tcp4), qr/X-Remote-Port: 12345/, 'no remote port tcp4'); +like(pp_get('/pp/real', $tcp6), qr/X-Remote-Port: 12345/, 'remote port tcp6'); +unlike(pp_get('/pp', $tcp6), qr/X-Remote-Port: 12345/, 'no remote port tcp6'); # log @@ -94,7 +94,7 @@ pp_get('/log', $tcp4); my $log = $t->read_file('/port.log'); chomp $log; -is($log, 1234, 'pp port log'); +is($log, 12345, 'pp port log'); ###############################################################################