From 5deba7264c2cca4721b6e974fb47dc30ec0ced34 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 12 May 2015 21:23:17 -0400 Subject: [PATCH] Add tests.config support to BootstrapForTesting Several plugins (e.g. elasticsearch-cloud-aws, elasticsearch-cloud-azure, elasticsearch-cloud-gce) have integration tests that run with actual credentials to a remote service, so test runs need access to this file. These all require the tester (or jenkins) to supply the file with -Dtests.config. --- .../resources/org/elasticsearch/bootstrap/security.policy | 2 ++ .../org/elasticsearch/bootstrap/BootstrapForTesting.java | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/main/resources/org/elasticsearch/bootstrap/security.policy b/src/main/resources/org/elasticsearch/bootstrap/security.policy index 23dc35f9d81..ef79e807cd7 100644 --- a/src/main/resources/org/elasticsearch/bootstrap/security.policy +++ b/src/main/resources/org/elasticsearch/bootstrap/security.policy @@ -73,6 +73,8 @@ grant { permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch"; // needed by groovy engine permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect"; + // needed by aws core sdk (TODO: look into this) + permission java.lang.RuntimePermission "accessClassInPackage.sun.security.ssl"; // needed by RandomizedRunner permission java.lang.RuntimePermission "accessDeclaredMembers"; diff --git a/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java index 42eb82db4f2..c0444eb81be 100644 --- a/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java +++ b/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java @@ -23,8 +23,10 @@ import org.apache.lucene.util.TestSecurityManager; import org.elasticsearch.bootstrap.Bootstrap; import org.elasticsearch.bootstrap.ESPolicy; import org.elasticsearch.bootstrap.Security; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.PathUtils; +import java.io.FilePermission; import java.nio.file.Path; import java.security.Permissions; import java.security.Policy; @@ -68,6 +70,10 @@ public class BootstrapForTesting { Path javaTmpDir = PathUtils.get(Objects.requireNonNull(System.getProperty("java.io.tmpdir"), "please set ${java.io.tmpdir} in pom.xml")); Security.addPath(perms, javaTmpDir, "read,readlink,write,delete"); + // custom test config file + if (Strings.hasLength(System.getProperty("tests.config"))) { + perms.add(new FilePermission(System.getProperty("tests.config"), "read,readlink")); + } Policy.setPolicy(new ESPolicy(perms)); System.setSecurityManager(new TestSecurityManager()); Security.selfTest();