manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1460908 - /manifoldcf/integration/elasticsearch/trunk/src/test/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerTest.java
Date Mon, 25 Mar 2013 21:39:24 GMT
Author: kwright
Date: Mon Mar 25 21:39:24 2013
New Revision: 1460908

URL: http://svn.apache.org/r1460908
Log:
Add mapping to set default values

Modified:
    manifoldcf/integration/elasticsearch/trunk/src/test/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerTest.java

Modified: manifoldcf/integration/elasticsearch/trunk/src/test/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/integration/elasticsearch/trunk/src/test/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerTest.java?rev=1460908&r1=1460907&r2=1460908&view=diff
==============================================================================
--- manifoldcf/integration/elasticsearch/trunk/src/test/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerTest.java
(original)
+++ manifoldcf/integration/elasticsearch/trunk/src/test/java/org/apache/manifoldcf/elasticsearch/MCFAuthorizerTest.java
Mon Mar 25 21:39:24 2013
@@ -93,7 +93,10 @@ public class MCFAuthorizerTest
     
     // Question: We need the equivalent of default field values.  How do we set that in ElasticSearch?
     // MHL
-    client.admin().indices().create(createIndexRequest("test")).actionGet();
+    client.admin().indices().create(
+      createIndexRequest("test")
+        .mapping("type1",aclsource())
+      ).actionGet();
     //             |     share    |   document
     //             |--------------|--------------
     //             | allow | deny | allow | deny
@@ -164,6 +167,31 @@ public class MCFAuthorizerTest
     return client("server");
   }
   
+  private static XContentBuilder aclsource() throws IOException
+  {
+    XContentBuilder builder = XContentFactory.jsonBuilder()
+      .startObject()
+      .startObject("type1")
+      .startObject("properties");
+    addField(builder,"allow_token_document");
+    addField(builder,"allow_token_share");
+    addField(builder,"deny_token_document");
+    addField(builder,"deny_token_share");
+    builder.endObject()
+      .endObject()
+      .endObject();
+    return builder;
+  }
+  
+  private static void addField(XContentBuilder builder, String fieldName)
+    throws IOException
+  {
+    builder.startObject(fieldName)
+      .field("type","string")
+      .field("null_value","__nosecurity__")
+      .endObject();
+  }
+  
   private static XContentBuilder source(String id, String... argPairs) throws IOException
{
     XContentBuilder builder = XContentFactory.jsonBuilder()
       .startObject()



Mime
View raw message