diff options
Diffstat (limited to '')
-rw-r--r-- | t/lib/FakeAPI.pm | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/t/lib/FakeAPI.pm b/t/lib/FakeAPI.pm index d51a469..0f53157 100644 --- a/t/lib/FakeAPI.pm +++ b/t/lib/FakeAPI.pm @@ -1,14 +1,31 @@ package FakeAPI; use Moose; use MooseX::Net::API; +use LWP::UserAgent; +use HTTP::Response; +use JSON::XS; net_api_declare demorest => ( - base_url => 'http://lumberjaph.net/demorest/rest', + base_url => "http://example.com/", format => 'json', format_mode => 'content-type', authentication => 0, username => 'foo', password => 'bar', + useragent => sub { + my ($self) = @_; + my $ua = LWP::UserAgent->new(); + $ua->add_handler( + request_send => sub { + my $request = shift; + my $res = HTTP::Response->new(200, 'OK'); + $res->header('content-type' => 'application/json'); + $res->content(encode_json {status => 1}); + return $res; + } + ); + return $ua; + }, ); net_api_method users => ( @@ -52,7 +69,8 @@ net_api_method delete_user => ( ); net_api_method auth_get_user => ( - description => 'fetch information about a specific user with authentication', + description => + 'fetch information about a specific user with authentication', method => 'GET', path => '/auth_user/$id', params => [qw/id/], |