Skip to content
Browse files

Resolve localhost in tests

  • Loading branch information...
1 parent ef3d37a commit 669e431250b97e65f75d47b53bc2b8f4df549fd0 @und3f committed May 2, 2012
Showing with 13 additions and 7 deletions.
  1. +8 −4 t/basic.t
  2. +5 −3 t/client-auth.t
View
12 t/basic.t
@@ -8,7 +8,9 @@ use Test::TCP;
use Plack::Loader;
use LWP::UserAgent;
use FindBin '$Bin';
+use Socket;
+my $host = "localhost";
my $ca_cert = "$Bin/ca.pem";
my $server_pem = "$Bin/server.pem";
@@ -25,16 +27,16 @@ subtest 'tls connection' => sub {
my $ua =
LWP::UserAgent->new(
ssl_opts => {verify_hostname => 1, SSL_ca_file => $ca_cert});
- my $res = $ua->get("https://localhost:$port");
+ my $res = $ua->get("https://$host:$port");
$success = $res->is_success or die $res->status_line;
$content = $res->decoded_content;
},
server => sub {
my $port = shift;
my $server = Plack::Loader->load(
'Twiggy::TLS',
+ host => inet_ntoa(inet_aton($host)),
port => $port,
- host => '127.0.0.1',
tls_key => $server_pem,
tls_cert => $server_pem,
);
@@ -48,8 +50,10 @@ subtest 'tls connection' => sub {
['Content-Type' => 'text/plain'],
[$env->{"psgi.url_scheme"}]
];
- });
- });
+ }
+ );
+ }
+ );
ok $success, "https connection success";
is $content, "https", "returned content is right";
View
8 t/client-auth.t
@@ -8,7 +8,9 @@ use Test::TCP;
use Plack::Loader;
use LWP::UserAgent;
use FindBin '$Bin';
+use Socket;
+my $host = "localhost";
my $ca_cert = "$Bin/ca.pem";
my $server_pem = "$Bin/server.pem";
my $client_pem = "$Bin/client.pem";
@@ -28,11 +30,11 @@ subtest 'tls connection' => sub {
verify_hostname => 1,
SSL_ca_file => $ca_cert,
- SSL_key_file => $client_pem,
+ SSL_key_file => $client_pem,
SSL_cert_file => $client_pem,
}
);
- my $res = $ua->get("https://localhost:$port");
+ my $res = $ua->get("https://$host:$port");
$success = $res->is_success or die $res->status_line;
$content = $res->decoded_content;
@@ -41,8 +43,8 @@ subtest 'tls connection' => sub {
my $port = shift;
my $server = Plack::Loader->load(
'Twiggy::TLS',
+ host => inet_ntoa(inet_aton($host)),
port => $port,
- host => '127.0.0.1',
tls_key => $server_pem,
tls_cert => $server_pem,
tls_ca => $ca_cert,

0 comments on commit 669e431

Please sign in to comment.
Something went wrong with that request. Please try again.