File Coverage

blib/lib/Test/PlugAuth.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Test::PlugAuth;
2              
3 1     1   1536 use strict;
  1         3  
  1         30  
4 1     1   4 use warnings;
  1         2  
  1         21  
5 1     1   10 use v5.10;
  1         3  
  1         36  
6 1     1   35 use PlugAuth::Lite;
  0            
  0            
7             use Mojo::UserAgent;
8              
9             # ABSTRACT: minimum PlugAuth server to test Clustericious apps against
10             our $VERSION = '0.07'; # VERSION
11              
12              
13             sub new
14             {
15             my $class = shift;
16             my $config = ref $_[0] ? $_[0] : {@_};
17             my $self = bless {}, $class;
18            
19             $self->{app} = PlugAuth::Lite->new($config);
20             $self->{ua} = Mojo::UserAgent->new;
21             eval { $self->ua->server->app($self->app) } // $self->ua->app($self->app);
22            
23             $self->{url} = eval { $self->ua->server->url->to_string } // $self->ua->app_url->to_string;
24             $self->{url} =~ s{/$}{};
25            
26             return $self;
27             }
28              
29              
30             sub ua { shift->{ua} }
31              
32              
33             sub app { shift->{app} }
34              
35              
36             sub url { shift->{url} }
37              
38              
39             sub apply_to_client_app
40             {
41             my($self, $client_app) = @_;
42             $client_app->helper(auth_ua => sub { $self->ua });
43             return;
44             }
45              
46             1;
47              
48             __END__