DJabberd/Authen/InMemoryOnly.pm

filter: Statementstmt 38.6% 17 / 44 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.6% 7 / 11 Podpod 0.0% 0 / 8 totaltotal 32.8% 24 / 73 CC 6 SCAR 16.0
CC
6
Cov
31%
check_cleartext
12.0
unregister_jid
6.0
register_jid
6.0
CRAP 4.9
« DJabberd/SASL/Manager/AuthenSASL.pm ↑ Summary DJabberd/Connection/ServerIn.pm »
1 package DJabberd::Authen::InMemoryOnly;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use base 'DJabberd::Authen';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub new {
7 1 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 1 my $self = $class->SUPER::new;
9 1 $self->{_users} = {}; # username -> $password
10 1 return $self;
11 }
12  
13 1 ▶sub can_register_jids { 1 }
Subroutine can_register_jids: called CC=1 SCAR=0.0
Pod undocumented
14 1 ▶sub can_unregister_jids { 1 }
Subroutine can_unregister_jids: called CC=1 SCAR=0.0
Pod undocumented
15 1 ▶sub can_retrieve_cleartext { 1 }
Subroutine can_retrieve_cleartext: called CC=1 SCAR=0.0
Pod undocumented
16  
17 sub unregister_jid {
18 0 ▶ my ($self, $cb, %args) = @_;
Subroutine unregister_jid: not called CC=2 SCAR=17.9
Pod undocumented
19 0 my $user = $args{'username'};
20 0 ▶ if (delete $self->{_users}{$user}) {
Branch: 1 branch
BranchTrueFalseTotal
if (delete $self->{'_users'}{$user}) { } 0 0 0
21 0 $cb->deleted;
22 } else {
23 0 $cb->notfound;
24 }
25 }
26  
27 sub register_jid {
28 0 ▶ my ($self, $cb, %args) = @_;
Subroutine register_jid: not called CC=2 SCAR=17.9
Pod undocumented
29 0 my $user = $args{'username'};
30 0 my $pass = $args{'password'};
31  
32 0 ▶ if (defined $self->{_users}{$user}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_users"}{$user}) 0 0 0
33 0 $cb->conflict;
34 }
35  
36 0 $self->{_users}{$user} = $pass;
37 0 $cb->saved;
38 }
39  
40 sub check_cleartext {
41 0 ▶ my ($self, $cb, %args) = @_;
Subroutine check_cleartext: not called CC=3 SCAR=24.8
Pod undocumented
42 0 my $user = $args{'username'};
43  
44 0 my $pass = $args{'password'};
45 0 ▶ unless (defined $self->{_users}{$user}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_users"}{$user}) 0 0 0
46 0 return $cb->reject;
47 }
48  
49 0 my $goodpass = $self->{_users}{$user};
50 0 ▶ unless ($pass eq $goodpass) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pass eq $goodpass) 0 0 0
51 0 return $cb->reject;
52 }
53  
54 0 $cb->decline;
55 }
56  
57 sub get_password {
58 0 ▶ my ($self, $cb, %args) = @_;
Subroutine get_password: not called CC=2 SCAR=17.9
Pod undocumented
59 0 my $user = $args{'username'};
60 0 ▶ if (my $pass = $self->{_users}{$user}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pass = $self->{"_users"}{$user}) 0 0 0
61 0 $cb->set($pass);
62 0 return;
63 }
64 0 $cb->decline;
65 }
66  
67 1 1;
« DJabberd/SASL/Manager/AuthenSASL.pm ↑ Summary DJabberd/Connection/ServerIn.pm »