blib/lib/Langertha/Knarr/TokenStore.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 4 / 4 totaltotal 100% 40 / 40 CC 4 SCAR 5.9
CC
4
Cov
100%
invalidate
3.0
hash_token
2.0
BEGIN
1.0
CRAP 1.8
« blib/lib/Langertha/Knarr/Handler/Raider.pm ↑ Summary blib/lib/Langertha/Knarr/CLI/Role/GlobalOptions.pm »
1 package Langertha::Knarr::TokenStore;
2 # ABSTRACT: Role for the stores token_auth looks access tokens up in
3 2 our $VERSION = '1.103';
4 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Digest::SHA qw( sha256_hex );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Log::Any qw( $log );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 2 requires qw( lookup_f lookup available );
10  
11 2 has on_invalidate => (
12 is => 'rw',
13 isa => 'Maybe[CodeRef]',
14 );
15  
16 1 ▶sub start { }
Subroutine start: called CC=1 SCAR=0.0
Pod documented
17  
18 1 ▶sub poll { }
Subroutine poll: called CC=1 SCAR=0.0
Pod documented
19  
20 5 ▶sub invalidate {
Subroutine invalidate: called CC=3 SCAR=11.0
Pod documented
21 5 my ($self, $reason) = @_;
22 5 ▶ my $cb = $self->on_invalidate or return;
Branch: 1 branch
BranchTrueFalseTotal
my $cb = $self->on_invalidate or return 4 1 5
23 4 ▶ eval { $cb->($reason); 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &$cb($reason); 1 } } or $Langertha::Knarr::TokenStore::log->errorf("token store: invalidate listener failed: %s", $@) 3 1 4
24 or $log->errorf( 'token store: invalidate listener failed: %s', $@ );
25 4 return;
26 }
27  
28 24 ▶sub hash_token {
Subroutine hash_token: called CC=2 SCAR=6.9
Pod documented
29 24 my ($self, $token) = @_;
30 24 my $bytes = $token;
31 24 ▶ utf8::downgrade( $bytes, 1 ) or utf8::encode($bytes);
Branch: 1 branch
BranchTrueFalseTotal
utf8::downgrade($bytes, 1) or utf8::encode($bytes) 23 1 24
32 24 return lc sha256_hex($bytes);
33 }
34  
35 2 1;
36  
37 __END__
« blib/lib/Langertha/Knarr/Handler/Raider.pm ↑ Summary blib/lib/Langertha/Knarr/CLI/Role/GlobalOptions.pm »