diff --git a/elasticsearch/license/base/src/main/java/org/elasticsearch/license/core/License.java b/elasticsearch/license/base/src/main/java/org/elasticsearch/license/core/License.java index 37c410d0a55..97f0a3a23b2 100644 --- a/elasticsearch/license/base/src/main/java/org/elasticsearch/license/core/License.java +++ b/elasticsearch/license/base/src/main/java/org/elasticsearch/license/core/License.java @@ -102,30 +102,6 @@ public class License implements ToXContent { throw new IllegalArgumentException("unknown type [" + type + "]"); } } - - /** - * Determine if the operation mode should be treated like a paid license. - *
- * This should be used for licenses that do not tier features, but that require a paid license. - *
- * Note: This does not mean that the license state is enabled! - * - * @return {@code true} if the license is not {@link #BASIC}. - */ - public boolean isPaid() { - return this != BASIC; - } - - /** - * Determine if the current operation mode unlocks all features. - *
- * Note: This does not mean that the license state is enabled! - * - * @return {@code true} if the license is either {@link #TRIAL} or {@link #PLATINUM}. - */ - public boolean allFeaturesEnabled() { - return this == TRIAL || this == PLATINUM; - } } private License(int version, String uid, String issuer, String issuedTo, long issueDate, String type, diff --git a/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseOperationModeTests.java b/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseOperationModeTests.java index 827533ba246..9eaf477169a 100644 --- a/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseOperationModeTests.java +++ b/elasticsearch/license/base/src/test/java/org/elasticsearch/license/core/LicenseOperationModeTests.java @@ -16,29 +16,6 @@ import static org.hamcrest.Matchers.equalTo; * If you change the behavior of these tests, then it means that licensing changes across the products! */ public class LicenseOperationModeTests extends ESTestCase { - public void testIsPaid() { - assertThat(OperationMode.BASIC.isPaid(), equalTo(false)); - - // EVERY other operation mode is expected to be equivalent to paid; loop will catch any new mode - for (OperationMode mode : OperationMode.values()) { - if (mode != OperationMode.BASIC) { - assertThat(mode.isPaid(), equalTo(true)); - } - } - } - - public void testAllFeaturesEnabled() { - assertThat(OperationMode.TRIAL.allFeaturesEnabled(), equalTo(true)); - assertThat(OperationMode.PLATINUM.allFeaturesEnabled(), equalTo(true)); - - // EVERY other operation mode is expected to NOT enable everything; loop will catch any new mode - for (OperationMode mode : OperationMode.values()) { - if (mode != OperationMode.TRIAL && mode != OperationMode.PLATINUM) { - assertThat(mode.allFeaturesEnabled(), equalTo(false)); - } - } - } - public void testResolveTrial() { // assert 1.x BWC assertResolve(OperationMode.TRIAL, "nONE", "DEv", "deveLopment"); @@ -53,14 +30,14 @@ public class LicenseOperationModeTests extends ESTestCase { public void testResolveGold() { // assert expected (2.x+) variant (note: no different 1.x variant of GOLD) - assertResolve(OperationMode.BASIC, "SiLvEr", "gOlD", "silver", "gold"); + assertResolve(OperationMode.GOLD, "SiLvEr", "gOlD", "silver", "gold"); } public void testResolvePlatinum() { // assert 1.x BWC - assertResolve(OperationMode.TRIAL, "iNtErNaL"); + assertResolve(OperationMode.PLATINUM, "iNtErNaL"); // assert expected (2.x+) variant - assertResolve(OperationMode.TRIAL, "PlAtINum", "platinum"); + assertResolve(OperationMode.PLATINUM, "PlAtINum", "platinum"); } public void testResolveUnknown() { diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java b/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java index 9e5b39cad16..a6eba86c532 100644 --- a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java +++ b/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/LicenseState.java @@ -38,14 +38,5 @@ public enum LicenseState { * changes to {@link #ENABLED}, otherwise * remains unchanged */ - DISABLED; - - /** - * Determine if the license should be treated as active. - * - * @return {@code true} if it is not {@link #DISABLED}. - */ - public boolean isActive() { - return this != DISABLED; - } + DISABLED } diff --git a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java b/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java index ec557c5aad8..27432b4ce8c 100644 --- a/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java +++ b/elasticsearch/license/plugin-api/src/main/java/org/elasticsearch/license/plugin/core/Licensee.java @@ -67,10 +67,6 @@ public interface Licensee { *
* Note: Knowing the mode does not indicate whether the {@link #getLicenseState() state} is disabled. If that matters (e.g., * disabling services when a license becomes disabled), then you should check it as well! - * - * @see OperationMode#allFeaturesEnabled() - * @see OperationMode#isPaid() - * @see LicenseState#isActive() */ public OperationMode getMode() { return mode; @@ -82,8 +78,6 @@ public interface Licensee { * the state changes to {@link LicenseState#GRACE_PERIOD} * and after the grace period has ended the state changes * to {@link LicenseState#DISABLED} - * - * @see LicenseState#isActive() */ public LicenseState getLicenseState() { return licenseState; diff --git a/elasticsearch/license/plugin-api/src/test/java/org/elasticsearch/license/plugin/core/LicenseStateTests.java b/elasticsearch/license/plugin-api/src/test/java/org/elasticsearch/license/plugin/core/LicenseStateTests.java deleted file mode 100644 index dfef24e499e..00000000000 --- a/elasticsearch/license/plugin-api/src/test/java/org/elasticsearch/license/plugin/core/LicenseStateTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.license.plugin.core; - -import org.elasticsearch.test.ESTestCase; - -import static org.hamcrest.Matchers.equalTo; - -/** - * Tests {@link LicenseState} correctness. - *
- * If you change the behavior of these tests, then it means that licensing changes across the products!
- */
-public class LicenseStateTests extends ESTestCase {
- public void testIsActive() {
- assertThat(LicenseState.DISABLED.isActive(), equalTo(false));
-
- // all other states are considered active; loop will catch any new state
- for (LicenseState state : LicenseState.values()) {
- if (state != LicenseState.DISABLED) {
- assertThat(state.isActive(), equalTo(true));
- }
- }
- }
-}
diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java
index 15996f64266..5b6e66ec8e8 100644
--- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java
+++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java
@@ -9,7 +9,9 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.core.License;
+import org.elasticsearch.license.core.License.OperationMode;
import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent;
+import org.elasticsearch.license.plugin.core.LicenseState;
import org.elasticsearch.license.plugin.core.LicenseeRegistry;
import org.elasticsearch.graph.Graph;
@@ -31,17 +33,39 @@ public class GraphLicensee extends AbstractLicenseeComponent
+ * Exploration is only disabled when the license has expired or if the mode is not:
+ *
- * Collection is only disabled automatically when the license expires.
+ * Collection is only disabled automatically when the license expires. All modes are valid for collection.
*
- *
* Collection can be disabled explicitly by the user, although that's generally a temporary solution to unrelated issues
* (e.g., initial setup when the monitoring cluster doesn't actually exist).
*
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
*/
public boolean collectionEnabled() {
- return status.getLicenseState().isActive();
+ return status.getLicenseState() != LicenseState.DISABLED;
}
/**
* Determine if the index cleaning service is enabled.
*
- * Index cleaning is only disabled when the license expires.
+ * Index cleaning is only disabled when the license expires. All modes are valid for cleaning.
*
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
*/
public boolean cleaningEnabled() {
- return status.getLicenseState().isActive();
+ return status.getLicenseState() != LicenseState.DISABLED;
}
/**
* Determine if the current license allows the retention of indices to be modified.
*
- * Only users with a paid license type (or equivalent in the case of trial licenses) can update the retention period.
- *
+ * Only users with the following license types can update the retention period:
+ *
+ * DLS and FLS are only disabled when the mode is not:
+ *
+ * Custom Realms are only disabled when the mode is not:
+ *
+ * Watcher is only disabled when the license has expired or if the mode is not:
+ *
+ *
+ *
+ * @return {@code true} as long as the license is valid. Otherwise {@code false}.
+ */
public boolean isGraphExploreEnabled() {
// status is volatile
Status localStatus = status;
- return localStatus.getLicenseState().isActive() && localStatus.getMode().allFeaturesEnabled();
+ OperationMode operationMode = localStatus.getMode();
+
+ boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
+
+ return licensed && localStatus.getLicenseState() != LicenseState.DISABLED;
}
}
diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java
index 712d0704708..ebf339b7d88 100644
--- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java
+++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java
@@ -5,15 +5,9 @@
*/
package org.elasticsearch.graph.license;
-import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.license.core.License;
+import org.elasticsearch.license.core.License.OperationMode;
import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase;
-import org.elasticsearch.license.plugin.core.Licensee;
-import org.elasticsearch.license.plugin.core.LicenseeRegistry;
-
-import java.util.ArrayList;
-import java.util.List;
import static org.hamcrest.Matchers.is;
@@ -22,15 +16,15 @@ public class LicenseTests extends AbstractLicenseeTestCase {
private SimpleLicenseeRegistry licenseeRegistry = new SimpleLicenseeRegistry();
public void testPlatinumTrialLicenseCanDoEverything() throws Exception {
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
assertLicensePlatinumTrialBehaviour(graphLicensee);
}
- public void testFreeLicenseIsDisabled() throws Exception {
- licenseeRegistry.setOperationMode(randomFreeMode());
+ public void testBasicLicenseIsDisabled() throws Exception {
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
@@ -38,7 +32,7 @@ public class LicenseTests extends AbstractLicenseeTestCase {
}
public void testNoLicenseDoesNotWork() {
- licenseeRegistry.setOperationMode(randomFreeMode());
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
licenseeRegistry.disable();
@@ -47,7 +41,7 @@ public class LicenseTests extends AbstractLicenseeTestCase {
}
public void testExpiredPlatinumTrialLicenseIsRestricted() throws Exception {
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
licenseeRegistry.disable();
@@ -55,48 +49,48 @@ public class LicenseTests extends AbstractLicenseeTestCase {
assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee);
}
- public void testUpgradingFromFreeLicenseWorks() {
- licenseeRegistry.setOperationMode(randomFreeMode());
+ public void testUpgradingFromBasicLicenseWorks() {
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee);
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
assertLicensePlatinumTrialBehaviour(graphLicensee);
}
- public void testDowngradingToFreeLicenseWorks() {
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ public void testDowngradingToBasicLicenseWorks() {
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
assertLicensePlatinumTrialBehaviour(graphLicensee);
- licenseeRegistry.setOperationMode(randomFreeMode());
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee);
}
public void testDowngradingToGoldLicenseWorks() {
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
assertLicensePlatinumTrialBehaviour(graphLicensee);
- licenseeRegistry.setOperationMode(License.OperationMode.GOLD);
+ licenseeRegistry.setOperationMode(OperationMode.GOLD);
assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee);
}
public void testUpgradingExpiredLicenseWorks() {
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(graphLicensee);
licenseeRegistry.disable();
assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee);
- licenseeRegistry.setOperationMode(randomAllFeaturesMode());
+ licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode());
assertLicensePlatinumTrialBehaviour(graphLicensee);
}
@@ -107,36 +101,4 @@ public class LicenseTests extends AbstractLicenseeTestCase {
private void assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(GraphLicensee graphLicensee) {
assertThat("Expected graph exploration not to be allowed", graphLicensee.isGraphExploreEnabled(), is(false));
}
-
- public static class SimpleLicenseeRegistry extends AbstractComponent implements LicenseeRegistry {
- private final List
+ *
* Note: This does not consider the state of the license so that any change is remembered for when they fix their license.
*
* @return {@code true} if the user is allowed to modify the retention. Otherwise {@code false}.
*/
public boolean allowUpdateRetention() {
- return status.getMode().isPaid();
+ return status.getMode() != OperationMode.BASIC;
}
}
diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java
index 9c9ce10ed7b..ea7754bebe0 100644
--- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java
+++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java
@@ -31,42 +31,42 @@ public class MarvelLicenseeTests extends AbstractLicenseeTestCase {
private final MarvelLicensee licensee = new MarvelLicensee(Settings.EMPTY, registry);
public void testAcknowledgementMessagesToAnyFromFreeIsNoOp() {
- assertEmptyAck(randomFreeMode(), randomFrom(OperationMode.values()), licensee);
+ assertEmptyAck(OperationMode.BASIC, randomMode(), licensee);
}
- public void testAcknowledgementMessagesToPaidFromAnyIsNoOp() {
- assertEmptyAck(randomFrom(OperationMode.values()), randomPaidMode(), licensee);
+ public void testAcknowledgementMessagesToTrialGoldOrPlatinumFromAnyIsNoOp() {
+ assertEmptyAck(randomMode(), randomTrialGoldOrPlatinumMode(), licensee);
}
- public void testAcknowledgementMessagesToFreeFromPaidNotesLimits() {
- String[] messages = ackLicenseChange(randomPaidMode(), randomFreeMode(), licensee);
+ public void testAcknowledgementMessagesToBasicFromNotBasicNotesLimits() {
+ String[] messages = ackLicenseChange(randomModeExcept(OperationMode.BASIC), OperationMode.BASIC, licensee);
// leaving messages up to inspection
assertThat(messages.length, equalTo(2));
}
public void testCollectionEnabledIsTrueForActiveState() {
- assertEnabled(randomActiveState(), MarvelLicensee::collectionEnabled, true);
+ assertEnabled(randomEnabledOrGracePeriodState(), MarvelLicensee::collectionEnabled, true);
}
public void testCollectionEnabledIsFalseForInactiveState() {
- assertEnabled(randomInactiveState(), MarvelLicensee::collectionEnabled, false);
+ assertEnabled(LicenseState.DISABLED, MarvelLicensee::collectionEnabled, false);
}
public void testCleaningEnabledIsTrueForActiveState() {
- assertEnabled(randomActiveState(), MarvelLicensee::cleaningEnabled, true);
+ assertEnabled(randomEnabledOrGracePeriodState(), MarvelLicensee::cleaningEnabled, true);
}
public void testCleaningEnabledIsFalseForInactiveState() {
- assertEnabled(randomInactiveState(), MarvelLicensee::cleaningEnabled, false);
+ assertEnabled(LicenseState.DISABLED, MarvelLicensee::cleaningEnabled, false);
}
- public void testAllowUpdateRetentionIsTrueForPaid() {
- assertEnabled(randomPaidMode(), MarvelLicensee::allowUpdateRetention, true);
+ public void testAllowUpdateRetentionIsTrueForNotBasic() {
+ assertEnabled(randomModeExcept(OperationMode.BASIC), MarvelLicensee::allowUpdateRetention, true);
}
- public void testAllowUpdateRetentionIsFalseForFree() {
- assertEnabled(randomFreeMode(), MarvelLicensee::allowUpdateRetention, false);
+ public void testAllowUpdateRetentionIsFalseForBasic() {
+ assertEnabled(OperationMode.BASIC, MarvelLicensee::allowUpdateRetention, false);
}
/**
@@ -95,7 +95,7 @@ public class MarvelLicenseeTests extends AbstractLicenseeTestCase {
* @param predicate The method to invoke (expected to be an instance method).
* @param expected The expected outcome given the {@code mode} and {@code predicate}.
*/
- private void assertEnabled(License.OperationMode mode, Predicate
+ *
+ * Note: This does not consider the state of the license so that Security does not suddenly leak information!
+ *
+ * @return {@code true} to enable DLS and FLS. Otherwise {@code false}.
*/
public boolean documentAndFieldLevelSecurityEnabled() {
- return status.getMode().allFeaturesEnabled();
+ Status status = this.status;
+ return status.getMode() == OperationMode.TRIAL || status.getMode() == OperationMode.PLATINUM;
}
/**
- * @return true if the license enables the use of custom authentication realms
+ * Determine if Custom Realms should be enabled.
+ *
+ *
+ * Note: This does not consider the state of the license so that Security does not suddenly block requests!
+ *
+ * @return {@code true} to enable Custom Realms. Otherwise {@code false}.
*/
public boolean customRealmsEnabled() {
- return status.getMode().allFeaturesEnabled();
+ Status status = this.status;
+ return status.getMode() == OperationMode.TRIAL || status.getMode() == OperationMode.PLATINUM;
}
void updateStatus(Status status) {
diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java
index 5ee1ff9f165..7befc95f4c6 100644
--- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java
+++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java
@@ -48,19 +48,31 @@ public class ShieldLicensee extends AbstractLicenseeComponent
+ *
+ *
+ * @return {@code true} as long as the license is valid. Otherwise {@code false}.
+ */
public boolean isWatcherTransportActionAllowed() {
// status is volatile, so a local variable is used for a consistent view
Status localStatus = status;
- return localStatus.getLicenseState().isActive() && localStatus.getMode().isPaid();
+ OperationMode operationMode = localStatus.getMode();
+ boolean licensed = operationMode == TRIAL || operationMode == GOLD || operationMode == PLATINUM;
+
+ return licensed && localStatus.getLicenseState() != LicenseState.DISABLED;
}
}
diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java
index cddb77515a1..742d8454915 100644
--- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java
+++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java
@@ -5,15 +5,9 @@
*/
package org.elasticsearch.watcher.license;
-import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.license.core.License;
+import org.elasticsearch.license.core.License.OperationMode;
import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase;
-import org.elasticsearch.license.plugin.core.Licensee;
-import org.elasticsearch.license.plugin.core.LicenseeRegistry;
-
-import java.util.ArrayList;
-import java.util.List;
import static org.hamcrest.Matchers.is;
@@ -22,7 +16,7 @@ public class LicenseTests extends AbstractLicenseeTestCase {
private SimpleLicenseeRegistry licenseeRegistry = new SimpleLicenseeRegistry();
public void testPlatinumGoldTrialLicenseCanDoEverything() throws Exception {
- licenseeRegistry.setOperationMode(randomPaidMode());
+ licenseeRegistry.setOperationMode(randomTrialGoldOrPlatinumMode());
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
@@ -30,7 +24,7 @@ public class LicenseTests extends AbstractLicenseeTestCase {
}
public void testBasicLicenseIsDisabled() throws Exception {
- licenseeRegistry.setOperationMode(randomFreeMode());
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
@@ -38,7 +32,7 @@ public class LicenseTests extends AbstractLicenseeTestCase {
}
public void testNoLicenseDoesNotWork() {
- licenseeRegistry.setOperationMode(randomFreeMode());
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
licenseeRegistry.disable();
@@ -47,7 +41,7 @@ public class LicenseTests extends AbstractLicenseeTestCase {
}
public void testExpiredPlatinumGoldTrialLicenseIsRestricted() throws Exception {
- licenseeRegistry.setOperationMode(randomPaidMode());
+ licenseeRegistry.setOperationMode(randomTrialGoldOrPlatinumMode());
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
licenseeRegistry.disable();
@@ -56,36 +50,36 @@ public class LicenseTests extends AbstractLicenseeTestCase {
}
public void testUpgradingFromBasicLicenseWorks() {
- licenseeRegistry.setOperationMode(randomFreeMode());
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
assertLicenseBasicOrNoneOrExpiredBehaviour(watcherLicensee);
- licenseeRegistry.setOperationMode(randomPaidMode());
+ licenseeRegistry.setOperationMode(randomTrialGoldOrPlatinumMode());
assertLicenseGoldPlatinumTrialBehaviour(watcherLicensee);
}
public void testDowngradingToBasicLicenseWorks() {
- licenseeRegistry.setOperationMode(randomPaidMode());
+ licenseeRegistry.setOperationMode(randomTrialGoldOrPlatinumMode());
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
assertLicenseGoldPlatinumTrialBehaviour(watcherLicensee);
- licenseeRegistry.setOperationMode(randomFreeMode());
+ licenseeRegistry.setOperationMode(OperationMode.BASIC);
assertLicenseBasicOrNoneOrExpiredBehaviour(watcherLicensee);
}
public void testUpgradingExpiredLicenseWorks() {
- licenseeRegistry.setOperationMode(randomPaidMode());
+ licenseeRegistry.setOperationMode(randomTrialGoldOrPlatinumMode());
WatcherLicensee watcherLicensee = new WatcherLicensee(Settings.EMPTY, licenseeRegistry);
licenseeRegistry.register(watcherLicensee);
licenseeRegistry.disable();
assertLicenseBasicOrNoneOrExpiredBehaviour(watcherLicensee);
- licenseeRegistry.setOperationMode(randomPaidMode());
+ licenseeRegistry.setOperationMode(randomTrialGoldOrPlatinumMode());
assertLicenseGoldPlatinumTrialBehaviour(watcherLicensee);
}
@@ -102,36 +96,4 @@ public class LicenseTests extends AbstractLicenseeTestCase {
assertThat("Expected watcher transport actions not to be allowed", watcherLicensee.isWatcherTransportActionAllowed(), is(false));
assertThat("Expected actions of a watch not to be executed", watcherLicensee.isExecutingActionsAllowed(), is(false));
}
-
- public static class SimpleLicenseeRegistry extends AbstractComponent implements LicenseeRegistry {
- private final List