1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
use strict;
use warnings;
use lib 't/lib';
use Test::More;
use Plack::Request;
use Try::Tiny;
use TestDataHandler;
use OAuth::Lite2::Server::GrantHandler::ServerState;
use OAuth::Lite2::Util qw(build_content);
my $dh = TestDataHandler->new;
my $action = OAuth::Lite2::Server::GrantHandler::ServerState->new;
sub test_success {
my $params = shift;
my $expected = shift;
my $request = Plack::Request->new({
REQUEST_URI => q{http://example.org/token},
REQUEST_METHOD => q{GET},
QUERY_STRING => build_content($params),
});
my $dh = TestDataHandler->new(request => $request);
my $res; try {
$res = $action->handle_request($dh);
} catch {
my $error_message = ($_->isa("OAuth::Lite2::Error"))
? $_->type : $_;
};
is($res->{server_state}, $expected->{server_state});
is($res->{expires_in}, $expected->{expires_in});
}
&test_success({
client_id => q{foo},
}, {
server_state => q{server_state_0},
expires_in => q{3600},
});
done_testing;
|