# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1681702262 -10800
# Mon Apr 17 06:31:02 2023 +0300
# Node ID 90913cb36b512c45cd9a171cbb4320b12ff24b48
# Parent 0103d7cd7b5c46af63642dbb02481563662fb3d9
Tests: simplified stream SSL tests with IO::Socket::SSL.
The stream SSL tests which previously used IO::Socket::SSL were converted
to use infrastructure in Test::Nginx::Stream where appropriate.
diff --git a/stream_ssl_alpn.t b/stream_ssl_alpn.t
--- a/stream_ssl_alpn.t
+++ b/stream_ssl_alpn.t
@@ -100,25 +100,12 @@ like($t->read_file('test.log'), qr/500$/
sub get_ssl {
my (@alpn) = @_;
- my $s = stream('127.0.0.1:' . port(8080));
- eval {
- local $SIG{ALRM} = sub { die "timeout\n" };
- local $SIG{PIPE} = sub { die "sigpipe\n" };
- alarm(8);
- IO::Socket::SSL->start_SSL($s->{_socket},
- SSL_alpn_protocols => [ @alpn ],
- SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
- SSL_error_trap => sub { die $_[1] }
- );
- alarm(0);
- };
- alarm(0);
-
- if ($@) {
- log_in("died: $@");
- return undef;
- }
+ my $s = stream(
+ PeerAddr => '127.0.0.1:' . port(8080),
+ SSL => 1,
+ SSL_alpn_protocols => [ @alpn ]
+ );
return $s->read();
}
diff --git a/stream_ssl_preread.t b/stream_ssl_preread.t
--- a/stream_ssl_preread.t
+++ b/stream_ssl_preread.t
@@ -142,7 +142,7 @@ is(get_ssl('bar', 8081), $p2, 'sni 2 aga
is(get_ssl('', 8081), $p3, 'no sni');
is(get_ssl('foo', 8082), $p3, 'preread off');
-is(get_ssl('foo', 8083), undef, 'preread buffer full');
+is(get_ssl('foo', 8083), '', 'preread buffer full');
is(stream('127.0.0.1:' . port(8080))->io('x' x 1000), "127.0.0.1:$p3",
'not a handshake');
@@ -202,25 +202,12 @@ sub get_oldver {
sub get_ssl {
my ($host, $port) = @_;
- my $s = stream('127.0.0.1:' . port($port));
- eval {
- local $SIG{ALRM} = sub { die "timeout\n" };
- local $SIG{PIPE} = sub { die "sigpipe\n" };
- alarm(8);
- IO::Socket::SSL->start_SSL($s->{_socket},
- SSL_hostname => $host,
- SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
- SSL_error_trap => sub { die $_[1] }
- );
- alarm(0);
- };
- alarm(0);
-
- if ($@) {
- log_in("died: $@");
- return undef;
- }
+ my $s = stream(
+ PeerAddr => '127.0.0.1:' . port($port),
+ SSL => 1,
+ SSL_hostname => $host
+ );
return $s->read();
}
diff --git a/stream_ssl_preread_alpn.t b/stream_ssl_preread_alpn.t
--- a/stream_ssl_preread_alpn.t
+++ b/stream_ssl_preread_alpn.t
@@ -114,25 +114,12 @@ get_ssl(8081, '');
sub get_ssl {
my ($port, @alpn) = @_;
- my $s = stream('127.0.0.1:' . port($port));
- eval {
- local $SIG{ALRM} = sub { die "timeout\n" };
- local $SIG{PIPE} = sub { die "sigpipe\n" };
- alarm(8);
- IO::Socket::SSL->start_SSL($s->{_socket},
- SSL_alpn_protocols => [ @alpn ],
- SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
- SSL_error_trap => sub { die $_[1] }
- );
- alarm(0);
- };
- alarm(0);
-
- if ($@) {
- log_in("died: $@");
- return undef;
- }
+ my $s = stream(
+ PeerAddr => '127.0.0.1:' . port($port),
+ SSL => 1,
+ SSL_alpn_protocols => [ @alpn ]
+ );
return $s->read();
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel