Added support for public metadata response in the search api.

Change-Id: Ic6297c192c813520d1c83c1a35d2206059eadb8e
diff --git a/core/Changes b/core/Changes
index 62aa351..5051644 100644
--- a/core/Changes
+++ b/core/Changes
@@ -1,3 +1,10 @@
+# version 0.62.1
+08/07/2019
+   - Added support for public metadata response in search api (margaretha, 
+     issue #43)
+   - Disabled some unused web-services: search post, query serialization, 
+     collocation base (margaretha)
+
 # version 0.62
 18/03/2019
    - Added close index controller (margaretha)
diff --git a/core/pom.xml b/core/pom.xml
index ae28c9c..a3c9da7 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-core</artifactId>
-	<version>0.62</version>
+	<version>0.62.1</version>
 
 	<properties>
 		<java.version>1.8</java.version>
diff --git a/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java b/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
index 5d3953f..35f3547 100644
--- a/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
+++ b/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
@@ -16,6 +16,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.core.util.MultivaluedMapImpl;
 
 import de.ids_mannheim.de.init.VCLoader;
@@ -28,6 +29,7 @@
 import de.ids_mannheim.korap.rewrite.RewriteHandler;
 import de.ids_mannheim.korap.user.User;
 import de.ids_mannheim.korap.user.User.CorpusAccess;
+import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.web.ClientsHandler;
 import de.ids_mannheim.korap.web.SearchKrill;
 
@@ -62,7 +64,8 @@
     @SuppressWarnings("unchecked")
     public String serializeQuery (String q, String ql, String v, String cq,
             Integer pageIndex, Integer startPage, Integer pageLength,
-            String context, Boolean cutoff) throws KustvaktException {
+            String context, Boolean cutoff, boolean accessRewriteDisabled)
+            throws KustvaktException {
         QuerySerializer ss = new QuerySerializer().setQuery(q, ql, v);
         if (cq != null) ss.setCollection(cq);
 
@@ -88,38 +91,56 @@
         authenticationManager.setAccessAndLocation(user, headers);
         if (DEBUG) {
             if (user != null) {
-                jlog.debug("Debug: /getMatchInfo/: location="
-                        + user.locationtoString() + ", access="
-                        + user.accesstoString());
+                jlog.debug("Debug: user location=" + user.locationtoString()
+                        + ", access=" + user.accesstoString());
             }
         }
         return user;
     }
 
-    public String search (String jsonld) {
+    public String search (String jsonld, String username, HttpHeaders headers)
+            throws KustvaktException {
+
+        User user = createUser(username, headers);
+
+        JsonNode node  = JsonUtils.readTree(jsonld);
+        node = node.at("/meta/snippets");
+        if (node !=null && node.asBoolean()){
+            user.setCorpusAccess(CorpusAccess.ALL);
+        }
+        
+        String query = this.rewriteHandler.processQuery(jsonld, user);
         // MH: todo: should be possible to add the meta part to
         // the query serialization
         // User user = controller.getUser(ctx.getUsername());
         // jsonld = this.processor.processQuery(jsonld, user);
-        return searchKrill.search(jsonld);
+        return searchKrill.search(query);
     }
 
     @SuppressWarnings("unchecked")
     public String search (String engine, String username, HttpHeaders headers,
             String q, String ql, String v, String cq, String fields,
             Integer pageIndex, Integer pageInteger, String ctx,
-            Integer pageLength, Boolean cutoff) throws KustvaktException {
+            Integer pageLength, Boolean cutoff, boolean accessRewriteDisabled)
+            throws KustvaktException {
 
         KustvaktConfiguration.BACKENDS eng = this.config.chooseBackend(engine);
         User user = createUser(username, headers);
         CorpusAccess corpusAccess = user.getCorpusAccess();
         
+        // EM: TODO: check if requested fields are public metadata. Currently 
+        // it is not needed because all metadata are public.        
+        if (accessRewriteDisabled){
+            corpusAccess = CorpusAccess.ALL;
+            user.setCorpusAccess(CorpusAccess.ALL);
+        }
+            
         QuerySerializer serializer = new QuerySerializer();
         serializer.setQuery(q, ql, v);
         if (cq != null) serializer.setCollection(cq);
 
         MetaQueryBuilder meta = createMetaQuery(pageIndex, pageInteger, ctx,
-                pageLength, cutoff, corpusAccess, fields);
+                pageLength, cutoff, corpusAccess, fields, accessRewriteDisabled);
         serializer.setMeta(meta.raw());
 
         // There is an error in query processing
@@ -148,7 +169,8 @@
 
     private MetaQueryBuilder createMetaQuery (Integer pageIndex,
             Integer pageInteger, String ctx, Integer pageLength,
-            Boolean cutoff, CorpusAccess corpusAccess, String fields) {
+            Boolean cutoff, CorpusAccess corpusAccess, String fields,
+            boolean accessRewriteDisabled) {
         MetaQueryBuilder meta = new MetaQueryBuilder();
         meta.addEntry("startIndex", pageIndex);
         meta.addEntry("startPage", pageInteger);
@@ -156,6 +178,7 @@
         meta.addEntry("count", pageLength);
         // todo: what happened to cutoff?
         meta.addEntry("cutOff", cutoff);
+        meta.addEntry("snippets", !accessRewriteDisabled);
         // meta.addMeta(pageIndex, pageInteger, pageLength, ctx,
         // cutoff);
         // fixme: should only apply to CQL queries per default!
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
index ef3b16b..8ccb8f1 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
@@ -6,6 +6,7 @@
 import java.util.Set;
 
 import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -41,7 +42,7 @@
  * 
  * @author hanl, margaretha, diewald
  * @date 29/01/2014
- * @lastUpdate 09/07/2018
+ * @lastUpdate 05/07/2019
  * 
  */
 @Controller
@@ -77,31 +78,13 @@
     }
     
     
-    /**
-     * Builds a json query serialization from the given parameters.
-     * 
-     * @param locale
-     * @param securityContext
-     * @param q
-     *            query string
-     * @param ql
-     *            query language
-     * @param v
-     *            version
-     * @param context
-     * @param cutoff
-     *            true if the number of results should be limited
-     * @param pageLength
-     *            number of results per page
-     * @param pageIndex
-     * @param startPage
-     * @param cq
-     *            corpus query
-     * @return
-     */
-    // ref query parameter removed!
-    @GET
-    @Path("{version}/query")
+//     EM: This web service is DISABLED until there is a need for it.
+//     ND: In case rewrite is supported, it could be used to check the authorization 
+//         scope without searching etc. In case not, it helps to compare queries in 
+//         different query languages.
+//     MH: ref query parameter removed!
+//    @GET
+//    @Path("{version}/query")
     public Response serializeQuery (@Context Locale locale,
             @Context SecurityContext securityContext, @QueryParam("q") String q,
             @QueryParam("ql") String ql, @QueryParam("v") String v,
@@ -110,12 +93,14 @@
             @QueryParam("count") Integer pageLength,
             @QueryParam("offset") Integer pageIndex,
             @QueryParam("page") Integer startPage,
+            @QueryParam("access-rewrite-disabled") boolean accessRewriteDisabled,
             @QueryParam("cq") String cq) {
         TokenContext ctx = (TokenContext) securityContext.getUserPrincipal();
         try {
             scopeService.verifyScope(ctx, OAuth2Scope.SERIALIZE_QUERY);
             String result = searchService.serializeQuery(q, ql, v, cq,
-                    pageIndex, startPage, pageLength, context, cutoff);
+                    pageIndex, startPage, pageLength, context, cutoff,
+                    accessRewriteDisabled);
             if (DEBUG){
                 jlog.debug("Query: " + result);
             }
@@ -126,32 +111,35 @@
         }
     }
 
-    @POST
-    @Path("{version}/search")
+    
+//    This web service is DISABLED until there is a need for it. 
+//    @POST
+//    @Path("{version}/search")
     public Response searchPost (@Context SecurityContext context,
-            @Context Locale locale, @QueryParam("engine") String engine,
+            @Context Locale locale, 
+            @Context HttpHeaders headers,
             String jsonld) {
+        
+        if (DEBUG){
+            jlog.debug("Serialized search: " + jsonld);
+        }
+        
         TokenContext ctx = (TokenContext) context.getUserPrincipal();
         try {
             scopeService.verifyScope(ctx, OAuth2Scope.SEARCH);
+            String result = searchService.search(jsonld, ctx.getUsername(),
+                    headers);
+            return Response.ok(result).build();
         }
         catch (KustvaktException e) {
             throw kustvaktResponseHandler.throwit(e);
         }
-
-        if (DEBUG){
-            jlog.debug("Serialized search: " + jsonld);
-        }
-        String result = searchService.search(jsonld);
-        if (DEBUG){
-            jlog.debug("The result set: " + result);
-        }
-        return Response.ok(result).build();
     }
 
     @GET
     @Path("{version}/search")
     public Response searchGet (@Context SecurityContext securityContext,
+            @Context HttpServletRequest request,
             @Context HttpHeaders headers, @Context Locale locale,
             @QueryParam("q") String q, @QueryParam("ql") String ql,
             @QueryParam("v") String v, @QueryParam("context") String ctx,
@@ -160,7 +148,9 @@
             @QueryParam("offset") Integer pageIndex,
             @QueryParam("page") Integer pageInteger,
             @QueryParam("fields") String fields,
-            @QueryParam("cq") String cq, @QueryParam("engine") String engine) {
+            @QueryParam("access-rewrite-disabled") boolean accessRewriteDisabled,
+            @QueryParam("cq") String cq, 
+            @QueryParam("engine") String engine) {
 
         TokenContext context =
                 (TokenContext) securityContext.getUserPrincipal();
@@ -170,7 +160,7 @@
             scopeService.verifyScope(context, OAuth2Scope.SEARCH);
             result = searchService.search(engine, context.getUsername(),
                     headers, q, ql, v, cq, fields, pageIndex, pageInteger, ctx,
-                    pageLength, cutoff);
+                    pageLength, cutoff, accessRewriteDisabled);
         }
         catch (KustvaktException e) {
             throw kustvaktResponseHandler.throwit(e);
@@ -257,8 +247,9 @@
         }
     }
 
-    @POST
-    @Path("{version}/colloc")
+//  EM: This web service requires Karang and is DISABLED.
+//    @POST
+//    @Path("{version}/colloc")
     public Response getCollocationBase (@QueryParam("q") String query) {
         String result;
         try {
diff --git a/full/Changes b/full/Changes
index 36a4c52..82ff399 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,3 +1,8 @@
+# version 0.62.1
+08/07/2019
+   - Added tests for public metadata response in search api (margaretha, issue #43)
+   - Disabled some tests of unused/disabled web-services (margaretha)
+
 # version 0.62
 28/02/2019
    - Removed old VC controllers and updated tests (margaretha, issue #34)
diff --git a/full/pom.xml b/full/pom.xml
index ea825bc..87b0b74 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-full</artifactId>
-	<version>0.62</version>
+	<version>0.62.1</version>
 	<properties>
 		<java.version>1.8</java.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -205,7 +205,7 @@
 		<dependency>
 			<groupId>de.ids_mannheim.korap</groupId>
 			<artifactId>Kustvakt-core</artifactId>
-			<version>[0.62,)</version>
+			<version>[0.62.1,)</version>
 		</dependency>
 		<!-- LDAP -->
 		<dependency>
diff --git a/full/src/main/resources/ehcache.xml b/full/src/main/resources/ehcache.xml
index 27a4b56..2531fdb 100644
--- a/full/src/main/resources/ehcache.xml
+++ b/full/src/main/resources/ehcache.xml
@@ -1,6 +1,7 @@
 <ehcache xsi:noNamespaceSchemaLocation="http://www.ehcache.org/ehcache.xsd"
 	updateCheck="true" monitoring="autodetect" dynamicConfig="true">
 	
+	<sizeOfPolicy maxDepth="100" maxDepthExceededBehavior="abort" />
     <defaultCache eternal='true' overflowToDisk='false'/>
     <!--maxBytesLocalHeap="200M"-->
     <diskStore path="./cache_store"/>
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/PublicMetadataTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/PublicMetadataTest.java
new file mode 100644
index 0000000..5412949
--- /dev/null
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/PublicMetadataTest.java
@@ -0,0 +1,133 @@
+package de.ids_mannheim.korap.web.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.net.HttpHeaders;
+import com.sun.jersey.api.client.ClientResponse;
+
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
+import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.utils.JsonUtils;
+
+public class PublicMetadataTest extends SpringJerseyTest {
+
+    @Test
+    public void testSearchPublicMetadata () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .queryParam("q", "Sonne").queryParam("ql", "poliqarp")
+                .queryParam("access-rewrite-disabled", "true")
+                .get(ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+        
+        assertEquals("availability(ALL)",
+                node.at("/collection/rewrites/0/scope").asText());
+
+        assertTrue(node.at("/matches/0/snippet").isMissingNode());
+    }
+
+    @Test
+    public void testSearchPublicMetadataExtern () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .queryParam("q", "Sonne").queryParam("ql", "poliqarp")
+                .queryParam("access-rewrite-disabled", "true")
+                .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+                .get(ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+        
+        assertEquals("availability(ALL)",
+                node.at("/collection/rewrites/0/scope").asText());
+
+        assertTrue(node.at("/matches/0/snippet").isMissingNode());
+    }
+
+//  EM: The API is disabled
+    @Ignore
+    @Test
+    public void testSearchPostPublicMetadata () throws KustvaktException {
+        QuerySerializer s = new QuerySerializer();
+        s.setQuery("[orth=der]", "poliqarp");
+        s.setCollection("corpusSigle=GOE");
+        s.setQuery("Wasser", "poliqarp");
+        
+        MetaQueryBuilder meta = new MetaQueryBuilder();
+        meta.addEntry("snippets", "true");
+        s.setMeta(meta);
+        
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .post(ClientResponse.class, s.toJSON());
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String ent = response.getEntity(String.class);
+
+        JsonNode node = JsonUtils.readTree(ent);
+        assertEquals("availability(ALL)",
+                node.at("/collection/rewrites/0/scope").asText());
+        assertTrue(node.at("/matches/0/snippet").isMissingNode());
+    }
+    
+    @Test
+    public void testSearchPublicMetadataWithSystemVC ()
+            throws KustvaktException {
+
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .queryParam("q", "Sonne").queryParam("ql", "poliqarp")
+                .queryParam("cq", "referTo system-vc")
+                .queryParam("access-rewrite-disabled", "true")
+                .get(ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+
+        assertEquals("operation:and",
+                node.at("/collection/operation").asText());
+        node = node.at("/collection/operands/1");
+        assertEquals("koral:doc", node.at("/@type").asText());
+        assertEquals("GOE", node.at("/value").asText());
+        assertEquals("match:eq", node.at("/match").asText());
+        assertEquals("corpusSigle", node.at("/key").asText());
+
+        assertEquals("operation:deletion",
+                node.at("/rewrites/0/operation").asText());
+        assertEquals("@type(koral:docGroupRef)",
+                node.at("/rewrites/0/scope").asText());
+
+        assertEquals("operation:deletion",
+                node.at("/rewrites/1/operation").asText());
+        assertEquals("ref(system-vc)", node.at("/rewrites/1/scope").asText());
+
+        assertEquals("operation:insertion",
+                node.at("/rewrites/2/operation").asText());
+    }
+
+    @Test
+    public void testSearchPublicMetadataWithPrivateVC ()
+            throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .queryParam("q", "Sonne").queryParam("ql", "poliqarp")
+                .queryParam("cq", "referTo \"dory/dory-vc\"")
+                .queryParam("access-rewrite-disabled", "true")
+                .get(ClientResponse.class);
+
+        String entity = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(entity);
+
+        assertEquals(StatusCodes.AUTHORIZATION_FAILED,
+                node.at("/errors/0/0").asInt());
+        assertEquals("guest", node.at("/errors/0/2").asText());
+    }
+}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java
index 483a059..cd35e86 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/QuerySerializationControllerTest.java
@@ -24,8 +24,8 @@
 import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.web.FastJerseyTest;
 
-/* EM: potentially an unused service! */
 
+// EM: The API is disabled
 @Ignore
 public class QuerySerializationControllerTest extends FastJerseyTest {
 
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
index 1fb3915..33b6729 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
@@ -42,6 +42,14 @@
         return node;
     }
     
+    private String createJsonQuery(){
+        QuerySerializer s = new QuerySerializer();
+        s.setQuery("[orth=der]", "poliqarp");
+        s.setCollection("corpusSigle=GOE");
+        s.setQuery("Wasser", "poliqarp");
+        return s.toJSON();
+    }
+    
     @Test
     public void testSearchWithField () throws KustvaktException {
         JsonNode node = requestSearchWithFields("author");
@@ -296,6 +304,8 @@
         assertNotEquals("${project.version}", "/meta/version");
     }
 
+//  EM: The API is disabled
+    @Ignore
     @Test
     public void testSearchSimpleCQL () throws KustvaktException {
         QuerySerializer s = new QuerySerializer();
@@ -313,16 +323,12 @@
         // assertEquals(17027, node.at("/meta/totalResults").asInt());
     }
 
+//  EM: The API is disabled
     @Test
+    @Ignore
     public void testSearchRawQuery () throws KustvaktException {
-        QuerySerializer s = new QuerySerializer();
-        s.setQuery("[orth=der]", "poliqarp");
-        s.setCollection("corpusSigle=GOE");
-
-        s.setQuery("Wasser", "poliqarp");
-        // System.out.println(s.toJSON());
         ClientResponse response = resource().path(API_VERSION).path("search")
-                .post(ClientResponse.class, s.toJSON());
+                .post(ClientResponse.class, createJsonQuery());
         assertEquals(ClientResponse.Status.OK.getStatusCode(),
                 response.getStatus());
         String ent = response.getEntity(String.class);
@@ -330,6 +336,54 @@
         JsonNode node = JsonUtils.readTree(ent);
         assertNotNull(node);
         assertNotEquals(0, node.path("matches").size());
-        // assertEquals(10993, node.at("/meta/totalResults").asInt());
+        
+        assertEquals("availability(FREE)",
+                node.at("/collection/rewrites/0/scope").asText());
+    }
+    
+//  EM: The API is disabled    
+    @Test
+    @Ignore
+    public void testSearchPostAll () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .header(HttpHeaders.X_FORWARDED_FOR, "10.27.0.32")
+                .header(Attributes.AUTHORIZATION,
+                        HttpAuthorizationHandler
+                                .createBasicAuthorizationHeaderValue("kustvakt",
+                                        "kustvakt2015"))
+                .post(ClientResponse.class, createJsonQuery());
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String ent = response.getEntity(String.class);
+
+        JsonNode node = JsonUtils.readTree(ent);
+        assertNotNull(node);
+        assertNotEquals(0, node.path("matches").size());
+        
+        assertEquals("availability(ALL)",
+                node.at("/collection/rewrites/0/scope").asText());
+    }
+    
+//  EM: The API is disabled
+    @Test
+    @Ignore
+    public void testSearchPostPublic () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+                .header(Attributes.AUTHORIZATION,
+                        HttpAuthorizationHandler
+                                .createBasicAuthorizationHeaderValue("kustvakt",
+                                        "kustvakt2015"))
+                .post(ClientResponse.class, createJsonQuery());
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String ent = response.getEntity(String.class);
+
+        JsonNode node = JsonUtils.readTree(ent);
+        assertNotNull(node);
+        assertNotEquals(0, node.path("matches").size());
+        
+        assertEquals("availability(PUB)",
+                node.at("/collection/rewrites/0/scope").asText());
     }
 }
diff --git a/lite/Changes b/lite/Changes
index 1bc17e8..5cc49c6 100644
--- a/lite/Changes
+++ b/lite/Changes
@@ -1,3 +1,8 @@
+# version 0.62.1
+08/07/2019
+   - Added tests for public metadata response in search api (margaretha, issue #43)
+   - Disabled some tests of unused/disabled web-services (margaretha)
+
 version 0.62
 19/03/2019
   - Added close index controller (margaretha)  
diff --git a/lite/pom.xml b/lite/pom.xml
index a830c0c..67d1421 100644
--- a/lite/pom.xml
+++ b/lite/pom.xml
@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>de.ids_mannheim.korap</groupId>
 	<artifactId>Kustvakt-lite</artifactId>
-	<version>0.62</version>
+	<version>0.62.1</version>
 	<properties>
 		<java.version>1.8</java.version>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -137,7 +137,7 @@
 		<dependency>
 			<groupId>de.ids_mannheim.korap</groupId>
 			<artifactId>Kustvakt-core</artifactId>
-			<version>[0.62,)</version>
+			<version>[0.62.1,)</version>
 		</dependency>
 		<!-- Jersey test framework -->
 		<dependency>
diff --git a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchControllerTest.java b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchControllerTest.java
index 7bd2409..fb993be 100644
--- a/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchControllerTest.java
+++ b/lite/src/test/java/de/ids_mannheim/korap/web/service/LiteSearchControllerTest.java
@@ -14,6 +14,7 @@
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.eclipse.jetty.http.HttpStatus;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -35,6 +36,8 @@
     @Autowired
     private SearchKrill searchKrill;
     
+//  EM: The API is disabled
+    @Ignore   
     @Test
     public void testGetJSONQuery () throws KustvaktException {
         ClientResponse response = resource().path(API_VERSION).path("query")
@@ -51,7 +54,9 @@
         assertEquals("sentence", node.at("/meta/context").asText());
         assertEquals("13", node.at("/meta/count").asText());
     }
-
+    
+//  EM: The API is disabled
+    @Ignore
     @Test
     public void testbuildAndPostQuery () throws KustvaktException {
         ClientResponse response = resource().path(API_VERSION).path("query")
@@ -126,7 +131,9 @@
         assertEquals("opennlp", node.at("/query/wrap/foundry").asText());
     }
 
+//  EM: The API is disabled
     @Test
+    @Ignore
     public void testQueryPost () throws KustvaktException {
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[orth=das]", "poliqarp");
@@ -238,7 +245,9 @@
         assertEquals("GOE/AGA/01784", node.at("/textSigle").asText());
         assertEquals("Belagerung von Mainz", node.at("/title").asText());
     };
-
+    
+//  EM: The API is disabled
+    @Ignore
     @Test
     public void testCollectionQueryParameter () throws KustvaktException {
         ClientResponse response = resource().path(API_VERSION).path("query")
@@ -385,6 +394,20 @@
     }
     
     @Test
+    public void testSearchPublicMetadata () throws KustvaktException {
+        ClientResponse response = resource().path(API_VERSION).path("search")
+                .queryParam("q", "[orth=das]").queryParam("ql", "poliqarp")
+                .queryParam("access-rewrite-disabled", "true")
+                .get(ClientResponse.class);
+        assertEquals(ClientResponse.Status.OK.getStatusCode(),
+                response.getStatus());
+        String query = response.getEntity(String.class);
+        JsonNode node = JsonUtils.readTree(query);
+
+        assertTrue(node.at("/matches/0/snippet").isMissingNode());
+    }
+    
+    @Test
     public void testCloseIndex () throws IOException {
         searchKrill.getStatistics(null);
         assertEquals(true, searchKrill.getIndex().isReaderOpen());