From 9b4566b72b4a6267aad8c68f9c10c5087bebfad0 Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Mon, 26 Jan 2015 16:26:31 +0100 Subject: [PATCH] Testing: Fix ClusterPrivilegeTests by using jsonBuilder instead of handcrafting JSON Original commit: elastic/x-pack-elasticsearch@07d79b0f0c3eebecefd287d9bccc591e3152e511 --- .../org/elasticsearch/integration/ClusterPrivilegeTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java b/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java index f451f5fbf49..fd78a543e6c 100644 --- a/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java +++ b/src/test/java/org/elasticsearch/integration/ClusterPrivilegeTests.java @@ -13,6 +13,7 @@ import org.junit.Test; import java.io.File; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope.TEST; @@ -109,7 +110,7 @@ public class ClusterPrivilegeTests extends AbstractPrivilegeTests { @Test public void testThatSnapshotAndRestore() throws Exception { File repositoryLocation = newTempDir(); - String repoJson = "{ \"type\" : \"fs\", \"settings\" : { \"location\" : \"" + repositoryLocation.getAbsolutePath() + "\" } }"; + String repoJson = jsonBuilder().startObject().field("type", "fs").startObject("settings").field("location", repositoryLocation.getAbsolutePath()).endObject().endObject().string(); assertAccessIsDenied("user_b", "PUT", "/_snapshot/my-repo", repoJson); assertAccessIsDenied("user_c", "PUT", "/_snapshot/my-repo", repoJson); assertAccessIsAllowed("user_a", "PUT", "/_snapshot/my-repo", repoJson);