Skip to content

Commit

Permalink
more advanced authentication example for Test::Mojo
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 1, 2013
1 parent b89f57d commit 88171ad
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/Test/Mojo.pm
Expand Up @@ -463,17 +463,18 @@ User agent used for testing, defaults to a L<Mojo::UserAgent> object.
# Allow redirects
$t->ua->max_redirects(10);
# Use absolute URL for request with Basic authentication
my $url = $t->ua->app_url->userinfo('sri:secr3t')->path('/secrets.json');
$t->post_ok($url => json => {limit => 10})
->status_is(200)
->json_is('/1/content', 'Mojo rocks!');
# Customize all transactions (including followed redirects)
$t->ua->on(start => sub {
my ($ua, $tx) = @_;
$tx->req->headers->accept_language('en-US');
});
# Use absolute URL for request with Basic authentication
$t->get_ok($t->ua->app_url->userinfo('sri:secr3t')->path('/secrets.json'))
->status_is(200)
->json_is('/1/content', 'Mojo rocks!');
=head1 METHODS
L<Test::Mojo> inherits all methods from L<Mojo::Base> and implements the
Expand Down

0 comments on commit 88171ad

Please sign in to comment.