File Coverage

blib/lib/cPanel/APIClient/Authn/Password.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package cPanel::APIClient::Authn::Password;
2              
3             # Copyright 2020 cPanel, L. L. C.
4             # All rights reserved.
5             # http://cpanel.net
6             #
7             # This is free software; you can redistribute it and/or modify it under the
8             # same terms as Perl itself. See L.
9              
10 1     1   68 use strict;
  1         3  
  1         65  
11 1     1   7 use warnings;
  1         2  
  1         32  
12              
13 1     1   5 use parent 'cPanel::APIClient::Authn';
  1         2  
  1         5  
14              
15             sub new {
16 1     1 0 4 my ( $class, $username, $password ) = @_;
17              
18 1         13 return bless [ $username, $password ], $class;
19             }
20              
21             sub get_http_headers_for_service {
22 1     1 0 3 my ( $self, $service_obj ) = @_;
23              
24 1         464 require MIME::Base64;
25              
26 1         1021 my $b64 = MIME::Base64::encode( $self->[0] . ":" . $self->[1] );
27 1         5 $b64 =~ tr<\x0d\x0a><>d;
28              
29 1         7 return [ Authorization => "Basic $b64" ];
30             }
31              
32             1;