Plagger/Plugin/UserAgent/AuthenRequest.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 32 CC 1 SCAR 6.9
CC
1
Cov
0%
register
2.0
add_credentials
2.0
BEGIN
2.0
CRAP 2.0
1 package Plagger::Plugin::UserAgent::AuthenRequest;
2 use strict;
3 use warnings;
4 use base qw/Plagger::Plugin/;
5  
6 use List::Util qw/first/;
7  
8 sub register {
9 my($self, $context) = @_;
10 $context->register_hook(
11 $self,
12 'useragent.init' => \&add_credentials,
13 );
14 }
15  
16 sub add_credentials {
17 my($self, $context, $args) = @_;
18  
19 my $creds = $self->conf->{credentials} || [ $self->conf ];
20  
21 for my $auth (@$creds) {
22 $context->log(info => "Adding credential to $auth->{realm} at $auth->{host}");
23 $args->{ua}->credentials($auth->{host}, $auth->{realm}, $auth->{username}, $auth->{password});
24 }
25 }
26  
27 1;
28  
29 __END__