File Coverage

blib/lib/Docker/Registry/Auth/Basic.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package Docker::Registry::Auth::Basic;
2 1     1   8 use Moo;
  1         3  
  1         7  
3 1     1   377 use Types::Standard qw/Str/;
  1         3  
  1         15  
4             with 'Docker::Registry::Auth';
5              
6 1     1   1102 use MIME::Base64 qw/encode_base64/;
  1         739  
  1         185  
7              
8             has username => (is => 'ro', isa => Str, required => 1);
9             has password => (is => 'ro', isa => Str, required => 1);
10              
11             sub authorize {
12 3     3 0 2237 my ($self, $request) = @_;
13              
14 3         36 my $auth_header = "Basic " . encode_base64(sprintf("%s:%s", $self->username, $self->password), '');
15 3         18 $request->header('Authorization', $auth_header);
16              
17 3         100 return $request;
18             }
19              
20             1;