blib/lib/Net/POP3/XOAuth2.pm

filter: Statementstmt 64.7% 22 / 34 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod n/a totaltotal 50.0% 28 / 56 CC 6 SCAR 29.2
CC
6
Cov
49%
__ANON__
42.0
__ANON__
1.1
__ANON__
1.1
CRAP 18.6
↑ Summary
1 package Net::POP3::XOAuth2;
2  
3 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Net::POP3;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use MIME::Base64;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '0.0.2';
12  
13 0 ▶*Net::POP3::_AUTH = sub { shift->command('AUTH', $_[0])->response() == Net::POP3::CMD_OK };
Subroutine __ANON__: not called CC=1 SCAR=1.2
14 # Send a token directly
15 0 ▶*Net::POP3::_XOAUTH2_TOKEN = sub { shift->command($_[0])->response() == Net::POP3::CMD_OK };
Subroutine __ANON__: not called CC=1 SCAR=1.2
16 0 ▶*Net::POP3::xoauth2 = sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
17 0 ▶ @_ >= 1 && @_ <= 4 or croak 'usage: $pop3->xoauth2( USER, TOKEN, separate_flag )';
Branch: 1 branch
BranchTrueFalseTotal
@_ >= 1 and @_ <= 4 or croak("usage: \$pop3->xoauth2( USER, TOKEN, separate_flag )") 0 0 0
Condition0%0/3
@_ >= 1 and @_ <= 4
!ll&&!rl&&r
000
MC/DC0%0/2
@_ >= 1 and @_ <= 4
@_ >= 1 @_ <= 4
Truth table0%0/3
A and B
A= @_ >= 1B= @_ <= 4
ABresult
0X0
100
111
18 0 my ($me, $user, $token, $separate_flag) = @_;
19 0 my $xoauth2_token = encode_base64("user=$user\001auth=Bearer $token\001\001");
20 0 $xoauth2_token =~ s/[\r\n]//g;
21  
22 # If you use office365, need to call 'XOAUTH2' and token separately
23 # https://docs.microsoft.com/ja-jp/Exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
24 0 ▶ if ($separate_flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($separate_flag) { } 0 0 0
25 0 $me->_AUTH("XOAUTH2");
26 0 my $r = $me->_XOAUTH2_TOKEN($xoauth2_token);
27 0 ▶ return unless $r;
Branch: 1 branch
BranchTrueFalseTotal
unless $r 0 0 0
28 } else {
29 0 ▶ return unless ($me->_AUTH("XOAUTH2 $xoauth2_token"));
Branch: 1 branch
BranchTrueFalseTotal
unless $me->_AUTH("XOAUTH2 $xoauth2_token") 0 0 0
30 }
31 0 $me->_get_mailbox_count();
32 1 };
33  
34 1 1;
35 __END__
↑ Summary