File Coverage

blib/lib/App/PAIA/Command/session.pm
Criterion Covered Total %
statement 21 28 75.0
branch 4 10 40.0
condition n/a
subroutine 5 6 83.3
pod 1 1 100.0
total 31 45 68.8


line stmt bran cond sub pod time code
1             package App::PAIA::Command::session;
2 4     4   1539 use strict;
  4         6  
  4         95  
3 4     4   26 use v5.10;
  4         9  
  4         130  
4 4     4   12 use parent 'App::PAIA::Command';
  4         4  
  4         13  
5              
6 4     4   186 use App::PAIA::JSON;
  4         4  
  4         734  
7              
8             sub description {
9             <
10             This command shows the current PAIA auth session.
11             The exit code indicates whether a session file was found with not-expired
12             access token and PAIA server URLs. Options --verbose|-v enables details.
13             MSG
14 0     0 1 0 }
15              
16             sub _execute {
17 2     2   2 my ($self, $opt, $args) = @_;
18              
19 2 100       10 if (defined $self->session->file ) {
20 1         3 my $data = $self->session->load;
21 1 50       5 say encode_json($data) if $self->app->global_options->verbose;
22 1         23 my $msg = $self->not_authentificated;
23 1 50       3 die "$msg.\n" if $msg;
24 1         6 say "session looks fine.";
25             } else {
26 1         23 die "no session file found.\n";
27             }
28              
29 1 0       18 if (!$self->auth) {
30 0           die "PAIA auth server URL not found\n";
31             } else {
32 0           $self->logger->('auth URL: '.$self->auth);
33             }
34              
35 0 0         if (!$self->core) {
36 0           die "PAIA core server URL not found\n";
37             } else {
38 0           $self->logger->('core URL: '.$self->core);
39             }
40              
41 0           return;
42             }
43              
44             1;
45             __END__