lib/WWW/FBX/Role/Auth.pm

filter: Statementstmt 34.4% 10 / 29 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 26.5% 13 / 49 CC 7 SCAR 36.8
CC
7
Cov
24%
BUILD
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 39.5
« lib/WWW/FBX.pm ↑ Summary lib/WWW/FBX/Role/API/APIv3.pm »
1 package WWW::FBX::Role::Auth;
2 23 ▶use 5.014001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 23 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use Digest::HMAC_SHA1 qw/ hmac_sha1_hex /;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 23 has [ qw/app_token track_id/ ] => ( isa => 'Str', is => 'rw', default => '');
7  
8 0 ▶sub BUILD {
Subroutine BUILD: not called CC=7 SCAR=40.3
Pod undocumented
9 0 my $self=shift;
10 0 my $au_sts;
11 my $challenge;
12 0 my $res;
13  
14 #Do not perform connection automatically
15 0 ▶ return if $self->noauth;
Branch: 1 branch
BranchTrueFalseTotal
if $self->noauth 0 0 0
16  
17 #Get API version if we're called first
18 0 $self->api_version;
19
20 0 ▶ unless ( $self->app_token and $self->track_id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->app_token and $self->track_id) 0 0 0
Condition0%0/3
$self->app_token and $self->track_id
!ll&&!rl&&r
000
MC/DC0%0/2
$self->app_token and $self->track_id
$self->app_token $self->track_id
Truth table0%0/3
A and B
A= $self->app_tokenB= $self->track_id
ABresult
0X0
100
111
21 #Request token
22 0 $res = $self->req_auth ( { app_id => $self->app_id,
23 app_name => $self->app_name,
24 app_version => $self->app_version,
25 device_name => $self->device_name } );
26 0 $self->track_id( $res->{track_id} );
27 0 $self->app_token( $res->{app_token} );
28 }
29  
30 #Check auth status or wait for physical granting on the device
31 0 $res = $self->auth_progress( $self->track_id );
32 0 ▶ while( ( $au_sts = $res->{status} ) eq "pending" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($au_sts = $res->{"status"}) eq "pending") 0 0 0
33 0 $challenge = $res->{challenge};
34 0 print "Please Confirm on the FB - Merci d'autoriser sur la FB\n";
35 0 $res = $self->auth_progress( $self->track_id );
36 0 sleep 1;
37 }
38  
39 0 ▶ die "Authorization not granted($au_sts)" unless $au_sts eq "granted";
Branch: 1 branch
BranchTrueFalseTotal
unless $au_sts eq "granted" 0 0 0
40  
41 0 ▶ $challenge = $self->login->{challenge} unless ($challenge);
Branch: 1 branch
BranchTrueFalseTotal
unless $challenge 0 0 0
42  
43 0 $res = $self->open_session( {
44 app_id => $self->app_id,
45 app_version => $self->app_version,
46 password => hmac_sha1_hex( $challenge, $self->app_token ),
47 } );
48
49 0 $self->ua->default_header('X-Fbx-App-Auth' => $res->{session_token});
50  
51 }
52  
53 23 1;
54 __END__
« lib/WWW/FBX.pm ↑ Summary lib/WWW/FBX/Role/API/APIv3.pm »