[nginx-tests] Tests: improved server tokens tests to accept alte...

Maxim Dounin mdounin at mdounin.ru
Tue Feb 20 17:12:10 UTC 2024


details:   http://freenginx.org/hg/nginx-tests/rev/78452573505c
branches:  
changeset: 1948:78452573505c
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Tue Feb 20 20:10:15 2024 +0300
description:
Tests: improved server tokens tests to accept alternative names.

diffstat:

 h2_server_tokens.t |  8 ++++----
 h3_server_tokens.t |  8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diffs (46 lines):

diff --git a/h2_server_tokens.t b/h2_server_tokens.t
--- a/h2_server_tokens.t
+++ b/h2_server_tokens.t
@@ -96,15 +96,15 @@ open STDERR, ">&", \*OLDERR;
 
 ###############################################################################
 
-my $re = qr/nginx\/\d+\.\d+\.\d+/;
+my $re = qr/\w+\/\d+\.\d+\.\d+/;
 
 like(header_server('/200'), qr/^$re$/, 'http2 tokens default 200');
 like(header_server('/404'), qr/^$re$/, 'http2 tokens default 404');
 like(body('/404'), qr/$re/, 'http2 tokens default 404 body');
 
-is(header_server('/off/200'), 'nginx', 'http2 tokens off 200');
-is(header_server('/off/404'), 'nginx', 'http2 tokens off 404');
-like(body('/off/404'), qr/nginx(?!\/)/, 'http2 tokens off 404 body');
+like(header_server('/off/200'), qr/^\w+$/, 'http2 tokens off 200');
+like(header_server('/off/404'), qr/^\w+$/, 'http2 tokens off 404');
+unlike(body('/off/404'), $re, 'http2 tokens off 404 body');
 
 like(header_server('/on/200'), qr/^$re$/, 'http2 tokens on 200');
 like(header_server('/on/404'), qr/^$re$/, 'http2 tokens on 404');
diff --git a/h3_server_tokens.t b/h3_server_tokens.t
--- a/h3_server_tokens.t
+++ b/h3_server_tokens.t
@@ -115,15 +115,15 @@ foreach my $name ('localhost') {
 
 ###############################################################################
 
-my $re = qr/nginx\/\d+\.\d+\.\d+/;
+my $re = qr/\w+\/\d+\.\d+\.\d+/;
 
 like(header_server('/200'), qr/^$re$/, 'http3 tokens default 200');
 like(header_server('/404'), qr/^$re$/, 'http3 tokens default 404');
 like(body('/404'), qr/$re/, 'http3 tokens default 404 body');
 
-is(header_server('/off/200'), 'nginx', 'http3 tokens off 200');
-is(header_server('/off/404'), 'nginx', 'http3 tokens off 404');
-like(body('/off/404'), qr/nginx(?!\/)/, 'http3 tokens off 404 body');
+like(header_server('/off/200'), qr/^\w+$/, 'http3 tokens off 200');
+like(header_server('/off/404'), qr/^\w+$/, 'http3 tokens off 404');
+unlike(body('/off/404'), $re, 'http3 tokens off 404 body');
 
 like(header_server('/on/200'), qr/^$re$/, 'http3 tokens on 200');
 like(header_server('/on/404'), qr/^$re$/, 'http3 tokens on 404');



More information about the nginx-devel mailing list