Show source code of registered plugins

Change-Id: I8ddc6b59fe3dbff068a23c4aca6d17181a881a2e
diff --git a/t/plugin/auth-oauth.t b/t/plugin/auth-oauth.t
index 80afe05..45281df 100644
--- a/t/plugin/auth-oauth.t
+++ b/t/plugin/auth-oauth.t
@@ -494,7 +494,7 @@
 $csrf = $t->post_ok('/settings/oauth/register' => form => {
   name => 'MyApp',
   type => 'PUBLIC',
-  desc => 'This is my application'
+  desc => 'This is my plugin application'
 })
   ->text_is('div.notify-error', 'Bad CSRF token')
   ->tx->res->dom->at('input[name="csrf_token"]')
@@ -504,7 +504,7 @@
 $t->post_ok('/settings/oauth/register' => form => {
   name => 'MyApp',
   type => 'CONFIDENTIAL',
-  desc => 'This is my application',
+  desc => 'This is my plugin application',
   csrf_token => $csrf,
   src => {
     filename => '',
@@ -526,7 +526,7 @@
   ->text_is('.form-table legend', 'Register new client application')
   ->attr_is('.oauth-register','action', '/settings/oauth/register')
   ->text_is('ul.client-list > li > span.client-name a', 'MyApp')
-  ->text_is('ul.client-list > li > p.client-desc', 'This is my application')
+  ->text_is('ul.client-list > li > p.client-desc', 'This is my plugin application')
   ->header_is('Cache-Control','max-age=0, no-cache, no-store, must-revalidate')
   ->header_is('Expires','Thu, 01 Jan 1970 00:00:00 GMT')
   ->header_is('Pragma','no-cache')
@@ -537,7 +537,7 @@
 $t->get_ok('/settings/oauth/fCBbQkA2NDA3MzM1Yw==')
   ->status_is(200)
   ->text_is('ul.client-list > li.client > span.client-name', 'MyApp')
-  ->text_is('ul.client-list > li.client > p.client-desc', 'This is my application')
+  ->text_is('ul.client-list > li.client > p.client-desc', 'This is my plugin application')
   ->text_is('a.client-unregister', 'Unregister')
   ->attr_is('a.client-unregister', 'href', '/settings/oauth/fCBbQkA2NDA3MzM1Yw==/unregister?name=MyApp')
   ;
@@ -591,7 +591,7 @@
 $t->post_ok('/settings/oauth/register' => form => {
   name => 'MyApp2',
   type => 'PUBLIC',
-  desc => 'This is my application',
+  desc => 'This is my plugin application',
   csrf_token => $csrf
 })->status_is(200)
   ->element_exists('div.notify-success')
@@ -607,7 +607,7 @@
 
 $t->get_ok('/settings/oauth/fCBbQkA2NDA3MzM1Yw==')
   ->text_is('.client-name', 'MyApp2')
-  ->text_is('.client-desc', 'This is my application')
+  ->text_is('.client-desc', 'This is my plugin application')
   ->text_is('.client-issue-token', 'Issue new token')
   ->attr_is('.client-issue-token', 'href', '/settings/oauth/fCBbQkA2NDA3MzM1Yw==/token?name=MyApp2')
   ->header_is('Cache-Control','max-age=0, no-cache, no-store, must-revalidate')
@@ -725,7 +725,7 @@
 $csrf = $t->post_ok('/settings/oauth/register' => form => {
   name => 'MyConfApp',
   type => 'CONFIDENTIAL',
-  desc => 'This is my application',
+  desc => 'This is my plugin application',
 })
   ->text_is('div.notify-error', 'Bad CSRF token')
   ->tx->res->dom->at('input[name="csrf_token"]')
@@ -896,7 +896,7 @@
 my $json_post = {
   name => 'Funny',
   type => 'PUBLIC',
-  desc => 'This is my application',
+  desc => 'This is my plugin application 2',
   csrf_token => $csrf,
   src => 'hMMM'
 };
@@ -938,6 +938,15 @@
   ->text_is('div.notify-success', 'Registration successful')
   ;
 
+$t->get_ok('/settings/oauth/jh0gfjhjbfdsgzjghj==')
+  ->status_is(200)
+  ->text_is('div.notify-error', undef)
+  ->text_is('li.client #client_source', '{"name":"example"}')
+  ->text_is('li.client span.client-name', 'Funny')
+  ->text_is('li.client p.client-desc', 'This is my plugin application 2')
+  ->element_exists_not('li.client .client-redirect-uri tt')
+  ->text_is('li.client .client-type tt', 'CONFIDENTIAL')
+  ;
 
 
 done_testing;
diff --git a/t/server/mock.pl b/t/server/mock.pl
index 1f32a39..abc6846 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -22,6 +22,7 @@
   'refresh_token_2' => "fghijk",
   'new_client_id' => 'fCBbQkA2NDA3MzM1Yw==',
   'new_client_id_2' => 'hghGHhjhFRz_gJhjrd==',
+  'new_client_id_3' => 'jh0gfjhjbfdsgzjghj==',
   'new_client_secret' => 'KUMaFxs6R1WGud4HM22w3HbmYKHMnNHIiLJ2ihaWtB4N5JxGzZgyqs5GTLutrORj',
   'auth_token_1'    => 'mscajfdghnjdfshtkjcuynxahgz5il'
 );
@@ -558,15 +559,23 @@
 
   my $list = $c->app->defaults('oauth.client_list');
 
-  push @$list, {
+  my $obj = {
     "client_id" => $tokens{new_client_id},
     "client_name" => $name,
     "client_description" => $desc,
     "client_url" => $url,
     "client_redirect_uri" => $redirect_uri,
-    "client_source" => $src
+    "client_type" => $type
   };
 
+  # Plugin!
+  if ($src) {
+    $obj->{source} = $src;
+    $obj->{client_id} = $tokens{new_client_id_3};
+  };
+
+  push @$list, $obj;
+
   if ($redirect_uri && $redirect_uri =~ /FAIL$/) {
     return $c->render(
       status => 400,