File: app-auth.t

package info (click to toggle)
libnet-twitter-perl 4.01043-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 844 kB
  • sloc: perl: 6,703; makefile: 13
file content (29 lines) | stat: -rwxr-xr-x 691 bytes parent folder | download | duplicates (3)
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
#!perl
use warnings;
use strict;
use Test::More;
use Test::Fatal;

use Net::Twitter;

plan skip_all => 'LWP::UserAgent 5.819 required' if $@;

my $nt = Net::Twitter->new(
    traits          => [ qw/AppAuth API::RESTv1_1/ ],
    consumer_key    => 'my-key',
    consumer_secret => 'my-secret',
    ssl             => 1,
);
isa_ok $nt, 'Net::Twitter';

my ( $req, $res );
$nt->ua->add_handler(request_send => sub { $req = shift; $res });

$res = HTTP::Response->new(200, 'OK');
$res->content('{"access_token":"my-token","token_type":"bearer"}');

$nt->request_access_token;
ok $nt->authorized, 'has an access token';
is $nt->access_token, 'my-token', 'with the correct value';

done_testing;