blib/lib/CPAN/HTTP/Credentials.pm

filter: Statementstmt 43.4% 20 / 46 Branchbran 33.3% 4 / 12 Conditioncond 38.4% 5 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 5 totaltotal 35.8% 33 / 92 CC 12 SCAR 20.3
CC
12
Cov
41%
_get_username_and_password_from_user
12.0
get_proxy_credentials
10.5
get_non_proxy_credentials
7.7
CRAP 7.6
« lib/CPAN/Plugin.pm ↑ Summary blib/lib/CPAN/Plugin.pm »
1 # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2 # vim: ts=4 sts=4 sw=4:
3 package CPAN::HTTP::Credentials;
4 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶use vars qw($USER $PASSWORD $PROXY_USER $PROXY_PASSWORD);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 24 $CPAN::HTTP::Credentials::VERSION = $CPAN::HTTP::Credentials::VERSION = "1.9601";
8  
9 sub clear_credentials {
10 0 ▶ clear_non_proxy_credentials();
Subroutine clear_credentials: not called CC=1 SCAR=6.9
Pod undocumented
11 0 clear_proxy_credentials();
12 }
13  
14 sub clear_non_proxy_credentials {
15 0 ▶ undef $USER;
Subroutine clear_non_proxy_credentials: not called CC=1 SCAR=6.9
Pod undocumented
16 0 undef $PASSWORD;
17 }
18  
19 sub clear_proxy_credentials {
20 0 ▶ undef $PROXY_USER;
Subroutine clear_proxy_credentials: not called CC=1 SCAR=6.9
Pod undocumented
21 0 undef $PROXY_PASSWORD;
22 }
23  
24 sub get_proxy_credentials {
25 2 ▶ my $self = shift;
Subroutine get_proxy_credentials: called CC=6 SCAR=23.5
Pod undocumented
26 2 ▶ if ($PROXY_USER && $PROXY_PASSWORD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::HTTP::Credentials::PROXY_USER and $CPAN::HTTP::Credentials::PROXY_PASSWORD) 0 2 2
Condition33%1/3
$CPAN::HTTP::Credentials::PROXY_USER and $CPAN::HTTP::Credentials::PROXY_PASSWORD
!ll&&!rl&&r
200
MC/DC0%0/2
$CPAN::HTTP::Credentials::PROXY_USER and $CPAN::HTTP::Credentials::PROXY_PASSWORD
$CPAN::HTTP::Credentials::PROXY_USER $CPAN::HTTP::Credentials::PROXY_PASSWORD
Truth table33%1/3
A and B
A= $CPAN::HTTP::Credentials::PROXY_USERB= $CPAN::HTTP::Credentials::PROXY_PASSWORD
ABresult
0X0
100
111
27 0 return ($PROXY_USER, $PROXY_PASSWORD);
28 }
29 2 ▶ if ( defined $CPAN::Config->{proxy_user}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $CPAN::Config->{"proxy_user"} and $CPAN::Config->{"proxy_user"}) 2 0 2
Condition33%1/3
defined $CPAN::Config->{"proxy_user"} and $CPAN::Config->{"proxy_user"}
!ll&&!rl&&r
002
MC/DC0%0/2
defined $CPAN::Config->{"proxy_user"} and $CPAN::Config->{"proxy_user"}
defined $CPAN::Config->{"proxy_user"} $CPAN::Config->{"proxy_user"}
Truth table33%1/3
A and B
A= defined $CPAN::Config->{"proxy_user"}B= $CPAN::Config->{"proxy_user"}
ABresult
0X0
100
111
30 && $CPAN::Config->{proxy_user}
31 ) {
32 2 $PROXY_USER = $CPAN::Config->{proxy_user};
33 2 ▶ $PROXY_PASSWORD = $CPAN::Config->{proxy_pass} || "";
Condition50%1/2
$CPAN::Config->{'proxy_pass'} || ''
l!l
20
MC/DC0%0/1
$CPAN::Config->{'proxy_pass'} || ''
$CPAN::Config->{'proxy_pass'}
Truth table50%1/2
A
A= $CPAN::Config->{'proxy_pass'}
Aresult
11
00
34 2 return ($PROXY_USER, $PROXY_PASSWORD);
35 }
36 0 my $username_prompt = "\nProxy authentication needed!
37 (Note: to permanently configure username and password run
38 o conf proxy_user your_username
39 o conf proxy_pass your_password
40 )\nUsername:";
41 0 ($PROXY_USER, $PROXY_PASSWORD) =
42 _get_username_and_password_from_user($username_prompt);
43 0 return ($PROXY_USER,$PROXY_PASSWORD);
44 }
45  
46 sub get_non_proxy_credentials {
47 1 ▶ my $self = shift;
Subroutine get_non_proxy_credentials: called CC=5 SCAR=20.4
Pod undocumented
48 1 ▶ if ($USER && $PASSWORD) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::HTTP::Credentials::USER and $CPAN::HTTP::Credentials::PASSWORD) 0 1 1
Condition33%1/3
$CPAN::HTTP::Credentials::USER and $CPAN::HTTP::Credentials::PASSWORD
!ll&&!rl&&r
100
MC/DC0%0/2
$CPAN::HTTP::Credentials::USER and $CPAN::HTTP::Credentials::PASSWORD
$CPAN::HTTP::Credentials::USER $CPAN::HTTP::Credentials::PASSWORD
Truth table33%1/3
A and B
A= $CPAN::HTTP::Credentials::USERB= $CPAN::HTTP::Credentials::PASSWORD
ABresult
0X0
100
111
49 0 return ($USER, $PASSWORD);
50 }
51 1 ▶ if ( defined $CPAN::Config->{username} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $CPAN::Config->{"username"}) 1 0 1
52 1 $USER = $CPAN::Config->{username};
53 1 ▶ $PASSWORD = $CPAN::Config->{password} || "";
Condition50%1/2
$CPAN::Config->{'password'} || ''
l!l
10
MC/DC0%0/1
$CPAN::Config->{'password'} || ''
$CPAN::Config->{'password'}
Truth table50%1/2
A
A= $CPAN::Config->{'password'}
Aresult
11
00
54 1 return ($USER, $PASSWORD);
55 }
56 0 my $username_prompt = "\nAuthentication needed!
57 (Note: to permanently configure username and password run
58 o conf username your_username
59 o conf password your_password
60 )\nUsername:";
61  
62 0 ($USER, $PASSWORD) =
63 _get_username_and_password_from_user($username_prompt);
64 0 return ($USER,$PASSWORD);
65 }
66  
67 sub _get_username_and_password_from_user {
68 0 ▶ my $username_message = shift;
Subroutine _get_username_and_password_from_user: not called CC=3 SCAR=24.8
69 0 my ($username,$password);
70  
71 0 ExtUtils::MakeMaker->import(qw(prompt));
72 0 $username = prompt($username_message);
73 0 ▶ if ($CPAN::META->has_inst("Term::ReadKey")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::META->has_inst('Term::ReadKey')) { } 0 0 0
74 0 Term::ReadKey::ReadMode("noecho");
75 }
76 else {
77 0 $CPAN::Frontend->mywarn(
78 "Warning: Term::ReadKey seems not to be available, your password will be echoed to the terminal!\n"
79 );
80 }
81 0 $password = prompt("Password:");
82  
83 0 ▶ if ($CPAN::META->has_inst("Term::ReadKey")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::META->has_inst("Term::ReadKey")) 0 0 0
84 0 Term::ReadKey::ReadMode("restore");
85 }
86 0 $CPAN::Frontend->myprint("\n\n");
87 0 return ($username,$password);
88 }
89  
90 24 1;
91  
« lib/CPAN/Plugin.pm ↑ Summary blib/lib/CPAN/Plugin.pm »