Implemented OpenId configuration.

Change-Id: I4e41a6072797742266d86c1709ad8941ae2c17f1
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java
index 98502ea..15d627f 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/AvailabilityTest.java
@@ -1,8 +1,8 @@
 package de.ids_mannheim.korap.web.controller;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -103,35 +103,6 @@
 
     }
 
-    private void checkAndAll (String json) throws KustvaktException {
-        JsonNode node = JsonUtils.readTree(json);
-        assertNotNull(node);
-        assertEquals("availability(ALL)",
-                node.at("/collection/rewrites/0/scope").asText());
-        assertEquals("operation:insertion",
-                node.at("/collection/rewrites/0/operation").asText());
-
-        assertEquals("operation:and",
-                node.at("/collection/operation").asText());
-
-        node = node.at("/collection/operands/0");
-        assertEquals("operation:or", node.at("/operation").asText());
-
-        assertEquals("match:eq", node.at("/operands/0/match").asText());
-        assertEquals("match:eq", node.at("/operands/0/match").asText());
-        assertEquals("type:regex", node.at("/operands/0/type").asText());
-        assertEquals("availability", node.at("/operands/0/key").asText());
-        assertEquals("CC-BY.*", node.at("/operands/0/value").asText());
-
-        node = node.at("/operands/1");
-        assertEquals("operation:or", node.at("/operation").asText());
-        assertEquals("match:eq", node.at("/operands/0/match").asText());
-        assertEquals("ACA.*", node.at("/operands/0/value").asText());
-        assertEquals("match:eq", node.at("/operands/1/match").asText());
-        assertEquals("QAO.*", node.at("/operands/1/value").asText());
-
-    }
-
     private void checkAndAllWithACA (String json) throws KustvaktException {
         JsonNode node = JsonUtils.readTree(json);
         assertNotNull(node);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
index 97efe8d..497218c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ControllerTest.java
@@ -171,7 +171,7 @@
         MultivaluedMap<String, String> authForm = new MultivaluedMapImpl();
         authForm.add("response_type", "code");
         authForm.add("client_id", "fCBbQkAyYzI4NzUxMg");
-        authForm.add("scope", "read_username");
+        authForm.add("scope", "username");
 
         ClientResponse response =
                 requestAuthorizationConfidentialClient(authForm);
@@ -181,7 +181,7 @@
         String code = params.get("code").get(0);
         String scopes = params.get("scope").get(0);
 
-        assertEquals(scopes, "read_username");
+        assertEquals(scopes, "username");
 
         MultivaluedMap<String, String> tokenForm = new MultivaluedMapImpl();
         tokenForm.add("grant_type", "authorization_code");
@@ -241,7 +241,7 @@
         MultivaluedMap<String, String> authForm = new MultivaluedMapImpl();
         authForm.add("response_type", "code");
         authForm.add("client_id", "fCBbQkAyYzI4NzUxMg");
-        authForm.add("scope", "read_username");
+        authForm.add("scope", "username");
         authForm.add("redirect_uri", uri);
 
         ClientResponse response =
@@ -437,7 +437,7 @@
         form.add("grant_type", "client_credentials");
         form.add("client_id", "fCBbQkAyYzI4NzUxMg");
         form.add("client_secret", "secret");
-        form.add("scope", "read_username read_client_info");
+        form.add("scope", "preferred_username client_info");
 
         ClientResponse response = requestToken(form);
         String entity = response.getEntity(String.class);
@@ -450,7 +450,7 @@
         assertEquals(TokenType.BEARER.toString(),
                 node.at("/token_type").asText());
         assertNotNull(node.at("/expires_in").asText());
-        assertEquals("read_client_info", node.at("/scope").asText());
+        assertEquals("client_info", node.at("/scope").asText());
     }
 
     @Test
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java
index 5459c6d..6594fdd 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2OpenIdControllerTest.java
@@ -316,7 +316,7 @@
     @Test
     public void testPublicKeyAPI () throws KustvaktException {
         ClientResponse response = resource().path("oauth2").path("openid")
-                .path("key").path("public").get(ClientResponse.class);
+                .path("jwks").get(ClientResponse.class);
         String entity = response.getEntity(String.class);
         JsonNode node = JsonUtils.readTree(entity);
         assertEquals(1,node.at("/keys").size());
@@ -326,4 +326,18 @@
         assertNotNull(node.at("/e").asText());
         assertNotNull(node.at("/n").asText());
     }
+ 
+    @Test
+    public void testOpenIDConfiguration () throws KustvaktException {
+        ClientResponse response = resource().path("oauth2").path("openid")
+                .path("config").get(ClientResponse.class);
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+        assertNotNull(node.at("/issuer"));
+        assertNotNull(node.at("/authorization_endpoint"));
+        assertNotNull(node.at("/token_endpoint"));
+        assertNotNull(node.at("/response_types_supported"));
+        assertNotNull(node.at("/subject_types_supported"));
+        assertNotNull(node.at("/id_token_signing_alg_values_supported"));
+    }
 }
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
index e96e523..fa40e73 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/ResourceInfoControllerTest.java
@@ -14,7 +14,6 @@
 
 import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
 import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.constant.TokenType;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.web.FastJerseyTest;