blib/lib/OpusVL/AppKit/FormFu/Constraint/AppKitPassword.pm

filter: Statementstmt 82.6% 19 / 23 Branchbran 75.0% 6 / 8 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 68.0% 34 / 50 CC 8 SCAR 21.4
CC
8
Cov
72%
constrain_value
10.4
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« blib/lib/OpusVL/AppKit/Controller/Root.pm ↑ Summary blib/lib/OpusVL/AppKit/RolesFor/Controller/GUI.pm »
1 package OpusVL::AppKit::FormFu::Constraint::AppKitPassword;
2  
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base 'HTML::FormFu::Constraint';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8  
9 sub constrain_value
10 {
11 12 ▶ my $self = shift;
Subroutine constrain_value: called CC=8 SCAR=23.4
Pod documented
12 12 my ($value, $params) = @_;
13 12 my $c = $self->form->stash->{context};
14 12 ▶ return 1 unless $value;
Branch: 1 branch
BranchTrueFalseTotal
unless $value 1 11 12
15 11 my $password = $value;
16  
17 my ($pass_min_length, $pass_numerics, $pass_symbols) = (
18 $c->config->{AppKit}->{password_min_characters},
19 $c->config->{AppKit}->{password_force_numerics},
20 $c->config->{AppKit}->{password_force_symbols},
21 11 );
22  
23 11 ▶ if ($pass_min_length && length($password) < $pass_min_length) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass_min_length and length $password < $pass_min_length) 1 10 11
Condition66%2/3
$pass_min_length and length $password < $pass_min_length
!ll&&!rl&&r
0101
MC/DC50%1/2
$pass_min_length and length $password < $pass_min_length
$pass_min_length length $password < $pass_min_length
Truth table66%2/3
A and B
A= $pass_min_lengthB= length $password < $pass_min_length
ABresult
0X0
100
111
24 1 $self->{message} = "Minimum length for password is ${pass_min_length} characters";
25 1 return 0;
26 }
27  
28 10 ▶ if ($pass_numerics && $password !~ /[0-9]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass_numerics and not $password =~ /[0-9]/) 0 10 10
Condition33%1/3
$pass_numerics and not $password =~ /[0-9]/
!ll&&!rl&&r
1000
MC/DC0%0/2
$pass_numerics and not $password =~ /[0-9]/
$pass_numerics not $password =~ /[0-9]/
Truth table33%1/3
A and not(B)
A= $pass_numericsB= not $password =~ /[0-9]/
ABresult
0X0
100
111
29 0 $self->{message} = "Expecting a numeric character in password. None found";
30 0 return 0;
31 }
32  
33 10 ▶ if ($pass_symbols && $password !~ /\W/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass_symbols and not $password =~ /\W/) 0 10 10
Condition33%1/3
$pass_symbols and not $password =~ /\W/
!ll&&!rl&&r
1000
MC/DC0%0/2
$pass_symbols and not $password =~ /\W/
$pass_symbols not $password =~ /\W/
Truth table33%1/3
A and not(B)
A= $pass_symbolsB= not $password =~ /\W/
ABresult
0X0
100
111
34 0 $self->{message} = "Expecting a symbol character in password. None found";
35 0 return 0;
36 }
37  
38 10 return 1;
39 }
40  
41 ##
42 3 1;
43  
44 __END__
45  
46 =pod
47  
48 =encoding UTF-8
49  
50 =head1 NAME
51  
52 OpusVL::AppKit::FormFu::Constraint::AppKitPassword
53  
54 =head1 VERSION
55  
56 version 2.22
57  
58 =head1 DESCRIPTION
59  
60 Ensures that passwords are validated against the preferences set in the Catalyst config
61  
62 =head1 NAME
63  
64 OpusVL::AppKit::FormFu::Constraint::AppKitPassword - constraint to validate passwords.
65  
66 =head1 METHODS
67  
68 =head2 constrain_value
69  
70 This method is used by formfu to hook into this constraints, constraining code.
71  
72 Returns:
73 boolean - 0 = did not validate, 1 = validated
74  
75 =head1 AUTHOR
76  
77 OpusVL - www.opusvl.com
78  
79 =head1 COPYRIGHT AND LICENSE
80  
81 This software is copyright (c) 2010 by OpusVL - www.opusvl.com.
82  
83 This is free software; you can redistribute it and/or modify it under
84 the same terms as the Perl 5 programming language system itself.
85  
86 =cut
« blib/lib/OpusVL/AppKit/Controller/Root.pm ↑ Summary blib/lib/OpusVL/AppKit/RolesFor/Controller/GUI.pm »