Skip to content

Commit

Permalink
more proxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 16, 2014
1 parent 7a1ce18 commit 4eadb95
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions t/mojo/websocket_proxy_tls.t
Expand Up @@ -146,7 +146,11 @@ $id = Mojo::IOLoop->server(
$stream->on(read => sub { shift->close });
}
);
my $fake = Mojo::IOLoop->acceptor($id)->handle->sockport;
my $close = Mojo::IOLoop->acceptor($id)->handle->sockport;

# Fake server to test idle connection
$id = Mojo::IOLoop->server(sub { });
my $idle = Mojo::IOLoop->acceptor($id)->handle->sockport;

# User agent with valid certificates
my $ua = Mojo::UserAgent->new(
Expand Down Expand Up @@ -290,8 +294,13 @@ 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';
$tx = $ua->get("https://localhost:$close");
is $err->{message}, 'Proxy connection failed', 'right error';

# Idle connection through proxy
$tx = $ua->connect_timeout(0.5)->get("https://localhost:$idle");
is $err->{message}, 'Proxy connection failed', 'right error';
$ua->connect_timeout(10);

# Blocking proxy request again
$tx = $ua->get("https://localhost:$port/proxy");
Expand Down

0 comments on commit 4eadb95

Please sign in to comment.