Replace usage of settingsBuilder with just builder.
Original commit: elastic/x-pack-elasticsearch@fe038bbc49
This commit is contained in:
parent
703a88f95f
commit
5b57727b34
|
@ -28,7 +28,7 @@ import java.util.Set;
|
|||
@SuppressForbidden(reason = "gradle is broken and tries to run me as a test")
|
||||
public final class MessyTestUtils {
|
||||
public static ScriptServiceProxy getScriptServiceProxy(ThreadPool tp) throws Exception {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("script.inline", "true")
|
||||
.put("script.indexed", "true")
|
||||
.put("path.home", LuceneTestCase.createTempDir())
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserValid() throws Exception {
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
|
||||
XContentBuilder builder = createConditionContent("ctx.payload.hits.total > 1", null, ScriptType.INLINE);
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserInvalid() throws Exception {
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject().endObject();
|
||||
XContentParser parser = XContentFactory.xContent(builder.bytes()).createParser(builder.bytes());
|
||||
|
@ -120,7 +120,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testScriptConditionParserBadScript() throws Exception {
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
ScriptType scriptType = randomFrom(ScriptType.values());
|
||||
String script;
|
||||
switch (scriptType) {
|
||||
|
@ -146,7 +146,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testScriptConditionParser_badLang() throws Exception {
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
ScriptType scriptType = ScriptType.INLINE;
|
||||
String script = "return true";
|
||||
XContentBuilder builder = createConditionContent(script, "not_a_valid_lang", scriptType);
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||
|
@ -68,7 +67,7 @@ public class TransformIT extends AbstractWatcherIntegrationTestCase {
|
|||
throw new RuntimeException(ex);
|
||||
}
|
||||
//Set path so ScriptService will pick up the test scripts
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put("path.conf", configDir.toString()).build();
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put("path.conf", configDir.toString()).build();
|
||||
}
|
||||
|
||||
public void testScriptTransform() throws Exception {
|
||||
|
|
|
@ -56,7 +56,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
|
@ -110,7 +109,7 @@ public class SearchInputIT extends ESIntegTestCase {
|
|||
|
||||
|
||||
//Set path so ScriptService will pick up the test scripts
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put("path.conf", configPath).build();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
|
||||
|
@ -122,7 +121,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
|||
throw new RuntimeException("failed to copy mustache template");
|
||||
}
|
||||
//Set path so ScriptService will pick up the test scripts
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
// we're not extending from the base watcher test case, so we should prevent the watcher plugin from being loaded
|
||||
.put("path.conf", configPath).build();
|
||||
|
@ -137,7 +136,7 @@ public class SearchTransformIT extends ESIntegTestCase {
|
|||
|
||||
@Override
|
||||
public Settings indexSettings() {
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.indexSettings())
|
||||
|
||||
// we have to test this on an index that has at least 2 shards. Otherwise when searching indices with
|
||||
|
|
|
@ -42,7 +42,7 @@ public abstract class AbstractLicensesConsumerPluginIntegrationTestCase extends
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
// this setting is only used in tests
|
||||
.put("_trial_license_duration_in_seconds", trialLicenseDurationInSeconds)
|
||||
|
|
|
@ -34,7 +34,7 @@ public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationT
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
// this setting is only used in tests
|
||||
.put("_trial_license_duration_in_seconds", trialLicenseDurationInSeconds)
|
||||
|
|
|
@ -33,13 +33,13 @@ public class LicensesPluginsIntegrationTests extends AbstractLicensesIntegration
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.build();
|
||||
}
|
||||
|
||||
private Settings nodeSettingsWithConsumerPlugin(int trialLicenseDuration) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(0))
|
||||
// this setting is only used in tests
|
||||
.put("_trial_license_duration_in_seconds", trialLicenseDuration)
|
||||
|
|
|
@ -25,7 +25,7 @@ import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
|
|||
public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
|
||||
.build();
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
|
|||
|
||||
public void testClusterStateCollectorOneIndex() throws Exception {
|
||||
int nbShards = randomIntBetween(1, 5);
|
||||
assertAcked(prepareCreate("test").setSettings(Settings.settingsBuilder()
|
||||
assertAcked(prepareCreate("test").setSettings(Settings.builder()
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, nbShards)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
.build()));
|
||||
|
@ -65,7 +65,7 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
|
|||
for (int i = 0; i < nbIndices; i++) {
|
||||
shardsPerIndex[i] = randomIntBetween(1, 5);
|
||||
nbShards += shardsPerIndex[i];
|
||||
assertAcked(prepareCreate("test-" + i).setSettings(Settings.settingsBuilder()
|
||||
assertAcked(prepareCreate("test-" + i).setSettings(Settings.builder()
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, shardsPerIndex[i])
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
.build()));
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|||
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
|
@ -46,7 +45,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(MarvelSettings.INDEX_RECOVERY_ACTIVE_ONLY.getKey(), activeOnly)
|
||||
.put(MarvelSettings.INDICES.getKey(), indexName)
|
||||
|
@ -66,7 +65,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
|||
assertThat(results, is(empty()));
|
||||
|
||||
logger.info("--> create index [{}] on node [{}]", indexName, node1);
|
||||
assertAcked(prepareCreate(indexName, 1, settingsBuilder().put(SETTING_NUMBER_OF_SHARDS, 3).put(SETTING_NUMBER_OF_REPLICAS, 1)));
|
||||
assertAcked(prepareCreate(indexName, 1, Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 3).put(SETTING_NUMBER_OF_REPLICAS, 1)));
|
||||
|
||||
logger.info("--> indexing sample data");
|
||||
final int numDocs = between(50, 150);
|
||||
|
@ -169,7 +168,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyCluster() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(),
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(),
|
||||
Strings.EMPTY_ARRAY));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
|
@ -181,7 +180,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyClusterAllIndices() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL));
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
try {
|
||||
|
@ -192,7 +191,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyClusterMissingIndex() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(), "unknown"));
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), "unknown"));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
try {
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
@ -52,7 +52,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyClusterAllIndices() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL));
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
try {
|
||||
|
@ -63,7 +63,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyClusterMissingIndex() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(), "unknown"));
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), "unknown"));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
try {
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.hamcrest.Matchers.arrayWithSize;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -52,7 +52,7 @@ public class IndicesStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyClusterAllIndices() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL));
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
try {
|
||||
|
@ -63,7 +63,7 @@ public class IndicesStatsCollectorTests extends AbstractCollectorTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyClusterMissingIndex() throws Exception {
|
||||
final String node = internalCluster().startNode(settingsBuilder().put(MarvelSettings.INDICES.getKey(), "unknown"));
|
||||
final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), "unknown"));
|
||||
waitForNoBlocksOnNode(node);
|
||||
|
||||
try {
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Arrays;
|
|||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver.DELIMITER;
|
||||
import static org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver.PREFIX;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -68,7 +67,7 @@ public class TimestampedResolverTests extends MonitoringIndexNameResolverTestCas
|
|||
for (String format : Arrays.asList("YYYY", "YYYY.MM", "YYYY.MM.dd", "YYYY.MM.dd-HH", "YYYY.MM.dd-HH.mm", "YYYY.MM.dd-HH.mm.SS")) {
|
||||
Settings settings = Settings.EMPTY;
|
||||
if (format != null) {
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put(MonitoringIndexNameResolver.Timestamped.INDEX_NAME_TIME_FORMAT_SETTING.getKey(), format)
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.junit.After;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
|
@ -64,7 +63,7 @@ public class MultiNodesStatsTests extends MarvelIntegTestCase {
|
|||
n = randomIntBetween(1, 2);
|
||||
logger.debug("--> starting {} client only nodes", n);
|
||||
InternalTestCluster.Async<List<String>> clientNodes = internalCluster().startNodesAsync(n,
|
||||
settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), false)
|
||||
Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), false)
|
||||
.put(Node.NODE_INGEST_SETTING.getKey(), false).build());
|
||||
clientNodes.get();
|
||||
nodes += n;
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.joda.time.DateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
|
@ -41,7 +40,7 @@ public class LocalIndicesCleanerTests extends AbstractIndicesCleanerTestCase {
|
|||
@Override
|
||||
protected void createIndex(String name, DateTime creationDate) {
|
||||
assertAcked(prepareCreate(name)
|
||||
.setSettings(settingsBuilder().put(IndexMetaData.SETTING_CREATION_DATE, creationDate.getMillis()).build()));
|
||||
.setSettings(Settings.builder().put(IndexMetaData.SETTING_CREATION_DATE, creationDate.getMillis()).build()));
|
||||
ensureYellow(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ public class Security {
|
|||
return Settings.EMPTY;
|
||||
}
|
||||
|
||||
Settings.Builder settingsBuilder = Settings.settingsBuilder();
|
||||
Settings.Builder settingsBuilder = Settings.builder();
|
||||
settingsBuilder.put(NetworkModule.TRANSPORT_TYPE_KEY, Security.NAME);
|
||||
settingsBuilder.put(NetworkModule.TRANSPORT_SERVICE_TYPE_KEY, Security.NAME);
|
||||
settingsBuilder.put(NetworkModule.HTTP_TYPE_SETTING.getKey(), Security.NAME);
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.shield.authc.ldap.support.LdapSearchScope.ONE_LEVEL;
|
||||
import static org.elasticsearch.shield.authc.ldap.support.LdapSearchScope.SUB_TREE;
|
||||
|
@ -75,7 +74,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Path nodeFiles = createTempDir();
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(realmConfig.buildSettings())
|
||||
//we need ssl to the LDAP server
|
||||
|
@ -160,7 +159,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
throw new ElasticsearchException("store path [" + store + "] doesn't exist");
|
||||
}
|
||||
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", store)
|
||||
.put("xpack.security.ssl.keystore.password", password)
|
||||
.put(ShieldNettyTransport.HOSTNAME_VERIFICATION_SETTING.getKey(), false)
|
||||
|
@ -174,7 +173,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
enum RealmConfig {
|
||||
|
||||
AD(false, AD_ROLE_MAPPING,
|
||||
settingsBuilder()
|
||||
Settings.builder()
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".type", ActiveDirectoryRealm.TYPE)
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".domain_name", "ad.test.elasticsearch.com")
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".group_search.base_dn", "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com")
|
||||
|
@ -183,7 +182,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
.build()),
|
||||
|
||||
AD_LDAP_GROUPS_FROM_SEARCH(true, AD_ROLE_MAPPING,
|
||||
settingsBuilder()
|
||||
Settings.builder()
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.TYPE)
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".url", "ldaps://ad.test.elasticsearch.com:636")
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".group_search.base_dn", "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com")
|
||||
|
@ -193,7 +192,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
.build()),
|
||||
|
||||
AD_LDAP_GROUPS_FROM_ATTRIBUTE(true, AD_ROLE_MAPPING,
|
||||
settingsBuilder()
|
||||
Settings.builder()
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.TYPE)
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".url", "ldaps://ad.test.elasticsearch.com:636")
|
||||
.putArray(SHIELD_AUTHC_REALMS_EXTERNAL + ".user_dn_templates",
|
||||
|
@ -201,7 +200,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
.build()),
|
||||
|
||||
OLDAP(false, OLDAP_ROLE_MAPPING,
|
||||
settingsBuilder()
|
||||
Settings.builder()
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".type", LdapRealm.TYPE)
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".url", "ldaps://54.200.235.244:636")
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".group_search.base_dn",
|
||||
|
@ -224,7 +223,7 @@ abstract public class AbstractAdLdapRealmTestCase extends ShieldIntegTestCase {
|
|||
}
|
||||
|
||||
public Settings buildSettings() {
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".order", 1)
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".hostname_verification", false)
|
||||
.put(SHIELD_AUTHC_REALMS_EXTERNAL + ".unmapped_groups_as_roles", mapGroupsAsRoles)
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ShieldPluginEnabledDisabledTests extends ShieldIntegTestCase {
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
logger.info("******* shield is {}", enabled ? "enabled" : "disabled");
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.NAME), enabled)
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
|
||||
|
@ -73,7 +73,7 @@ public class ShieldPluginEnabledDisabledTests extends ShieldIntegTestCase {
|
|||
|
||||
@Override
|
||||
protected Settings transportClientSettings() {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.transportClientSettings())
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.NAME), enabled)
|
||||
.build();
|
||||
|
|
|
@ -43,7 +43,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.ShieldTestsUtils.assertAuthenticationException;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -65,23 +64,23 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
@Before
|
||||
public void initializeSslSocketFactory() throws Exception {
|
||||
Path keystore = getDataPath("support/ldaptrust.jks");
|
||||
Environment env = new Environment(settingsBuilder().put("path.home", createTempDir()).build());
|
||||
Environment env = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
/*
|
||||
* Prior to each test we reinitialize the socket factory with a new SSLService so that we get a new SSLContext.
|
||||
* If we re-use a SSLContext, previously connected sessions can get re-established which breaks hostname
|
||||
* verification tests since a re-established connection does not perform hostname verification.
|
||||
*/
|
||||
clientSSLService = new ClientSSLService(settingsBuilder()
|
||||
clientSSLService = new ClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", keystore)
|
||||
.put("xpack.security.ssl.keystore.password", "changeit")
|
||||
.build());
|
||||
clientSSLService.setEnvironment(env);
|
||||
|
||||
globalSettings = settingsBuilder().put("path.home", createTempDir()).build();
|
||||
globalSettings = Settings.builder().put("path.home", createTempDir()).build();
|
||||
}
|
||||
|
||||
public void testSupportsUnauthenticatedSessions() throws Exception {
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, "", LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", "")
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -101,7 +100,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -135,7 +134,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -174,7 +173,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "cn=William Bush,ou=people,o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -209,7 +208,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -248,7 +247,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "ou=people,o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -283,7 +282,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -321,7 +320,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -354,7 +353,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
public void testUserSearchWithActiveDirectory() throws Exception {
|
||||
String groupSearchBase = "DC=ad,DC=test,DC=elasticsearch,DC=com";
|
||||
String userSearchBase = "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(LdapTestCase.buildLdapSettings(new String[] { ActiveDirectorySessionFactoryTests.AD_LDAP_URL }, Strings.EMPTY_ARRAY,
|
||||
groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
|
@ -397,7 +396,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
public void testUserSearchwithBindUserOpenLDAP() throws Exception {
|
||||
String groupSearchBase = "ou=people,dc=oldap,dc=test,dc=elasticsearch,dc=com";
|
||||
String userSearchBase = "ou=people,dc=oldap,dc=test,dc=elasticsearch,dc=com";
|
||||
RealmConfig config = new RealmConfig("oldap-test", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("oldap-test", Settings.builder()
|
||||
.put(LdapTestCase.buildLdapSettings(new String[] { OpenLdapTests.OPEN_LDAP_URL }, Strings.EMPTY_ARRAY, groupSearchBase,
|
||||
LdapSearchScope.ONE_LEVEL))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
|
@ -431,7 +430,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
public void testConnectionPoolDefaultSettings() throws Exception {
|
||||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -457,7 +456,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
public void testConnectionPoolSettings() throws Exception {
|
||||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_dn", "cn=Horatio Hornblower,ou=people,o=sevenSeas")
|
||||
|
@ -482,7 +481,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
public void testThatEmptyBindDNThrowsExceptionWithHealthCheckEnabled() throws Exception {
|
||||
String groupSearchBase = "o=sevenSeas";
|
||||
String userSearchBase = "o=sevenSeas";
|
||||
RealmConfig config = new RealmConfig("ldap_realm", settingsBuilder()
|
||||
RealmConfig config = new RealmConfig("ldap_realm", Settings.builder()
|
||||
.put(buildLdapSettings(ldapUrls(), Strings.EMPTY_ARRAY, groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
.put("bind_password", "pass")
|
||||
|
@ -497,12 +496,12 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
}
|
||||
|
||||
public void testEmptyBindDNReturnsNullBindRequest() {
|
||||
BindRequest request = LdapUserSearchSessionFactory.bindRequest(settingsBuilder().put("bind_password", "password").build());
|
||||
BindRequest request = LdapUserSearchSessionFactory.bindRequest(Settings.builder().put("bind_password", "password").build());
|
||||
assertThat(request, is(nullValue()));
|
||||
}
|
||||
|
||||
public void testThatBindRequestReturnsSimpleBindRequest() {
|
||||
BindRequest request = LdapUserSearchSessionFactory.bindRequest(settingsBuilder()
|
||||
BindRequest request = LdapUserSearchSessionFactory.bindRequest(Settings.builder()
|
||||
.put("bind_password", "password")
|
||||
.put("bind_dn", "cn=ironman")
|
||||
.build());
|
||||
|
@ -515,7 +514,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
public void testThatLDAPServerConnectErrorDoesNotPreventNodeFromStarting() throws IOException {
|
||||
String groupSearchBase = "DC=ad,DC=test,DC=elasticsearch,DC=com";
|
||||
String userSearchBase = "CN=Users,DC=ad,DC=test,DC=elasticsearch,DC=com";
|
||||
Settings ldapSettings = settingsBuilder()
|
||||
Settings ldapSettings = Settings.builder()
|
||||
.put(LdapTestCase.buildLdapSettings(new String[] { "ldaps://elastic.co:636" }, Strings.EMPTY_ARRAY,
|
||||
groupSearchBase, LdapSearchScope.SUB_TREE))
|
||||
.put("user_search.base_dn", userSearchBase)
|
||||
|
@ -526,7 +525,7 @@ public class LdapUserSearchSessionFactoryTests extends LdapTestCase {
|
|||
.put("type", "ldap")
|
||||
.build();
|
||||
|
||||
Settings.Builder builder = settingsBuilder();
|
||||
Settings.Builder builder = Settings.builder();
|
||||
for (Map.Entry<String, String> entry : ldapSettings.getAsMap().entrySet()) {
|
||||
builder.put("xpack.security.authc.realms.ldap1." + entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.shield.authc.RealmConfig;
|
|||
import org.elasticsearch.shield.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -29,7 +28,7 @@ public class SessionFactoryTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testConnectionFactoryReturnsCorrectLDAPConnectionOptions() {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(SessionFactory.TIMEOUT_TCP_CONNECTION_SETTING, "10ms")
|
||||
.put(SessionFactory.HOSTNAME_VERIFICATION_SETTING, "false")
|
||||
.put(SessionFactory.TIMEOUT_TCP_READ_SETTING, "20ms")
|
||||
|
@ -57,7 +56,7 @@ public class SessionFactoryTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private SessionFactory createSessionFactory() {
|
||||
Settings global = settingsBuilder().put("path.home", createTempDir()).build();
|
||||
Settings global = Settings.builder().put("path.home", createTempDir()).build();
|
||||
return new SessionFactory(new RealmConfig("_name", Settings.builder().put("url", "ldap://localhost:389").build(), global), null) {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -235,7 +235,7 @@ public class DnRoleMapperTests extends ESTestCase {
|
|||
|
||||
public void testYaml() throws Exception {
|
||||
Path file = getDataPath("role_mapping.yml");
|
||||
Settings ldapSettings = Settings.settingsBuilder()
|
||||
Settings ldapSettings = Settings.builder()
|
||||
.put(DnRoleMapper.ROLE_MAPPING_FILE_SETTING, file.toAbsolutePath())
|
||||
.build();
|
||||
RealmConfig config = new RealmConfig("ldap1", ldapSettings, settings);
|
||||
|
|
|
@ -843,7 +843,7 @@ public class DefaultIndicesResolverTests extends ESTestCase {
|
|||
// TODO with the removal of DeleteByQuery is there another way to test resolving a write action?
|
||||
|
||||
private static IndexMetaData.Builder indexBuilder(String index) {
|
||||
return IndexMetaData.builder(index).settings(Settings.settingsBuilder()
|
||||
return IndexMetaData.builder(index).settings(Settings.builder()
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ShieldLicenseeTests extends AbstractLicenseeTestCase {
|
|||
}
|
||||
|
||||
public void testDoesNotStartWithTribeNode() {
|
||||
Settings settings = Settings.settingsBuilder().put("tribe.fake.cluster.name", "notchecked").build();
|
||||
Settings settings = Settings.builder().put("tribe.fake.cluster.name", "notchecked").build();
|
||||
ShieldLicensee licensee = new ShieldLicensee(settings, registry, shieldState);
|
||||
|
||||
// starting the Licensee as a tribe node should not trigger it being registered
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -46,12 +45,12 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
@Before
|
||||
public void setup() throws Exception {
|
||||
testclientStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testclient.jks");
|
||||
env = randomBoolean() ? new Environment(settingsBuilder().put("path.home", createTempDir()).build()) : null;
|
||||
env = randomBoolean() ? new Environment(Settings.builder().put("path.home", createTempDir()).build()) : null;
|
||||
}
|
||||
|
||||
public void testThatInvalidProtocolThrowsException() throws Exception {
|
||||
try {
|
||||
new ClientSSLService(settingsBuilder()
|
||||
new ClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.protocol", "non-existing")
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
|
@ -67,12 +66,12 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
public void testThatCustomTruststoreCanBeSpecified() throws Exception {
|
||||
Path testnodeStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks");
|
||||
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
||||
Settings.Builder settingsBuilder = settingsBuilder()
|
||||
Settings.Builder settingsBuilder = Settings.builder()
|
||||
.put("truststore.path", testnodeStore)
|
||||
.put("truststore.password", "testnode");
|
||||
|
||||
|
@ -84,7 +83,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSslContextCachingWorks() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
@ -97,7 +96,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
|
||||
public void testThatKeyStoreAndKeyCanHaveDifferentPasswords() throws Exception {
|
||||
Path differentPasswordsStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-different-passwords.jks");
|
||||
createClientSSLService(settingsBuilder()
|
||||
createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", differentPasswordsStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.put("xpack.security.ssl.keystore.key_password", "testnode1")
|
||||
|
@ -107,7 +106,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
public void testIncorrectKeyPasswordThrowsException() throws Exception {
|
||||
Path differentPasswordsStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-different-passwords.jks");
|
||||
try {
|
||||
createClientSSLService(settingsBuilder()
|
||||
createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", differentPasswordsStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build()).createSSLEngine();
|
||||
|
@ -118,7 +117,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSSLv3IsNotEnabled() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
@ -127,7 +126,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSSLSessionCacheHasDefaultLimits() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
@ -137,7 +136,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSettingSSLSessionCacheLimitsWorks() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.put("xpack.security.ssl.session.cache_size", "300")
|
||||
|
@ -155,7 +154,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatCreateSSLEngineWithOnlyTruststoreWorks() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", testclientStore)
|
||||
.put("xpack.security.ssl.truststore.password", "testclient")
|
||||
.build());
|
||||
|
@ -164,7 +163,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatCreateSSLEngineWithOnlyKeystoreWorks() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
@ -186,7 +185,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
|
||||
@Network
|
||||
public void testThatSSLContextWithKeystoreDoesNotTrustAllPublicCAs() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
@ -203,7 +202,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatTruststorePasswordIsRequired() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", testclientStore)
|
||||
.build());
|
||||
try {
|
||||
|
@ -215,7 +214,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatKeystorePasswordIsRequired() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.build());
|
||||
try {
|
||||
|
@ -230,7 +229,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
List<String> ciphers = new ArrayList<>(SSLSettings.Globals.DEFAULT_CIPHERS);
|
||||
ciphers.add("foo");
|
||||
ciphers.add("bar");
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.putArray("xpack.security.ssl.ciphers", ciphers.toArray(new String[ciphers.size()]))
|
||||
.build());
|
||||
SSLEngine engine = sslService.createSSLEngine();
|
||||
|
@ -240,7 +239,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testInvalidCiphersOnlyThrowsException() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.putArray("xpack.security.ssl.ciphers", new String[] { "foo", "bar" })
|
||||
.build());
|
||||
try {
|
||||
|
@ -252,7 +251,7 @@ public class ClientSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSSLSocketFactoryHasProperCiphersAndProtocols() throws Exception {
|
||||
ClientSSLService sslService = createClientSSLService(settingsBuilder()
|
||||
ClientSSLService sslService = createClientSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testclientStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient")
|
||||
.build());
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.elasticsearch.test.ESTestCase;
|
|||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
@ -34,7 +33,7 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatOnlyKeystoreInSettingsSetsTruststoreSettings() {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", "path")
|
||||
.put("xpack.security.ssl.keystore.password", "password")
|
||||
.build();
|
||||
|
@ -46,7 +45,7 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
assertThat(sslSettings.trustStorePassword, is(equalTo(sslSettings.keyStorePassword)));
|
||||
|
||||
// Pass settings in as profile settings
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put("keystore.path", "path")
|
||||
.put("keystore.password", "password")
|
||||
.build();
|
||||
|
@ -58,14 +57,14 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatKeystorePasswordIsDefaultKeyPassword() {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.password", "password")
|
||||
.build();
|
||||
// Pass settings in as component settings
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settings);
|
||||
assertThat(sslSettings.keyPassword, is(equalTo(sslSettings.keyStorePassword)));
|
||||
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put("keystore.password", "password")
|
||||
.build();
|
||||
// Pass settings in as profile settings
|
||||
|
@ -74,7 +73,7 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatKeyPasswordCanBeSet() {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.password", "password")
|
||||
.put("xpack.security.ssl.keystore.key_password", "key")
|
||||
.build();
|
||||
|
@ -84,7 +83,7 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
assertThat(sslSettings.keyPassword, is(equalTo("key")));
|
||||
|
||||
// Pass settings in as profile settings
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put("keystore.password", "password")
|
||||
.put("keystore.key_password", "key")
|
||||
.build();
|
||||
|
@ -94,7 +93,7 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatProfileSettingsOverrideServiceSettings() {
|
||||
Settings profileSettings = settingsBuilder()
|
||||
Settings profileSettings = Settings.builder()
|
||||
.put("keystore.path", "path")
|
||||
.put("keystore.password", "password")
|
||||
.put("keystore.key_password", "key")
|
||||
|
@ -107,7 +106,7 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
.put("session.cache_timeout", "10m")
|
||||
.build();
|
||||
|
||||
Settings serviceSettings = settingsBuilder()
|
||||
Settings serviceSettings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", "comp path")
|
||||
.put("xpack.security.ssl.keystore.password", "comp password")
|
||||
.put("xpack.security.ssl.keystore.key_password", "comp key")
|
||||
|
@ -143,9 +142,9 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSettingsWithDifferentKeystoresAreNotEqual() {
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", "path").build());
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", "path1").build());
|
||||
assertThat(sslSettings.equals(sslSettings1), is(equalTo(false)));
|
||||
assertThat(sslSettings1.equals(sslSettings), is(equalTo(false)));
|
||||
|
@ -154,9 +153,9 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSettingsWithDifferentProtocolsAreNotEqual() {
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.protocol", "ssl").build());
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.protocol", "tls").build());
|
||||
assertThat(sslSettings.equals(sslSettings1), is(equalTo(false)));
|
||||
assertThat(sslSettings1.equals(sslSettings), is(equalTo(false)));
|
||||
|
@ -165,9 +164,9 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSettingsWithDifferentTruststoresAreNotEqual() {
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", "/trust").build());
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", "/truststore").build());
|
||||
assertThat(sslSettings.equals(sslSettings1), is(equalTo(false)));
|
||||
assertThat(sslSettings1.equals(sslSettings), is(equalTo(false)));
|
||||
|
@ -182,25 +181,25 @@ public class SSLSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSettingsWithDifferentKeystoresHaveDifferentHashCode() {
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", "path").build());
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", "path1").build());
|
||||
assertThat(sslSettings.hashCode(), is(not(equalTo(sslSettings1.hashCode()))));
|
||||
}
|
||||
|
||||
public void testThatSettingsWithDifferentProtocolsHaveDifferentHashCode() {
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.protocol", "ssl").build());
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.protocol", "tls").build());
|
||||
assertThat(sslSettings.hashCode(), is(not(equalTo(sslSettings1.hashCode()))));
|
||||
}
|
||||
|
||||
public void testThatSettingsWithDifferentTruststoresHaveDifferentHashCode() {
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", "/trust").build());
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, settingsBuilder()
|
||||
SSLSettings sslSettings1 = new SSLSettings(Settings.EMPTY, Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", "/truststore").build());
|
||||
assertThat(sslSettings.hashCode(), is(not(equalTo(sslSettings1.hashCode()))));
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -40,11 +39,11 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
@Before
|
||||
public void setup() throws Exception {
|
||||
testnodeStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks");
|
||||
env = new Environment(settingsBuilder().put("path.home", createTempDir()).build());
|
||||
env = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
}
|
||||
|
||||
public void testThatInvalidProtocolThrowsException() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.protocol", "non-existing")
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
|
@ -62,13 +61,13 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
public void testThatCustomTruststoreCanBeSpecified() throws Exception {
|
||||
Path testClientStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testclient.jks");
|
||||
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build();
|
||||
ServerSSLService sslService = new ServerSSLService(settings, env);
|
||||
|
||||
Settings.Builder settingsBuilder = settingsBuilder()
|
||||
Settings.Builder settingsBuilder = Settings.builder()
|
||||
.put("truststore.path", testClientStore)
|
||||
.put("truststore.password", "testclient");
|
||||
|
||||
|
@ -80,7 +79,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSslContextCachingWorks() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build(), env);
|
||||
|
@ -93,7 +92,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
|
||||
public void testThatKeyStoreAndKeyCanHaveDifferentPasswords() throws Exception {
|
||||
Path differentPasswordsStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-different-passwords.jks");
|
||||
new ServerSSLService(settingsBuilder()
|
||||
new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", differentPasswordsStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.put("xpack.security.ssl.keystore.key_password", "testnode1")
|
||||
|
@ -103,7 +102,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
public void testIncorrectKeyPasswordThrowsException() throws Exception {
|
||||
Path differentPasswordsStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode-different-passwords.jks");
|
||||
try {
|
||||
new ServerSSLService(settingsBuilder()
|
||||
new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", differentPasswordsStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build(), env).createSSLEngine();
|
||||
|
@ -114,7 +113,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSSLv3IsNotEnabled() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build(), env);
|
||||
|
@ -123,7 +122,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSSLSessionCacheHasDefaultLimits() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build(), env);
|
||||
|
@ -133,7 +132,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSettingSSLSessionCacheLimitsWorks() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.put("xpack.security.ssl.session.cache_size", "300")
|
||||
|
@ -155,7 +154,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatCreateSSLEngineWithOnlyTruststoreDoesNotWork() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.truststore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.truststore.password", "testnode")
|
||||
.build(), env);
|
||||
|
@ -168,7 +167,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatTruststorePasswordIsRequired() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.put("xpack.security.ssl.truststore.path", testnodeStore)
|
||||
|
@ -182,7 +181,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatKeystorePasswordIsRequired() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.build(), env);
|
||||
try {
|
||||
|
@ -197,7 +196,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
List<String> ciphers = new ArrayList<>(SSLSettings.Globals.DEFAULT_CIPHERS);
|
||||
ciphers.add("foo");
|
||||
ciphers.add("bar");
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.putArray("xpack.security.ssl.ciphers", ciphers.toArray(new String[ciphers.size()]))
|
||||
|
@ -209,7 +208,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testInvalidCiphersOnlyThrowsException() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.putArray("xpack.security.ssl.ciphers", new String[] { "foo", "bar" })
|
||||
|
@ -223,7 +222,7 @@ public class ServerSSLServiceTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatSSLSocketFactoryHasProperCiphersAndProtocols() throws Exception {
|
||||
ServerSSLService sslService = new ServerSSLService(settingsBuilder()
|
||||
ServerSSLService sslService = new ServerSSLService(Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build(), env);
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.nio.file.Path;
|
|||
import java.util.Collections;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.shield.test.ShieldTestUtils.createFolder;
|
||||
import static org.elasticsearch.shield.test.ShieldTestUtils.writeFile;
|
||||
import static org.elasticsearch.test.ShieldSettingsSource.getSSLSettingsForStore;
|
||||
|
@ -54,7 +53,7 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder settingsBuilder = settingsBuilder();
|
||||
Settings.Builder settingsBuilder = Settings.builder();
|
||||
String randomClientPortRange = randomClientPort + "-" + (randomClientPort+100);
|
||||
|
||||
Path store;
|
||||
|
@ -93,7 +92,7 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
|
|||
String unicastHost = NetworkAddress.format(inetSocketAddress);
|
||||
|
||||
// test that starting up a node works
|
||||
Settings nodeSettings = settingsBuilder()
|
||||
Settings nodeSettings = Settings.builder()
|
||||
.put(getSSLSettingsForStore("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks", "testnode"))
|
||||
.put("node.mode", "network")
|
||||
.put("node.name", "my-test-node")
|
||||
|
@ -119,7 +118,7 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
|
|||
Path folder = createFolder(createTempDir(), getClass().getSimpleName() + "-" + randomAsciiOfLength(10));
|
||||
|
||||
// test that starting up a node works
|
||||
Settings nodeSettings = settingsBuilder()
|
||||
Settings nodeSettings = Settings.builder()
|
||||
.put("xpack.security.authc.realms.file.type", FileRealm.TYPE)
|
||||
.put("xpack.security.authc.realms.file.order", 0)
|
||||
.put("xpack.security.authc.realms.file.files.users", writeFile(folder, "users", configUsers()))
|
||||
|
|
|
@ -57,7 +57,7 @@ import static org.mockito.Mockito.when;
|
|||
public class TransportFilterTests extends ESIntegTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put("node.mode", "network")
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -82,7 +81,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatIpV4AddressesCanBeProcessed() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "127.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "10.0.0.0/8")
|
||||
.build();
|
||||
|
@ -95,7 +94,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
public void testThatIpV6AddressesCanBeProcessed() throws Exception {
|
||||
// you have to use the shortest possible notation in order to match, so
|
||||
// 1234:0db8:85a3:0000:0000:8a2e:0370:7334 becomes 1234:db8:85a3:0:0:8a2e:370:7334
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "2001:0db8:1234::/48")
|
||||
.putArray("xpack.security.transport.filter.deny", "1234:db8:85a3:0:0:8a2e:370:7334", "4321:db8:1234::/48")
|
||||
.build();
|
||||
|
@ -109,7 +108,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
|
||||
@Network // requires network for name resolution
|
||||
public void testThatHostnamesCanBeProcessed() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "127.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "*.google.com")
|
||||
.build();
|
||||
|
@ -121,7 +120,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatAnAllowAllAuthenticatorWorks() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "_all")
|
||||
.build();
|
||||
ipFilter = new IPFilter(settings, auditTrail, clusterSettings, licenseState);
|
||||
|
@ -131,7 +130,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatProfilesAreSupported() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "localhost")
|
||||
.put("xpack.security.transport.filter.deny", "_all")
|
||||
.put("transport.profiles.client.xpack.security.filter.allow", "192.168.0.1")
|
||||
|
@ -146,7 +145,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatAllowWinsOverDeny() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "10.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "10.0.0.0/8")
|
||||
.build();
|
||||
|
@ -157,7 +156,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testDefaultAllow() throws Exception {
|
||||
Settings settings = settingsBuilder().build();
|
||||
Settings settings = Settings.builder().build();
|
||||
ipFilter = new IPFilter(settings, auditTrail, clusterSettings, licenseState);
|
||||
ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses());
|
||||
assertAddressIsAllowed("10.0.0.1");
|
||||
|
@ -165,7 +164,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatHttpWorks() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "127.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "10.0.0.0/8")
|
||||
.put("xpack.security.http.filter.allow", "10.0.0.0/8")
|
||||
|
@ -179,7 +178,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatHttpFallsbackToDefault() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "127.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "10.0.0.0/8")
|
||||
.build();
|
||||
|
@ -199,10 +198,10 @@ public class IPFilterTests extends ESTestCase {
|
|||
|
||||
Settings settings;
|
||||
if (randomBoolean()) {
|
||||
settings = settingsBuilder().putArray("xpack.security.transport.filter.deny",
|
||||
settings = Settings.builder().putArray("xpack.security.transport.filter.deny",
|
||||
addressStrings.toArray(new String[addressStrings.size()])).build();
|
||||
} else {
|
||||
settings = settingsBuilder().put("xpack.security.transport.filter.deny", "_all").build();
|
||||
settings = Settings.builder().put("xpack.security.transport.filter.deny", "_all").build();
|
||||
}
|
||||
ipFilter = new IPFilter(settings, auditTrail, clusterSettings, licenseState);
|
||||
ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses());
|
||||
|
@ -215,7 +214,7 @@ public class IPFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testThatAllAddressesAreAllowedWhenLicenseDisablesSecurity() {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.deny", "_all")
|
||||
.build();
|
||||
when(licenseState.securityEnabled()).thenReturn(false);
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.net.InetAddress;
|
|||
import java.net.UnknownHostException;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
@ -36,7 +35,7 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
String randomClientPortRange = randomClientPort + "-" + (randomClientPort+100);
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), httpEnabled)
|
||||
.put("xpack.security.transport.filter.deny", "127.0.0.200")
|
||||
|
@ -53,14 +52,14 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
assertConnectionAccepted(".http", "127.0.0.8");
|
||||
assertConnectionAccepted("client", "127.0.0.8");
|
||||
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "127.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "127.0.0.8")
|
||||
.build();
|
||||
updateSettings(settings);
|
||||
assertConnectionRejected("default", "127.0.0.8");
|
||||
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.putArray("xpack.security.http.filter.allow", "127.0.0.1")
|
||||
.putArray("xpack.security.http.filter.deny", "127.0.0.8")
|
||||
.build();
|
||||
|
@ -68,7 +67,7 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
assertConnectionRejected("default", "127.0.0.8");
|
||||
assertConnectionRejected(".http", "127.0.0.8");
|
||||
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put("transport.profiles.client.xpack.security.filter.allow", "127.0.0.1")
|
||||
.put("transport.profiles.client.xpack.security.filter.deny", "127.0.0.8")
|
||||
.build();
|
||||
|
@ -87,7 +86,7 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
assertThat(clusterState.metaData().settings().get("transport.profiles.client.xpack.security.filter.deny"), is("127.0.0.8"));
|
||||
|
||||
// now disable ip filtering dynamically and make sure nothing is rejected
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put(IPFilter.IP_FILTER_ENABLED_SETTING.getKey(), false)
|
||||
.put(IPFilter.IP_FILTER_ENABLED_HTTP_SETTING.getKey(), true)
|
||||
.build();
|
||||
|
@ -107,7 +106,7 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
// now also disable for HTTP
|
||||
if (httpEnabled) {
|
||||
assertConnectionRejected(".http", "127.0.0.8");
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put(IPFilter.IP_FILTER_ENABLED_HTTP_SETTING.getKey(), false)
|
||||
.build();
|
||||
// as we permanently switch between persistent and transient settings, just set both here to make sure we overwrite
|
||||
|
@ -119,13 +118,13 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
|
||||
// issue #762, occured because in the above test we use HTTP and transport
|
||||
public void testThatDisablingIpFilterWorksAsExpected() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.deny", "127.0.0.8")
|
||||
.build();
|
||||
updateSettings(settings);
|
||||
assertConnectionRejected("default", "127.0.0.8");
|
||||
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put(IPFilter.IP_FILTER_ENABLED_SETTING.getKey(), false)
|
||||
.build();
|
||||
updateSettings(settings);
|
||||
|
@ -133,13 +132,13 @@ public class IpFilteringUpdateTests extends ShieldIntegTestCase {
|
|||
}
|
||||
|
||||
public void testThatDisablingIpFilterForProfilesWorksAsExpected() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("transport.profiles.client.xpack.security.filter.deny", "127.0.0.8")
|
||||
.build();
|
||||
updateSettings(settings);
|
||||
assertConnectionRejected("client", "127.0.0.8");
|
||||
|
||||
settings = settingsBuilder()
|
||||
settings = Settings.builder()
|
||||
.put(IPFilter.IP_FILTER_ENABLED_SETTING.getKey(), false)
|
||||
.build();
|
||||
updateSettings(settings);
|
||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.shield.transport.netty;
|
|||
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.shield.ssl.ServerSSLService;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -47,7 +46,6 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.anyOf;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
@ -71,11 +69,11 @@ public class HandshakeWaitingHandlerTests extends ESTestCase {
|
|||
randomPort = randomIntBetween(49000, 65500);
|
||||
iterations = randomIntBetween(10, 100);
|
||||
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks"))
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build();
|
||||
Environment env = new Environment(settingsBuilder().put("path.home", createTempDir()).build());
|
||||
Environment env = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
ServerSSLService sslService = new ServerSSLService(settings, env);
|
||||
|
||||
sslContext = sslService.sslContext();
|
||||
|
|
|
@ -36,7 +36,7 @@ import java.net.SocketAddress;
|
|||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -49,7 +49,7 @@ public class IPFilterNettyUpstreamHandlerTests extends ESTestCase {
|
|||
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.transport.filter.allow", "127.0.0.1")
|
||||
.put("xpack.security.transport.filter.deny", "10.0.0.0/8")
|
||||
.build();
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.elasticsearch.transport.TransportSettings;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
public class IPHostnameVerificationTests extends ShieldIntegTestCase {
|
||||
|
@ -34,7 +33,7 @@ public class IPHostnameVerificationTests extends ShieldIntegTestCase {
|
|||
unicastAddresses[i] = address.replace("localhost", "127.0.0.1");
|
||||
}
|
||||
|
||||
Settings.Builder settingsBuilder = settingsBuilder()
|
||||
Settings.Builder settingsBuilder = Settings.builder()
|
||||
.put(settings)
|
||||
.putArray("discovery.zen.ping.unicast.hosts", unicastAddresses);
|
||||
|
||||
|
@ -60,7 +59,7 @@ public class IPHostnameVerificationTests extends ShieldIntegTestCase {
|
|||
|
||||
@Override
|
||||
protected Settings transportClientSettings() {
|
||||
return settingsBuilder().put(super.transportClientSettings())
|
||||
return Settings.builder().put(super.transportClientSettings())
|
||||
.put(ShieldNettyTransport.HOSTNAME_VERIFICATION_SETTING.getKey(), true)
|
||||
.put(ShieldNettyTransport.HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING.getKey(), false)
|
||||
.put("xpack.security.ssl.keystore.path", keystore.toAbsolutePath())
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.junit.Before;
|
|||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
@ -33,11 +32,11 @@ public class ShieldNettyHttpServerTransportTests extends ESTestCase {
|
|||
@Before
|
||||
public void createSSLService() throws Exception {
|
||||
Path testnodeStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks");
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build();
|
||||
Environment env = new Environment(settingsBuilder().put("path.home", createTempDir()).build());
|
||||
Environment env = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
serverSSLService = new ServerSSLService(settings, env);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.junit.Before;
|
|||
import java.nio.file.Path;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
|
@ -37,38 +36,38 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
@Before
|
||||
public void createSSLService() throws Exception {
|
||||
Path testnodeStore = getDataPath("/org/elasticsearch/shield/transport/ssl/certs/simple/testnode.jks");
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("xpack.security.ssl.keystore.path", testnodeStore)
|
||||
.put("xpack.security.ssl.keystore.password", "testnode")
|
||||
.build();
|
||||
Environment env = new Environment(settingsBuilder().put("path.home", createTempDir()).build());
|
||||
Environment env = new Environment(Settings.builder().put("path.home", createTempDir()).build());
|
||||
serverSSLService = new ServerSSLService(settings, env);
|
||||
clientSSLService = new ClientSSLService(settings);
|
||||
clientSSLService.setEnvironment(env);
|
||||
}
|
||||
|
||||
public void testThatSSLCanBeDisabledByProfile() throws Exception {
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService, mock(NamedWriteableRegistry.class));
|
||||
NettyMockUtil.setOpenChannelsHandlerToMock(transport);
|
||||
ChannelPipelineFactory factory = transport.configureServerChannelPipelineFactory("client",
|
||||
settingsBuilder().put("xpack.security.ssl", false).build());
|
||||
Settings.builder().put("xpack.security.ssl", false).build());
|
||||
assertThat(factory.getPipeline().get(SslHandler.class), nullValue());
|
||||
}
|
||||
|
||||
public void testThatSSLCanBeEnabledByProfile() throws Exception {
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), false).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), false).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService, mock(NamedWriteableRegistry.class));
|
||||
NettyMockUtil.setOpenChannelsHandlerToMock(transport);
|
||||
ChannelPipelineFactory factory = transport.configureServerChannelPipelineFactory("client",
|
||||
settingsBuilder().put("xpack.security.ssl", true).build());
|
||||
Settings.builder().put("xpack.security.ssl", true).build());
|
||||
assertThat(factory.getPipeline().get(SslHandler.class), notNullValue());
|
||||
}
|
||||
|
||||
public void testThatProfileTakesDefaultSSLSetting() throws Exception {
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService, mock(NamedWriteableRegistry.class));
|
||||
NettyMockUtil.setOpenChannelsHandlerToMock(transport);
|
||||
|
@ -77,7 +76,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testDefaultClientAuth() throws Exception {
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService, mock(NamedWriteableRegistry.class));
|
||||
NettyMockUtil.setOpenChannelsHandlerToMock(transport);
|
||||
|
@ -88,7 +87,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
|
||||
public void testRequiredClientAuth() throws Exception {
|
||||
String value = randomFrom(SSLClientAuth.REQUIRED.name(), SSLClientAuth.REQUIRED.name().toLowerCase(Locale.ROOT), "true");
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
.put(ShieldNettyTransport.CLIENT_AUTH_SETTING.getKey(), value).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
|
@ -101,7 +100,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
|
||||
public void testNoClientAuth() throws Exception {
|
||||
String value = randomFrom(SSLClientAuth.NO.name(), "false", "FALSE", SSLClientAuth.NO.name().toLowerCase(Locale.ROOT));
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
.put(ShieldNettyTransport.CLIENT_AUTH_SETTING.getKey(), value).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
|
@ -114,7 +113,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
|
||||
public void testOptionalClientAuth() throws Exception {
|
||||
String value = randomFrom(SSLClientAuth.OPTIONAL.name(), SSLClientAuth.OPTIONAL.name().toLowerCase(Locale.ROOT));
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
.put(ShieldNettyTransport.CLIENT_AUTH_SETTING.getKey(), value).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
|
@ -127,7 +126,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
|
||||
public void testProfileRequiredClientAuth() throws Exception {
|
||||
String value = randomFrom(SSLClientAuth.REQUIRED.name(), SSLClientAuth.REQUIRED.name().toLowerCase(Locale.ROOT), "true", "TRUE");
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService, mock(NamedWriteableRegistry.class));
|
||||
NettyMockUtil.setOpenChannelsHandlerToMock(transport);
|
||||
|
@ -139,7 +138,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
|
||||
public void testProfileNoClientAuth() throws Exception {
|
||||
String value = randomFrom(SSLClientAuth.NO.name(), "false", "FALSE", SSLClientAuth.NO.name().toLowerCase(Locale.ROOT));
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class), mock(NetworkService.class),
|
||||
mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService, mock(NamedWriteableRegistry.class));
|
||||
NettyMockUtil.setOpenChannelsHandlerToMock(transport);
|
||||
|
@ -151,7 +150,7 @@ public class ShieldNettyTransportTests extends ESTestCase {
|
|||
|
||||
public void testProfileOptionalClientAuth() throws Exception {
|
||||
String value = randomFrom(SSLClientAuth.OPTIONAL.name(), SSLClientAuth.OPTIONAL.name().toLowerCase(Locale.ROOT));
|
||||
Settings settings = settingsBuilder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(ShieldNettyTransport.SSL_SETTING.getKey(), true).build();
|
||||
ShieldNettyTransport transport = new ShieldNettyTransport(settings, mock(ThreadPool.class),
|
||||
mock(NetworkService.class), mock(BigArrays.class), Version.CURRENT, null, serverSSLService, clientSSLService,
|
||||
mock(NamedWriteableRegistry.class));
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.net.InetSocketAddress;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -32,7 +31,7 @@ public class SslHostnameVerificationTests extends ShieldIntegTestCase {
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder settingsBuilder = settingsBuilder().put(super.nodeSettings(nodeOrdinal));
|
||||
Settings.Builder settingsBuilder = Settings.builder().put(super.nodeSettings(nodeOrdinal));
|
||||
Path keystore;
|
||||
try {
|
||||
/*
|
||||
|
@ -72,7 +71,7 @@ public class SslHostnameVerificationTests extends ShieldIntegTestCase {
|
|||
assertThat(transportAddress, instanceOf(InetSocketTransportAddress.class));
|
||||
InetSocketAddress inetSocketAddress = ((InetSocketTransportAddress) transportAddress).address();
|
||||
|
||||
Settings settings = settingsBuilder().put(transportClientSettings())
|
||||
Settings settings = Settings.builder().put(transportClientSettings())
|
||||
.put(ShieldNettyTransport.HOSTNAME_VERIFICATION_SETTING.getKey(), true)
|
||||
.build();
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.io.IOException;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
||||
import static org.elasticsearch.test.ShieldSettingsSource.getSSLSettingsForStore;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -38,7 +37,7 @@ import static org.hamcrest.Matchers.containsString;
|
|||
public class SslClientAuthTests extends ShieldIntegTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
// invert the require auth settings
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -74,7 +73,7 @@ public class SslClientAuthTests extends ShieldIntegTestCase {
|
|||
}
|
||||
|
||||
public void testThatHttpWorksWithSslClientAuth() throws IOException {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(getSSLSettingsForStore("/org/elasticsearch/shield/transport/ssl/certs/simple/testclient.jks", "testclient"))
|
||||
.build();
|
||||
ClientSSLService sslService = new ClientSSLService(settings);
|
||||
|
@ -102,7 +101,7 @@ public class SslClientAuthTests extends ShieldIntegTestCase {
|
|||
throw new ElasticsearchException("store path doesn't exist");
|
||||
}
|
||||
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
.put("xpack.security.ssl.keystore.path", store)
|
||||
.put("xpack.security.ssl.keystore.password", "testclient-client-profile")
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.security.KeyStore;
|
|||
import java.security.SecureRandom;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.ShieldSettingsSource.getSSLSettingsForStore;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
@ -46,7 +45,7 @@ import static org.hamcrest.Matchers.instanceOf;
|
|||
public class SslIntegrationTests extends ShieldIntegTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal))
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
|
||||
.put(ShieldNettyHttpServerTransport.SSL_SETTING.getKey(), true).build();
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ public class SslIntegrationTests extends ShieldIntegTestCase {
|
|||
|
||||
// no SSL exception as this is the exception is returned when connecting
|
||||
public void testThatUnconfiguredCiphersAreRejected() {
|
||||
try (TransportClient transportClient = TransportClient.builder().addPlugin(XPackPlugin.class).settings(settingsBuilder()
|
||||
try (TransportClient transportClient = TransportClient.builder().addPlugin(XPackPlugin.class).settings(Settings.builder()
|
||||
.put(transportClientSettings())
|
||||
.put("node.name", "programmatic_transport_client")
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
|
@ -77,7 +76,7 @@ public class SslIntegrationTests extends ShieldIntegTestCase {
|
|||
|
||||
// no SSL exception as this is the exception is returned when connecting
|
||||
public void testThatTransportClientUsingSSLv3ProtocolIsRejected() {
|
||||
try(TransportClient transportClient = TransportClient.builder().addPlugin(XPackPlugin.class).settings(settingsBuilder()
|
||||
try(TransportClient transportClient = TransportClient.builder().addPlugin(XPackPlugin.class).settings(Settings.builder()
|
||||
.put(transportClientSettings())
|
||||
.put("node.name", "programmatic_transport_client")
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.net.InetAddress;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.ShieldSettingsSource.DEFAULT_PASSWORD;
|
||||
import static org.elasticsearch.test.ShieldSettingsSource.DEFAULT_USER_NAME;
|
||||
import static org.elasticsearch.test.ShieldSettingsSource.getSSLSettingsForStore;
|
||||
|
@ -64,7 +63,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
// client set up here
|
||||
.put("transport.profiles.client.port", randomClientPortRange)
|
||||
|
@ -88,7 +87,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
}
|
||||
|
||||
private TransportClient createTransportClient(Settings additionalSettings) {
|
||||
Settings settings = settingsBuilder().put(transportClientSettings())
|
||||
Settings settings = Settings.builder().put(transportClientSettings())
|
||||
.put("node.name", "programmatic_transport_client")
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(additionalSettings)
|
||||
|
@ -223,7 +222,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* Uses a transport client with SSL disabled. This test connects to the no_ssl profile, which should always succeed
|
||||
*/
|
||||
public void testThatTransportClientCanConnectToNoSslProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.build();
|
||||
|
@ -238,7 +237,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* as a non-ssl transport client cannot connect to a ssl profile
|
||||
*/
|
||||
public void testThatTransportClientCannotConnectToDefaultProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.build();
|
||||
|
@ -256,7 +255,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* as a non-ssl transport client cannot connect to a ssl profile
|
||||
*/
|
||||
public void testThatTransportClientCannotConnectToClientProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.build();
|
||||
|
@ -274,7 +273,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* as a non-ssl transport client cannot connect to a ssl profile
|
||||
*/
|
||||
public void testThatTransportClientCannotConnectToNoClientAuthProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.build();
|
||||
|
@ -294,7 +293,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* the testnode certificate and does not require to present a certificate, so this connection should always succeed
|
||||
*/
|
||||
public void testThatTransportClientWithOnlyTruststoreCanConnectToNoClientAuthProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -316,7 +315,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* the client has no certificate to present
|
||||
*/
|
||||
public void testThatTransportClientWithOnlyTruststoreCannotConnectToClientProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -340,7 +339,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* the client has no certificate to present
|
||||
*/
|
||||
public void testThatTransportClientWithOnlyTruststoreCannotConnectToDefaultProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -363,7 +362,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* SSL so the connection should never succeed
|
||||
*/
|
||||
public void testThatTransportClientWithOnlyTruststoreCannotConnectToNoSslProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -386,7 +385,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* will never be trusted by the default truststore so the connection should always fail
|
||||
*/
|
||||
public void testThatSSLTransportClientWithNoTruststoreCannotConnectToDefaultProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -406,7 +405,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* will never be trusted by the default truststore so the connection should always fail
|
||||
*/
|
||||
public void testThatSSLTransportClientWithNoTruststoreCannotConnectToClientProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -426,7 +425,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* will never be trusted by the default truststore so the connection should always fail
|
||||
*/
|
||||
public void testThatSSLTransportClientWithNoTruststoreCannotConnectToNoClientAuthProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
@ -447,7 +446,7 @@ public class SslMultiPortTests extends ShieldIntegTestCase {
|
|||
* will not work
|
||||
*/
|
||||
public void testThatSSLTransportClientWithNoTruststoreCannotConnectToNoSslProfile() throws Exception {
|
||||
Settings settings = settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.USER_SETTING.getKey(), DEFAULT_USER_NAME + ":" + DEFAULT_PASSWORD)
|
||||
.put("cluster.name", internalCluster().getClusterName())
|
||||
.put(ShieldNettyTransport.SSL_SETTING.getKey(), true)
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean;
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.test.ESTestCase.randomFrom;
|
||||
import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basicAuthHeaderValue;
|
||||
import static org.elasticsearch.shield.test.ShieldTestUtils.writeFile;
|
||||
|
@ -48,7 +47,7 @@ import static org.elasticsearch.shield.test.ShieldTestUtils.writeFile;
|
|||
*/
|
||||
public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZen {
|
||||
|
||||
public static final Settings DEFAULT_SETTINGS = settingsBuilder()
|
||||
public static final Settings DEFAULT_SETTINGS = Settings.builder()
|
||||
.put("node.mode", "network")
|
||||
.build();
|
||||
|
||||
|
@ -120,7 +119,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
|
|||
@Override
|
||||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
Path folder = ShieldTestUtils.createFolder(parentFolder, subfolderPrefix + "-" + nodeOrdinal);
|
||||
Settings.Builder builder = settingsBuilder().put(super.nodeSettings(nodeOrdinal))
|
||||
Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
|
||||
//TODO: for now isolate shield tests from watcher & monitoring (randomize this later)
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false)
|
||||
|
@ -144,7 +143,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
|
|||
|
||||
@Override
|
||||
public Settings transportClientSettings() {
|
||||
Settings.Builder builder = settingsBuilder().put(super.transportClientSettings())
|
||||
Settings.Builder builder = Settings.builder().put(super.transportClientSettings())
|
||||
.put(getClientSSLSettings());
|
||||
if (randomBoolean()) {
|
||||
builder.put(Security.USER_SETTING.getKey(),
|
||||
|
@ -247,7 +246,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
|
|||
|
||||
final String sslEnabledSetting =
|
||||
randomFrom(ShieldNettyTransport.SSL_SETTING.getKey(), ShieldNettyTransport.DEPRECATED_SSL_SETTING.getKey());
|
||||
Settings.Builder builder = settingsBuilder().put(sslEnabledSetting, sslTransportEnabled);
|
||||
Settings.Builder builder = Settings.builder().put(sslEnabledSetting, sslTransportEnabled);
|
||||
|
||||
if (transportClient == false) {
|
||||
builder.put(ShieldNettyHttpServerTransport.SSL_SETTING.getKey(), false);
|
||||
|
|
|
@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.startsWith;
|
|||
public class ShieldServerTransportServiceTests extends ShieldIntegTestCase {
|
||||
@Override
|
||||
protected Settings transportClientSettings() {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.transportClientSettings())
|
||||
.put(Security.enabledSetting(), true)
|
||||
.build();
|
||||
|
|
|
@ -93,8 +93,6 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
|
||||
public class Watcher {
|
||||
|
||||
public static final String NAME = "watcher";
|
||||
|
@ -162,7 +160,7 @@ public class Watcher {
|
|||
if (enabled == false || transportClient) {
|
||||
return Settings.EMPTY;
|
||||
}
|
||||
Settings additionalSettings = settingsBuilder()
|
||||
Settings additionalSettings = Settings.builder()
|
||||
.put(HistoryModule.additionalSettings(settings))
|
||||
.build();
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.not;
|
|||
public class WatcherPluginDisableTests extends ESIntegTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.settingsBuilder()
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class AlwaysConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserValid() throws Exception {
|
||||
AlwaysConditionFactory factory = new AlwaysConditionFactory(Settings.settingsBuilder().build());
|
||||
AlwaysConditionFactory factory = new AlwaysConditionFactory(Settings.builder().build());
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.endObject();
|
||||
|
@ -38,7 +38,7 @@ public class AlwaysConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserInvalid() throws Exception {
|
||||
ConditionFactory factor = new AlwaysConditionFactory(Settings.settingsBuilder().build());
|
||||
ConditionFactory factor = new AlwaysConditionFactory(Settings.builder().build());
|
||||
XContentBuilder builder = jsonBuilder()
|
||||
.startObject()
|
||||
.field("foo", "bar")
|
||||
|
|
|
@ -27,7 +27,7 @@ public class NeverConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserValid() throws Exception {
|
||||
NeverConditionFactory factory = new NeverConditionFactory(Settings.settingsBuilder().build());
|
||||
NeverConditionFactory factory = new NeverConditionFactory(Settings.builder().build());
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.endObject();
|
||||
|
@ -40,7 +40,7 @@ public class NeverConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserInvalid() throws Exception {
|
||||
ConditionFactory factory = new NeverConditionFactory(Settings.settingsBuilder().build());
|
||||
ConditionFactory factory = new NeverConditionFactory(Settings.builder().build());
|
||||
XContentBuilder builder = jsonBuilder();
|
||||
builder.startObject();
|
||||
builder.field("foo", "bar");
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserValid() throws Exception {
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
|
||||
XContentBuilder builder = createConditionContent("ctx.payload.hits.total > 1", null, ScriptType.INLINE);
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testParserInvalid() throws Exception {
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory factory = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||
builder.startObject().endObject();
|
||||
XContentParser parser = XContentFactory.xContent(builder.bytes()).createParser(builder.bytes());
|
||||
|
@ -120,7 +120,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testScriptConditionParserBadScript() throws Exception {
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
ScriptType scriptType = randomFrom(ScriptType.values());
|
||||
String script;
|
||||
switch (scriptType) {
|
||||
|
@ -146,7 +146,7 @@ public class ScriptConditionTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testScriptConditionParser_badLang() throws Exception {
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptConditionFactory conditionParser = new ScriptConditionFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
ScriptType scriptType = ScriptType.INLINE;
|
||||
String script = "return true";
|
||||
XContentBuilder builder = createConditionContent(script, "not_a_valid_lang", scriptType);
|
||||
|
|
|
@ -238,7 +238,7 @@ public final class WatcherTestUtils {
|
|||
}
|
||||
|
||||
public static ScriptServiceProxy getScriptServiceProxy(ThreadPool tp) throws Exception {
|
||||
Settings settings = Settings.settingsBuilder()
|
||||
Settings settings = Settings.builder()
|
||||
.put("script.inline", "true")
|
||||
.put("script.indexed", "true")
|
||||
.put("path.home", createTempDir())
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.io.OutputStream;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.search.builder.SearchSourceBuilder.searchSource;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
||||
|
@ -59,7 +58,7 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas
|
|||
throw new RuntimeException(ex);
|
||||
}
|
||||
//Set path so ScriptService will pick up the test scripts
|
||||
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put("path.conf", configDir.toString()).build();
|
||||
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put("path.conf", configDir.toString()).build();
|
||||
}
|
||||
|
||||
public void testScriptTransform() throws Exception {
|
||||
|
|
|
@ -170,7 +170,7 @@ public class ScriptTransformTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testScriptConditionParserBadScript() throws Exception {
|
||||
ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
ScriptType scriptType = randomFrom(ScriptType.values());
|
||||
String script;
|
||||
switch (scriptType) {
|
||||
|
@ -202,7 +202,7 @@ public class ScriptTransformTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testScriptConditionParserBadLang() throws Exception {
|
||||
ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.settingsBuilder().build(), getScriptServiceProxy(tp));
|
||||
ScriptTransformFactory transformFactory = new ScriptTransformFactory(Settings.builder().build(), getScriptServiceProxy(tp));
|
||||
ScriptType scriptType = randomFrom(ScriptType.values());
|
||||
String script = "return true";
|
||||
XContentBuilder builder = jsonBuilder().startObject()
|
||||
|
|
Loading…
Reference in New Issue