Testing: Fix ClusterPrivilegeTests by using jsonBuilder instead of handcrafting JSON

Original commit: elastic/x-pack-elasticsearch@07d79b0f0c
This commit is contained in:
Alexander Reelsen 2015-01-26 16:26:31 +01:00
parent 383e41d6ca
commit 9b4566b72b
1 changed files with 2 additions and 1 deletions

View File

@ -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);