OAuth/Lite2/Server/GrantHandler/AuthorizationCode.pm

filter: Statementstmt 100% 41 / 41 Branchbran 82.1% 23 / 28 Conditioncond 58.3% 7 / 12 MC/DCmcdc 37.5% 3 / 8 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 84.5% 82 / 97 CC 19 SCAR 27.6
CC
19
Cov
88%
handle_request
20.5
BEGIN
1.0
BEGIN
1.0
CRAP 15.8
« OAuth/Lite2/Agent/Strict.pm ↑ Summary OAuth/Lite2/Server/GrantHandler/GroupingRefreshToken.pm »
1 package OAuth::Lite2::Server::GrantHandler::AuthorizationCode;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 ▶use parent 'OAuth::Lite2::Server::GrantHandler';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use OAuth::Lite2::Server::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use OAuth::Lite2::ParamMethod::AuthHeader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 19 ▶sub handle_request {
Subroutine handle_request: called CC=19 SCAR=30.2
Pod documented
12 19 my ($self, $dh) = @_;
13  
14 19 my $req = $dh->request;
15  
16 19 my $parser = OAuth::Lite2::ParamMethod::AuthHeader->new;
17 19 my $header_credentials = $parser->basic_credentials($req);
18 19 ▶ my $client_id = ($header_credentials->{client_id}) ? $header_credentials->{client_id} : $req->param("client_id");
Branch: 1 branch
BranchTrueFalseTotal
$header_credentials->{'client_id'} ? : 3 16 19
19  
20 19 ▶ my $code = $req->param("code")
Branch: 1 branch
BranchTrueFalseTotal
my $code = $req->param("code") or "OAuth::Lite2::Server::Error::InvalidRequest"->throw("description", "'code' not found") 18 1 19
21 or OAuth::Lite2::Server::Error::InvalidRequest->throw(
22 description => "'code' not found"
23 );
24  
25 18 ▶ my $redirect_uri = $req->param("redirect_uri")
Branch: 1 branch
BranchTrueFalseTotal
my $redirect_uri = $req->param("redirect_uri") or "OAuth::Lite2::Server::Error::InvalidRequest"->throw("description", "'redirect_uri' not found") 17 1 18
26 or OAuth::Lite2::Server::Error::InvalidRequest->throw(
27 description => "'redirect_uri' not found"
28 );
29  
30 17 my $server_state = $req->param("server_state");
31  
32 17 ▶ my $auth_info = $dh->get_auth_info_by_code($code)
Branch: 1 branch
BranchTrueFalseTotal
my $auth_info = $dh->get_auth_info_by_code($code) or "OAuth::Lite2::Server::Error::InvalidGrant"->throw 14 3 17
33 or OAuth::Lite2::Server::Error::InvalidGrant->throw;
34  
35 14 ▶ Carp::croak "OAuth::Lite2::Server::DataHandler::get_auth_info_by_code doesn't return OAuth::Lite2::Model::AuthInfo"
Branch: 1 branch
BranchTrueFalseTotal
unless $auth_info and $auth_info->isa("OAuth::Lite2::Model::AuthInfo") 0 14 14
Condition33%1/3
$auth_info and $auth_info->isa("OAuth::Lite2::Model::AuthInfo")
!ll&&!rl&&r
0014
MC/DC0%0/2
$auth_info and $auth_info->isa("OAuth::Lite2::Model::AuthInfo")
$auth_info $auth_info->isa("OAuth::Lite2::Model::AuthInfo")
Truth table33%1/3
A and B
A= $auth_infoB= $auth_info->isa("OAuth::Lite2::Model::AuthInfo")
ABresult
0X0
100
111
36 unless ($auth_info
37 && $auth_info->isa("OAuth::Lite2::Model::AuthInfo"));
38  
39 14 ▶ OAuth::Lite2::Server::Error::InvalidClient->throw
Branch: 1 branch
BranchTrueFalseTotal
unless $auth_info->client_id eq $client_id 1 13 14
40 unless ($auth_info->client_id eq $client_id);
41  
42 13 ▶ OAuth::Lite2::Server::Error::RedirectURIMismatch->throw
Branch: 1 branch
BranchTrueFalseTotal
unless $auth_info->redirect_uri and $auth_info->redirect_uri eq $redirect_uri 3 10 13
Condition66%2/3
$auth_info->redirect_uri and $auth_info->redirect_uri eq $redirect_uri
!ll&&!rl&&r
0310
MC/DC50%1/2
$auth_info->redirect_uri and $auth_info->redirect_uri eq $redirect_uri
$auth_info->redirect_uri $auth_info->redirect_uri eq $redirect_uri
Truth table66%2/3
A and B
A= $auth_info->redirect_uriB= $auth_info->redirect_uri eq $redirect_uri
ABresult
0X0
100
111
43 unless ( $auth_info->redirect_uri
44 && $auth_info->redirect_uri eq $redirect_uri);
45  
46 10 ▶ if ( $auth_info->server_state ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth_info->server_state) { } 6 4 10
47 6 ▶ OAuth::Lite2::Server::Error::InvalidServerState->throw
Branch: 1 branch
BranchTrueFalseTotal
unless $server_state and $server_state eq $auth_info->server_state 4 2 6
Condition100%3/3
$server_state and $server_state eq $auth_info->server_state
!ll&&!rl&&r
222
MC/DC100%2/2
$server_state and $server_state eq $auth_info->server_state
$server_state $server_state eq $auth_info->server_state
Truth table100%3/3
A and B
A= $server_stateB= $server_state eq $auth_info->server_state
ABresult
0X0
100
111
48 unless ( $server_state and $server_state eq $auth_info->server_state );
49 } else {
50 4 ▶ OAuth::Lite2::Server::Error::InvalidServerState->throw if ( $server_state );
Branch: 1 branch
BranchTrueFalseTotal
if $server_state 1 3 4
51 }
52  
53 5 my $access_token = $dh->create_or_update_access_token(
54 auth_info => $auth_info,
55 );
56 5 ▶ Carp::croak "OAuth::Lite2::Server::DataHandler::create_or_update_access_token doesn't return OAuth::Lite2::Model::AccessToken"
Branch: 1 branch
BranchTrueFalseTotal
unless $access_token and $access_token->isa("OAuth::Lite2::Model::AccessToken") 0 5 5
Condition33%1/3
$access_token and $access_token->isa("OAuth::Lite2::Model::AccessToken")
!ll&&!rl&&r
005
MC/DC0%0/2
$access_token and $access_token->isa("OAuth::Lite2::Model::AccessToken")
$access_token $access_token->isa("OAuth::Lite2::Model::AccessToken")
Truth table33%1/3
A and B
A= $access_tokenB= $access_token->isa("OAuth::Lite2::Model::AccessToken")
ABresult
0X0
100
111
57 unless ($access_token
58 && $access_token->isa("OAuth::Lite2::Model::AccessToken"));
59  
60 5 my $res = {
61 token_type => 'Bearer',
62 access_token => $access_token->token,
63 };
64  
65 5 ▶ $res->{expires_in} = int($access_token->expires_in)
Branch: 1 branch
BranchTrueFalseTotal
if $access_token->expires_in 5 0 5
66 if $access_token->expires_in;
67 5 ▶ $res->{refresh_token} = $auth_info->refresh_token
Branch: 1 branch
BranchTrueFalseTotal
if $auth_info->refresh_token 5 0 5
68 if $auth_info->refresh_token;
69 5 ▶ $res->{scope} = $auth_info->scope
Branch: 1 branch
BranchTrueFalseTotal
if $auth_info->scope 5 0 5
70 if $auth_info->scope;
71  
72 5 return $res;
73 }
74  
75 =head1 NAME
76  
77 OAuth::Lite2::Server::GrantHandler::AuthorizationCode - handler for 'authorization-code' grant_type request
78  
79 =head1 SYNOPSIS
80  
81 my $handler = OAuth::Lite2::Server::GrantHandler::AuthorizationCode->new;
82 my $res = $handler->handle_request( $data_handler );
83  
84 =head1 DESCRIPTION
85  
86 handler for 'authorization-code' grant_type request.
87  
88 =head1 METHODS
89  
90 =head2 handle_request( $req )
91  
92 See L<OAuth::Lite2::Server::GrantHandler> document.
93  
94 =head1 AUTHOR
95  
96 Ryo Ito, E<lt>ritou.06@gmail.comE<gt>
97  
98 Lyo Kato, E<lt>lyo.kato@gmail.comE<gt>
99  
100 =head1 COPYRIGHT AND LICENSE
101  
102 Copyright (C) 2010 by Lyo Kato
103  
104 This library is free software; you can redistribute it and/or modify
105 it under the same terms as Perl itself, either Perl version 5.8.8 or,
106 at your option, any later version of Perl 5 you may have available.
107  
108 =cut
109  
110 8 1;
« OAuth/Lite2/Agent/Strict.pm ↑ Summary OAuth/Lite2/Server/GrantHandler/GroupingRefreshToken.pm »