| 1 | package InfluxDB::Writer::AuthHeaderRole; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Helper role | ||||||||||||||||||||||||||||
| 4 | 4 | our $VERSION = '1.003'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use MIME::Base64 qw/encode_base64/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Log::Any qw($log); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | has 'influx_username' => ( is => 'ro', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||
| 11 | 4 | has 'influx_password' => ( is => 'ro', isa => 'Str', required => 0 ); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | has '_with_auth' => ( is => 'rw', isa => 'Bool', lazy => 1, default => sub { return shift->_auth_header ? 1 : 0 } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 4 | has '_auth_header' => ( is => 'ro', isa => 'Str', lazy_build => 1, builder => '_build__auth_header', required => 1 ); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub _build__auth_header { | ||||||||||||||||||||||||||
|
Subroutine
_build__auth_header: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if ( $self->influx_username && $self->influx_password ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->influx_username and $self->influx_password
MC/DC0%0/2
$self->influx_username and $self->influx_password
$self->influx_username
$self->influx_password
Truth table0%0/3
A and B
A= $self->influx_usernameB= $self->influx_password
| |||||||||||||||||||||||||||||
| 20 | 0 | my $base64 = encode_base64( | |||||||||||||||||||||||||||
| 21 | join( ":", $self->influx_username, $self->influx_password ) ); | ||||||||||||||||||||||||||||
| 22 | 0 | chomp($base64); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | return "Basic $base64"; | |||||||||||||||||||||||||||
| 25 | } else { | ||||||||||||||||||||||||||||
| 26 | 0 | return ""; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | 1; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | __END__ | ||||||||||||||||||||||||||||