Catalyst-Authentication-Credential-OpenID
view release on metacpan or search on metacpan
t/live-app.t view on Meta::CPAN
use strict;
use warnings;
use FindBin;
use IO::Socket;
use Test::More;
eval <<_DEPS_;
use Test::WWW::Mechanize;
use Catalyst::Runtime;
use Catalyst::Devel;
use Cache::FastMmap;
use Catalyst::Authentication::User::Hash;
use Catalyst::Plugin::Session::State::Cookie;
use Catalyst::Plugin::Session::Store::FastMmap;
use Class::Accessor::Fast;
use Crypt::DH;
use ExtUtils::MakeMaker;
use HTML::Parser 3;
use LWP::UserAgent;
use Net::OpenID::Consumer;
use Net::OpenID::Server;
use Test::WWW::Mechanize;
use Net::DNS;
use IO::Socket::INET;
_DEPS_
if ( $@ )
{
plan skip_all => 'Test application dependencies not satisfied ' . $@;
}
elsif ( not $ENV{TEST_HTTP} )
{
plan skip_all => 'Set TEST_HTTP to enable this test';
}
else
{
plan tests => 21;
}
# One port for consumer app, one for provider.
my $consumer_port = 10000 + int rand(1 + 10000);
my $provider_port = $consumer_port;
$provider_port = 10000 + int rand(1 + 10000) until $consumer_port != $provider_port;
my $provider_pipe = "perl -I$FindBin::Bin/../lib -I$FindBin::Bin/Provider/lib $FindBin::Bin/Provider/script/testapp_server.pl -p $consumer_port |";
my $consumer_pipe = "perl -I$FindBin::Bin/../lib -I$FindBin::Bin/Consumer/lib $FindBin::Bin/Consumer/script/testapp_server.pl -p $provider_port |";
my $provider_pid = open my $provider, $provider_pipe
or die "Unable to spawn standalone HTTP server for Provider: $!";
diag("Started Provider with pid $provider_pid");
my $consumer_pid = open my $consumer, $consumer_pipe
or die "Unable to spawn standalone HTTP server for Consumer: $!";
diag("Started Consumer with pid $consumer_pid");
# How long to wait for test server to start and timeout for UA.
my $seconds = 15;
diag("Waiting (up to $seconds seconds) for application servers to start...");
eval {
local $SIG{ALRM} = sub { die "Servers took too long to start\n" }; # NB: \n required
alarm($seconds);
sleep 1 while check_port( 'localhost', $provider_port ) != 1;
sleep 1 while check_port( 'localhost', $consumer_port ) != 1;
alarm(0)
};
if ( $@ )
{
( run in 1.231 second using v1.01-cache-2.11-cpan-39bf76dae61 )