Initial token management

Change-Id: I6177b46961b7a0e53b9fa1fa9430a4d5562ae2da
diff --git a/t/server/mock.pl b/t/server/mock.pl
index a1f0596..21192f0 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -15,10 +15,12 @@
 my $fixture_path = path(Mojo::File->new(__FILE__)->dirname)->child('..', 'fixtures');
 
 our %tokens = (
-  "access_token"    => "4dcf8784ccfd26fac9bdb82778fe60e2",
-  "refresh_token"   => "hlWci75xb8atDiq3924NUSvOdtAh7Nlf9z",
-  "access_token_2"  => "abcde",
-  "refresh_token_2" => "fghijk"
+  'access_token'    => "4dcf8784ccfd26fac9bdb82778fe60e2",
+  'refresh_token'   => "hlWci75xb8atDiq3924NUSvOdtAh7Nlf9z",
+  'access_token_2'  => "abcde",
+  'refresh_token_2' => "fghijk",
+  'new_client_id' => 'fCBbQkA2NDA3MzM1Yw==',
+  'new_client_secret' => 'KUMaFxs6R1WGud4HM22w3HbmYKHMnNHIiLJ2ihaWtB4N5JxGzZgyqs5GTLutrORj',
 );
 
 helper get_token => sub {
@@ -487,6 +489,31 @@
   )
 };
 
+# Register a client
+post '/v1.0/oauth2/client/register' => sub {
+  my $c = shift;
+  my $json = $c->req->json;
+
+  my $name = $json->{name};
+  my $desc = $json->{desc};
+  my $type = $json->{type};
+  my $url  = $json->{url};
+  my $redirect_url = $json->{redirectURI};
+
+  # Confidential server application
+  if ($type eq 'CONFIDENTIAL') {
+    return $c->render(json => {
+      client_id => $tokens{new_client_id},
+      client_secret => $tokens{new_client_secret}
+    });
+  };
+
+  # Desktop application
+  return $c->render(json => {
+    client_id => $tokens{new_client_id}
+  });
+};
+
 
 app->start;