Added warnings when requesting non-public fields via the search API with
accessRewriteDisabled (resolved #43).
Change-Id: I917415f242c1adf884bacb832fd7644cddaa6973
diff --git a/lite/Changes b/lite/Changes
index 5cc49c6..39ac301 100644
--- a/lite/Changes
+++ b/lite/Changes
@@ -1,3 +1,7 @@
+# version 0.62.2
+13/11/2019
+ - Added tests for issue #43 (margaretha)
+
# version 0.62.1
08/07/2019
- Added tests for public metadata response in search api (margaretha, issue #43)
diff --git a/lite/pom.xml b/lite/pom.xml
index 67d1421..c2f72f0 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.1</version>
+ <version>0.62.2</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.1,)</version>
+ <version>[0.62.2,)</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 d5d885d..6463ce9 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
@@ -409,6 +409,46 @@
}
@Test
+ public void testSearchPublicMetadataWithCustomFields () throws KustvaktException {
+ ClientResponse response = resource().path(API_VERSION).path("search")
+ .queryParam("q", "Sonne").queryParam("ql", "poliqarp")
+ .queryParam("fields", "author,title")
+ .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);
+
+ assertTrue(node.at("/matches/0/snippet").isMissingNode());
+ assertEquals("Goethe, Johann Wolfgang von",
+ node.at("/matches/0/author").asText());
+ assertEquals("Italienische Reise",
+ node.at("/matches/0/title").asText());
+ assertEquals(3, node.at("/matches/0").size());
+ }
+
+ @Test
+ public void testSearchPublicMetadataWithNonPublicField () throws KustvaktException {
+ ClientResponse response = resource().path(API_VERSION).path("search")
+ .queryParam("q", "Sonne").queryParam("ql", "poliqarp")
+ .queryParam("fields", "author,title,snippet")
+ .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(StatusCodes.NON_PUBLIC_FIELD_IGNORED,
+ node.at("/warnings/0/0").asInt());
+ assertEquals("The requested non public fields are ignored",
+ node.at("/warnings/0/1").asText());
+ assertEquals("snippet",
+ node.at("/warnings/0/2").asText());
+ }
+
+ @Test
public void testSearchWithInvalidPage () throws KustvaktException {
ClientResponse response = resource().path(API_VERSION).path("search")
.queryParam("q", "[orth=die]").queryParam("ql", "poliqarp")