Advertisement
Guest User

Untitled

a guest
Apr 30th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.71 KB | None | 0 0
  1. my $t = Test::Mojo->new("MyApp");
  2.  
  3. my $auth = "Basic " . encode_base64("$u:$p");
  4. $t->ua->on(start => sub {
  5.         my ($ua, $tx) = @_;
  6.         $tx->req->headers->accept("application/json");
  7.         $tx->req->headers->content_type("application/json");
  8.         $tx->req->headers->authorization($auth);
  9.         $tx->req->headers->header("X-token" => 1);
  10.     }
  11. );
  12. $t->get_ok("/api/plugins")
  13.     ->status_is(200)
  14.     ->json_is('/success', 1)
  15.     ->json_has('/data/0/id')
  16.     ->json_has('/data/0/name');
  17.  
  18. my $id = $t->tx->res->json->{data}->[0]->{id};
  19.  
  20. $t->get_ok("/api/plugin?id=$id")
  21.     ->status_is(200)
  22.     ->json_is('/success', 1)
  23.     ->json_has('/data/id')
  24.     ->json_has('/data/name');
  25.  
  26. done_testing;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement