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         9  
3 1     1   381 use Types::Standard qw/Str/;
  1         2  
  1         17  
4             with 'Docker::Registry::Auth';
5              
6 1     1   1428 use MIME::Base64 qw/encode_base64/;
  1         808  
  1         192  
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 2458 my ($self, $request) = @_;
13              
14 3         25 my $auth_header = "Basic " . encode_base64(sprintf("%s:%s", $self->username, $self->password), '');
15 3         16 $request->header('Authorization', $auth_header);
16              
17 3         99 return $request;
18             }
19              
20             1;