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
45
46
47
48
49
50
51
52
|
use strict;
use warnings;
use Test::More;
plan tests => 3;
use Net::HTTP::Spore;
use JSON;
my $api = {
base_url => "http://term.ie/oauth/example",
name => "term.ie",
methods => {
echo => {
path => "/echo_api.php",
method => "GET",
expected_status => [200],
authentication => 1,
},
get_request_token => {
path => "/request_token.php",
method => "GET",
expected_status => [200],
authentication => 1,
},
get_access_token => {
path => "/access_token.php",
method => "GET",
expected_status => [200],
authentication => 1,
}
},
};
SKIP: {
skip "require RUN_HTTP_TEST", 3 unless $ENV{RUN_HTTP_TEST};
my $client = Net::HTTP::Spore->new_from_string( JSON::encode_json($api), trace => 1 );
$client->enable(
'Auth::OAuth',
oauth_consumer_key => 'key',
oauth_consumer_secret => 'secret',
);
my $body = $client->get_request_token->body;
use YAML::Syck; warn $body; ok 1;
# ok my $r = $client->echo(method => 'foo', bar => 'baz');
# is $r->status, 200;
# like $r->body, qr/bar=baz&method=foo/;
}
|