SASL.pm

filter: Statementstmt 94.0% 63 / 67 Branchbran 70.5% 24 / 34 Conditioncond 50.0% 9 / 18 MC/DCmcdc 36.3% 4 / 11 Subroutinesub 100% 15 / 15 Podpod 60.0% 6 / 10 totaltotal 78.0% 121 / 155 CC 27 SCAR 16.2
CC
27
Cov
81%
server_new
9.2
client_new
7.3
new
7.0
CRAP 5.0
« SASL/Perl/OAUTHBEARER.pm ↑ Summary SASL/Perl/LOGIN.pm »
1 # Copyright (c) 2004-2006 Graham Barr <gbarr@pobox.com>. All rights reserved.
2 # This program is free software; you can redistribute it and/or
3 # modify it under the same terms as Perl itself.
4  
5 package Authen::SASL 2.2100;
6  
7 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use vars qw(@Plugins);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 16 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 16 @Plugins = qw(
14 Authen::SASL::XS
15 Authen::SASL::Perl
16 );
17  
18  
19 18 ▶sub import {
Subroutine import: called CC=5 SCAR=17.0
20 18 shift;
21 18 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 17 18
22  
23 17 local $SIG{__DIE__};
24 17 ▶ @Plugins = grep { /^[:\w]+$/ and eval "require $_" } map { /::/ ? $_ : "Authen::SASL::$_" } @_
Branch: 2 branches
BranchTrueFalseTotal
@Authen::SASL::Plugins = grep({/^[:\w]+$/ and eval "require $_";} map({/::/ ? $_ : "Authen::SASL::$_";} @_)) or croak("no valid Authen::SASL plugins found") 17 0 17
/::/ ? : 0 17 17
Condition33%1/3
/^[:\w]+$/ && eval "require $_"
!ll&&!rl&&r
0017
MC/DC0%0/2
/^[:\w]+$/ && eval "require $_"
/^[:\w]+$/ eval "require $_"
Truth table33%1/3
A && B
A= /^[:\w]+$/B= eval "require $_"
ABresult
0X0
100
111
25 or croak "no valid Authen::SASL plugins found";
26 }
27  
28  
29 53 ▶sub new {
Subroutine new: called CC=7 SCAR=19.5
Pod documented
30 53 my $pkg = shift;
31 53 ▶ my %opt = ((@_ % 2 ? 'mechanism' : ()), @_);
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 ? : 1 52 53
32  
33 my $self = bless {
34 mechanism => $opt{mechanism} || $opt{mech},
35 callback => {},
36 debug => $opt{debug},
37 53 ▶ }, $pkg;
Condition100%3/3
$opt{'mechanism'} || $opt{'mech'}
l!l&&r!l&&!r
5111
MC/DC100%2/2
$opt{'mechanism'} || $opt{'mech'}
$opt{'mechanism'} $opt{'mech'}
Truth table100%3/3
A || B
A= $opt{'mechanism'}B= $opt{'mech'}
ABresult
1X1
011
000
38  
39 53 ▶ $self->callback(%{$opt{callback}}) if ref($opt{callback}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $opt{"callback"} eq "HASH" 49 4 53
40  
41 # Compat
42 53 ▶ $self->callback(user => ($self->{user} = $opt{user})) if exists $opt{user};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{"user"} 0 53 53
43 53 ▶ $self->callback(pass => $opt{password}) if exists $opt{password};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{"password"} 3 50 53
44 53 ▶ $self->callback(pass => $opt{response}) if exists $opt{response};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{"response"} 0 53 53
45  
46 53 $self;
47 }
48  
49  
50 82 ▶sub mechanism {
Subroutine mechanism: called CC=2 SCAR=7.2
Pod documented
51 82 my $self = shift;
52 @_ ? $self->{mechanism} = shift
53 82 ▶ : $self->{mechanism};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 82 82
54 }
55  
56 200 ▶sub callback {
Subroutine callback: called CC=2 SCAR=7.0
Pod documented
57 200 my $self = shift;
58  
59 200 ▶ return $self->{callback}{$_[0]} if @_ == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 0 200 200
60  
61 200 my %new = @_;
62 200 @{$self->{callback}}{keys %new} = values %new;
63  
64 200 $self->{callback};
65 }
66  
67 # The list of packages should not really be hardcoded here
68 # We need some way to discover what plugins are installed
69  
70 36 ▶sub client_new { # $self, $service, $host, $secflags
Subroutine client_new: called CC=6 SCAR=19.9
Pod documented
71 36 my $self = shift;
72  
73 36 my $err;
74 36 foreach my $pkg (@Plugins) {
75 37 ▶ if (eval "require $pkg" and $pkg->can("client_new")) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require $pkg" and $pkg->can("client_new")) 36 1 37
Condition66%2/3
eval "require $pkg" and $pkg->can("client_new")
!ll&&!rl&&r
1036
MC/DC50%1/2
eval "require $pkg" and $pkg->can("client_new")
eval "require $pkg" $pkg->can("client_new")
Truth table66%2/3
A and B
A= eval "require $pkg"B= $pkg->can("client_new")
ABresult
0X0
100
111
76 36 ▶ if ($self->{conn} = eval { $pkg->client_new($self, @_) }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"conn"} = eval { do { $pkg->client_new($self, @_) } }) 36 0 36
77 36 return $self->{conn};
78 }
79 0 $err = $@;
80 }
81 }
82  
83 0 ▶ croak $err || "Cannot find a SASL Connection library";
Condition0%0/2
$err || 'Cannot find a SASL Connection library'
l!l
00
MC/DC0%0/1
$err || 'Cannot find a SASL Connection library'
$err
Truth table0%0/2
A
A= $err
Aresult
11
00
84 }
85  
86 20 ▶sub server_new { # $self, $service, $host, $secflags
Subroutine server_new: called CC=6 SCAR=22.1
Pod documented
87 20 my $self = shift;
88  
89 20 my $err;
90 20 foreach my $pkg (@Plugins) {
91 20 ▶ if (eval "require $pkg" and $pkg->can("server_new")) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require $pkg" and $pkg->can("server_new")) 20 0 20
Condition33%1/3
eval "require $pkg" and $pkg->can("server_new")
!ll&&!rl&&r
0020
MC/DC0%0/2
eval "require $pkg" and $pkg->can("server_new")
eval "require $pkg" $pkg->can("server_new")
Truth table33%1/3
A and B
A= eval "require $pkg"B= $pkg->can("server_new")
ABresult
0X0
100
111
92 20 ▶ if ($self->{conn} = eval { $pkg->server_new($self, @_) } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"conn"} = eval { do { $pkg->server_new($self, @_) } }) 20 0 20
93 20 return $self->{conn};
94 }
95 0 $err = $@;
96 }
97 }
98 0 ▶ croak $err || "Cannot find a SASL Connection library for server-side authentication";
Condition0%0/2
$err || 'Cannot find a SASL Connection library for server-side authentication'
l!l
00
MC/DC0%0/1
$err || 'Cannot find a SASL Connection library for server-side authentication'
$err
Truth table0%0/2
A
A= $err
Aresult
11
00
99 }
100  
101 1 ▶sub error {
Subroutine error: called CC=2 SCAR=7.2
Pod documented
102 1 my $self = shift;
103 1 ▶ $self->{conn} && $self->{conn}->error;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"conn"} and $self->{"conn"}->error 0 1 1
104 }
105  
106 # Compat.
107 3 ▶sub user {
Subroutine user: called CC=2 SCAR=6.9
Pod undocumented
108 3 my $self = shift;
109 3 my $user = $self->{callback}{user};
110 3 ▶ $self->{callback}{user} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 1 3
111 3 $user;
112 }
113  
114 1 ▶sub challenge {
Subroutine challenge: called CC=1 SCAR=0.0
Pod undocumented
115 1 my $self = shift;
116 1 $self->{conn}->client_step(@_);
117 }
118  
119 1 ▶sub initial {
Subroutine initial: called CC=1 SCAR=0.0
Pod undocumented
120 1 my $self = shift;
121 1 $self->client_new($self)->client_start;
122 }
123  
124 3 ▶sub name {
Subroutine name: called CC=3 SCAR=11.0
Pod undocumented
125 3 my $self = shift;
126 3 ▶ $self->{conn} ? $self->{conn}->mechanism : (($self->{mechanism} || '') =~ /(\S+)/)[0];
Branch: 1 branch
BranchTrueFalseTotal
$self->{'conn'} ? : 1 2 3
Condition100%2/2
$self->{'mechanism'} || ''
l!l
11
MC/DC100%1/1
$self->{'mechanism'} || ''
$self->{'mechanism'}
Truth table100%2/2
A
A= $self->{'mechanism'}
Aresult
11
00
127 }
128  
129 16 1;
« SASL/Perl/OAUTHBEARER.pm ↑ Summary SASL/Perl/LOGIN.pm »