Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my $t = Test::Mojo->new("MyApp");
- my $auth = "Basic " . encode_base64("$u:$p");
- $t->ua->on(start => sub {
- my ($ua, $tx) = @_;
- $tx->req->headers->accept("application/json");
- $tx->req->headers->content_type("application/json");
- $tx->req->headers->authorization($auth);
- $tx->req->headers->header("X-token" => 1);
- }
- );
- $t->get_ok("/api/plugins")
- ->status_is(200)
- ->json_is('/success', 1)
- ->json_has('/data/0/id')
- ->json_has('/data/0/name');
- my $id = $t->tx->res->json->{data}->[0]->{id};
- $t->get_ok("/api/plugin?id=$id")
- ->status_is(200)
- ->json_is('/success', 1)
- ->json_has('/data/id')
- ->json_has('/data/name');
- done_testing;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement