From e8472908c14b9a924b11663aba461cd0da22f550 Mon Sep 17 00:00:00 2001 From: Suyog Rao Date: Tue, 27 Jun 2017 14:21:00 -0700 Subject: [PATCH] [Logstash] Change config management license to Gold (elastic/x-pack-elasticsearch#1843) * [Logstash] Change management license to Gold Previously the license type for LS config management was `BASIC`. In order to use the security features in Standard/Gold, we had to bump Logstash as well to Gold license. relates elastic/x-pack-elasticsearch#1841 Original commit: elastic/x-pack-elasticsearch@29194b2417fc432b804794e2c808c9c869f07d29 --- .../license/XPackLicenseState.java | 22 +++++++++++++++---- .../license/XPackLicenseStateTests.java | 21 +++++++++++++----- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/license/XPackLicenseState.java b/plugin/src/main/java/org/elasticsearch/license/XPackLicenseState.java index 9edea6222c3..58ce641d6d0 100644 --- a/plugin/src/main/java/org/elasticsearch/license/XPackLicenseState.java +++ b/plugin/src/main/java/org/elasticsearch/license/XPackLicenseState.java @@ -176,9 +176,9 @@ public class XPackLicenseState { private static String[] logstashAcknowledgementMessages(OperationMode currentMode, OperationMode newMode) { switch (newMode) { - case TRIAL: + case BASIC: switch (currentMode) { - case BASIC: + case TRIAL: case STANDARD: case GOLD: case PLATINUM: @@ -429,11 +429,25 @@ public class XPackLicenseState { } /** - * Logstash is always allowed as long as there is an active license + * Logstash is allowed as long as there is an active license of type TRIAL, STANDARD, GOLD or PLATINUM * @return {@code true} as long as there is a valid license */ public boolean isLogstashAllowed() { - return status.active; + Status localStatus = status; + + if (localStatus.active == false) { + return false; + } + + switch (localStatus.mode) { + case TRIAL: + case GOLD: + case PLATINUM: + case STANDARD: + return true; + default: + return false; + } } /** diff --git a/plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java b/plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java index a2cb37d6acd..394768ea516 100644 --- a/plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java +++ b/plugin/src/test/java/org/elasticsearch/license/XPackLicenseStateTests.java @@ -292,13 +292,22 @@ public class XPackLicenseStateTests extends ESTestCase { assertAllowed(PLATINUM, false, XPackLicenseState::isMachineLearningAllowed, false); } - public void testLogstashAllowed() { - assertAllowed(randomMode(), true, XPackLicenseState::isLogstashAllowed, true); - assertAllowed(randomMode(), false, XPackLicenseState::isLogstashAllowed, false); + public void testLogstashPlatinumGoldTrialStandard() throws Exception { + assertAllowed(TRIAL, true, XPackLicenseState::isLogstashAllowed, true); + assertAllowed(GOLD, true, XPackLicenseState::isLogstashAllowed, true); + assertAllowed(PLATINUM, true, XPackLicenseState::isLogstashAllowed, true); + assertAllowed(STANDARD, true, XPackLicenseState::isLogstashAllowed, true); } - public void testLogstashAckNotBasicToTrial() { - OperationMode from = randomFrom(STANDARD, BASIC, GOLD, PLATINUM); - assertAckMesssages(Logstash.NAME, from, TRIAL, 1); + public void testLogstashBasicLicense() throws Exception { + assertAllowed(BASIC, true, XPackLicenseState::isLogstashAllowed, false); + } + + public void testLogstashInactive() { + assertAllowed(BASIC, false, XPackLicenseState::isLogstashAllowed, false); + assertAllowed(TRIAL, false, XPackLicenseState::isLogstashAllowed, false); + assertAllowed(GOLD, false, XPackLicenseState::isLogstashAllowed, false); + assertAllowed(PLATINUM, false, XPackLicenseState::isLogstashAllowed, false); + assertAllowed(STANDARD, false, XPackLicenseState::isLogstashAllowed, false); } }