Bio-CIPRES
view release on metacpan or search on metacpan
lib/Bio/CIPRES.pm view on Meta::CPAN
$self->{agent} = LWP::UserAgent->new(
agent => __PACKAGE__ . "/$VERSION",
ssl_opts => {verify_hostname => 0},
timeout => $self->{cfg}->{timeout},
);
# create URI object for easier protocol/port parsing
$self->{uri} = URI->new( $self->{cfg}->{url} );
my $netloc = join ':', $self->{uri}->host, $self->{uri}->port;
$self->{agent}->credentials(
$netloc,
$DOMAIN,
$self->{cfg}->{user},
$self->{cfg}->{pass}
);
my %headers = ( 'cipres-appkey' => $self->{cfg}->{app_id} );
$self->{account} = uri_escape( $self->{cfg}->{user} );
lib/Bio/CIPRES.pm view on Meta::CPAN
Takes a single argument (string containing the job handle/ID) and returns a
L<Bio::CIPRES::Job> object representing the appropriate job, or undef if not
found.
=back
=head1 TESTING
The distribution can be installed and tested in the usual ways. Note however,
that running the full test suite requires CIPRES REST credentials (not shipped
with package for obvious reasons). If a credentials file is found at
"$ENV{HOME}/.cipres", the full test suite will be run -- otherwise only
rudimentary tests will be run and most will be skipped.
=head1 CAVEATS AND BUGS
This is code is in alpha testing stage and the API is not guaranteed to be
stable.
Currently the use of UMBRELLA authentication is not implemented.
t/90-cipres.t view on Meta::CPAN
use Test::More;
use Net::Ping;
use List::Util qw/first/;
use LWP::Simple;
use Bio::CIPRES;
use Bio::CIPRES::Error qw/:constants/;
# The first SKIP block contains limited tests which can be run without valid
# credentials. Mostly this checks that the server connection can be initiated
# and that the expected Error objects are returned on failure;
SKIP: {
my $p = Net::Ping->new();
# Check for necessary network connections and skip otherwise
skip "CIPRES server not reachable", 7 if (! $p->ping($Bio::CIPRES::SERVER));
skip "CIPRES httpd not reachable", 7
if (! is_success(getprint("https://$Bio::CIPRES::SERVER")));
# direct config with bogus credentials
my $ua = Bio::CIPRES->new(
user => 'foo',
pass => 'bar',
app_id => 'baz',
);
isa_ok( $ua, 'Bio::CIPRES' );
ok( $ua->{cfg}->{user} eq 'foo' );
# config from file with bogus credentials
$ua = Bio::CIPRES->new(
conf => 't/test_data/cipres.conf',
);
isa_ok( $ua, 'Bio::CIPRES' );
ok( $ua->{cfg}->{user} eq 'bar' );
# job submission should fail with authentication error
eval { $ua->submit_job() };
ok( $@, "submit_job threw expected exception" );
t/90-cipres.t view on Meta::CPAN
cmp_ok( $@, '==', ERR_AUTHENTICATION, "exception == ERR_AUTHENTICATION");
}
# The second SKIP block contains more substantial tests that will run in a
# real config file is found. These will usually only be run on the developer's
# system.
SKIP: {
# Skip the rest if no user credentials found
skip "No valid credentials available", 21
if ( ! -r "$ENV{HOME}/.cipres"
&& (! defined $ENV{CIPRES_USER} || ! defined $ENV{CIPRES_PASS}) );
# additional tests for Bio::CIPRES::Error
eval { Bio::CIPRES::Error->new() };
ok($@ =~ /Undefined XML string in constructor/, "new Error missing XML" );
eval { Bio::CIPRES::Error->new('foo') };
ok($@ =~ /Start tag expected/, "new Error invalid XML" );
# Good (testing) credentials
my $ua = -r "$ENV{HOME}/.cipres"
? Bio::CIPRES->new(
conf => "$ENV{HOME}/.cipres",
)
: Bio::CIPRES->new(
user => $ENV{CIPRES_USER},
pass => $ENV{CIPRES_PASS},
);
isa_ok( $ua, 'Bio::CIPRES' );
( run in 0.284 second using v1.01-cache-2.11-cpan-a5abf4f5562 )