Issue a new token for a public client
Change-Id: Id44501d46aff4fd540339c0b2901879ab8a77734
diff --git a/t/server/mock.pl b/t/server/mock.pl
index 31bd494..21b938f 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -18,9 +18,11 @@
'access_token' => "4dcf8784ccfd26fac9bdb82778fe60e2",
'refresh_token' => "hlWci75xb8atDiq3924NUSvOdtAh7Nlf9z",
'access_token_2' => "abcde",
+ 'access_token_3' => 'jvgjbvjgzucgdwuiKHJK',
'refresh_token_2' => "fghijk",
'new_client_id' => 'fCBbQkA2NDA3MzM1Yw==',
'new_client_secret' => 'KUMaFxs6R1WGud4HM22w3HbmYKHMnNHIiLJ2ihaWtB4N5JxGzZgyqs5GTLutrORj',
+ 'auth_token_1' => 'mscajfdghnjdfshtkjcuynxahgz5il'
);
helper get_token => sub {
@@ -461,6 +463,21 @@
);
}
+ # Get auth_token_1
+ elsif ($grant_type eq 'authorization_code') {
+ if ($c->param('code') eq $tokens{auth_token_1}) {
+ return $c->render(
+ status => 200,
+ json => {
+ "access_token" => $tokens{access_token_3},
+ "expires_in" => 31536000,
+ "scope" => 'match_info search openid',
+ "token_type" => "Bearer"
+ }
+ );
+ };
+ }
+
# Unknown token grant
else {
return $c->render(
@@ -580,6 +597,23 @@
);
};
+post '/v1.0/oauth2/authorize' => sub {
+ my $c = shift;
+ my $type = $c->param('response_type');
+ my $client_id = $c->param('client_id');
+ my $redirect_uri = $c->param('redirect_uri');
+
+ if ($type eq 'code') {
+
+ return $c->redirect_to(
+ Mojo::URL->new($redirect_uri)->query({
+ code => $tokens{auth_token_1},
+ scope => 'match_info search openid'
+ })
+ );
+ }
+};
+
app->start;