CatalystX/OAuth2/Controller/Role/Provider.pm

filter: Statementstmt 100% 27 / 27 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 86.9% 40 / 46 SCAR 16.1
CC
5
Cov
92%
check_provider_actions
3.7
__ANON__
3.0
BEGIN
1.0
CRAP 5.0
« Catalyst/ActionRole/OAuth2/ProtectedResource.pm ↑ Summary CatalystX/OAuth2/ClientPersistor.pm »
1 package CatalystX::OAuth2::Controller::Role::Provider;
2 9 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use MooseX::SetOnce;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use Moose::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use Class::Load;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: A role for writing oauth2 provider controllers
8  
9 9 with 'CatalystX::OAuth2::Controller::Role::WithStore';
10  
11 has $_ => (
12 isa => 'Catalyst::Action',
13 is => 'rw',
14 traits => [qw(SetOnce)],
15 predicate => "_has_$_"
16 9 ) for qw(_request_auth_action _get_auth_token_via_auth_grant_action);
17  
18 around create_action => sub {
19 325 ▶ my $orig = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
20 325 my $self = shift;
21 325 my $action = $self->$orig(@_);
22 325 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (Moose::Util::does_role($action, 'Catalyst::ActionRole::OAuth2::RequestAuth')) { } 32 293 325
elsif (Moose::Util::does_role($action, 'Catalyst::ActionRole::OAuth2::GrantAuth')) { } 32 261 293
23 Moose::Util::does_role(
24 $action, 'Catalyst::ActionRole::OAuth2::RequestAuth'
25 )
26 )
27 {
28 32 $self->_request_auth_action($action);
29 } elsif (
30 Moose::Util::does_role(
31 $action, 'Catalyst::ActionRole::OAuth2::GrantAuth'
32 )
33 )
34 {
35 32 $self->_get_auth_token_via_auth_grant_action($action);
36 }
37  
38 325 return $action;
39 9 };
40  
41 sub check_provider_actions {
42 33 ▶ my ($self) = @_;
Subroutine check_provider_actions: called CC=3 SCAR=13.1
Pod undocumented
43 33 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_has__request_auth_action and $self->_has__get_auth_token_via_auth_grant_action 0 33 33
Condition33%1/3
$self->_has__request_auth_action and $self->_has__get_auth_token_via_auth_grant_action
!ll&&!rl&&r
0033
MC/DC0%0/2
$self->_has__request_auth_action and $self->_has__get_auth_token_via_auth_grant_action
$self->_has__request_auth_action $self->_has__get_auth_token_via_auth_grant_action
Truth table33%1/3
A and B
A= $self->_has__request_auth_actionB= $self->_has__get_auth_token_via_auth_grant_action
ABresult
0X0
100
111
44 q{You need at least an auth action and a grant action for this controller to work}
45 unless $self->_has__request_auth_action
46 && $self->_has__get_auth_token_via_auth_grant_action;
47 }
48  
49 after register_actions => sub {
50 33 ▶ shift->check_provider_actions;
Subroutine __ANON__: called CC=1 SCAR=0.0
51 9 };
52  
53 9 1;
54  
55 __END__
56  
57 =pod
58  
59 =head1 NAME
60  
61 CatalystX::OAuth2::Controller::Role::Provider - A role for writing oauth2 provider controllers
62  
63 =head1 VERSION
64  
65 version 0.001006
66  
67 =head1 AUTHOR
68  
69 Eden Cardim <edencardim@gmail.com>
70  
71 =head1 COPYRIGHT AND LICENSE
72  
73 This software is copyright (c) 2017 by Suretec Systems Ltd.
74  
75 This is free software; you can redistribute it and/or modify it under
76 the same terms as the Perl 5 programming language system itself.
77  
78 =cut
« Catalyst/ActionRole/OAuth2/ProtectedResource.pm ↑ Summary CatalystX/OAuth2/ClientPersistor.pm »