Config.PL

filter: Statementstmt 10.2% 7 / 68 Branchbran 15.0% 3 / 20 Conditioncond 10.0% 2 / 20 MC/DCmcdc 0.0% 0 / 10 Subroutinesub n/a Podpod n/a totaltotal 10.1% 12 / 118 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/ServiceNow/Simple.pm ↑ Summary blib/lib/ServiceNow/Simple.cfg »
1 # Config.PL
2 #
3 # Configuration file generation for ServiceNow::Simple
4
5 # Just to tell make we are done with configuring
6 1 open CFG, '>', 'Config';
7 1 print CFG "\n";
8 1 close CFG;
9
10 # Are we being run from ActiveStates PPM
11 1 ▶if ($0 =~ /\.PPM$/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($0 =~ /\.PPM$/i) { } 0 1 1
12 {
13 0 print "Running from PPM...\n\n";
14 0 chdir '..';
15
16 # find ServiceNow::Simple.pm
17 0 foreach $dir (@INC)
18 {
19 0 ▶ if (-e $dir.'/ServiceNow/Simple.pm')
Branch: 1 branch
BranchTrueFalseTotal
if (-e $dir . '/ServiceNow/Simple.pm') 0 0 0
20 {
21 0 $configfile = $dir.'Simple.cfg';
22 0 last;
23 }
24 }
25 0 ▶ unless ($configfile)
Branch: 1 branch
BranchTrueFalseTotal
unless ($configfile) 0 0 0
26 {
27 0 print STDERR "The module ServiceNow::Simple.pm is not found. Are you realy running the script via PPM install?\n";
28 0 <STDIN>;
29 0 exit(1);
30 }
31 }
32 else
33 {
34 # called directly
35 1 ▶ unless (-d 'blib/lib')
Branch: 1 branch
BranchTrueFalseTotal
unless (-d "blib/lib") 0 1 1
36 {
37 0 die "Do not execute this script directly, run:\n\tperl Makefile.PL
38 \tmake\n\tmake test\n\tmake install\n
39 If you are using ActivePerl under Windows use 'nmake' or 'dmake' instead of 'make'.";
40 }
41 }
42
43 1 ▶if (($configfile && -f $configfile) || -f 'blib/lib/ServiceNow/Simple.cfg') { exit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($configfile and -f $configfile or -f "blib/lib/ServiceNow/Simple.cfg") 1 0 1
Condition33%2/6
$configfile and -f $configfile or -f "blib/lib/ServiceNow/Simple.cfg"
l!l&&r!l&&!r
010
$configfile and -f $configfile
!ll&&!rl&&r
100
MC/DC0%0/3
$configfile and -f $configfile or -f "blib/lib/ServiceNow/Simple.cfg"
$configfile -f $configfile -f "blib/lib/ServiceNow/Simple.cfg"
Truth table0%0/5
A and B or C
A= $configfileB= -f $configfileC= -f "blib/lib/ServiceNow/Simple.cfg"
ABCresult
11X1
0X11
1011
0X00
1000
44
45 0 my $user = '';
46 0 my $password = '';
47 0 my $proxy = '';
48 0 ▶unless ($ENV{PERL_MM_USE_DEFAULT} || $ENV{AUTOMATED_TESTING} || !-t STDIN)
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"} or not -t STDIN) 0 0 0
Condition0%0/6
$ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"} or not -t STDIN
l!l&&r!l&&!r
000
$ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"} or not -t STDIN
$ENV{"PERL_MM_USE_DEFAULT"} $ENV{"AUTOMATED_TESTING"} not -t STDIN
Truth table0%0/4
A or B or not(C)
A= $ENV{"PERL_MM_USE_DEFAULT"}B= $ENV{"AUTOMATED_TESTING"}C= not -t STDIN
ABCresult
1XX1
01X1
0011
0000
49 {
50 0 print "\n================ Set the defaults for module ServiceNow::Simple ================\n";
51 0 print "\nSpecify defaults for ServiceNow::Simple? (y/N) ";
52 0 $res = <STDIN>;
53 0 ▶ exit unless $res =~ /^y$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $res =~ /^y$/i 0 0 0
54
55 0 ▶ if (! $configfile)
Branch: 1 branch
BranchTrueFalseTotal
if (not $configfile) { } 0 0 0
56 {
57 0 print "\n\t... will be saved to .../lib/ServiceNow/Simple.cfg\n";
58 0 $configfile = 'blib/lib/ServiceNow/Simple.cfg';
59 }
60 else
61 {
62 0 print "\n\t... will be saved to $configfile\n";
63 }
64
65 #exit if -f $configfile;
66
67 # Gather the defaults
68 0 print "\nDefault user to use for API: ";
69 0 $user = <STDIN>;
70 0 $user =~ s/^\s+//;
71 0 $user =~ s/\s+$//;
72
73 0 print "Password for user '$user': ";
74 0 $password = <STDIN>;
75 0 $password =~ s/^\s+//;
76 0 $password =~ s/\s+$//;
77
78 0 print "\nIf you are operating behind a firewall, you may need\n";
79 0 print "to define the https proxy, a typical https proxy setting could be\n";
80 0 print " http://myproxy.mycompany.com/\n";
81 0 print "Either enter your proxy setting or just press ENTER for none: ";
82 0 $proxy = <STDIN>;
83 0 $proxy =~ s/^\s+//;
84 0 $proxy =~ s/\s+$//;
85
86 0 print "\nSaving config file, using the following:\n";
87 }
88
89 0 ▶if (! $configfile)
Branch: 1 branch
BranchTrueFalseTotal
unless ($configfile) 0 0 0
90 {
91 0 $configfile = 'blib/lib/ServiceNow/Simple.cfg';
92 }
93 0 ▶open $fh, '>', $configfile || die "failed to open $configfile: $!";
Condition0%0/2
$configfile || die("failed to open ${configfile}: $!")
l!l
00
MC/DC0%0/1
$configfile || die("failed to open ${configfile}: $!")
$configfile
Truth table0%0/2
A
A= $configfile
Aresult
11
00
94 0 print $fh "# Config file for ServiceNow::Simple\n# generated by Config.PL (".scalar(localtime).")\n# This file MUST be valid perl (as it is 'required')\n# Note user and password are obfuscated.\n\n";
95 0 print $fh q{%config = (} . "\n";
96
97 # Doing simple obfuscation of user and password
98 0 my $k = '5Jv@sI9^bl@D*j5H3@:7g4H[2]d%Ks314aNuGeX;';
99 0 my $x = substr($k, 0, length($user));
100 0 my $u = $user ^ $x;
101 0 my $up = unpack('H*', $u);
102 0 print $fh "\tuser => '$up',\n";
103
104 0 $x = substr($k, 0, length($password));
105 0 $u = $password ^ $x;
106 0 $up = unpack('H*', $u);
107 0 print $fh "\tpassword => '$up',\n";
108 0 print $fh "\tproxy => '$proxy',\n";
109 0 print $fh ");\n1;\n#--< End of File >--#\n";
110 0 close $fh;
111
112 0 ▶unless ($ENV{PERL_MM_USE_DEFAULT} || $ENV{AUTOMATED_TESTING} || !-t STDIN)
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"} or not -t STDIN) 0 0 0
Condition0%0/6
$ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"} or not -t STDIN
l!l&&r!l&&!r
000
$ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{"PERL_MM_USE_DEFAULT"} or $ENV{"AUTOMATED_TESTING"} or not -t STDIN
$ENV{"PERL_MM_USE_DEFAULT"} $ENV{"AUTOMATED_TESTING"} not -t STDIN
Truth table0%0/4
A or B or not(C)
A= $ENV{"PERL_MM_USE_DEFAULT"}B= $ENV{"AUTOMATED_TESTING"}C= not -t STDIN
ABCresult
1XX1
01X1
0011
0000
113 {
114 0 print "\tuser => '$user' (obfuscated),\n";
115 0 print "\tpassword => '$password' (obfuscated),\n";
116 0 print "\tproxy => '$proxy',\n";
117 0 print "\nFinished configuration\n";
118 }
119
120
121 #####################################################################
122 # DO NOT REMOVE THE FOLLOWING LINE, IT IS NEEDED TO LOAD THIS LIBRARY
123 1;
124
125 #---< End of File >---#
« blib/lib/ServiceNow/Simple.pm ↑ Summary blib/lib/ServiceNow/Simple.cfg »