lib/Langertha/Skeid/UsageStore.pm

filter: Statementstmt 97.8% 90 / 92 Branchbran 81.4% 70 / 86 Conditioncond 68.6% 83 / 121 MC/DCmcdc 40.9% 25 / 61 Subroutinesub 100% 11 / 11 Podpod 100% 5 / 5 totaltotal 75.5% 284 / 376 CC 92 SCAR 38.9
CC
92
Cov
81%
normalize_config
83.1
for_config
28.5
purge_request
17.2
CRAP 48.9
« bin/skeid ↑ Summary blib/lib/Langertha/Skeid/KeyBroker/OpenBao.pm »
1 package Langertha::Skeid::UsageStore;
2 129 our $VERSION = '0.005';
3 # ABSTRACT: Usage event sink - config normalization and backend factory
4 129 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 129 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 129 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 181 ▶sub normalize_config {
Subroutine normalize_config: called CC=50 SCAR=44.2
Pod documented
10 181 my ($class, $cfg, %opts) = @_;
11 181 ▶ $cfg ||= {};
Condition50%1/2
$cfg ||= {}
l!l
1810
MC/DC0%0/1
$cfg ||= {}
$cfg
Truth table50%1/2
A
A= $cfg
Aresult
11
00
12 181 ▶ croak 'usage_store must be a hashref' unless ref($cfg) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cfg eq "HASH" 0 181 181
13  
14 181 ▶ my $backend = lc($cfg->{backend} // '');
Condition100%2/2
$cfg->{"backend"} // ""
l!l
16516
MC/DC100%1/1
$cfg->{"backend"} // ""
$cfg->{"backend"}
Truth table100%2/2
A
A= $cfg->{"backend"}
Aresult
11
00
15 181 ▶ $backend = 'sqlite' if !$backend && (defined($cfg->{sqlite_path}) || defined($cfg->{path}) || defined($cfg->{db_path}));
Branch: 1 branch
BranchTrueFalseTotal
if not $backend and defined $cfg->{"sqlite_path"} || defined $cfg->{"path"} || defined $cfg->{"db_path"} 14 167 181
Condition77%7/9
not $backend and defined $cfg->{"sqlite_path"} || defined $cfg->{"path"} || defined $cfg->{"db_path"}
!ll&&!rl&&r
165214
defined $cfg->{"sqlite_path"} or defined $cfg->{"path"} or defined $cfg->{"db_path"}
l!l&&r!l&&!r
1402
defined $cfg->{"sqlite_path"} or defined $cfg->{"path"}
l!l&&r!l&&!r
1402
MC/DC50%2/4
not $backend and defined $cfg->{"sqlite_path"} || defined $cfg->{"path"} || defined $cfg->{"db_path"}
not $backend defined $cfg->{"sqlite_path"} defined $cfg->{"path"} defined $cfg->{"db_path"}
Truth table60%3/5
not(A) and B or C or D
A= not $backendB= defined $cfg->{"sqlite_path"}C= defined $cfg->{"path"}D= defined $cfg->{"db_path"}
ABCDresult
0XXX0
10000
11XX1
101X1
10011
16 181 ▶ $backend = 'postgresql' if !$backend && defined($cfg->{dsn}) && $cfg->{dsn} =~ /^dbi:Pg:/i;
Branch: 1 branch
BranchTrueFalseTotal
if not $backend and defined $cfg->{"dsn"} and $cfg->{"dsn"} =~ /^dbi:Pg:/i 2 179 181
Condition66%4/6
not $backend and defined $cfg->{"dsn"} and $cfg->{"dsn"} =~ /^dbi:Pg:/i
!ll&&!rl&&r
17902
not $backend and defined $cfg->{"dsn"}
!ll&&!rl&&r
17902
MC/DC33%1/3
not $backend and defined $cfg->{"dsn"} and $cfg->{"dsn"} =~ /^dbi:Pg:/i
not $backend defined $cfg->{"dsn"} $cfg->{"dsn"} =~ /^dbi:Pg:/i
Truth table50%2/4
not(A) and B and C
A= not $backendB= defined $cfg->{"dsn"}C= $cfg->{"dsn"} =~ /^dbi:Pg:/i
ABCresult
0XX0
10X0
1100
1111
17 181 ▶ $backend = 'jsonlog' if !$backend && defined($cfg->{log_path});
Branch: 1 branch
BranchTrueFalseTotal
if not $backend and defined $cfg->{"log_path"} 0 181 181
Condition33%1/3
not $backend and defined $cfg->{"log_path"}
!ll&&!rl&&r
18100
MC/DC0%0/2
not $backend and defined $cfg->{"log_path"}
not $backend defined $cfg->{"log_path"}
Truth table33%1/3
not(A) and B
A= not $backendB= defined $cfg->{"log_path"}
ABresult
0X0
100
111
18 181 ▶ $backend = 'sqlite' unless length $backend;
Branch: 1 branch
BranchTrueFalseTotal
unless length $backend 0 181 181
19 181 ▶ $backend = 'postgresql' if $backend =~ /^postgres/;
Branch: 1 branch
BranchTrueFalseTotal
if $backend =~ /^postgres/ 76 105 181
20 181 ▶ $backend = 'jsonlog' if $backend =~ /^json/;
Branch: 1 branch
BranchTrueFalseTotal
if $backend =~ /^json/ 60 121 181
21  
22 181 ▶ if ($backend eq 'sqlite') {
Branch: 1 branch
BranchTrueFalseTotal
if ($backend eq "sqlite") 45 136 181
23 45 ▶ my $path = $cfg->{sqlite_path} // $cfg->{path} // $cfg->{db_path} // $opts{default_sqlite_path};
Condition44%4/9
(($cfg->{"sqlite_path"} // $cfg->{"path"}) // $cfg->{"db_path"}) // $opts{"default_sqlite_path"}
l!l&&r!l&&!r
4500
($cfg->{"sqlite_path"} // $cfg->{"path"}) // $cfg->{"db_path"}
l!l&&r!l&&!r
4500
$cfg->{"sqlite_path"} // $cfg->{"path"}
l!l&&r!l&&!r
4320
MC/DC0%0/4
(($cfg->{"sqlite_path"} // $cfg->{"path"}) // $cfg->{"db_path"}) // $opts{"default_sqlite_path"}
$cfg->{"sqlite_path"} $cfg->{"path"} $cfg->{"db_path"} $opts{"default_sqlite_path"}
Truth table40%2/5
A // B // C // D
A= $cfg->{"sqlite_path"}B= $cfg->{"path"}C= $cfg->{"db_path"}D= $opts{"default_sqlite_path"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
24 45 ▶ if (!defined($path) || !length($path)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $path and length $path) 0 45 45
Condition33%1/3
defined $path and length $path
!ll&&!rl&&r
0045
MC/DC0%0/2
defined $path and length $path
defined $path length $path
Truth table33%1/3
A and B
A= defined $pathB= length $path
ABresult
0X0
100
111
25 0 croak 'usage_store.sqlite_path (or path/db_path) is required for sqlite backend';
26 }
27 return {
28 backend => 'sqlite',
29 path => $path,
30 dsn => "dbi:SQLite:dbname=$path",
31 user => '',
32 password => '',
33 schema_file => ($cfg->{schema_file} // ''),
34 45 ▶ auto_migrate => exists($cfg->{auto_migrate}) ? ($cfg->{auto_migrate} ? 1 : 0) : 1,
Branch: 2 branches
BranchTrueFalseTotal
exists $cfg->{'auto_migrate'} ? : 2 43 45
$cfg->{'auto_migrate'} ? : 2 0 2
Condition100%2/2
$cfg->{"schema_file"} // ""
l!l
243
MC/DC100%1/1
$cfg->{"schema_file"} // ""
$cfg->{"schema_file"}
Truth table100%2/2
A
A= $cfg->{"schema_file"}
Aresult
11
00
35 flush_interval_ms => $class->_flush_interval_ms($cfg),
36 spool_dir => $class->_spool_dir($cfg),
37 $class->_retention($cfg),
38 };
39 }
40  
41 136 ▶ if ($backend eq 'postgresql') {
Branch: 1 branch
BranchTrueFalseTotal
if ($backend eq "postgresql") 76 60 136
42 76 my $dsn = $cfg->{dsn};
43 76 ▶ if (!defined($dsn) || !length($dsn)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $dsn and length $dsn) 4 72 76
Condition66%2/3
defined $dsn and length $dsn
!ll&&!rl&&r
4072
MC/DC50%1/2
defined $dsn and length $dsn
defined $dsn length $dsn
Truth table66%2/3
A and B
A= defined $dsnB= length $dsn
ABresult
0X0
100
111
44 4 ▶ my $host = $cfg->{host} // '127.0.0.1';
Condition50%1/2
$cfg->{"host"} // "127.0.0.1"
l!l
40
MC/DC0%0/1
$cfg->{"host"} // "127.0.0.1"
$cfg->{"host"}
Truth table50%1/2
A
A= $cfg->{"host"}
Aresult
11
00
45 4 ▶ my $port = $cfg->{port} // 5432;
Condition100%2/2
$cfg->{"port"} // 5432
l!l
22
MC/DC100%1/1
$cfg->{"port"} // 5432
$cfg->{"port"}
Truth table100%2/2
A
A= $cfg->{"port"}
Aresult
11
00
46 4 ▶ my $name = $cfg->{dbname} // $cfg->{database} // 'skeid';
Condition40%2/5
($cfg->{"dbname"} // $cfg->{"database"}) // "skeid"
l!l
40
$cfg->{"dbname"} // $cfg->{"database"}
l!l&&r!l&&!r
400
MC/DC0%0/2
($cfg->{"dbname"} // $cfg->{"database"}) // "skeid"
$cfg->{"dbname"} $cfg->{"database"}
Truth table33%1/3
A // B
A= $cfg->{"dbname"}B= $cfg->{"database"}
ABresult
1X1
011
000
47 4 $dsn = "dbi:Pg:dbname=$name;host=$host;port=$port";
48 }
49 76 ▶ my $password = defined($cfg->{password}) ? $cfg->{password} : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $cfg->{'password'} ? : 2 74 76
50 76 ▶ if (!length($password) && defined($cfg->{password_env}) && length($cfg->{password_env})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not length $password and defined $cfg->{"password_env"} and length $cfg->{"password_env"}) 3 73 76
Condition83%5/6
not length $password and defined $cfg->{"password_env"} and length $cfg->{"password_env"}
!ll&&!rl&&r
7303
not length $password and defined $cfg->{"password_env"}
!ll&&!rl&&r
2713
MC/DC66%2/3
not length $password and defined $cfg->{"password_env"} and length $cfg->{"password_env"}
not length $password defined $cfg->{"password_env"} length $cfg->{"password_env"}
Truth table75%3/4
not(A) and B and C
A= not length $passwordB= defined $cfg->{"password_env"}C= length $cfg->{"password_env"}
ABCresult
0XX0
10X0
1100
1111
51 3 ▶ $password = $ENV{$cfg->{password_env}} // '';
Condition100%2/2
$ENV{$cfg->{"password_env"}} // ""
l!l
21
MC/DC100%1/1
$ENV{$cfg->{"password_env"}} // ""
$ENV{$cfg->{"password_env"}}
Truth table100%2/2
A
A= $ENV{$cfg->{"password_env"}}
Aresult
11
00
52 }
53 return {
54 backend => 'postgresql',
55 path => '',
56 dsn => $dsn,
57 user => ($cfg->{user} // ''),
58 password => $password,
59 schema_file => ($cfg->{schema_file} // ''),
60 76 ▶ auto_migrate => exists($cfg->{auto_migrate}) ? ($cfg->{auto_migrate} ? 1 : 0) : 1,
Branch: 2 branches
BranchTrueFalseTotal
exists $cfg->{'auto_migrate'} ? : 0 76 76
$cfg->{'auto_migrate'} ? : 0 0 0
Condition75%3/4
$cfg->{"user"} // ""
l!l
2056
$cfg->{"schema_file"} // ""
l!l
076
MC/DC100%1/1
$cfg->{"user"} // ""
$cfg->{"user"}
MC/DC0%0/1
$cfg->{"schema_file"} // ""
$cfg->{"schema_file"}
Truth table100%2/2
A
A= $cfg->{"user"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"schema_file"}
Aresult
11
00
61 flush_interval_ms => $class->_flush_interval_ms($cfg),
62 spool_dir => $class->_spool_dir($cfg),
63 $class->_retention($cfg),
64 };
65 }
66  
67 60 ▶ if ($backend eq 'jsonlog') {
Branch: 1 branch
BranchTrueFalseTotal
if ($backend eq "jsonlog") 60 0 60
68 60 ▶ my $path = $cfg->{log_path} // $cfg->{path} // '';
Condition60%3/5
($cfg->{"log_path"} // $cfg->{"path"}) // ""
l!l
600
$cfg->{"log_path"} // $cfg->{"path"}
l!l&&r!l&&!r
25350
MC/DC0%0/2
($cfg->{"log_path"} // $cfg->{"path"}) // ""
$cfg->{"log_path"} $cfg->{"path"}
Truth table66%2/3
A // B
A= $cfg->{"log_path"}B= $cfg->{"path"}
ABresult
1X1
011
000
69 60 ▶ croak 'usage_store.log_path (or path) is required for jsonlog backend' unless length $path;
Branch: 1 branch
BranchTrueFalseTotal
unless length $path 0 60 60
70 60 ▶ my $mode = $cfg->{mode} // '';
Condition100%2/2
$cfg->{"mode"} // ""
l!l
3525
MC/DC100%1/1
$cfg->{"mode"} // ""
$cfg->{"mode"}
Truth table100%2/2
A
A= $cfg->{"mode"}
Aresult
11
00
71 60 ▶ if (!length($mode)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $mode) 25 35 60
72 25 ▶ $mode = (-d $path || $path =~ m{/$}) ? 'dir' : 'file';
Branch: 1 branch
BranchTrueFalseTotal
-d $path || $path =~ m[/$] ? : 19 6 25
Condition100%3/3
-d $path or $path =~ m[/$]
l!l&&r!l&&!r
1726
MC/DC100%2/2
-d $path or $path =~ m[/$]
-d $path $path =~ m[/$]
Truth table100%3/3
A or B
A= -d $pathB= $path =~ m[/$]
ABresult
1X1
011
000
73 }
74 return {
75 backend => 'jsonlog',
76 path => $path,
77 mode => $mode,
78 60 ▶ fsync => ($cfg->{fsync} ? 1 : 0),
Branch: 1 branch
BranchTrueFalseTotal
$cfg->{'fsync'} ? : 1 59 60
79 $class->_retention($cfg),
80 };
81 }
82  
83 0 croak "unsupported usage_store backend '$backend'";
84 }
85  
86 # Write-behind for the DBI backends (skeid k78). 0 -- the default -- is the synchronous write
87 # every deployment had before; anything else widens the loss window, so it has to be asked for
88 # with a number that means what it says.
89 121 ▶sub _flush_interval_ms {
Subroutine _flush_interval_ms: called CC=3 SCAR=11.0
90 121 my ($class, $cfg) = @_;
91 121 ▶ my $ms = $cfg->{flush_interval_ms} // 0;
Condition100%2/2
$cfg->{"flush_interval_ms"} // 0
l!l
12109
MC/DC100%1/1
$cfg->{"flush_interval_ms"} // 0
$cfg->{"flush_interval_ms"}
Truth table100%2/2
A
A= $cfg->{"flush_interval_ms"}
Aresult
11
00
92 121 ▶ croak 'usage_store.flush_interval_ms must be a whole number of milliseconds (0 = write each event at once)'
Branch: 1 branch
BranchTrueFalseTotal
unless $ms =~ /\A\d+\z/ 3 118 121
93 unless $ms =~ /\A\d+\z/;
94 118 return 0 + $ms;
95 }
96  
97 # How long usage events are kept (skeid k122): whole days, or absent for "until deleted". Read by
98 # `skeid usage-purge --retention`, never on the request path.
99 177 ▶sub _retention {
Subroutine _retention: called CC=5 SCAR=16.1
100 177 my ($class, $cfg) = @_;
101 177 my $days = $cfg->{retention_days};
102 177 ▶ return () unless defined $days;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $days 162 15 177
103 15 ▶ croak 'usage_store.retention_days must be a whole number of days, at least 1'
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $days and $days =~ /\A[0-9]+\z/ and $days >= 1 2 13 15
Condition83%5/6
not ref $days and $days =~ /\A[0-9]+\z/ and $days >= 1
!ll&&!rl&&r
1113
not ref $days and $days =~ /\A[0-9]+\z/
!ll&&!rl&&r
0114
MC/DC66%2/3
not ref $days and $days =~ /\A[0-9]+\z/ and $days >= 1
not ref $days $days =~ /\A[0-9]+\z/ $days >= 1
Truth table75%3/4
not(A) and B and C
A= not ref $daysB= $days =~ /\A[0-9]+\z/C= $days >= 1
ABCresult
0XX0
10X0
1100
1111
104 unless !ref($days) && $days =~ /\A[0-9]+\z/ && $days >= 1;
105 13 return (retention_days => 0 + $days);
106 }
107  
108  
109 30 ▶sub purge_request {
Subroutine purge_request: called CC=17 SCAR=28.5
Pod documented
110 30 my ($class, $args) = @_;
111 30 ▶ return (undef, 'a purge needs arguments') unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 30 30
112 30 my ($ids, $before);
113 30 ▶ if (defined $args->{api_key_ids}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{"api_key_ids"}) 21 9 30
114 21 my $list = $args->{api_key_ids};
115 return (undef, 'api_key_ids must be a non-empty list of key ids')
116 unless ref($list) eq 'ARRAY' && @$list
117 21 ▶ && !grep { !defined($_) || ref($_) || !length($_) || length($_) > 256 } @$list;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $list eq "ARRAY" and @$list and not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list) 3 18 21
Condition80%12/15
ref $list eq "ARRAY" and @$list and not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
!ll&&!rl&&r
2118
ref $list eq "ARRAY" and @$list
!ll&&!rl&&r
1119
!defined($_) || ref $_ || !length($_) || length $_ > 256
l!l&&r!l&&!r
1027
not defined $_ or ref $_ or not length $_
l!l&&r!l&&!r
1027
not defined $_ or ref $_
l!l&&r!l&&!r
1027
MC/DC100%3/3
ref $list eq "ARRAY" and @$list and not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
ref $list eq "ARRAY" @$list not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
MC/DC25%1/4
!defined($_) || ref $_ || !length($_) || length $_ > 256
not defined $_ ref $_ not length $_ length $_ > 256
Truth table100%4/4
A and B and not(C)
A= ref $list eq "ARRAY"B= @$listC= not grep({not defined $_ or ref $_ or not length $_ or length $_ > 256;} @$list)
ABCresult
0XX0
10X0
1100
1111
Truth table40%2/5
not(A) or B or not(C) || D
A= not defined $_B= ref $_C= not length $_D= length $_ > 256
ABCDresult
1XXX1
01XX1
001X1
00011
00000
118 18 my %seen;
119 18 $ids = [ grep { !$seen{$_}++ } map { "$_" } @$list ];
120 }
121 27 ▶ if (defined $args->{before}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{"before"}) 6 21 27
122 6 $before = $args->{before};
123 6 ▶ return (undef, 'before must be an ISO 8601 UTC timestamp (YYYY-MM-DDTHH:MM:SSZ)')
Branch: 1 branch
BranchTrueFalseTotal
if ref $before or not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/ 2 4 6
Condition66%2/3
ref $before or not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
l!l&&r!l&&!r
024
MC/DC50%1/2
ref $before or not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
ref $before not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
Truth table66%2/3
A or not(B)
A= ref $beforeB= not $before =~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/
ABresult
1X1
011
000
124 if ref($before) || $before !~ /\A\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\z/;
125 }
126 25 ▶ return (undef, 'a purge needs api_key_ids, before, or both') unless $ids || defined $before;
Branch: 1 branch
BranchTrueFalseTotal
unless $ids or defined $before 3 22 25
Condition100%3/3
$ids or defined $before
l!l&&r!l&&!r
1843
MC/DC100%2/2
$ids or defined $before
$ids defined $before
Truth table100%3/3
A or B
A= $idsB= defined $before
ABresult
1X1
011
000
127 return ({
128 ($ids ? (api_key_ids => $ids) : ()),
129 (defined($before) ? (before => "$before") : ()),
130 22 ▶ dry_run => ($args->{dry_run} ? 1 : 0),
Branch: 3 branches
BranchTrueFalseTotal
$ids ? : 18 4 22
defined $before ? : 4 18 22
$args->{'dry_run'} ? : 6 16 22
131 });
132 }
133  
134 # The usage spool of the DBI backends (skeid k110, ADR 0027). Empty -- the default -- keeps the
135 # behavior from before: what the database cannot take is reported lost.
136 118 ▶sub _spool_dir {
Subroutine _spool_dir: called CC=3 SCAR=11.0
137 118 my ($class, $cfg) = @_;
138 118 ▶ my $dir = $cfg->{spool_dir} // '';
Condition100%2/2
$cfg->{"spool_dir"} // ""
l!l
6112
MC/DC100%1/1
$cfg->{"spool_dir"} // ""
$cfg->{"spool_dir"}
Truth table100%2/2
A
A= $cfg->{"spool_dir"}
Aresult
11
00
139 118 ▶ croak 'usage_store.spool_dir must be a directory path' if ref $dir;
Branch: 1 branch
BranchTrueFalseTotal
if ref $dir 1 117 118
140 117 return "$dir";
141 }
142  
143  
144 88 ▶sub for_config {
Subroutine for_config: called CC=17 SCAR=33.5
Pod documented
145 88 my ($class, $cfg) = @_;
146 88 ▶ return unless ref($cfg) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cfg eq "HASH" 0 88 88
147 88 ▶ my $backend = $cfg->{backend} // '';
Condition50%1/2
$cfg->{"backend"} // ""
l!l
880
MC/DC0%0/1
$cfg->{"backend"} // ""
$cfg->{"backend"}
Truth table50%1/2
A
A= $cfg->{"backend"}
Aresult
11
00
148 88 ▶ return unless length $backend;
Branch: 1 branch
BranchTrueFalseTotal
unless length $backend 0 88 88
149  
150 88 ▶ if ($backend eq 'jsonlog') {
Branch: 1 branch
BranchTrueFalseTotal
if ($backend eq "jsonlog") 49 39 88
151 49 require Langertha::Skeid::UsageStore::JsonLog;
152 return Langertha::Skeid::UsageStore::JsonLog->new(
153 path => ($cfg->{path} // ''),
154 mode => ($cfg->{mode} // 'dir'),
155 49 ▶ fsync => ($cfg->{fsync} ? 1 : 0),
Branch: 1 branch
BranchTrueFalseTotal
$cfg->{'fsync'} ? : 1 48 49
Condition50%2/4
$cfg->{"path"} // ""
l!l
490
$cfg->{"mode"} // "dir"
l!l
490
MC/DC0%0/1
$cfg->{"path"} // ""
$cfg->{"path"}
MC/DC0%0/1
$cfg->{"mode"} // "dir"
$cfg->{"mode"}
Truth table50%1/2
A
A= $cfg->{"path"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"mode"}
Aresult
11
00
156 );
157 }
158  
159 39 require Langertha::Skeid::UsageStore::DBI;
160 return Langertha::Skeid::UsageStore::DBI->new(
161 backend => $backend,
162 dsn => ($cfg->{dsn} // ''),
163 user => ($cfg->{user} // ''),
164 password => ($cfg->{password} // ''),
165 path => ($cfg->{path} // ''),
166 schema_file => ($cfg->{schema_file} // ''),
167 auto_migrate => (exists($cfg->{auto_migrate}) ? ($cfg->{auto_migrate} ? 1 : 0) : 1),
168 flush_interval_ms => ($cfg->{flush_interval_ms} // 0),
169 39 ▶ spool_dir => ($cfg->{spool_dir} // q{}),
Branch: 2 branches
BranchTrueFalseTotal
exists $cfg->{'auto_migrate'} ? : 39 0 39
$cfg->{'auto_migrate'} ? : 39 0 39
Condition50%7/14
$cfg->{"dsn"} // ""
l!l
390
$cfg->{"user"} // ""
l!l
390
$cfg->{"password"} // ""
l!l
390
$cfg->{"path"} // ""
l!l
390
$cfg->{"schema_file"} // ""
l!l
390
$cfg->{"flush_interval_ms"} // 0
l!l
390
$cfg->{"spool_dir"} // ""
l!l
390
MC/DC0%0/1
$cfg->{"dsn"} // ""
$cfg->{"dsn"}
MC/DC0%0/1
$cfg->{"user"} // ""
$cfg->{"user"}
MC/DC0%0/1
$cfg->{"password"} // ""
$cfg->{"password"}
MC/DC0%0/1
$cfg->{"path"} // ""
$cfg->{"path"}
MC/DC0%0/1
$cfg->{"schema_file"} // ""
$cfg->{"schema_file"}
MC/DC0%0/1
$cfg->{"flush_interval_ms"} // 0
$cfg->{"flush_interval_ms"}
MC/DC0%0/1
$cfg->{"spool_dir"} // ""
$cfg->{"spool_dir"}
Truth table50%1/2
A
A= $cfg->{"dsn"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"user"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"password"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"path"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"schema_file"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"flush_interval_ms"}
Aresult
11
00
Truth table50%1/2
A
A= $cfg->{"spool_dir"}
Aresult
11
00
170 );
171 }
172  
173  
174 4819 ▶sub num {
Subroutine num: called CC=2 SCAR=6.9
Pod documented
175 4819 my ($v) = @_;
176 4819 ▶ return 0 unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 1000 3819 4819
177 3819 return 0 + $v;
178 }
179  
180  
181 173 ▶sub read_text_file {
Subroutine read_text_file: called CC=2 SCAR=7.0
Pod documented
182 173 my ($path) = @_;
183 173 ▶ open my $fh, '<', $path or die "Cannot open $path: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $path or die "Cannot open ${path}: $!" 173 0 173
184 173 local $/;
185 173 my $text = <$fh>;
186 173 close $fh;
187 173 return $text;
188 }
189  
190  
191 129 1;
192  
193 __END__
« bin/skeid ↑ Summary blib/lib/Langertha/Skeid/KeyBroker/OpenBao.pm »