BigIP-REST
view release on metacpan or search on metacpan
#!/usr/bin/perl
use strict;
use warnings;
use English qw(-no_match_vars);
use BigIP::REST;
use IO::Socket::SSL;
use Test::More;
use Test::Exception;
plan(skip_all => 'live test, set $ENV{BIGIP_TEST_URL} to a true value to run')
if !$ENV{BIGIP_TEST_URL};
plan(skip_all => 'live test, set $ENV{BIGIP_TEST_USERNAME} to a true value to run')
if !$ENV{BIGIP_TEST_USERNAME};
plan(skip_all => 'live test, set $ENV{BIGIP_TEST_PASSWORD} to a true value to run')
if !$ENV{BIGIP_TEST_PASSWORD};
plan tests => 24;
my $bigip;
lives_ok {
$bigip = BigIP::REST->new(
url => $ENV{BIGIP_TEST_URL},
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => SSL_VERIFY_NONE
}
);
} 'connection succeeds';
isa_ok($bigip, 'BigIP::REST');
lives_ok {
$bigip->create_session(
username => $ENV{BIGIP_TEST_USERNAME},
password => $ENV{BIGIP_TEST_PASSWORD},
);
} 'authentication succeeds';
BAIL_OUT('unable to connect, skipping remaining tests') if $EVAL_ERROR;
ok(
defined $bigip->{agent}->default_header('X-F5-Auth-Token'),
'bigip handle has authentication token'
);
my $result;
# certificates
$result = $bigip->get_certificates();
my $all = $result->{items};
is(ref $all, 'ARRAY', 'full certificates list');
my $cert = $all->[0];
ok(
defined $cert->{name} &&
defined $cert->{issuer} &&
defined $cert->{partition},
"full certificate has all properties"
);
SKIP: {
skip 'no test partition', 3 unless $ENV{BIGIP_TEST_PARTITION};
$result = $bigip->get_certificates(
( run in 1.129 second using v1.01-cache-2.11-cpan-39bf76dae61 )