blob: 59794ca5e4cd1345671b3f338445cee72070125d (
plain)
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
|
use lib '.';
use t::Helper;
my $app = t::Helper->make_app;
my $t = Test::Mojo->new($app);
Mojo::Util::monkey_patch('Mojolicious::Plugin::OAuth2', _ua => sub { $t->ua });
$app->routes->get(
'/oauth-error' => sub {
my $c = shift;
$c->oauth2->get_token_p('test')->then(
sub {
return unless my $provider_res = shift;
return $c->render(text => "Token $provider_res->{access_token}");
}
)->catch(
sub {
return $c->render(text => shift, status => 500);
}
);
}
);
$t->get_ok('/oauth-error')->status_is(302); # ->content_like(qr/bar/);
$t->get_ok('/oauth-error?code=123')->status_is(200);
$t->get_ok('/oauth-error?error=access_denied')->status_is(500);
done_testing;
|