changeset 1896:8b74936ff2ac

Tests: added has_feature() test for CryptX.
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 29 May 2023 17:04:36 +0400
parents acd68670b064
children 38f1fd9ca3e6
files h3_absolute_redirect.t h3_headers.t h3_keepalive.t h3_limit_conn.t h3_limit_req.t h3_proxy.t h3_proxy_max_temp_file_size.t h3_reusable.t h3_server_name.t h3_server_tokens.t h3_ssl_reject_handshake.t h3_ssl_session_reuse.t h3_trailers.t lib/Test/Nginx.pm quic_migration.t
diffstat 15 files changed, 21 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/h3_absolute_redirect.t
+++ b/h3_absolute_redirect.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 proxy rewrite/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 proxy rewrite cryptx/)
 	->has_daemon('openssl')->plan(23);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/h3_headers.t
+++ b/h3_headers.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 proxy rewrite/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 proxy rewrite cryptx/)
 	->has_daemon('openssl')->plan(68)
 	->write_file_expand('nginx.conf', <<'EOF');
 
--- a/h3_keepalive.t
+++ b/h3_keepalive.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/)
 	->has_daemon('openssl')->plan(15)
 	->write_file_expand('nginx.conf', <<'EOF');
 
--- a/h3_limit_conn.t
+++ b/h3_limit_conn.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 limit_conn proxy/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 limit_conn proxy cryptx/)
 	->has_daemon('openssl')->plan(2);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/h3_limit_req.t
+++ b/h3_limit_req.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 proxy limit_req/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 proxy limit_req cryptx/)
 	->has_daemon('openssl')->plan(6);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/h3_proxy.t
+++ b/h3_proxy.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 proxy/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 proxy cryptx/)
 	->has_daemon('openssl')->plan(3)
 	->write_file_expand('nginx.conf', <<'EOF');
 
--- a/h3_proxy_max_temp_file_size.t
+++ b/h3_proxy_max_temp_file_size.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 proxy/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 proxy cryptx/)
 	->has_daemon('openssl')->plan(4);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/h3_reusable.t
+++ b/h3_reusable.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/)
 	->has_daemon('openssl')->plan(1)
 	->write_file_expand('nginx.conf', <<'EOF');
 
--- a/h3_server_name.t
+++ b/h3_server_name.t
@@ -24,11 +24,8 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
 my $t = Test::Nginx->new()
-	->has(qw/http http_ssl http_v2 http_v3 rewrite socket_ssl_alpn/)
+	->has(qw/http http_ssl http_v2 http_v3 rewrite socket_ssl_alpn cryptx/)
 	->has_daemon('openssl')->plan(6);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/h3_server_tokens.t
+++ b/h3_server_tokens.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3 rewrite/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 rewrite cryptx/)
 	->has_daemon('openssl')->plan(12);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/h3_ssl_reject_handshake.t
+++ b/h3_ssl_reject_handshake.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/)
 	->has_daemon('openssl')->plan(7)
 	->write_file_expand('nginx.conf', <<'EOF');
 
--- a/h3_ssl_session_reuse.t
+++ b/h3_ssl_session_reuse.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/)
 	->has_daemon('openssl')->plan(8)
 	->write_file_expand('nginx.conf', <<'EOF');
 
--- a/h3_trailers.t
+++ b/h3_trailers.t
@@ -23,10 +23,7 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
-my $t = Test::Nginx->new()->has(qw/http http_v3/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/)
 	->has_daemon('openssl')->plan(8);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
--- a/lib/Test/Nginx.pm
+++ b/lib/Test/Nginx.pm
@@ -288,6 +288,13 @@ sub has_feature($) {
 		return 1;
 	}
 
+	if ($feature eq 'cryptx') {
+		eval { require Crypt::Misc; };
+		return 0 if $@;
+		eval { die if $Crypt::Misc::VERSION < 0.067; };
+		return !$@;
+	}
+
 	return 0;
 }
 
--- a/quic_migration.t
+++ b/quic_migration.t
@@ -23,13 +23,10 @@ use Test::Nginx::HTTP3;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
-plan(skip_all => 'CryptX version >= 0.067 required') if $@;
-
 plan(skip_all => '127.0.0.20 local address required')
 	unless defined IO::Socket::INET->new( LocalAddr => '127.0.0.20' );
 
-my $t = Test::Nginx->new()->has(qw/http http_v3/)
+my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/)
 	->has_daemon('openssl')->plan(2);
 
 $t->write_file_expand('nginx.conf', <<'EOF');