From 077599b63fb0d151be5cf9e7f6e8ef8982dc5292 Mon Sep 17 00:00:00 2001 From: markharwood Date: Thu, 28 Apr 2016 13:47:19 +0100 Subject: [PATCH] X-plugin tests - added testing for Standard licence in graph plugin. See https://github.com/elastic/x-plugins/issues/1263 Original commit: elastic/x-pack-elasticsearch@6773ead0fc66945e9ef62a3f0eb9a65089874451 --- .../graph/license/LicenseTests.java | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) 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 fc1084c43b9..c27a43b495c 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 @@ -29,8 +29,16 @@ public class LicenseTests extends AbstractLicenseeTestCase { GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry); licenseeRegistry.register(graphLicensee); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); } + + public void testStandardLicenseIsDisabled() throws Exception { + licenseeRegistry.setOperationMode(OperationMode.STANDARD); + GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry); + licenseeRegistry.register(graphLicensee); + + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); + } public void testNoLicenseDoesNotWork() { licenseeRegistry.setOperationMode(OperationMode.BASIC); @@ -38,7 +46,7 @@ public class LicenseTests extends AbstractLicenseeTestCase { licenseeRegistry.register(graphLicensee); licenseeRegistry.disable(); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); } public void testExpiredPlatinumTrialLicenseIsRestricted() throws Exception { @@ -47,7 +55,7 @@ public class LicenseTests extends AbstractLicenseeTestCase { licenseeRegistry.register(graphLicensee); licenseeRegistry.disable(); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); } public void testUpgradingFromBasicLicenseWorks() { @@ -55,7 +63,7 @@ public class LicenseTests extends AbstractLicenseeTestCase { GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry); licenseeRegistry.register(graphLicensee); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode()); assertLicensePlatinumTrialBehaviour(graphLicensee); @@ -69,9 +77,31 @@ public class LicenseTests extends AbstractLicenseeTestCase { assertLicensePlatinumTrialBehaviour(graphLicensee); licenseeRegistry.setOperationMode(OperationMode.BASIC); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); } + public void testUpgradingFromStandardLicenseWorks() { + licenseeRegistry.setOperationMode(OperationMode.STANDARD); + GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry); + licenseeRegistry.register(graphLicensee); + + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); + + licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode()); + assertLicensePlatinumTrialBehaviour(graphLicensee); + } + + public void testDowngradingToStandardLicenseWorks() { + licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode()); + GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry); + licenseeRegistry.register(graphLicensee); + + assertLicensePlatinumTrialBehaviour(graphLicensee); + + licenseeRegistry.setOperationMode(OperationMode.STANDARD); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); + } + public void testDowngradingToGoldLicenseWorks() { licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode()); GraphLicensee graphLicensee = new GraphLicensee(Settings.EMPTY, licenseeRegistry); @@ -80,7 +110,7 @@ public class LicenseTests extends AbstractLicenseeTestCase { assertLicensePlatinumTrialBehaviour(graphLicensee); licenseeRegistry.setOperationMode(OperationMode.GOLD); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); } public void testUpgradingExpiredLicenseWorks() { @@ -89,7 +119,7 @@ public class LicenseTests extends AbstractLicenseeTestCase { licenseeRegistry.register(graphLicensee); licenseeRegistry.disable(); - assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(graphLicensee); + assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(graphLicensee); licenseeRegistry.setOperationMode(randomTrialOrPlatinumMode()); assertLicensePlatinumTrialBehaviour(graphLicensee); @@ -99,7 +129,7 @@ public class LicenseTests extends AbstractLicenseeTestCase { assertThat("Expected graph exploration to be allowed", graphLicensee.isAvailable(), is(true)); } - private void assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(GraphLicensee graphLicensee) { + private void assertLicenseBasicOrStandardGoldOrNoneOrExpiredBehaviour(GraphLicensee graphLicensee) { assertThat("Expected graph exploration not to be allowed", graphLicensee.isAvailable(), is(false)); } }