Hetula-Client
view release on metacpan or search on metacpan
t/01-usage.t view on Meta::CPAN
#!/usr/bin/env perl
use Modern::Perl '2015';
#use feature qw(signatures);
#no warnings qw(experimental::signatures);
use FindBin;
use lib "$FindBin::Bin/../lib";
use Test::Most tests => 15;
use Mojolicious;
use File::Slurp;
use File::Temp;
use Hetula::Client;
#$ENV{HETULA_DEBUG} = 1;
#$ENV{MOJO_INSECURE} = 1;
$ENV{MOJO_LOG_LEVEL} = 'info';
## Get credentials to use. Alternatively one can temporarily test with real credentials this predesigned test suite.
my $realCredentials = 0;
my $credentialsFile = "$FindBin::Bin/credentials";
my @credentials = File::Slurp::read_file($credentialsFile, chomp => 1);
my $username = $credentials[0];
my $password = $credentials[1];
my $organization = $credentials[2];
my $baseURL = $credentials[3];
if ($realCredentials) { #test with real credentials here
$username = '';
$password = '';
$organization = '';
$baseURL = '';
}
## Credentials dealt with.
my $hc = Hetula::Client->new({baseURL => $baseURL});
mockServer($hc) unless $realCredentials;
my $resp = $hc->login({username => 'master', password => 'blaster', organization => $organization});
ok($resp->{error}, "Login failed - Using bad credentials, got error '$resp->{error}'");
$resp = $hc->login({username => $username, password => $password, organization => $organization});
ok(! $resp->{error}, "Login success");
$resp = $hc->loginActive();
ok(! $resp->{error}, "Login active");
$resp = $hc->ssnAdd({ssn => 'bad-ssn'});
ok($resp->{error}, "SSN add failed - Bad SSN '$resp->{error}'");
$resp = $hc->ssnGet({id => 1});
ok(! $resp->{error}, "SSN got");
( run in 1.860 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )