Added description and URL to list-authorized-clients service (close #53)

Change-Id: I161d357e3c438817456f7cb6fae54e5c6da029e5


Change-Id: Iada426803ebc8964ecdb84d0a4e4c1ce96b22f30
diff --git a/full/Changes b/full/Changes
index 6a8b188..257ee98 100644
--- a/full/Changes
+++ b/full/Changes
@@ -13,7 +13,9 @@
      (margaretha, resolved #35)  
 13/11/2019
    - Added tests for issue #43 (margaretha)
-     
+14/11/2019
+   - Added client description and URL to list-authorized-clients service 
+     (margaretha, close #53)     
 
 # version 0.62.1
 08/07/2019
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2ClientInfoDto.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2ClientInfoDto.java
index 3970c8d..018cf38 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2ClientInfoDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2ClientInfoDto.java
@@ -18,7 +18,7 @@
     private String name;
     private String description;
     private String isSuper;
-    private String redirectURI;
+    private String url;
     private String registeredBy;
     private OAuth2ClientType type;
 
@@ -27,7 +27,7 @@
         this.name = client.getName();
         this.description = client.getDescription();
         this.setType(client.getType());
-        this.redirectURI = client.getRedirectURI();
+        this.url = client.getUrl();
         this.registeredBy = client.getRegisteredBy();
 
         if (client.isSuper()) {
@@ -67,12 +67,12 @@
         this.isSuper = isSuper;
     }
 
-    public String getRedirectURI () {
-        return redirectURI;
+    public String getUrl () {
+        return url;
     }
 
-    public void setRedirectURI (String redirectURI) {
-        this.redirectURI = redirectURI;
+    public void setUrl (String url) {
+        this.url = url;
     }
 
     public String getRegisteredBy () {
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2UserClientDto.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2UserClientDto.java
index 3fa44b5..64d88cc 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2UserClientDto.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/dto/OAuth2UserClientDto.java
@@ -9,6 +9,8 @@
     
     private String clientId;
     private String clientName;
+    private String description;
+    private String url;
     
     public String getClientName () {
         return clientName;
@@ -22,4 +24,16 @@
     public void setClientId (String clientId) {
         this.clientId = clientId;
     }
+    public String getDescription () {
+        return description;
+    }
+    public void setDescription (String description) {
+        this.description = description;
+    }
+    public String getUrl () {
+        return url;
+    }
+    public void setUrl (String url) {
+        this.url = url;
+    }
 }
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
index fb7e5ea..9bf6259 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
@@ -367,6 +367,8 @@
             OAuth2UserClientDto dto = new OAuth2UserClientDto();
             dto.setClientId(uc.getId());
             dto.setClientName(uc.getName());
+            dto.setDescription(uc.getDescription());
+            dto.setUrl(uc.getUrl());
             dtoList.add(dto);
         }
         return dtoList;
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java
index 7fc6077..69cb4e0 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java
@@ -211,7 +211,7 @@
     }
 
     @GET
-    @Path("info/{client_id}")
+    @Path("{client_id}")
     @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
     public OAuth2ClientInfoDto retrieveClientInfo (
             @Context SecurityContext securityContext,
@@ -240,6 +240,10 @@
      * user and client authentications.
      * 
      * @param context
+     * @param clientId
+     *            the client id of the super client
+     * @param clientSecret
+     *            the client secret of the super client
      * @return a list of clients having refresh tokens of the
      *         given user
      */
@@ -248,7 +252,7 @@
     @ResourceFilters({ AuthenticationFilter.class, BlockingFilter.class })
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
-    public List<OAuth2UserClientDto> listUserApp (
+    public List<OAuth2UserClientDto> listUserAuthorizedClients (
             @Context SecurityContext context,
             @FormParam("client_id") String clientId,
             @FormParam("client_secret") String clientSecret) {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
index f56292e..827684e 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
@@ -80,7 +80,7 @@
             throws UniformInterfaceException, ClientHandlerException,
             KustvaktException {
         ClientResponse response = resource().path(API_VERSION).path("oauth2")
-                .path("client").path("info").path(clientId)
+                .path("client").path(clientId)
                 .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
                         .createBasicAuthorizationHeaderValue(username, "pass"))
                 .get(ClientResponse.class);
@@ -98,14 +98,14 @@
         assertEquals(publicClientId, clientInfo.at("/id").asText());
         assertEquals("third party client", clientInfo.at("/name").asText());
         assertNotNull(clientInfo.at("/description"));
-        assertNotNull(clientInfo.at("/redirectURI"));
+        assertNotNull(clientInfo.at("/url"));
         assertEquals("PUBLIC", clientInfo.at("/type").asText());
 
         // confidential client
         clientInfo = retrieveClientInfo(confidentialClientId, "system");
         assertEquals(confidentialClientId, clientInfo.at("/id").asText());
         assertEquals("non super confidential client", clientInfo.at("/name").asText());
-        assertNotNull(clientInfo.at("/redirectURI"));
+        assertNotNull(clientInfo.at("/url"));
         assertEquals(false,clientInfo.at("/isSuper").asBoolean());
         assertEquals("CONFIDENTIAL", clientInfo.at("/type").asText());
         
@@ -113,7 +113,7 @@
         clientInfo = retrieveClientInfo(superClientId, "system");
         assertEquals(superClientId, clientInfo.at("/id").asText());
         assertEquals("super confidential client", clientInfo.at("/name").asText());
-        assertNotNull(clientInfo.at("/redirectURI"));
+        assertNotNull(clientInfo.at("/url"));
         assertEquals("CONFIDENTIAL", clientInfo.at("/type").asText());
         assertTrue(clientInfo.at("/isSuper").asBoolean());
     }
@@ -263,7 +263,7 @@
                         .createBasicAuthorizationHeaderValue(username, "pass"))
                 .delete(ClientResponse.class);
 
-        assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
+        assertEquals(Status.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatus());
     }
 
     private void testDeregisterPublicClient (String clientId)