Skip to content

Commit

Permalink
test failed TLS handshake through proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 8, 2014
1 parent 5c958f2 commit 922e957
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion t/mojo/websocket_proxy_tls.t
Expand Up @@ -139,6 +139,15 @@ my $id = Mojo::IOLoop->server(
);
my $proxy = Mojo::IOLoop->acceptor($id)->handle->sockport;

# Fake server to test failed TLS handshake
$id = Mojo::IOLoop->server(
sub {
my ($loop, $stream) = @_;
$stream->on(read => sub { shift->close });
}
);
my $fake = Mojo::IOLoop->acceptor($id)->handle->sockport;

# User agent with valid certificates
my $ua = Mojo::UserAgent->new(
ioloop => Mojo::IOLoop->singleton,
Expand Down Expand Up @@ -280,8 +289,11 @@ Mojo::IOLoop->start;
ok !$success, 'no success';
is $err->{message}, 'Proxy connection failed', 'right error';

# Failed TLS handshake through proxy
$tx = $ua->get("https://localhost:$fake");
ok $tx->res->error, 'has error';

# Blocking proxy request again
$ua->proxy->https("http://localhost:$proxy");
$tx = $ua->get("https://localhost:$port/proxy");
is $tx->res->code, 200, 'right status';
is $tx->res->body, "https://localhost:$port/proxy", 'right content';
Expand Down

0 comments on commit 922e957

Please sign in to comment.