Marketplace: List plugins

Change-Id: I3bd0d0f1db8224cbfe7efd255eb99d7cd54faf11
diff --git a/t/server/mock.pl b/t/server/mock.pl
index e615306..af03832 100644
--- a/t/server/mock.pl
+++ b/t/server/mock.pl
@@ -57,6 +57,13 @@
   push @$list, $client;
 };
 
+# Add plugin to plugin list for marketplace
+helper 'add_plugin' => sub {
+  my $c = shift;
+  my $cplugin = shift;
+  my $pl_list = $c->app->defaults('oauth.plugin_list');
+  push @$pl_list, $cplugin;
+};
 
 # Load fixture responses
 helper 'load_response' => sub {
@@ -89,6 +96,7 @@
 };
 
 app->defaults('oauth.client_list' => []);
+app->defaults('oauth.plugin_list' => []);
 
 
 # Base page
@@ -552,9 +560,8 @@
   });
 };
 
-
-# Register a client
-post '/v1.0/oauth2/client/list' => sub {
+# List plugins
+post '/v1.0/plugins' => sub {
   my $c = shift;
 
   my $v = $c->validation;
@@ -568,6 +575,48 @@
       status => 400
     );
   };
+  
+  my $p;
+  if($c->param("permitted_only")){
+    $p = $c->param("permitted_only");
+  }
+  else{
+    $p="false";
+  }
+
+  #Mocks the return only of permitted plugins
+  if($p eq "true"){
+    my @p_plugin_list = grep{$_->{permitted} eq "true"}  @{$c->stash('oauth.plugin_list')};
+    my $listref = \@p_plugin_list;
+    return $c->render(
+      json => $listref,
+      status => 200
+    );
+  }
+  else{
+  return $c->render(
+   json => $c->stash('oauth.plugin_list'),
+    status => 200
+  );
+  }
+
+};
+
+# Register a client
+post '/v1.0/oauth2/client/list' => sub {
+  my $c = shift;
+
+  my $v = $c->validation;
+  $v->required('super_client_id');
+  $v->required('super_client_secret');
+
+  if ($v->has_error) {
+    return $c->render(
+      json => [],
+      status => 400
+    );
+  };
+
 
   # $c->param('client_secret');