blib/lib/Finance/Bank/PNC.pm

filter: Statementstmt 28.5% 14 / 49 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 23.0% 18 / 78 CC 11 SCAR 45.8
CC
11
Cov
20%
check_PNC_balance
132.0
BEGIN
1.0
BEGIN
1.0
CRAP 97.1
↑ Summary
1 package Finance::Bank::PNC;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.01';
5 1 ▶use WWW::Mechanize;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use HTML::TokeParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub check_PNC_balance {
Subroutine check_PNC_balance: not called CC=11 SCAR=48.8
Pod undocumented
9 0 my ( $class, %opts ) = @_;
10 0 my @accounts;
11 0 ▶ croak "Must provide a user id" unless exists $opts{userId};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"userId"} 0 0 0
12 0 ▶ croak "Must provide a password" unless exists $opts{password};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"password"} 0 0 0
13  
14 0 my $self = bless {%opts}, $class;
15 0 my $mech = WWW::Mechanize->new();
16 0 $mech->agent_alias('Windows Mozilla');
17 0 $mech->cookie_jar( HTTP::Cookies->new() );
18  
19 $mech->post(
20 'https://www.onlinebanking.pnc.com/alservlet/ValidateUserIdServlet',
21 { hiddenAcctLetter => 'p', origin => 'p', userId => $opts{userId} }
22 0 ▶ ) or die "$!";
Branch: 1 branch
BranchTrueFalseTotal
$mech->post("https://www.onlinebanking.pnc.com/alservlet/ValidateUserIdServlet", {"hiddenAcctLetter", "p", "origin", "p", "userId", $opts{"userId"}}) or die "$!" 0 0 0
23
24 #Security Question
25 0 ▶ my $stream = HTML::TokeParser->new( \$mech->content() ) or die "$!";
Branch: 1 branch
BranchTrueFalseTotal
my $stream = "HTML::TokeParser"->new(\$mech->content) or die "$!" 0 0 0
26 0 $stream->get_tag('table');
27 0 $stream->get_tag('tr');
28 0 $stream->get_tag('tr');
29 0 $stream->get_tag('td');
30 0 $stream->get_tag('td');
31 0 print $stream->get_trimmed_text('/td'), "\n";
32 0 my $answer = <>;
33  
34 0 ▶ $mech->post(
Branch: 1 branch
BranchTrueFalseTotal
$mech->post("https://www.onlinebanking.pnc.com/alservlet/SigninChallengeServlet", {"counter", 0, "challengeErrorCounter", 0, "bindDevice", "no", "answer", $answer}) or die "$!" 0 0 0
35 'https://www.onlinebanking.pnc.com/alservlet/SigninChallengeServlet',
36 {
37 counter => 0,
38 challengeErrorCounter => 0,
39 bindDevice => 'no',
40 answer => $answer
41 }
42 ) or die "$!";
43
44 $mech->post(
45 'https://www.onlinebanking.pnc.com/alservlet/VerifyPasswordServlet',
46 {
47 counter => 0,
48 passwordErrorCounter => 0,
49 oldUserId => 12345,
50 password => $opts{password}
51 }
52 0 ▶ ) or die "$!";
Branch: 1 branch
BranchTrueFalseTotal
$mech->post("https://www.onlinebanking.pnc.com/alservlet/VerifyPasswordServlet", {"counter", 0, "passwordErrorCounter", 0, "oldUserId", 12345, "password", $opts{"password"}}) or die "$!" 0 0 0
53  
54 #Scraping account page
55 0 ▶ $stream = HTML::TokeParser->new( \$mech->content() ) or die "$!";
Branch: 1 branch
BranchTrueFalseTotal
$stream = "HTML::TokeParser"->new(\$mech->content) or die "$!" 0 0 0
56 0 $stream->get_tag('table');
57 0 $stream->get_tag('tr');
58 0 ▶ while ( my $token = $stream->get_tag("tr") ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $stream->get_tag("tr")) 0 0 0
59 0 $token = $stream->get_tag("td");
60 0 ▶ last if ( $token->[1]{class} and $token->[1]{class} eq 'col213' );
Branch: 1 branch
BranchTrueFalseTotal
if $token->[1]{"class"} and $token->[1]{"class"} eq "col213" 0 0 0
Condition0%0/3
$token->[1]{"class"} and $token->[1]{"class"} eq "col213"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[1]{"class"} and $token->[1]{"class"} eq "col213"
$token->[1]{"class"} $token->[1]{"class"} eq "col213"
Truth table0%0/3
A and B
A= $token->[1]{"class"}B= $token->[1]{"class"} eq "col213"
ABresult
0X0
100
111
61 0 $stream->get_tag("td");
62 0 my $type = $stream->get_trimmed_text("/td");
63 0 $stream->get_tag("td");
64 0 my $number = $stream->get_trimmed_text("/td");
65 0 $stream->get_tag("td");
66 0 my $balance = $stream->get_trimmed_text("/td");
67 0 $stream->get_tag("td");
68 0 my $available = $stream->get_trimmed_text("/td");
69 0 push @accounts,
70 {
71 type => $type,
72 account => $number,
73 balance => $balance,
74 available => $available
75 };
76 }
77 0 return @accounts;
78 }
79 1 1;
80 __END__
↑ Summary