PlugAuth/Plugin/Test.pm

filter: Statementstmt 32.5% 27 / 83 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 23.3% 7 / 30 Podpod 0.0% 0 / 21 totaltotal 24.2% 34 / 140 CC 5 SCAR 11.5
CC
5
Cov
30%
__ANON__
12.0
real_auth
6.0
real_authz
6.0
CRAP 3.1
« PlugAuth/Role/Authz.pm ↑ Summary PlugAuth/Role/Welcome.pm »
1 package PlugAuth::Plugin::Test;
2  
3 # ABSTRACT: Test Plugin server
4 4 our $VERSION = '0.39'; # VERSION
5  
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use PlugAuth::Plugin::FlatAuth;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use PlugAuth::Plugin::FlatAuthz;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Log::Log4perl qw( :easy );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Fcntl qw( :flock );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 with 'PlugAuth::Role::Plugin';
15 4 with 'PlugAuth::Role::Refresh';
16 4 with 'PlugAuth::Role::Auth';
17 4 with 'PlugAuth::Role::Authz';
18  
19 sub init
20 0 ▶{
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
21 0 my($self) = @_;
22 0 ▶ $self->app->routes->route('/test/setup/reset')->post(sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
23
24 0 foreach my $filename (map { $self->global_config->{$_} } qw( group_file resource_file user_file ))
25 {
26 0 open my $fh, '+<', $filename;
27 0 eval { flock $fh, LOCK_EX };
28 0 ▶ WARN "cannot lock $filename - $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
29 0 seek $fh, 0, 0;
30 0 truncate $fh, 0;
31 0 close $fh;
32 0 PlugAuth::Role::Flat->mark_changed($filename);
33 }
34
35 0 $self->real_auth->refresh;
36 0 $self->real_authz->refresh;
37  
38 0 shift->render(text => 'ok');
39 0 });
40 0 ▶ $self->app->routes->route('/test/setup/basic')->post(sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 my $auth = $self->real_auth;
42 0 $auth->create_user('primus', 'spark');
43 0 $auth->create_user('optimus', 'matrix');
44 0 $auth->refresh;
45
46 0 my $authz = $self->real_authz;
47 0 $authz->create_group('admin', 'primus');
48 0 $authz->refresh;
49 0 $authz->grant('admin', 'accounts', '/');
50 0 $authz->grant('primus', 'accounts', '/');
51
52 0 shift->render(text => 'ok');
53 0 });
54 }
55  
56 sub refresh
57 0 ▶{
Subroutine refresh: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my($self) = @_;
59 0 $self->real_auth->refresh;
60 0 $self->real_authz->refresh;
61 0 1;
62 }
63  
64 0 ▶sub check_credentials { shift->real_auth->check_credentials(@_) }
Subroutine check_credentials: not called CC=1 SCAR=6.9
Pod undocumented
65 0 ▶sub create_user { shift->real_auth->create_user(@_) }
Subroutine create_user: not called CC=1 SCAR=6.9
Pod undocumented
66 0 ▶sub change_password { shift->real_auth->change_password(@_) }
Subroutine change_password: not called CC=1 SCAR=6.9
Pod undocumented
67 0 ▶sub delete_user { shift->real_auth->delete_user(@_) }
Subroutine delete_user: not called CC=1 SCAR=6.9
Pod undocumented
68 sub all_users { shift->real_auth->all_users }
69 0 ▶sub can_user_action_resource { shift->real_authz->can_user_action_resource(@_) }
Subroutine can_user_action_resource: not called CC=1 SCAR=6.9
Pod undocumented
70  
71 0 ▶sub match_resources { shift->real_authz->match_resources(@_) }
Subroutine match_resources: not called CC=1 SCAR=6.9
Pod undocumented
72 0 ▶sub host_has_tag { shift->real_authz->host_has_tag(@_) }
Subroutine host_has_tag: not called CC=1 SCAR=6.9
Pod undocumented
73 0 ▶sub actions { shift->real_authz->actions(@_) }
Subroutine actions: not called CC=1 SCAR=6.9
Pod undocumented
74 0 ▶sub groups_for_user { shift->real_authz->groups_for_user(@_) }
Subroutine groups_for_user: not called CC=1 SCAR=6.9
Pod undocumented
75 0 ▶sub all_groups { shift->real_authz->all_groups(@_) }
Subroutine all_groups: not called CC=1 SCAR=6.9
Pod undocumented
76 0 ▶sub users_in_group { shift->real_authz->users_in_group(@_) }
Subroutine users_in_group: not called CC=1 SCAR=6.9
Pod undocumented
77  
78 0 ▶sub create_group { shift->real_authz->create_group(@_) }
Subroutine create_group: not called CC=1 SCAR=6.9
Pod undocumented
79 0 ▶sub delete_group { shift->real_authz->delete_group(@_) }
Subroutine delete_group: not called CC=1 SCAR=6.9
Pod undocumented
80 0 ▶sub grant { shift->real_authz->grant(@_) }
Subroutine grant: not called CC=1 SCAR=6.9
Pod undocumented
81 0 ▶sub revoke { shift->real_authz->revoke(@_) }
Subroutine revoke: not called CC=1 SCAR=6.9
Pod undocumented
82 0 ▶sub granted { shift->real_authz->granted(@_) }
Subroutine granted: not called CC=1 SCAR=6.9
Pod undocumented
83 0 ▶sub update_group { shift->real_authz->update_group(@_) }
Subroutine update_group: not called CC=1 SCAR=6.9
Pod undocumented
84  
85 sub real_auth
86 0 ▶{
Subroutine real_auth: not called CC=2 SCAR=17.9
Pod undocumented
87 0 my($self) = @_;
88
89 0 ▶ unless($self->{real_auth})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"real_auth"}) 0 0 0
90 {
91 0 my $auth = $self->{real_auth} = new PlugAuth::Plugin::FlatAuth(
92 Clustericious::Config->new({}),
93 Clustericious::Config->new({}),
94 $self->app
95 );
96 }
97
98 0 return $self->{real_auth};
99 }
100  
101 sub real_authz
102 0 ▶{
Subroutine real_authz: not called CC=2 SCAR=17.9
Pod undocumented
103 0 my($self) = @_;
104
105 0 ▶ unless($self->{real_authz})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"real_authz"}) 0 0 0
106 {
107 0 my $auth = $self->real_auth;
108 0 my $authz = $self->{real_authz} = new PlugAuth::Plugin::FlatAuthz(
109 Clustericious::Config->new({}),
110 Clustericious::Config->new({}),
111 $self->app
112 );
113 }
114
115 0 return $self->{real_authz};
116 }
117  
118 4 1;
119  
120 __END__
« PlugAuth/Role/Authz.pm ↑ Summary PlugAuth/Role/Welcome.pm »