update to make elasticsearch 2.0 the minumim required version
This change makes the license plugin compatible with elasticseach-2.0.0-SNAPSHOT. This project now uses the elasticsearch-parent pom to standardize the build with core. As part of this, the Java security manager is enabled and all tests pass with the security manager enabled. Closes elastic/elasticsearch#46 Original commit: elastic/x-pack-elasticsearch@5f471ea298
This commit is contained in:
parent
092bdbe0c9
commit
5758ca3c7b
|
@ -14,4 +14,19 @@
|
||||||
<properties>
|
<properties>
|
||||||
<license.basedir combine.self="override">${project.parent.basedir}</license.basedir>
|
<license.basedir combine.self="override">${project.parent.basedir}</license.basedir>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||||
|
<artifactId>junit4-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>tests</id>
|
||||||
|
<phase/>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
107
core/pom.xml
107
core/pom.xml
|
@ -25,113 +25,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||||
<artifactId>junit4-maven-plugin</artifactId>
|
<artifactId>junit4-maven-plugin</artifactId>
|
||||||
<version>2.1.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>tests</id>
|
|
||||||
<phase>test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>junit4</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<dir>${project.basedir}/target</dir>
|
|
||||||
<classesDirectory>${project.basedir}/target/classes</classesDirectory>
|
|
||||||
<heartbeat>20</heartbeat>
|
|
||||||
<jvmOutputAction>pipe,warn</jvmOutputAction>
|
|
||||||
<leaveTemporary>true</leaveTemporary>
|
|
||||||
<listeners>
|
|
||||||
<report-ant-xml mavenExtensions="true"
|
|
||||||
dir="${project.build.directory}/surefire-reports"/>
|
|
||||||
<report-text
|
|
||||||
showThrowable="true"
|
|
||||||
showStackTraces="true"
|
|
||||||
showOutput="${tests.output}"
|
|
||||||
showStatusOk="false"
|
|
||||||
showStatusError="true"
|
|
||||||
showStatusFailure="true"
|
|
||||||
showStatusIgnored="true"
|
|
||||||
showSuiteSummary="true"
|
|
||||||
timestamps="false"/>
|
|
||||||
<report-execution-times historyLength="20" file="${basedir}/${execution.hint.file}"/>
|
|
||||||
</listeners>
|
|
||||||
<assertions>
|
|
||||||
<enable/>
|
|
||||||
<disable package="${tests.assertion.disabled}"/>
|
|
||||||
<!-- pass org.elasticsearch to run without assertions -->
|
|
||||||
</assertions>
|
|
||||||
<parallelism>${tests.jvms}</parallelism>
|
|
||||||
<balancers>
|
|
||||||
<execution-times>
|
|
||||||
<fileset dir="${basedir}" includes="${execution.hint.file}"/>
|
|
||||||
</execution-times>
|
|
||||||
</balancers>
|
|
||||||
<includes>
|
|
||||||
<include>**/*Tests.class</include>
|
|
||||||
<include>**/*Test.class</include>
|
|
||||||
</includes>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/Abstract*.class</exclude>
|
|
||||||
<exclude>**/*StressTest.class</exclude>
|
|
||||||
</excludes>
|
|
||||||
<jvmArgs>
|
|
||||||
<param>-Xmx${tests.heap.size}</param>
|
|
||||||
<param>-Xms${tests.heap.size}</param>
|
|
||||||
<param>-Xss256k</param>
|
|
||||||
<param>-XX:MaxPermSize=128m</param>
|
|
||||||
<param>-XX:MaxDirectMemorySize=512m</param>
|
|
||||||
<param>-Des.logger.prefix=</param>
|
|
||||||
</jvmArgs>
|
|
||||||
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
|
|
||||||
<sysouts>${tests.verbose}</sysouts>
|
|
||||||
<seed>${tests.seed}</seed>
|
|
||||||
<haltOnFailure>${tests.failfast}</haltOnFailure>
|
|
||||||
<uniqueSuiteNames>false</uniqueSuiteNames>
|
|
||||||
<systemProperties>
|
|
||||||
<java.io.tmpdir>.</java.io.tmpdir>
|
|
||||||
<!-- we use '.' since this is different per JVM-->
|
|
||||||
<!-- RandomizedTesting library system properties -->
|
|
||||||
<tests.bwc>${tests.bwc}</tests.bwc>
|
|
||||||
<tests.bwc.path>${tests.bwc.path}</tests.bwc.path>
|
|
||||||
<tests.bwc.version>${tests.bwc.version}</tests.bwc.version>
|
|
||||||
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
|
|
||||||
<tests.processors>${tests.processors}</tests.processors>
|
|
||||||
<tests.appendseed>${tests.appendseed}</tests.appendseed>
|
|
||||||
<tests.iters>${tests.iters}</tests.iters>
|
|
||||||
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
|
|
||||||
<tests.failfast>${tests.failfast}</tests.failfast>
|
|
||||||
<tests.class>${tests.class}</tests.class>
|
|
||||||
<tests.method>${tests.method}</tests.method>
|
|
||||||
<tests.nightly>${tests.nightly}</tests.nightly>
|
|
||||||
<tests.verbose>${tests.verbose}</tests.verbose>
|
|
||||||
<tests.badapples>${tests.badapples}</tests.badapples>
|
|
||||||
<tests.weekly>${tests.weekly}</tests.weekly>
|
|
||||||
<tests.slow>${tests.slow}</tests.slow>
|
|
||||||
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
|
|
||||||
<tests.slow>${tests.slow}</tests.slow>
|
|
||||||
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
|
|
||||||
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
|
|
||||||
<tests.integration>${tests.integration}</tests.integration>
|
|
||||||
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
|
|
||||||
<tests.enable_mock_modules>${tests.enable_mock_modules}</tests.enable_mock_modules>
|
|
||||||
<tests.assertion.disabled>${tests.assertion.disabled}</tests.assertion.disabled>
|
|
||||||
<tests.rest>${tests.rest}</tests.rest>
|
|
||||||
<tests.rest.suite>${tests.rest.suite}</tests.rest.suite>
|
|
||||||
<tests.rest.blacklist>${tests.rest.blacklist}</tests.rest.blacklist>
|
|
||||||
<tests.rest.spec>${tests.rest.spec}</tests.rest.spec>
|
|
||||||
<tests.network>${tests.network}</tests.network>
|
|
||||||
<tests.cluster>${tests.cluster}</tests.cluster>
|
|
||||||
<tests.heap.size>${tests.heap.size}</tests.heap.size>
|
|
||||||
<tests.filter>${tests.filter}</tests.filter>
|
|
||||||
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
|
|
||||||
<es.node.mode>${es.node.mode}</es.node.mode>
|
|
||||||
<es.logger.level>${es.logger.level}</es.logger.level>
|
|
||||||
<tests.security.manager>${tests.security.manager}</tests.security.manager>
|
|
||||||
<tests.compatibility>${tests.compatibility}</tests.compatibility>
|
|
||||||
<java.awt.headless>true</java.awt.headless>
|
|
||||||
</systemProperties>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.license.core.shaded.CryptUtils;
|
import org.elasticsearch.license.core.shaded.CryptUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -115,8 +114,8 @@ public class LicenseVerifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] getPublicKeyContentFromResource(String resource) {
|
private static byte[] getPublicKeyContentFromResource(String resource) {
|
||||||
try (InputStream inputStream = LicenseVerifier.class.getResourceAsStream(resource)) {
|
try {
|
||||||
return Streams.copyToByteArray(inputStream);
|
return Streams.copyToBytesFromClasspath(resource);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new IllegalStateException(ex);
|
throw new IllegalStateException(ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,12 @@ package org.elasticsearch.license.core;
|
||||||
import org.elasticsearch.common.joda.DateMathParser;
|
import org.elasticsearch.common.joda.DateMathParser;
|
||||||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||||
import org.elasticsearch.common.joda.Joda;
|
import org.elasticsearch.common.joda.Joda;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
|
||||||
import org.hamcrest.MatcherAssert;
|
import org.hamcrest.MatcherAssert;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.*;
|
import static com.carrotsearch.randomizedtesting.RandomizedTest.*;
|
||||||
|
@ -59,12 +57,22 @@ public class TestUtils {
|
||||||
assertThat(license1.maxNodes(), equalTo(license2.maxNodes()));
|
assertThat(license1.maxNodes(), equalTo(license2.maxNodes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String dateMathString(String time, long now) {
|
public static String dateMathString(String time, final long now) {
|
||||||
return dateTimeFormatter.print(dateMathParser.parse(time, now));
|
return dateTimeFormatter.print(dateMathParser.parse(time, new Callable<Long>() {
|
||||||
|
@Override
|
||||||
|
public Long call() throws Exception {
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long dateMath(String time, long now) {
|
public static long dateMath(String time, final long now) {
|
||||||
return dateMathParser.parse(time, now);
|
return dateMathParser.parse(time, new Callable<Long>() {
|
||||||
|
@Override
|
||||||
|
public Long call() throws Exception {
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LicenseSpec generateRandomLicenseSpec() {
|
public static LicenseSpec generateRandomLicenseSpec() {
|
||||||
|
|
109
licensor/pom.xml
109
licensor/pom.xml
|
@ -34,7 +34,6 @@
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
|
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -57,7 +56,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>2.4</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>for-exec</id>
|
<id>for-exec</id>
|
||||||
|
@ -78,113 +76,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||||
<artifactId>junit4-maven-plugin</artifactId>
|
<artifactId>junit4-maven-plugin</artifactId>
|
||||||
<version>2.1.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>tests</id>
|
|
||||||
<phase>test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>junit4</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<dir>${project.basedir}/target</dir>
|
|
||||||
<classesDirectory>${project.basedir}/target/classes</classesDirectory>
|
|
||||||
<heartbeat>20</heartbeat>
|
|
||||||
<jvmOutputAction>pipe,warn</jvmOutputAction>
|
|
||||||
<leaveTemporary>true</leaveTemporary>
|
|
||||||
<listeners>
|
|
||||||
<report-ant-xml mavenExtensions="true"
|
|
||||||
dir="${project.build.directory}/surefire-reports"/>
|
|
||||||
<report-text
|
|
||||||
showThrowable="true"
|
|
||||||
showStackTraces="true"
|
|
||||||
showOutput="${tests.output}"
|
|
||||||
showStatusOk="false"
|
|
||||||
showStatusError="true"
|
|
||||||
showStatusFailure="true"
|
|
||||||
showStatusIgnored="true"
|
|
||||||
showSuiteSummary="true"
|
|
||||||
timestamps="false"/>
|
|
||||||
<report-execution-times historyLength="20" file="${basedir}/${execution.hint.file}"/>
|
|
||||||
</listeners>
|
|
||||||
<assertions>
|
|
||||||
<enable/>
|
|
||||||
<disable package="${tests.assertion.disabled}"/>
|
|
||||||
<!-- pass org.elasticsearch to run without assertions -->
|
|
||||||
</assertions>
|
|
||||||
<parallelism>${tests.jvms}</parallelism>
|
|
||||||
<balancers>
|
|
||||||
<execution-times>
|
|
||||||
<fileset dir="${basedir}" includes="${execution.hint.file}"/>
|
|
||||||
</execution-times>
|
|
||||||
</balancers>
|
|
||||||
<includes>
|
|
||||||
<include>**/*Tests.class</include>
|
|
||||||
<include>**/*Test.class</include>
|
|
||||||
</includes>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/Abstract*.class</exclude>
|
|
||||||
<exclude>**/*StressTest.class</exclude>
|
|
||||||
</excludes>
|
|
||||||
<jvmArgs>
|
|
||||||
<param>-Xmx${tests.heap.size}</param>
|
|
||||||
<param>-Xms${tests.heap.size}</param>
|
|
||||||
<param>-Xss256k</param>
|
|
||||||
<param>-XX:MaxPermSize=128m</param>
|
|
||||||
<param>-XX:MaxDirectMemorySize=512m</param>
|
|
||||||
<param>-Des.logger.prefix=</param>
|
|
||||||
</jvmArgs>
|
|
||||||
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
|
|
||||||
<sysouts>${tests.verbose}</sysouts>
|
|
||||||
<seed>${tests.seed}</seed>
|
|
||||||
<haltOnFailure>${tests.failfast}</haltOnFailure>
|
|
||||||
<uniqueSuiteNames>false</uniqueSuiteNames>
|
|
||||||
<systemProperties>
|
|
||||||
<java.io.tmpdir>.</java.io.tmpdir>
|
|
||||||
<!-- we use '.' since this is different per JVM-->
|
|
||||||
<!-- RandomizedTesting library system properties -->
|
|
||||||
<tests.bwc>${tests.bwc}</tests.bwc>
|
|
||||||
<tests.bwc.path>${tests.bwc.path}</tests.bwc.path>
|
|
||||||
<tests.bwc.version>${tests.bwc.version}</tests.bwc.version>
|
|
||||||
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
|
|
||||||
<tests.processors>${tests.processors}</tests.processors>
|
|
||||||
<tests.appendseed>${tests.appendseed}</tests.appendseed>
|
|
||||||
<tests.iters>${tests.iters}</tests.iters>
|
|
||||||
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
|
|
||||||
<tests.failfast>${tests.failfast}</tests.failfast>
|
|
||||||
<tests.class>${tests.class}</tests.class>
|
|
||||||
<tests.method>${tests.method}</tests.method>
|
|
||||||
<tests.nightly>${tests.nightly}</tests.nightly>
|
|
||||||
<tests.verbose>${tests.verbose}</tests.verbose>
|
|
||||||
<tests.badapples>${tests.badapples}</tests.badapples>
|
|
||||||
<tests.weekly>${tests.weekly}</tests.weekly>
|
|
||||||
<tests.slow>${tests.slow}</tests.slow>
|
|
||||||
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
|
|
||||||
<tests.slow>${tests.slow}</tests.slow>
|
|
||||||
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
|
|
||||||
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
|
|
||||||
<tests.integration>${tests.integration}</tests.integration>
|
|
||||||
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
|
|
||||||
<tests.enable_mock_modules>${tests.enable_mock_modules}</tests.enable_mock_modules>
|
|
||||||
<tests.assertion.disabled>${tests.assertion.disabled}</tests.assertion.disabled>
|
|
||||||
<tests.rest>${tests.rest}</tests.rest>
|
|
||||||
<tests.rest.suite>${tests.rest.suite}</tests.rest.suite>
|
|
||||||
<tests.rest.blacklist>${tests.rest.blacklist}</tests.rest.blacklist>
|
|
||||||
<tests.rest.spec>${tests.rest.spec}</tests.rest.spec>
|
|
||||||
<tests.network>${tests.network}</tests.network>
|
|
||||||
<tests.cluster>${tests.cluster}</tests.cluster>
|
|
||||||
<tests.heap.size>${tests.heap.size}</tests.heap.size>
|
|
||||||
<tests.filter>${tests.filter}</tests.filter>
|
|
||||||
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
|
|
||||||
<es.node.mode>${es.node.mode}</es.node.mode>
|
|
||||||
<es.logger.level>${es.logger.level}</es.logger.level>
|
|
||||||
<tests.security.manager>${tests.security.manager}</tests.security.manager>
|
|
||||||
<tests.compatibility>${tests.compatibility}</tests.compatibility>
|
|
||||||
<java.awt.headless>true</java.awt.headless>
|
|
||||||
</systemProperties>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -8,9 +8,9 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.license.core.DateUtils;
|
import org.elasticsearch.license.core.DateUtils;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -18,16 +18,22 @@ import java.util.UUID;
|
||||||
|
|
||||||
public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase {
|
public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase {
|
||||||
|
|
||||||
protected static String pubKeyPath = null;
|
protected String pubKeyPath = null;
|
||||||
protected static String priKeyPath = null;
|
protected String priKeyPath = null;
|
||||||
|
|
||||||
@BeforeClass
|
@Before
|
||||||
public static void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
pubKeyPath = getResourcePath("/public.key");
|
pubKeyPath = getResourcePath("/public.key");
|
||||||
priKeyPath = getResourcePath("/private.key");
|
priKeyPath = getResourcePath("/private.key");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<License> generateSignedLicenses(List<TestUtils.LicenseSpec> licenseSpecs) throws Exception {
|
@After
|
||||||
|
public void cleanUp() {
|
||||||
|
pubKeyPath = null;
|
||||||
|
priKeyPath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<License> generateSignedLicenses(List<TestUtils.LicenseSpec> licenseSpecs, String pubKeyPath, String priKeyPath) throws Exception {
|
||||||
LicenseSigner signer = new LicenseSigner(priKeyPath, pubKeyPath);
|
LicenseSigner signer = new LicenseSigner(priKeyPath, pubKeyPath);
|
||||||
Set<License> unSignedLicenses = new HashSet<>();
|
Set<License> unSignedLicenses = new HashSet<>();
|
||||||
for (TestUtils.LicenseSpec spec : licenseSpecs) {
|
for (TestUtils.LicenseSpec spec : licenseSpecs) {
|
||||||
|
@ -55,11 +61,11 @@ public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase {
|
||||||
return signer.sign(unSignedLicenses);
|
return signer.sign(unSignedLicenses);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static License generateSignedLicense(String feature, TimeValue expiryDuration) throws Exception {
|
public static License generateSignedLicense(String feature, TimeValue expiryDuration, String pubKeyPath, String priKeyPath) throws Exception {
|
||||||
return generateSignedLicense(feature, -1, expiryDuration);
|
return generateSignedLicense(feature, -1, expiryDuration, pubKeyPath, priKeyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static License generateSignedLicense(String feature, long issueDate, TimeValue expiryDuration) throws Exception {
|
public static License generateSignedLicense(String feature, long issueDate, TimeValue expiryDuration, String pubKeyPath, String priKeyPath) throws Exception {
|
||||||
long issue = (issueDate != -1l) ? issueDate : System.currentTimeMillis();
|
long issue = (issueDate != -1l) ? issueDate : System.currentTimeMillis();
|
||||||
final License licenseSpec = License.builder()
|
final License licenseSpec = License.builder()
|
||||||
.uid(UUID.randomUUID().toString())
|
.uid(UUID.randomUUID().toString())
|
||||||
|
@ -73,20 +79,19 @@ public abstract class AbstractLicensingTestBase extends ElasticsearchTestCase {
|
||||||
.maxNodes(5)
|
.maxNodes(5)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
LicenseSigner signer = new LicenseSigner(getTestPriKeyPath(), getTestPubKeyPath());
|
LicenseSigner signer = new LicenseSigner(priKeyPath, pubKeyPath);
|
||||||
return signer.sign(licenseSpec);
|
return signer.sign(licenseSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTestPriKeyPath() throws Exception {
|
public String getTestPriKeyPath() throws Exception {
|
||||||
return getResourcePath("/private.key");
|
return getResourcePath("/private.key");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTestPubKeyPath() throws Exception {
|
public String getTestPubKeyPath() throws Exception {
|
||||||
return getResourcePath("/public.key");
|
return getResourcePath("/public.key");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getResourcePath(String resource) throws Exception {
|
private String getResourcePath(String resource) throws Exception {
|
||||||
URL url = TestUtils.class.getResource(resource);
|
return getDataPath(resource).toString();
|
||||||
return url.toURI().getPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,21 @@ public class LicenseVerificationTests extends AbstractLicensingTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGeneratedLicenses() throws Exception {
|
public void testGeneratedLicenses() throws Exception {
|
||||||
License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24));
|
License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24), pubKeyPath, priKeyPath);
|
||||||
assertThat(LicenseVerifier.verifyLicense(shieldLicense), equalTo(true));
|
assertThat(LicenseVerifier.verifyLicense(shieldLicense), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleFeatureLicenses() throws Exception {
|
public void testMultipleFeatureLicenses() throws Exception {
|
||||||
License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24));
|
License shieldLicense = generateSignedLicense("shield", TimeValue.timeValueHours(2 * 24), pubKeyPath, priKeyPath);
|
||||||
License marvelLicense = generateSignedLicense("marvel", TimeValue.timeValueHours(2 * 24));
|
License marvelLicense = generateSignedLicense("marvel", TimeValue.timeValueHours(2 * 24), pubKeyPath, priKeyPath);
|
||||||
|
|
||||||
assertThat(LicenseVerifier.verifyLicenses(Arrays.asList(shieldLicense, marvelLicense)), equalTo(true));
|
assertThat(LicenseVerifier.verifyLicenses(Arrays.asList(shieldLicense, marvelLicense)), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLicenseTampering() throws Exception {
|
public void testLicenseTampering() throws Exception {
|
||||||
License license = generateSignedLicense("shield", TimeValue.timeValueHours(2));
|
License license = generateSignedLicense("shield", TimeValue.timeValueHours(2), pubKeyPath, priKeyPath);
|
||||||
|
|
||||||
final License tamperedLicense = License.builder()
|
final License tamperedLicense = License.builder()
|
||||||
.fromLicenseSpec(license, license.signature())
|
.fromLicenseSpec(license, license.signature())
|
||||||
|
@ -54,7 +54,7 @@ public class LicenseVerificationTests extends AbstractLicensingTestBase {
|
||||||
licenseSpecs.add(TestUtils.generateRandomLicenseSpec());
|
licenseSpecs.add(TestUtils.generateRandomLicenseSpec());
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<License> generatedLicenses = generateSignedLicenses(licenseSpecs);
|
Set<License> generatedLicenses = generateSignedLicenses(licenseSpecs, pubKeyPath, priKeyPath);
|
||||||
assertThat(generatedLicenses.size(), equalTo(n));
|
assertThat(generatedLicenses.size(), equalTo(n));
|
||||||
|
|
||||||
for (License generatedLicense: generatedLicenses) {
|
for (License generatedLicense: generatedLicenses) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.hamcrest.MatcherAssert;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean;
|
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean;
|
||||||
|
@ -31,6 +32,9 @@ import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class TestUtils {
|
public class TestUtils {
|
||||||
|
|
||||||
|
public static final String PUBLIC_KEY_RESOURCE = "/public.key";
|
||||||
|
public static final String PRIVATE_KEY_RESOURCE = "/private.key";
|
||||||
|
|
||||||
private final static FormatDateTimeFormatter formatDateTimeFormatter = Joda.forPattern("yyyy-MM-dd");
|
private final static FormatDateTimeFormatter formatDateTimeFormatter = Joda.forPattern("yyyy-MM-dd");
|
||||||
private final static DateMathParser dateMathParser = new DateMathParser(formatDateTimeFormatter, TimeUnit.MILLISECONDS);
|
private final static DateMathParser dateMathParser = new DateMathParser(formatDateTimeFormatter, TimeUnit.MILLISECONDS);
|
||||||
private final static org.elasticsearch.common.joda.time.format.DateTimeFormatter dateTimeFormatter = formatDateTimeFormatter.printer();
|
private final static org.elasticsearch.common.joda.time.format.DateTimeFormatter dateTimeFormatter = formatDateTimeFormatter.printer();
|
||||||
|
@ -71,12 +75,22 @@ public class TestUtils {
|
||||||
return builder.string();
|
return builder.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String dateMathString(String time, long now) {
|
public static String dateMathString(String time, final long now) {
|
||||||
return dateTimeFormatter.print(dateMathParser.parse(time, now));
|
return dateTimeFormatter.print(dateMathParser.parse(time, new Callable<Long>() {
|
||||||
|
@Override
|
||||||
|
public Long call() throws Exception {
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long dateMath(String time, long now) {
|
public static long dateMath(String time, final long now) {
|
||||||
return dateMathParser.parse(time, now);
|
return dateMathParser.parse(time, new Callable<Long>() {
|
||||||
|
@Override
|
||||||
|
public Long call() throws Exception {
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LicenseSpec generateRandomLicenseSpec() {
|
public static LicenseSpec generateRandomLicenseSpec() {
|
||||||
|
|
|
@ -8,13 +8,11 @@ package org.elasticsearch.license.licensor.tools;
|
||||||
import org.elasticsearch.common.cli.CliToolTestCase;
|
import org.elasticsearch.common.cli.CliToolTestCase;
|
||||||
import org.elasticsearch.common.cli.commons.MissingOptionException;
|
import org.elasticsearch.common.cli.commons.MissingOptionException;
|
||||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.license.licensor.tools.KeyPairGeneratorTool.KeyGenerator;
|
import org.elasticsearch.license.licensor.tools.KeyPairGeneratorTool.KeyGenerator;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
@ -27,23 +25,20 @@ import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
|
|
||||||
public class KeyPairGenerationToolTests extends CliToolTestCase {
|
public class KeyPairGenerationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsingMissingPath() throws Exception {
|
public void testParsingMissingPath() throws Exception {
|
||||||
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
|
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
|
||||||
File tempFile = temporaryFolder.newFile();
|
Path tempFile = createTempFile();
|
||||||
try {
|
try {
|
||||||
keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args(
|
keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args(
|
||||||
"--privateKeyPath " + tempFile.getAbsolutePath()));
|
"--privateKeyPath " + tempFile.toAbsolutePath()));
|
||||||
fail("no public key path provided");
|
fail("no public key path provided");
|
||||||
} catch (MissingOptionException e) {
|
} catch (MissingOptionException e) {
|
||||||
assertThat(e.getMessage(), containsString("pub"));
|
assertThat(e.getMessage(), containsString("pub"));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args(
|
keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args(
|
||||||
"--publicKeyPath " + tempFile.getAbsolutePath()));
|
"--publicKeyPath " + tempFile.toAbsolutePath()));
|
||||||
fail("no private key path provided");
|
fail("no private key path provided");
|
||||||
} catch (MissingOptionException e) {
|
} catch (MissingOptionException e) {
|
||||||
assertThat(e.getMessage(), containsString("pri"));
|
assertThat(e.getMessage(), containsString("pri"));
|
||||||
|
@ -53,20 +48,21 @@ public class KeyPairGenerationToolTests extends CliToolTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testParsingNeverOverrideKey() throws Exception {
|
public void testParsingNeverOverrideKey() throws Exception {
|
||||||
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
|
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
|
||||||
File tempFile = temporaryFolder.newFile();
|
Path tempFile = createTempFile();
|
||||||
File tempFile2 = temporaryFolder.newFile();
|
Path tempFile2 = createTempFile();
|
||||||
String nonExistentFilePath = tempFile2.getAbsolutePath();
|
String nonExistentFilePath = tempFile2.toAbsolutePath().toString();
|
||||||
assertThat(tempFile2.delete(), equalTo(true));
|
Files.delete(tempFile2);
|
||||||
|
assertThat(Files.exists(tempFile2), equalTo(false));
|
||||||
|
|
||||||
Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args("--privateKeyPath " + tempFile.getAbsolutePath()
|
Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] {"--privateKeyPath", tempFile.toAbsolutePath().toString(),
|
||||||
+ " --publicKeyPath " + nonExistentFilePath));
|
"--publicKeyPath", nonExistentFilePath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
Command.Exit exitCommand = (Command.Exit) command;
|
Command.Exit exitCommand = (Command.Exit) command;
|
||||||
assertThat(exitCommand.status(), equalTo(ExitStatus.USAGE));
|
assertThat(exitCommand.status(), equalTo(ExitStatus.USAGE));
|
||||||
|
|
||||||
command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args("--publicKeyPath " + tempFile.getAbsolutePath()
|
command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] {"--publicKeyPath", tempFile.toAbsolutePath().toString(),
|
||||||
+ " --privateKeyPath " + nonExistentFilePath));
|
"--privateKeyPath", nonExistentFilePath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
exitCommand = (Command.Exit) command;
|
exitCommand = (Command.Exit) command;
|
||||||
|
@ -76,18 +72,21 @@ public class KeyPairGenerationToolTests extends CliToolTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testToolSimple() throws Exception {
|
public void testToolSimple() throws Exception {
|
||||||
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
|
KeyPairGeneratorTool keyPairGeneratorTool = new KeyPairGeneratorTool();
|
||||||
File tempFile1 = temporaryFolder.newFile();
|
Path tempFile1 = createTempFile();
|
||||||
File tempFile2 = temporaryFolder.newFile();
|
Path tempFile2 = createTempFile();
|
||||||
String publicKeyPath = tempFile1.getAbsolutePath();
|
String publicKeyPath = tempFile1.toAbsolutePath().toString();
|
||||||
String privateKeyPath = tempFile2.getAbsolutePath();
|
String privateKeyPath = tempFile2.toAbsolutePath().toString();
|
||||||
Path publicKeyFilePath = Paths.get(publicKeyPath);
|
Path publicKeyFilePath = Paths.get(publicKeyPath);
|
||||||
Path privateKeyFilePath = Paths.get(privateKeyPath);
|
Path privateKeyFilePath = Paths.get(privateKeyPath);
|
||||||
|
Settings settings = ImmutableSettings.builder().put("path.home", createTempDir()).build();
|
||||||
|
|
||||||
assertThat(tempFile1.delete(), equalTo(true));
|
Files.delete(tempFile1);
|
||||||
assertThat(tempFile2.delete(), equalTo(true));
|
Files.delete(tempFile2);
|
||||||
|
assertThat(Files.exists(tempFile1), equalTo(false));
|
||||||
|
assertThat(Files.exists(tempFile2), equalTo(false));
|
||||||
|
|
||||||
Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, args("--privateKeyPath " + privateKeyPath
|
Command command = keyPairGeneratorTool.parse(KeyPairGeneratorTool.NAME, new String[] { "--privateKeyPath", privateKeyPath,
|
||||||
+ " --publicKeyPath " + publicKeyPath));
|
"--publicKeyPath", publicKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(KeyGenerator.class));
|
assertThat(command, instanceOf(KeyGenerator.class));
|
||||||
KeyGenerator keyGenerator = (KeyGenerator) command;
|
KeyGenerator keyGenerator = (KeyGenerator) command;
|
||||||
|
@ -97,7 +96,7 @@ public class KeyPairGenerationToolTests extends CliToolTestCase {
|
||||||
assertThat(Files.exists(publicKeyFilePath), equalTo(false));
|
assertThat(Files.exists(publicKeyFilePath), equalTo(false));
|
||||||
assertThat(Files.exists(privateKeyFilePath), equalTo(false));
|
assertThat(Files.exists(privateKeyFilePath), equalTo(false));
|
||||||
|
|
||||||
assertThat(keyGenerator.execute(ImmutableSettings.EMPTY, new Environment(ImmutableSettings.EMPTY)), equalTo(ExitStatus.OK));
|
assertThat(keyGenerator.execute(settings, new Environment(settings)), equalTo(ExitStatus.OK));
|
||||||
assertThat(Files.exists(publicKeyFilePath), equalTo(true));
|
assertThat(Files.exists(publicKeyFilePath), equalTo(true));
|
||||||
assertThat(Files.exists(privateKeyFilePath), equalTo(true));
|
assertThat(Files.exists(privateKeyFilePath), equalTo(true));
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,10 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
import org.elasticsearch.license.core.Licenses;
|
import org.elasticsearch.license.core.Licenses;
|
||||||
import org.elasticsearch.license.licensor.AbstractLicensingTestBase;
|
|
||||||
import org.elasticsearch.license.licensor.TestUtils;
|
import org.elasticsearch.license.licensor.TestUtils;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -36,17 +32,17 @@ import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
|
|
||||||
public class LicenseGenerationToolTests extends CliToolTestCase {
|
public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
protected static String pubKeyPath = null;
|
protected String pubKeyPath = null;
|
||||||
protected static String priKeyPath = null;
|
protected String priKeyPath = null;
|
||||||
|
protected Path homeDir = null;
|
||||||
@Rule
|
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@Before
|
||||||
public static void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
pubKeyPath = AbstractLicensingTestBase.getTestPubKeyPath();
|
logger.error("project.basedir [{}]", System.getProperty("project.basedir"));
|
||||||
priKeyPath = AbstractLicensingTestBase.getTestPriKeyPath();
|
pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString();
|
||||||
|
priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE).toString();
|
||||||
|
homeDir = createTempDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -54,18 +50,18 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec();
|
TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec();
|
||||||
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
||||||
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec))
|
new String[] {"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
|
||||||
+ " --publicKeyPath " + pubKeyPath.concat("invalid")
|
"--publicKeyPath", pubKeyPath.concat("invalid"),
|
||||||
+ " --privateKeyPath " + priKeyPath));
|
"--privateKeyPath", priKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
Command.Exit exitCommand = (Command.Exit) command;
|
Command.Exit exitCommand = (Command.Exit) command;
|
||||||
assertThat(exitCommand.status(), equalTo(ExitStatus.USAGE));
|
assertThat(exitCommand.status(), equalTo(ExitStatus.USAGE));
|
||||||
|
|
||||||
command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec))
|
new String[] {"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
|
||||||
+ " --privateKeyPath " + priKeyPath.concat("invalid")
|
"--privateKeyPath", priKeyPath.concat("invalid"),
|
||||||
+ " --publicKeyPath " + pubKeyPath));
|
"--publicKeyPath", pubKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
exitCommand = (Command.Exit) command;
|
exitCommand = (Command.Exit) command;
|
||||||
|
@ -76,8 +72,8 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
public void testParsingMissingLicenseSpec() throws Exception {
|
public void testParsingMissingLicenseSpec() throws Exception {
|
||||||
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
||||||
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args(" --publicKeyPath " + pubKeyPath
|
new String[] { "--publicKeyPath", pubKeyPath,
|
||||||
+ " --privateKeyPath " + priKeyPath));
|
"--privateKeyPath", priKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
Command.Exit exitCommand = (Command.Exit) command;
|
Command.Exit exitCommand = (Command.Exit) command;
|
||||||
|
@ -91,9 +87,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
boolean pubKeyMissing = randomBoolean();
|
boolean pubKeyMissing = randomBoolean();
|
||||||
try {
|
try {
|
||||||
licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec))
|
new String[] { "--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
|
||||||
+ ((!pubKeyMissing) ? " --publicKeyPath " + pubKeyPath : "")
|
((pubKeyMissing) ? "--privateKeyPath" : "--publicKeyPath"),
|
||||||
+ ((pubKeyMissing) ? " --privateKeyPath " + priKeyPath : "")));
|
((pubKeyMissing) ? priKeyPath : pubKeyPath) });
|
||||||
fail("missing argument: " + ((pubKeyMissing) ? "publicKeyPath" : "privateKeyPath") + " should throw an exception");
|
fail("missing argument: " + ((pubKeyMissing) ? "publicKeyPath" : "privateKeyPath") + " should throw an exception");
|
||||||
} catch (MissingOptionException e) {
|
} catch (MissingOptionException e) {
|
||||||
assertThat(e.getMessage(), containsString((pubKeyMissing) ? "pub" : "pri"));
|
assertThat(e.getMessage(), containsString((pubKeyMissing) ? "pub" : "pri"));
|
||||||
|
@ -105,9 +101,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec();
|
TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec();
|
||||||
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
||||||
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args("--license " + TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec))
|
new String[]{"--license", TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)),
|
||||||
+ " --publicKeyPath " + pubKeyPath
|
"--publicKeyPath", pubKeyPath,
|
||||||
+ " --privateKeyPath " + priKeyPath));
|
"--privateKeyPath", priKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(LicenseGenerator.class));
|
assertThat(command, instanceOf(LicenseGenerator.class));
|
||||||
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
|
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
|
||||||
|
@ -122,14 +118,14 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testParsingLicenseFile() throws Exception {
|
public void testParsingLicenseFile() throws Exception {
|
||||||
TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec();
|
TestUtils.LicenseSpec inputLicenseSpec = TestUtils.generateRandomLicenseSpec();
|
||||||
File tempFile = temporaryFolder.newFile("license_spec.json");
|
Path tempFile = createTempFile();
|
||||||
Files.write(Paths.get(tempFile.getAbsolutePath()), TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)).getBytes(StandardCharsets.UTF_8));
|
Files.write(tempFile, TestUtils.generateLicenseSpecString(Arrays.asList(inputLicenseSpec)).getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
||||||
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args("--licenseFile " + tempFile.getAbsolutePath()
|
new String[] { "--licenseFile", tempFile.toAbsolutePath().toString(),
|
||||||
+ " --publicKeyPath " + pubKeyPath
|
"--publicKeyPath", pubKeyPath,
|
||||||
+ " --privateKeyPath " + priKeyPath));
|
"--privateKeyPath", priKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(LicenseGenerator.class));
|
assertThat(command, instanceOf(LicenseGenerator.class));
|
||||||
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
|
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
|
||||||
|
@ -151,9 +147,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
}
|
}
|
||||||
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
LicenseGeneratorTool licenseGeneratorTool = new LicenseGeneratorTool();
|
||||||
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
Command command = licenseGeneratorTool.parse(LicenseGeneratorTool.NAME,
|
||||||
args("--license " + TestUtils.generateLicenseSpecString(new ArrayList<>(inputLicenseSpecs.values()))
|
new String[] { "--license", TestUtils.generateLicenseSpecString(new ArrayList<>(inputLicenseSpecs.values())),
|
||||||
+ " --publicKeyPath " + pubKeyPath
|
"--publicKeyPath", pubKeyPath,
|
||||||
+ " --privateKeyPath " + priKeyPath));
|
"--privateKeyPath", priKeyPath });
|
||||||
|
|
||||||
assertThat(command, instanceOf(LicenseGenerator.class));
|
assertThat(command, instanceOf(LicenseGenerator.class));
|
||||||
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
|
LicenseGenerator licenseGenerator = (LicenseGenerator) command;
|
||||||
|
@ -191,8 +187,9 @@ public class LicenseGenerationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
private String runLicenseGenerationTool(Path pubKeyPath, Path priKeyPath, Set<License> licenseSpecs, ExitStatus expectedExitStatus) throws Exception {
|
private String runLicenseGenerationTool(Path pubKeyPath, Path priKeyPath, Set<License> licenseSpecs, ExitStatus expectedExitStatus) throws Exception {
|
||||||
CaptureOutputTerminal outputTerminal = new CaptureOutputTerminal();
|
CaptureOutputTerminal outputTerminal = new CaptureOutputTerminal();
|
||||||
|
Settings settings = ImmutableSettings.builder().put("path.home", homeDir).build();
|
||||||
LicenseGenerator licenseGenerator = new LicenseGenerator(outputTerminal, pubKeyPath, priKeyPath, licenseSpecs);
|
LicenseGenerator licenseGenerator = new LicenseGenerator(outputTerminal, pubKeyPath, priKeyPath, licenseSpecs);
|
||||||
assertThat(execute(licenseGenerator, ImmutableSettings.EMPTY), equalTo(expectedExitStatus));
|
assertThat(execute(licenseGenerator, settings), equalTo(expectedExitStatus));
|
||||||
assertThat(outputTerminal.getTerminalOutput().size(), equalTo(1));
|
assertThat(outputTerminal.getTerminalOutput().size(), equalTo(1));
|
||||||
return outputTerminal.getTerminalOutput().get(0);
|
return outputTerminal.getTerminalOutput().get(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,13 @@ import org.elasticsearch.license.licensor.AbstractLicensingTestBase;
|
||||||
import org.elasticsearch.license.licensor.TestUtils;
|
import org.elasticsearch.license.licensor.TestUtils;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
import org.elasticsearch.license.core.Licenses;
|
import org.elasticsearch.license.core.Licenses;
|
||||||
import org.junit.Rule;
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.elasticsearch.common.cli.CliTool.Command;
|
import static org.elasticsearch.common.cli.CliTool.Command;
|
||||||
|
@ -36,13 +34,23 @@ import static org.hamcrest.core.IsEqual.equalTo;
|
||||||
|
|
||||||
public class LicenseVerificationToolTests extends CliToolTestCase {
|
public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Rule
|
protected static Path homeDir = null;
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setup() throws Exception {
|
||||||
|
homeDir = createTempDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void cleanUp() throws Exception {
|
||||||
|
homeDir = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsingMissingLicense() throws Exception {
|
public void testParsingMissingLicense() throws Exception {
|
||||||
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
||||||
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath " + AbstractLicensingTestBase.getTestPubKeyPath()));
|
Path path = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath " + path));
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
Command.Exit exitCommand = (Command.Exit) command;
|
Command.Exit exitCommand = (Command.Exit) command;
|
||||||
|
@ -51,8 +59,10 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsingMissingPublicKeyPath() throws Exception {
|
public void testParsingMissingPublicKeyPath() throws Exception {
|
||||||
|
Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
|
||||||
License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1",
|
License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1",
|
||||||
TimeValue.timeValueHours(1));
|
TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString());
|
||||||
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
||||||
try {
|
try {
|
||||||
licenseVerificationTool.parse(LicenseVerificationTool.NAME,
|
licenseVerificationTool.parse(LicenseVerificationTool.NAME,
|
||||||
|
@ -65,8 +75,9 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testParsingNonExistentPublicKeyPath() throws Exception {
|
public void testParsingNonExistentPublicKeyPath() throws Exception {
|
||||||
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
||||||
|
Path path = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath "
|
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(" --publicKeyPath "
|
||||||
+ AbstractLicensingTestBase.getTestPubKeyPath().concat(".invalid")));
|
+ path.toString().concat(".invalid")));
|
||||||
|
|
||||||
assertThat(command, instanceOf(Command.Exit.class));
|
assertThat(command, instanceOf(Command.Exit.class));
|
||||||
Command.Exit exitCommand = (Command.Exit) command;
|
Command.Exit exitCommand = (Command.Exit) command;
|
||||||
|
@ -75,12 +86,14 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsingSimple() throws Exception {
|
public void testParsingSimple() throws Exception {
|
||||||
|
Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
|
||||||
License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1",
|
License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1",
|
||||||
TimeValue.timeValueHours(1));
|
TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString());
|
||||||
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
||||||
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME,
|
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME,
|
||||||
args("--license " + TestUtils.dumpLicense(inputLicense)
|
args("--license " + TestUtils.dumpLicense(inputLicense)
|
||||||
+ " --publicKeyPath " + AbstractLicensingTestBase.getTestPubKeyPath()));
|
+ " --publicKeyPath " + getDataPath(TestUtils.PUBLIC_KEY_RESOURCE)));
|
||||||
assertThat(command, instanceOf(LicenseVerifier.class));
|
assertThat(command, instanceOf(LicenseVerifier.class));
|
||||||
LicenseVerifier licenseVerifier = (LicenseVerifier) command;
|
LicenseVerifier licenseVerifier = (LicenseVerifier) command;
|
||||||
assertThat(licenseVerifier.licenses.size(), equalTo(1));
|
assertThat(licenseVerifier.licenses.size(), equalTo(1));
|
||||||
|
@ -90,13 +103,15 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsingLicenseFile() throws Exception {
|
public void testParsingLicenseFile() throws Exception {
|
||||||
|
Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
|
||||||
License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1",
|
License inputLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1",
|
||||||
TimeValue.timeValueHours(1));
|
TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString());
|
||||||
|
|
||||||
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
||||||
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME,
|
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME,
|
||||||
args("--licenseFile " + dumpLicenseAsFile(inputLicense)
|
new String[] { "--licenseFile", dumpLicenseAsFile(inputLicense),
|
||||||
+ " --publicKeyPath " + AbstractLicensingTestBase.getTestPubKeyPath()));
|
"--publicKeyPath", getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString() });
|
||||||
assertThat(command, instanceOf(LicenseVerifier.class));
|
assertThat(command, instanceOf(LicenseVerifier.class));
|
||||||
LicenseVerifier licenseVerifier = (LicenseVerifier) command;
|
LicenseVerifier licenseVerifier = (LicenseVerifier) command;
|
||||||
assertThat(licenseVerifier.licenses.size(), equalTo(1));
|
assertThat(licenseVerifier.licenses.size(), equalTo(1));
|
||||||
|
@ -107,11 +122,14 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParsingMultipleLicense() throws Exception {
|
public void testParsingMultipleLicense() throws Exception {
|
||||||
|
Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
|
||||||
|
|
||||||
int n = randomIntBetween(2, 5);
|
int n = randomIntBetween(2, 5);
|
||||||
Map<String, License> inputLicenses = new HashMap<>();
|
Map<String, License> inputLicenses = new HashMap<>();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
License license = AbstractLicensingTestBase.generateSignedLicense("feature__" + i,
|
License license = AbstractLicensingTestBase.generateSignedLicense("feature__" + i,
|
||||||
TimeValue.timeValueHours(1));
|
TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString());
|
||||||
inputLicenses.put(license.feature(), license);
|
inputLicenses.put(license.feature(), license);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +138,7 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
argsBuilder.append(" --license ")
|
argsBuilder.append(" --license ")
|
||||||
.append(TestUtils.dumpLicense(inputLicense));
|
.append(TestUtils.dumpLicense(inputLicense));
|
||||||
}
|
}
|
||||||
argsBuilder.append(" --publicKeyPath ").append(AbstractLicensingTestBase.getTestPubKeyPath());
|
argsBuilder.append(" --publicKeyPath ").append(getDataPath(TestUtils.PUBLIC_KEY_RESOURCE).toString());
|
||||||
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
LicenseVerificationTool licenseVerificationTool = new LicenseVerificationTool();
|
||||||
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(argsBuilder.toString()));
|
Command command = licenseVerificationTool.parse(LicenseVerificationTool.NAME, args(argsBuilder.toString()));
|
||||||
|
|
||||||
|
@ -137,15 +155,18 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToolSimple() throws Exception {
|
public void testToolSimple() throws Exception {
|
||||||
|
Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
|
||||||
|
|
||||||
int n = randomIntBetween(2, 5);
|
int n = randomIntBetween(2, 5);
|
||||||
Map<String, License> inputLicenses = new HashMap<>();
|
Map<String, License> inputLicenses = new HashMap<>();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
License license = AbstractLicensingTestBase.generateSignedLicense("feature__" + i,
|
License license = AbstractLicensingTestBase.generateSignedLicense("feature__" + i,
|
||||||
TimeValue.timeValueHours(1));
|
TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString());
|
||||||
inputLicenses.put(license.feature(), license);
|
inputLicenses.put(license.feature(), license);
|
||||||
}
|
}
|
||||||
|
|
||||||
String output = runLicenseVerificationTool(new HashSet<>(inputLicenses.values()), Paths.get(AbstractLicensingTestBase.getTestPubKeyPath()), ExitStatus.OK);
|
String output = runLicenseVerificationTool(new HashSet<>(inputLicenses.values()), getDataPath(TestUtils.PUBLIC_KEY_RESOURCE), ExitStatus.OK);
|
||||||
List<License> outputLicenses = Licenses.fromSource(output.getBytes(StandardCharsets.UTF_8), true);
|
List<License> outputLicenses = Licenses.fromSource(output.getBytes(StandardCharsets.UTF_8), true);
|
||||||
assertThat(outputLicenses.size(), equalTo(inputLicenses.size()));
|
assertThat(outputLicenses.size(), equalTo(inputLicenses.size()));
|
||||||
|
|
||||||
|
@ -158,26 +179,29 @@ public class LicenseVerificationToolTests extends CliToolTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testToolInvalidLicense() throws Exception {
|
public void testToolInvalidLicense() throws Exception {
|
||||||
|
Path pubKeyPath = getDataPath(TestUtils.PUBLIC_KEY_RESOURCE);
|
||||||
|
Path priKeyPath = getDataPath(TestUtils.PRIVATE_KEY_RESOURCE);
|
||||||
License signedLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1"
|
License signedLicense = AbstractLicensingTestBase.generateSignedLicense("feature__1"
|
||||||
, TimeValue.timeValueHours(1));
|
, TimeValue.timeValueHours(1), pubKeyPath.toString(), priKeyPath.toString());
|
||||||
|
|
||||||
License tamperedLicense = License.builder()
|
License tamperedLicense = License.builder()
|
||||||
.fromLicenseSpec(signedLicense, signedLicense.signature())
|
.fromLicenseSpec(signedLicense, signedLicense.signature())
|
||||||
.expiryDate(signedLicense.expiryDate() + randomIntBetween(1, 1000)).build();
|
.expiryDate(signedLicense.expiryDate() + randomIntBetween(1, 1000)).build();
|
||||||
|
|
||||||
runLicenseVerificationTool(Collections.singleton(tamperedLicense), Paths.get(AbstractLicensingTestBase.getTestPubKeyPath()), ExitStatus.DATA_ERROR);
|
runLicenseVerificationTool(Collections.singleton(tamperedLicense), getDataPath(TestUtils.PUBLIC_KEY_RESOURCE), ExitStatus.DATA_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String dumpLicenseAsFile(License license) throws Exception {
|
private String dumpLicenseAsFile(License license) throws Exception {
|
||||||
File tempFile = temporaryFolder.newFile();
|
Path tempFile = createTempFile();
|
||||||
Files.write(Paths.get(tempFile.getAbsolutePath()), TestUtils.dumpLicense(license).getBytes(StandardCharsets.UTF_8));
|
Files.write(tempFile, TestUtils.dumpLicense(license).getBytes(StandardCharsets.UTF_8));
|
||||||
return tempFile.getAbsolutePath();
|
return tempFile.toAbsolutePath().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String runLicenseVerificationTool(Set<License> licenses, Path publicKeyPath, ExitStatus expectedExitStatus) throws Exception {
|
private String runLicenseVerificationTool(Set<License> licenses, Path publicKeyPath, ExitStatus expectedExitStatus) throws Exception {
|
||||||
CaptureOutputTerminal outputTerminal = new CaptureOutputTerminal();
|
CaptureOutputTerminal outputTerminal = new CaptureOutputTerminal();
|
||||||
|
Settings settings = ImmutableSettings.builder().put("path.home", homeDir).build();
|
||||||
LicenseVerifier licenseVerifier = new LicenseVerifier(outputTerminal, licenses, publicKeyPath);
|
LicenseVerifier licenseVerifier = new LicenseVerifier(outputTerminal, licenses, publicKeyPath);
|
||||||
assertThat(execute(licenseVerifier, ImmutableSettings.EMPTY), equalTo(expectedExitStatus));
|
assertThat(execute(licenseVerifier, settings), equalTo(expectedExitStatus));
|
||||||
if (expectedExitStatus == ExitStatus.OK) {
|
if (expectedExitStatus == ExitStatus.OK) {
|
||||||
assertThat(outputTerminal.getTerminalOutput().size(), equalTo(1));
|
assertThat(outputTerminal.getTerminalOutput().size(), equalTo(1));
|
||||||
|
|
||||||
|
|
101
plugin/pom.xml
101
plugin/pom.xml
|
@ -51,7 +51,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.3</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -94,7 +93,6 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<attach>false</attach>
|
<attach>false</attach>
|
||||||
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
|
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
|
||||||
|
@ -119,7 +117,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
<version>1.3.1</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<!-- TODO: do we want to always enforce non-default keys -->
|
<!-- TODO: do we want to always enforce non-default keys -->
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -149,7 +146,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>2.4</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>for-plugin</id>
|
<id>for-plugin</id>
|
||||||
|
@ -164,7 +160,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||||
<artifactId>junit4-maven-plugin</artifactId>
|
<artifactId>junit4-maven-plugin</artifactId>
|
||||||
<version>2.1.2</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>tests</id>
|
<id>tests</id>
|
||||||
|
@ -173,101 +168,7 @@
|
||||||
<goal>junit4</goal>
|
<goal>junit4</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<dir>${project.basedir}/target</dir>
|
<heartbeat combine.self="override">40</heartbeat>
|
||||||
<classesDirectory>${project.basedir}/target/classes</classesDirectory>
|
|
||||||
<heartbeat>40</heartbeat>
|
|
||||||
<jvmOutputAction>pipe,warn</jvmOutputAction>
|
|
||||||
<leaveTemporary>true</leaveTemporary>
|
|
||||||
<listeners>
|
|
||||||
<report-ant-xml mavenExtensions="true"
|
|
||||||
dir="${project.build.directory}/surefire-reports"/>
|
|
||||||
<report-text
|
|
||||||
showThrowable="true"
|
|
||||||
showStackTraces="true"
|
|
||||||
showOutput="${tests.output}"
|
|
||||||
showStatusOk="false"
|
|
||||||
showStatusError="true"
|
|
||||||
showStatusFailure="true"
|
|
||||||
showStatusIgnored="true"
|
|
||||||
showSuiteSummary="true"
|
|
||||||
timestamps="false"/>
|
|
||||||
<report-execution-times historyLength="20" file="${basedir}/${execution.hint.file}"/>
|
|
||||||
</listeners>
|
|
||||||
<assertions>
|
|
||||||
<enable/>
|
|
||||||
<disable package="${tests.assertion.disabled}"/>
|
|
||||||
<!-- pass org.elasticsearch to run without assertions -->
|
|
||||||
</assertions>
|
|
||||||
<parallelism>${tests.jvms}</parallelism>
|
|
||||||
<balancers>
|
|
||||||
<execution-times>
|
|
||||||
<fileset dir="${basedir}" includes="${execution.hint.file}"/>
|
|
||||||
</execution-times>
|
|
||||||
</balancers>
|
|
||||||
<includes>
|
|
||||||
<include>**/*Tests.class</include>
|
|
||||||
<include>**/*Test.class</include>
|
|
||||||
</includes>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/Abstract*.class</exclude>
|
|
||||||
<exclude>**/*StressTest.class</exclude>
|
|
||||||
</excludes>
|
|
||||||
<jvmArgs>
|
|
||||||
<param>-Xmx${tests.heap.size}</param>
|
|
||||||
<param>-Xms${tests.heap.size}</param>
|
|
||||||
<param>-Xss256k</param>
|
|
||||||
<param>-XX:MaxPermSize=128m</param>
|
|
||||||
<param>-XX:MaxDirectMemorySize=512m</param>
|
|
||||||
<param>-Des.logger.prefix=</param>
|
|
||||||
</jvmArgs>
|
|
||||||
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
|
|
||||||
<sysouts>${tests.verbose}</sysouts>
|
|
||||||
<seed>${tests.seed}</seed>
|
|
||||||
<haltOnFailure>${tests.failfast}</haltOnFailure>
|
|
||||||
<uniqueSuiteNames>false</uniqueSuiteNames>
|
|
||||||
<systemProperties>
|
|
||||||
<java.io.tmpdir>.</java.io.tmpdir>
|
|
||||||
<!-- we use '.' since this is different per JVM-->
|
|
||||||
<!-- RandomizedTesting library system properties -->
|
|
||||||
<tests.bwc>${tests.bwc}</tests.bwc>
|
|
||||||
<tests.bwc.path>${tests.bwc.path}</tests.bwc.path>
|
|
||||||
<tests.bwc.version>${tests.bwc.version}</tests.bwc.version>
|
|
||||||
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
|
|
||||||
<tests.processors>${tests.processors}</tests.processors>
|
|
||||||
<tests.appendseed>${tests.appendseed}</tests.appendseed>
|
|
||||||
<tests.iters>${tests.iters}</tests.iters>
|
|
||||||
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
|
|
||||||
<tests.failfast>${tests.failfast}</tests.failfast>
|
|
||||||
<tests.class>${tests.class}</tests.class>
|
|
||||||
<tests.method>${tests.method}</tests.method>
|
|
||||||
<tests.nightly>${tests.nightly}</tests.nightly>
|
|
||||||
<tests.verbose>${tests.verbose}</tests.verbose>
|
|
||||||
<tests.badapples>${tests.badapples}</tests.badapples>
|
|
||||||
<tests.weekly>${tests.weekly}</tests.weekly>
|
|
||||||
<tests.slow>${tests.slow}</tests.slow>
|
|
||||||
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
|
|
||||||
<tests.slow>${tests.slow}</tests.slow>
|
|
||||||
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
|
|
||||||
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
|
|
||||||
<tests.integration>${tests.integration}</tests.integration>
|
|
||||||
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
|
|
||||||
<tests.enable_mock_modules>${tests.enable_mock_modules}</tests.enable_mock_modules>
|
|
||||||
<tests.assertion.disabled>${tests.assertion.disabled}</tests.assertion.disabled>
|
|
||||||
<tests.rest>${tests.rest}</tests.rest>
|
|
||||||
<tests.rest.suite>${tests.rest.suite}</tests.rest.suite>
|
|
||||||
<tests.rest.blacklist>${tests.rest.blacklist}</tests.rest.blacklist>
|
|
||||||
<tests.rest.spec>${tests.rest.spec}</tests.rest.spec>
|
|
||||||
<tests.network>${tests.network}</tests.network>
|
|
||||||
<tests.cluster>${tests.cluster}</tests.cluster>
|
|
||||||
<tests.heap.size>${tests.heap.size}</tests.heap.size>
|
|
||||||
<tests.filter>${tests.filter}</tests.filter>
|
|
||||||
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
|
|
||||||
<es.node.mode>${es.node.mode}</es.node.mode>
|
|
||||||
<es.logger.level>${es.logger.level}</es.logger.level>
|
|
||||||
<tests.security.manager>${tests.security.manager}</tests.security.manager>
|
|
||||||
<tests.compatibility>${tests.compatibility}</tests.compatibility>
|
|
||||||
<java.awt.headless>true</java.awt.headless>
|
|
||||||
</systemProperties>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class LicensePlugin extends AbstractPlugin {
|
||||||
private final boolean isEnabled;
|
private final boolean isEnabled;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
MetaData.registerFactory(LicensesMetaData.TYPE, LicensesMetaData.FACTORY);
|
MetaData.registerPrototype(LicensesMetaData.TYPE, LicensesMetaData.PROTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class LicenseVersion implements Serializable {
|
||||||
public static final int V_1_0_0_ID = /*00*/1000099;
|
public static final int V_1_0_0_ID = /*00*/1000099;
|
||||||
public static final int V_2_0_0_ID = /*00*/2000099;
|
public static final int V_2_0_0_ID = /*00*/2000099;
|
||||||
public static final LicenseVersion V_1_0_0 = new LicenseVersion(V_1_0_0_ID, false, License.VERSION_START, Version.V_1_4_0_Beta1);
|
public static final LicenseVersion V_1_0_0 = new LicenseVersion(V_1_0_0_ID, false, License.VERSION_START, Version.V_1_4_0_Beta1);
|
||||||
public static final LicenseVersion V_2_0_0 = new LicenseVersion(V_2_0_0_ID, true, License.VERSION_START, Version.V_1_4_0_Beta1);
|
public static final LicenseVersion V_2_0_0 = new LicenseVersion(V_2_0_0_ID, true, License.VERSION_START, Version.V_2_0_0);
|
||||||
|
|
||||||
public static final LicenseVersion CURRENT = V_2_0_0;
|
public static final LicenseVersion CURRENT = V_2_0_0;
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.delete;
|
package org.elasticsearch.license.plugin.action.delete;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.ClusterAction;
|
import org.elasticsearch.action.Action;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ElasticsearchClient;
|
||||||
|
|
||||||
public class DeleteLicenseAction extends ClusterAction<DeleteLicenseRequest, DeleteLicenseResponse, DeleteLicenseRequestBuilder> {
|
public class DeleteLicenseAction extends Action<DeleteLicenseRequest, DeleteLicenseResponse, DeleteLicenseRequestBuilder> {
|
||||||
|
|
||||||
public static final DeleteLicenseAction INSTANCE = new DeleteLicenseAction();
|
public static final DeleteLicenseAction INSTANCE = new DeleteLicenseAction();
|
||||||
public static final String NAME = "cluster:admin/plugin/license/delete";
|
public static final String NAME = "cluster:admin/plugin/license/delete";
|
||||||
|
@ -23,7 +23,7 @@ public class DeleteLicenseAction extends ClusterAction<DeleteLicenseRequest, Del
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeleteLicenseRequestBuilder newRequestBuilder(ClusterAdminClient client) {
|
public DeleteLicenseRequestBuilder newRequestBuilder(ElasticsearchClient client) {
|
||||||
return new DeleteLicenseRequestBuilder(client);
|
return new DeleteLicenseRequestBuilder(client, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,31 +5,25 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.delete;
|
package org.elasticsearch.license.plugin.action.delete;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
|
||||||
import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder;
|
import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ClusterAdminClient;
|
||||||
|
import org.elasticsearch.client.ElasticsearchClient;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class DeleteLicenseRequestBuilder extends AcknowledgedRequestBuilder<DeleteLicenseRequest, DeleteLicenseResponse, DeleteLicenseRequestBuilder, ClusterAdminClient> {
|
public class DeleteLicenseRequestBuilder extends AcknowledgedRequestBuilder<DeleteLicenseRequest, DeleteLicenseResponse, DeleteLicenseRequestBuilder> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new get licenses request builder
|
* Creates new get licenses request builder
|
||||||
*
|
*
|
||||||
* @param clusterAdminClient cluster admin client
|
* @param client elasticsearch client
|
||||||
*/
|
*/
|
||||||
public DeleteLicenseRequestBuilder(ClusterAdminClient clusterAdminClient) {
|
public DeleteLicenseRequestBuilder(ElasticsearchClient client, DeleteLicenseAction action) {
|
||||||
super(clusterAdminClient, new DeleteLicenseRequest());
|
super(client, action, new DeleteLicenseRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeleteLicenseRequestBuilder setFeatures(Set<String> features) {
|
public DeleteLicenseRequestBuilder setFeatures(Set<String> features) {
|
||||||
request.features(features);
|
request.features(features);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doExecute(ActionListener<DeleteLicenseResponse> listener) {
|
|
||||||
client.execute(DeleteLicenseAction.INSTANCE, request, listener);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeOperationAc
|
||||||
@Inject
|
@Inject
|
||||||
public TransportDeleteLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService,
|
public TransportDeleteLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService,
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||||
super(settings, DeleteLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters);
|
super(settings, DeleteLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, DeleteLicenseRequest.class);
|
||||||
this.licensesManagerService = licensesManagerService;
|
this.licensesManagerService = licensesManagerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,6 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeOperationAc
|
||||||
return ThreadPool.Names.MANAGEMENT;
|
return ThreadPool.Names.MANAGEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected DeleteLicenseRequest newRequest() {
|
|
||||||
return new DeleteLicenseRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DeleteLicenseResponse newResponse() {
|
protected DeleteLicenseResponse newResponse() {
|
||||||
return new DeleteLicenseResponse();
|
return new DeleteLicenseResponse();
|
||||||
|
@ -50,7 +45,7 @@ public class TransportDeleteLicenseAction extends TransportMasterNodeOperationAc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(DeleteLicenseRequest request, ClusterState state) {
|
protected ClusterBlockException checkBlock(DeleteLicenseRequest request, ClusterState state) {
|
||||||
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, "");
|
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.get;
|
package org.elasticsearch.license.plugin.action.get;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.ClusterAction;
|
import org.elasticsearch.action.Action;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ElasticsearchClient;
|
||||||
|
|
||||||
public class GetLicenseAction extends ClusterAction<GetLicenseRequest, GetLicenseResponse, GetLicenseRequestBuilder> {
|
public class GetLicenseAction extends Action<GetLicenseRequest, GetLicenseResponse, GetLicenseRequestBuilder> {
|
||||||
|
|
||||||
public static final GetLicenseAction INSTANCE = new GetLicenseAction();
|
public static final GetLicenseAction INSTANCE = new GetLicenseAction();
|
||||||
public static final String NAME = "cluster:admin/plugin/license/get";
|
public static final String NAME = "cluster:admin/plugin/license/get";
|
||||||
|
@ -23,7 +23,7 @@ public class GetLicenseAction extends ClusterAction<GetLicenseRequest, GetLicens
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GetLicenseRequestBuilder newRequestBuilder(ClusterAdminClient client) {
|
public GetLicenseRequestBuilder newRequestBuilder(ElasticsearchClient client) {
|
||||||
return new GetLicenseRequestBuilder(client);
|
return new GetLicenseRequestBuilder(client, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,10 +7,6 @@ package org.elasticsearch.license.plugin.action.get;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequest;
|
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequest;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
|
||||||
public class GetLicenseRequest extends MasterNodeReadOperationRequest<GetLicenseRequest> {
|
public class GetLicenseRequest extends MasterNodeReadOperationRequest<GetLicenseRequest> {
|
||||||
|
@ -22,16 +18,4 @@ public class GetLicenseRequest extends MasterNodeReadOperationRequest<GetLicense
|
||||||
public ActionRequestValidationException validate() {
|
public ActionRequestValidationException validate() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
|
||||||
super.readFrom(in);
|
|
||||||
readLocal(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
|
||||||
super.writeTo(out);
|
|
||||||
writeLocal(out);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,24 +5,17 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.get;
|
package org.elasticsearch.license.plugin.action.get;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
|
||||||
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ElasticsearchClient;
|
||||||
|
|
||||||
public class GetLicenseRequestBuilder extends MasterNodeReadOperationRequestBuilder<GetLicenseRequest, GetLicenseResponse, GetLicenseRequestBuilder, ClusterAdminClient> {
|
public class GetLicenseRequestBuilder extends MasterNodeReadOperationRequestBuilder<GetLicenseRequest, GetLicenseResponse, GetLicenseRequestBuilder> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new get licenses request builder
|
* Creates new get licenses request builder
|
||||||
*
|
*
|
||||||
* @param clusterAdminClient cluster admin client
|
* @param client elasticsearch client
|
||||||
*/
|
*/
|
||||||
public GetLicenseRequestBuilder(ClusterAdminClient clusterAdminClient) {
|
public GetLicenseRequestBuilder(ElasticsearchClient client, GetLicenseAction action) {
|
||||||
super(clusterAdminClient, new GetLicenseRequest());
|
super(client, action, new GetLicenseRequest());
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doExecute(ActionListener<GetLicenseResponse> listener) {
|
|
||||||
client.execute(GetLicenseAction.INSTANCE, request, listener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadOperationA
|
||||||
@Inject
|
@Inject
|
||||||
public TransportGetLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService,
|
public TransportGetLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService, LicensesManagerService licensesManagerService,
|
||||||
ThreadPool threadPool, ActionFilters actionFilters) {
|
ThreadPool threadPool, ActionFilters actionFilters) {
|
||||||
super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters);
|
super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, GetLicenseRequest.class);
|
||||||
this.licensesManagerService = licensesManagerService;
|
this.licensesManagerService = licensesManagerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,11 +35,6 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadOperationA
|
||||||
return ThreadPool.Names.MANAGEMENT;
|
return ThreadPool.Names.MANAGEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected GetLicenseRequest newRequest() {
|
|
||||||
return new GetLicenseRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected GetLicenseResponse newResponse() {
|
protected GetLicenseResponse newResponse() {
|
||||||
return new GetLicenseResponse();
|
return new GetLicenseResponse();
|
||||||
|
@ -47,7 +42,7 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadOperationA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(GetLicenseRequest request, ClusterState state) {
|
protected ClusterBlockException checkBlock(GetLicenseRequest request, ClusterState state) {
|
||||||
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, "");
|
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_READ, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.put;
|
package org.elasticsearch.license.plugin.action.put;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.ClusterAction;
|
import org.elasticsearch.action.Action;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ElasticsearchClient;
|
||||||
|
|
||||||
public class PutLicenseAction extends ClusterAction<PutLicenseRequest, PutLicenseResponse, PutLicenseRequestBuilder> {
|
public class PutLicenseAction extends Action<PutLicenseRequest, PutLicenseResponse, PutLicenseRequestBuilder> {
|
||||||
|
|
||||||
public static final PutLicenseAction INSTANCE = new PutLicenseAction();
|
public static final PutLicenseAction INSTANCE = new PutLicenseAction();
|
||||||
public static final String NAME = "cluster:admin/plugin/license/put";
|
public static final String NAME = "cluster:admin/plugin/license/put";
|
||||||
|
@ -23,7 +23,7 @@ public class PutLicenseAction extends ClusterAction<PutLicenseRequest, PutLicens
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PutLicenseRequestBuilder newRequestBuilder(ClusterAdminClient client) {
|
public PutLicenseRequestBuilder newRequestBuilder(ElasticsearchClient client) {
|
||||||
return new PutLicenseRequestBuilder(client);
|
return new PutLicenseRequestBuilder(client, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.put;
|
package org.elasticsearch.license.plugin.action.put;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchIllegalArgumentException;
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
import org.elasticsearch.action.support.master.AcknowledgedRequest;
|
import org.elasticsearch.action.support.master.AcknowledgedRequest;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
@ -38,7 +37,7 @@ public class PutLicenseRequest extends AcknowledgedRequest<PutLicenseRequest> {
|
||||||
try {
|
try {
|
||||||
return licenses(Licenses.fromSource(licenseDefinition));
|
return licenses(Licenses.fromSource(licenseDefinition));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ElasticsearchIllegalArgumentException("failed to parse licenses source", e);
|
throw new IllegalArgumentException("failed to parse licenses source", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.action.put;
|
package org.elasticsearch.license.plugin.action.put;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
|
||||||
import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder;
|
import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder;
|
||||||
import org.elasticsearch.client.ClusterAdminClient;
|
import org.elasticsearch.client.ElasticsearchClient;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,15 +14,15 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Register license request builder
|
* Register license request builder
|
||||||
*/
|
*/
|
||||||
public class PutLicenseRequestBuilder extends AcknowledgedRequestBuilder<PutLicenseRequest, PutLicenseResponse, PutLicenseRequestBuilder, ClusterAdminClient> {
|
public class PutLicenseRequestBuilder extends AcknowledgedRequestBuilder<PutLicenseRequest, PutLicenseResponse, PutLicenseRequestBuilder> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs register license request
|
* Constructs register license request
|
||||||
*
|
*
|
||||||
* @param clusterAdminClient cluster admin client
|
* @param client elasticsearch client
|
||||||
*/
|
*/
|
||||||
public PutLicenseRequestBuilder(ClusterAdminClient clusterAdminClient) {
|
public PutLicenseRequestBuilder(ElasticsearchClient client, PutLicenseAction action) {
|
||||||
super(clusterAdminClient, new PutLicenseRequest());
|
super(client, action, new PutLicenseRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,9 +40,4 @@ public class PutLicenseRequestBuilder extends AcknowledgedRequestBuilder<PutLice
|
||||||
request.licenses(licenseSource);
|
request.licenses(licenseSource);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doExecute(ActionListener<PutLicenseResponse> listener) {
|
|
||||||
client.execute(PutLicenseAction.INSTANCE, request, listener);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class TransportPutLicenseAction extends TransportMasterNodeOperationActio
|
||||||
@Inject
|
@Inject
|
||||||
public TransportPutLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
public TransportPutLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
LicensesManagerService licensesManagerService, ThreadPool threadPool, ActionFilters actionFilters) {
|
LicensesManagerService licensesManagerService, ThreadPool threadPool, ActionFilters actionFilters) {
|
||||||
super(settings, PutLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters);
|
super(settings, PutLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, PutLicenseRequest.class);
|
||||||
this.licensesManagerService = licensesManagerService;
|
this.licensesManagerService = licensesManagerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,6 @@ public class TransportPutLicenseAction extends TransportMasterNodeOperationActio
|
||||||
return ThreadPool.Names.MANAGEMENT;
|
return ThreadPool.Names.MANAGEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected PutLicenseRequest newRequest() {
|
|
||||||
return new PutLicenseRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PutLicenseResponse newResponse() {
|
protected PutLicenseResponse newResponse() {
|
||||||
return new PutLicenseResponse();
|
return new PutLicenseResponse();
|
||||||
|
@ -51,7 +46,7 @@ public class TransportPutLicenseAction extends TransportMasterNodeOperationActio
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ClusterBlockException checkBlock(PutLicenseRequest request, ClusterState state) {
|
protected ClusterBlockException checkBlock(PutLicenseRequest request, ClusterState state) {
|
||||||
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA, "");
|
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.core;
|
package org.elasticsearch.license.plugin.core;
|
||||||
|
|
||||||
|
import org.elasticsearch.cluster.AbstractDiffable;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
import org.elasticsearch.common.collect.ImmutableList;
|
import org.elasticsearch.common.collect.ImmutableList;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
|
@ -17,17 +17,18 @@ import org.elasticsearch.license.core.Licenses;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains metadata about registered licenses
|
* Contains metadata about registered licenses
|
||||||
*/
|
*/
|
||||||
public class LicensesMetaData implements MetaData.Custom {
|
public class LicensesMetaData extends AbstractDiffable<MetaData.Custom> implements MetaData.Custom {
|
||||||
|
|
||||||
public static final String TYPE = "licenses";
|
public static final String TYPE = "licenses";
|
||||||
|
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final LicensesMetaData PROTO = new LicensesMetaData(Collections.<License>emptyList(), Collections.<License>emptyList());
|
||||||
|
|
||||||
private final ImmutableList<License> signedLicenses;
|
private final ImmutableList<License> signedLicenses;
|
||||||
|
|
||||||
|
@ -68,48 +69,11 @@ public class LicensesMetaData implements MetaData.Custom {
|
||||||
return signedLicenses.hashCode() + 31 * trialLicenses.hashCode();
|
return signedLicenses.hashCode() + 31 * trialLicenses.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Licenses metadata factory
|
|
||||||
*/
|
|
||||||
public static class Factory extends MetaData.Custom.Factory<LicensesMetaData> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String type() {
|
public String type() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public LicensesMetaData readFrom(StreamInput in) throws IOException {
|
|
||||||
List<License> signedLicenses = Licenses.readFrom(in);
|
|
||||||
int numTrialLicenses = in.readVInt();
|
|
||||||
List<License> trialLicenses = new ArrayList<>(numTrialLicenses);
|
|
||||||
for (int i = 0; i < numTrialLicenses; i++) {
|
|
||||||
trialLicenses.add(TrialLicenseUtils.fromEncodedTrialLicense(in.readString()));
|
|
||||||
}
|
|
||||||
return new LicensesMetaData(signedLicenses, trialLicenses);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void writeTo(LicensesMetaData licensesMetaData, StreamOutput out) throws IOException {
|
|
||||||
Licenses.writeTo(licensesMetaData.signedLicenses, out);
|
|
||||||
out.writeVInt(licensesMetaData.trialLicenses.size());
|
|
||||||
for (License trialLicense : licensesMetaData.trialLicenses) {
|
|
||||||
out.writeString(TrialLicenseUtils.toEncodedTrialLicense(trialLicense));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public LicensesMetaData fromXContent(XContentParser parser) throws IOException {
|
public LicensesMetaData fromXContent(XContentParser parser) throws IOException {
|
||||||
List<License> trialLicenses = new ArrayList<>();
|
List<License> trialLicenses = new ArrayList<>();
|
||||||
|
@ -143,32 +107,49 @@ public class LicensesMetaData implements MetaData.Custom {
|
||||||
return new LicensesMetaData(signedLicenses, trialLicenses);
|
return new LicensesMetaData(signedLicenses, trialLicenses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void toXContent(LicensesMetaData licensesMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
public EnumSet<MetaData.XContentContext> context() {
|
||||||
|
return EnumSet.of(MetaData.XContentContext.GATEWAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeTo(StreamOutput streamOutput) throws IOException {
|
||||||
|
Licenses.writeTo(signedLicenses, streamOutput);
|
||||||
|
streamOutput.writeVInt(trialLicenses.size());
|
||||||
|
for (License trialLicense : trialLicenses) {
|
||||||
|
streamOutput.writeString(TrialLicenseUtils.toEncodedTrialLicense(trialLicense));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetaData.Custom readFrom(StreamInput streamInput) throws IOException {
|
||||||
|
List<License> signedLicenses = Licenses.readFrom(streamInput);
|
||||||
|
int numTrialLicenses = streamInput.readVInt();
|
||||||
|
List<License> trialLicenses = new ArrayList<>(numTrialLicenses);
|
||||||
|
for (int i = 0; i < numTrialLicenses; i++) {
|
||||||
|
trialLicenses.add(TrialLicenseUtils.fromEncodedTrialLicense(streamInput.readString()));
|
||||||
|
}
|
||||||
|
return new LicensesMetaData(signedLicenses, trialLicenses);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startArray(Fields.TRIAL_LICENSES);
|
builder.startArray(Fields.TRIAL_LICENSES);
|
||||||
for (License trailLicense : licensesMetaData.trialLicenses) {
|
for (License trailLicense : trialLicenses) {
|
||||||
builder.value(TrialLicenseUtils.toEncodedTrialLicense(trailLicense));
|
builder.value(TrialLicenseUtils.toEncodedTrialLicense(trailLicense));
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
|
|
||||||
builder.startArray(Fields.SIGNED_LICENCES);
|
builder.startArray(Fields.SIGNED_LICENCES);
|
||||||
for (License license : licensesMetaData.signedLicenses) {
|
for (License license : signedLicenses) {
|
||||||
license.toXContent(builder, params);
|
license.toXContent(builder, params);
|
||||||
}
|
}
|
||||||
builder.endArray();
|
builder.endArray();
|
||||||
}
|
return builder;
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<MetaData.XContentContext> context() {
|
|
||||||
return EnumSet.of(MetaData.XContentContext.GATEWAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static class Fields {
|
private final static class Fields {
|
||||||
private static final String SIGNED_LICENCES = "signed_licenses";
|
private static final String SIGNED_LICENCES = "signed_licenses";
|
||||||
private static final String TRIAL_LICENSES = "trial_licenses";
|
private static final String TRIAL_LICENSES = "trial_licenses";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -37,7 +37,6 @@ import org.elasticsearch.transport.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
@ -128,7 +127,8 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
||||||
this.transportService = transportService;
|
this.transportService = transportService;
|
||||||
this.lastObservedLicensesState = new AtomicReference<>(null);
|
this.lastObservedLicensesState = new AtomicReference<>(null);
|
||||||
if (DiscoveryNode.masterNode(settings)) {
|
if (DiscoveryNode.masterNode(settings)) {
|
||||||
transportService.registerHandler(REGISTER_TRIAL_LICENSE_ACTION_NAME, new RegisterTrialLicenseRequestHandler());
|
transportService.registerRequestHandler(REGISTER_TRIAL_LICENSE_ACTION_NAME, RegisterTrialLicenseRequest.class,
|
||||||
|
ThreadPool.Names.SAME, new RegisterTrialLicenseRequestHandler());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1087,21 +1087,12 @@ public class LicensesService extends AbstractLifecycleComponent<LicensesService>
|
||||||
/**
|
/**
|
||||||
* Request handler for trial license generation to master
|
* Request handler for trial license generation to master
|
||||||
*/
|
*/
|
||||||
private class RegisterTrialLicenseRequestHandler extends BaseTransportRequestHandler<RegisterTrialLicenseRequest> {
|
private class RegisterTrialLicenseRequestHandler implements TransportRequestHandler<RegisterTrialLicenseRequest> {
|
||||||
@Override
|
|
||||||
public RegisterTrialLicenseRequest newInstance() {
|
|
||||||
return new RegisterTrialLicenseRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(RegisterTrialLicenseRequest request, TransportChannel channel) throws Exception {
|
public void messageReceived(RegisterTrialLicenseRequest request, TransportChannel channel) throws Exception {
|
||||||
registerTrialLicense(request);
|
registerTrialLicense(request);
|
||||||
channel.sendResponse(TransportResponse.Empty.INSTANCE);
|
channel.sendResponse(TransportResponse.Empty.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String executor() {
|
|
||||||
return ThreadPool.Names.SAME;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.core;
|
package org.elasticsearch.license.plugin.core;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchIllegalStateException;
|
|
||||||
|
|
||||||
public enum LicensesStatus {
|
public enum LicensesStatus {
|
||||||
VALID((byte) 0),
|
VALID((byte) 0),
|
||||||
INVALID((byte) 1),
|
INVALID((byte) 1),
|
||||||
|
@ -30,7 +28,7 @@ public enum LicensesStatus {
|
||||||
} else if (id == 2) {
|
} else if (id == 2) {
|
||||||
return EXPIRED;
|
return EXPIRED;
|
||||||
} else {
|
} else {
|
||||||
throw new ElasticsearchIllegalStateException("no valid LicensesStatus for id=" + id);
|
throw new IllegalStateException("no valid LicensesStatus for id=" + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.license.plugin.rest;
|
package org.elasticsearch.license.plugin.rest;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchIllegalArgumentException;
|
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
@ -34,10 +33,9 @@ public class RestDeleteLicenseAction extends BaseRestHandler {
|
||||||
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
|
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
|
||||||
final String[] features = Strings.splitStringByCommaToArray(request.param("features"));
|
final String[] features = Strings.splitStringByCommaToArray(request.param("features"));
|
||||||
if (features.length == 0) {
|
if (features.length == 0) {
|
||||||
throw new ElasticsearchIllegalArgumentException("no feature specified for license deletion");
|
throw new IllegalArgumentException("no feature specified for license deletion");
|
||||||
}
|
}
|
||||||
DeleteLicenseRequest deleteLicenseRequest = new DeleteLicenseRequest(features);
|
DeleteLicenseRequest deleteLicenseRequest = new DeleteLicenseRequest(features);
|
||||||
deleteLicenseRequest.listenerThreaded(false);
|
|
||||||
client.admin().cluster().execute(DeleteLicenseAction.INSTANCE, deleteLicenseRequest, new AcknowledgedRestListener<DeleteLicenseResponse>(channel));
|
client.admin().cluster().execute(DeleteLicenseAction.INSTANCE, deleteLicenseRequest, new AcknowledgedRestListener<DeleteLicenseResponse>(channel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ public class RestPutLicenseAction extends BaseRestHandler {
|
||||||
@Override
|
@Override
|
||||||
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
|
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
|
||||||
PutLicenseRequest putLicenseRequest = new PutLicenseRequest();
|
PutLicenseRequest putLicenseRequest = new PutLicenseRequest();
|
||||||
putLicenseRequest.listenerThreaded(false);
|
|
||||||
putLicenseRequest.licenses(request.content().toUtf8());
|
putLicenseRequest.licenses(request.content().toUtf8());
|
||||||
client.admin().cluster().execute(PutLicenseAction.INSTANCE, putLicenseRequest, new LicensesAcknowledgedListener(channel));
|
client.admin().cluster().execute(PutLicenseAction.INSTANCE, putLicenseRequest, new LicensesAcknowledgedListener(channel));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
|
import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
||||||
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService;
|
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService;
|
||||||
|
@ -32,6 +33,7 @@ import org.elasticsearch.test.InternalTestCluster;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@ -45,12 +47,22 @@ public abstract class AbstractLicensesIntegrationTests extends ElasticsearchInte
|
||||||
private final static org.elasticsearch.common.joda.time.format.DateTimeFormatter dateTimeFormatter = formatDateTimeFormatter.printer();
|
private final static org.elasticsearch.common.joda.time.format.DateTimeFormatter dateTimeFormatter = formatDateTimeFormatter.printer();
|
||||||
private final static DateMathParser dateMathParser = new DateMathParser(formatDateTimeFormatter, TimeUnit.MILLISECONDS);
|
private final static DateMathParser dateMathParser = new DateMathParser(formatDateTimeFormatter, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
public static String dateMathString(String time, long now) {
|
public static String dateMathString(String time, final long now) {
|
||||||
return dateTimeFormatter.print(dateMathParser.parse(time, now));
|
return dateTimeFormatter.print(dateMathParser.parse(time, new Callable<Long>() {
|
||||||
|
@Override
|
||||||
|
public Long call() throws Exception {
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long dateMath(String time, long now) {
|
public static long dateMath(String time, final long now) {
|
||||||
return dateMathParser.parse(time, now);
|
return dateMathParser.parse(time, new Callable<Long>() {
|
||||||
|
@Override
|
||||||
|
public Long call() throws Exception {
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
|
@ -92,7 +104,7 @@ public abstract class AbstractLicensesIntegrationTests extends ElasticsearchInte
|
||||||
|
|
||||||
protected void putLicense(String feature, TimeValue expiryDuration) throws Exception {
|
protected void putLicense(String feature, TimeValue expiryDuration) throws Exception {
|
||||||
License license1 = generateSignedLicense(feature, expiryDuration);
|
License license1 = generateSignedLicense(feature, expiryDuration);
|
||||||
final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster()).setLicense(Lists.newArrayList(license1)).get();
|
final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE).setLicense(Lists.newArrayList(license1)).get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase {
|
||||||
LicensesMetaData licensesMetaData = new LicensesMetaData(Arrays.asList(license), new ArrayList<License>());
|
LicensesMetaData licensesMetaData = new LicensesMetaData(Arrays.asList(license), new ArrayList<License>());
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
builder.startObject("licensesMetaData");
|
builder.startObject("licensesMetaData");
|
||||||
LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS);
|
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
byte[] serializedBytes = builder.bytes().toBytes();
|
byte[] serializedBytes = builder.bytes().toBytes();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase {
|
||||||
LicensesMetaData licensesMetaData = new LicensesMetaData(licenses, new ArrayList<License>());
|
LicensesMetaData licensesMetaData = new LicensesMetaData(licenses, new ArrayList<License>());
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
builder.startObject("licensesMetaData");
|
builder.startObject("licensesMetaData");
|
||||||
LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS);
|
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
byte[] serializedBytes = builder.bytes().toBytes();
|
byte[] serializedBytes = builder.bytes().toBytes();
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase {
|
||||||
LicensesMetaData licensesMetaData = new LicensesMetaData(new ArrayList<License>(), Arrays.asList(trialLicense));
|
LicensesMetaData licensesMetaData = new LicensesMetaData(new ArrayList<License>(), Arrays.asList(trialLicense));
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
builder.startObject("licensesMetaData");
|
builder.startObject("licensesMetaData");
|
||||||
LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS);
|
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
byte[] serializedBytes = builder.bytes().toBytes();
|
byte[] serializedBytes = builder.bytes().toBytes();
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase {
|
||||||
LicensesMetaData licensesMetaData = new LicensesMetaData(new ArrayList<License>(), trialLicenses);
|
LicensesMetaData licensesMetaData = new LicensesMetaData(new ArrayList<License>(), trialLicenses);
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
builder.startObject("licensesMetaData");
|
builder.startObject("licensesMetaData");
|
||||||
LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS);
|
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
byte[] serializedBytes = builder.bytes().toBytes();
|
byte[] serializedBytes = builder.bytes().toBytes();
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase {
|
||||||
LicensesMetaData licensesMetaData = new LicensesMetaData(licenses, trialLicenses);
|
LicensesMetaData licensesMetaData = new LicensesMetaData(licenses, trialLicenses);
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
builder.startObject("licensesMetaData");
|
builder.startObject("licensesMetaData");
|
||||||
LicensesMetaData.FACTORY.toXContent(licensesMetaData, builder, ToXContent.EMPTY_PARAMS);
|
licensesMetaData.toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
byte[] serializedBytes = builder.bytes().toBytes();
|
byte[] serializedBytes = builder.bytes().toBytes();
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class LicensesMetaDataSerializationTests extends ElasticsearchTestCase {
|
||||||
final XContentParser parser = XContentFactory.xContent(bytes).createParser(bytes);
|
final XContentParser parser = XContentFactory.xContent(bytes).createParser(bytes);
|
||||||
parser.nextToken(); // consume null
|
parser.nextToken(); // consume null
|
||||||
parser.nextToken(); // consume "licensesMetaData"
|
parser.nextToken(); // consume "licensesMetaData"
|
||||||
LicensesMetaData licensesMetaDataFromXContent = LicensesMetaData.FACTORY.fromXContent(parser);
|
LicensesMetaData licensesMetaDataFromXContent = LicensesMetaData.PROTO.fromXContent(parser);
|
||||||
parser.nextToken(); // consume endObject
|
parser.nextToken(); // consume endObject
|
||||||
assertThat(parser.nextToken(), nullValue());
|
assertThat(parser.nextToken(), nullValue());
|
||||||
return licensesMetaDataFromXContent;
|
return licensesMetaDataFromXContent;
|
||||||
|
|
|
@ -10,8 +10,10 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
|
import org.elasticsearch.license.plugin.action.get.GetLicenseAction;
|
||||||
import org.elasticsearch.license.plugin.action.get.GetLicenseRequestBuilder;
|
import org.elasticsearch.license.plugin.action.get.GetLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.get.GetLicenseResponse;
|
import org.elasticsearch.license.plugin.action.get.GetLicenseResponse;
|
||||||
|
import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
||||||
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin;
|
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin;
|
||||||
|
@ -20,7 +22,7 @@ import org.elasticsearch.license.plugin.consumer.LazyLicenseRegistrationConsumer
|
||||||
import org.elasticsearch.license.plugin.consumer.LazyLicenseRegistrationPluginService;
|
import org.elasticsearch.license.plugin.consumer.LazyLicenseRegistrationPluginService;
|
||||||
import org.elasticsearch.license.plugin.core.LicensesMetaData;
|
import org.elasticsearch.license.plugin.core.LicensesMetaData;
|
||||||
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
||||||
import org.elasticsearch.node.internal.InternalNode;
|
import org.elasticsearch.node.Node;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -57,7 +59,7 @@ public class LicensesServiceClusterTest extends AbstractLicensesIntegrationTests
|
||||||
.put(EagerLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 2)
|
.put(EagerLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 2)
|
||||||
.put(LazyLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 2)
|
.put(LazyLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 2)
|
||||||
.putArray("plugin.types", LicensePlugin.class.getName(), EagerLicenseRegistrationConsumerPlugin.class.getName(), LazyLicenseRegistrationConsumerPlugin.class.getName())
|
.putArray("plugin.types", LicensePlugin.class.getName(), EagerLicenseRegistrationConsumerPlugin.class.getName(), LazyLicenseRegistrationConsumerPlugin.class.getName())
|
||||||
.put(InternalNode.HTTP_ENABLED, true);
|
.put(Node.HTTP_ENABLED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -124,7 +126,7 @@ public class LicensesServiceClusterTest extends AbstractLicensesIntegrationTests
|
||||||
for (String feature : FEATURES) {
|
for (String feature : FEATURES) {
|
||||||
putLicenses.add(generateSignedLicense(feature, TimeValue.timeValueMinutes(1)));
|
putLicenses.add(generateSignedLicense(feature, TimeValue.timeValueMinutes(1)));
|
||||||
}
|
}
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(cluster);
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(cluster, PutLicenseAction.INSTANCE);
|
||||||
putLicenseRequestBuilder.setLicense(putLicenses);
|
putLicenseRequestBuilder.setLicense(putLicenses);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
|
@ -138,7 +140,7 @@ public class LicensesServiceClusterTest extends AbstractLicensesIntegrationTests
|
||||||
|
|
||||||
private void getAndCheckLicense(List<License> licenses) {
|
private void getAndCheckLicense(List<License> licenses) {
|
||||||
ClusterAdminClient cluster = internalCluster().client().admin().cluster();
|
ClusterAdminClient cluster = internalCluster().client().admin().cluster();
|
||||||
final GetLicenseResponse response = new GetLicenseRequestBuilder(cluster).get();
|
final GetLicenseResponse response = new GetLicenseRequestBuilder(cluster, GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(response.licenses().size(), equalTo(licenses.size()));
|
assertThat(response.licenses().size(), equalTo(licenses.size()));
|
||||||
TestUtils.isSame(licenses, response.licenses());
|
TestUtils.isSame(licenses, response.licenses());
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin;
|
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationConsumerPlugin;
|
||||||
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService;
|
import org.elasticsearch.license.plugin.consumer.EagerLicenseRegistrationPluginService;
|
||||||
import org.elasticsearch.node.internal.InternalNode;
|
import org.elasticsearch.node.Node;
|
||||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -31,7 +31,7 @@ public class LicensesServiceNodeTests extends AbstractLicensesIntegrationTests {
|
||||||
.put(super.nodeSettings(nodeOrdinal))
|
.put(super.nodeSettings(nodeOrdinal))
|
||||||
.put(EagerLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 60 * 5)
|
.put(EagerLicenseRegistrationConsumerPlugin.NAME + ".trial_license_duration_in_seconds", 60 * 5)
|
||||||
.putArray("plugin.types", LicensePlugin.class.getName(), EagerLicenseRegistrationConsumerPlugin.class.getName())
|
.putArray("plugin.types", LicensePlugin.class.getName(), EagerLicenseRegistrationConsumerPlugin.class.getName())
|
||||||
.put(InternalNode.HTTP_ENABLED, true)
|
.put(Node.HTTP_ENABLED, true)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,13 @@ import org.elasticsearch.action.ActionFuture;
|
||||||
import org.elasticsearch.common.collect.Sets;
|
import org.elasticsearch.common.collect.Sets;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.license.core.License;
|
import org.elasticsearch.license.core.License;
|
||||||
|
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseAction;
|
||||||
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseRequestBuilder;
|
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseResponse;
|
import org.elasticsearch.license.plugin.action.delete.DeleteLicenseResponse;
|
||||||
|
import org.elasticsearch.license.plugin.action.get.GetLicenseAction;
|
||||||
import org.elasticsearch.license.plugin.action.get.GetLicenseRequestBuilder;
|
import org.elasticsearch.license.plugin.action.get.GetLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.get.GetLicenseResponse;
|
import org.elasticsearch.license.plugin.action.get.GetLicenseResponse;
|
||||||
|
import org.elasticsearch.license.plugin.action.put.PutLicenseAction;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
||||||
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
||||||
|
@ -39,7 +42,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyGetLicense() throws Exception {
|
public void testEmptyGetLicense() throws Exception {
|
||||||
final ActionFuture<GetLicenseResponse> getLicenseFuture = new GetLicenseRequestBuilder(client().admin().cluster()).execute();
|
final ActionFuture<GetLicenseResponse> getLicenseFuture = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).execute();
|
||||||
final GetLicenseResponse getLicenseResponse = getLicenseFuture.get();
|
final GetLicenseResponse getLicenseResponse = getLicenseFuture.get();
|
||||||
assertThat("expected 0 licenses; but got: " + getLicenseResponse.licenses().size(), getLicenseResponse.licenses().size(), equalTo(0));
|
assertThat("expected 0 licenses; but got: " + getLicenseResponse.licenses().size(), getLicenseResponse.licenses().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
@ -50,14 +53,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
List<License> actualLicenses = Collections.singletonList(signedLicense);
|
List<License> actualLicenses = Collections.singletonList(signedLicense);
|
||||||
|
|
||||||
// put license
|
// put license
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(actualLicenses);
|
.setLicense(actualLicenses);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get license
|
// get license
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
||||||
|
|
||||||
|
@ -71,14 +74,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
String licenseString = TestUtils.dumpLicense(signedLicense);
|
String licenseString = TestUtils.dumpLicense(signedLicense);
|
||||||
|
|
||||||
// put license source
|
// put license source
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(licenseString);
|
.setLicense(licenseString);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get license
|
// get license
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
||||||
|
|
||||||
|
@ -97,7 +100,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
.validate()
|
.validate()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster());
|
PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE);
|
||||||
builder.setLicense(Collections.singletonList(tamperedLicense));
|
builder.setLicense(Collections.singletonList(tamperedLicense));
|
||||||
|
|
||||||
// try to put license (should be invalid)
|
// try to put license (should be invalid)
|
||||||
|
@ -105,7 +108,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.INVALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.INVALID));
|
||||||
|
|
||||||
// try to get invalid license
|
// try to get invalid license
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(0));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +117,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
License expiredLicense = generateSignedLicense("feature", dateMath("now-10d/d", System.currentTimeMillis()), TimeValue.timeValueMinutes(2));
|
License expiredLicense = generateSignedLicense("feature", dateMath("now-10d/d", System.currentTimeMillis()), TimeValue.timeValueMinutes(2));
|
||||||
License signedLicense = generateSignedLicense("feature", TimeValue.timeValueMinutes(2));
|
License signedLicense = generateSignedLicense("feature", TimeValue.timeValueMinutes(2));
|
||||||
|
|
||||||
PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster());
|
PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE);
|
||||||
builder.setLicense(Arrays.asList(signedLicense, expiredLicense));
|
builder.setLicense(Arrays.asList(signedLicense, expiredLicense));
|
||||||
|
|
||||||
// put license should return valid (as there is one valid license)
|
// put license should return valid (as there is one valid license)
|
||||||
|
@ -122,7 +125,7 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get license should not return the expired license
|
// get license should not return the expired license
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
||||||
|
|
||||||
TestUtils.isSame(getLicenseResponse.licenses().get(0), signedLicense);
|
TestUtils.isSame(getLicenseResponse.licenses().get(0), signedLicense);
|
||||||
|
@ -135,14 +138,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
List<License> actualLicenses = Arrays.asList(longerSignedLicense, shortedSignedLicense);
|
List<License> actualLicenses = Arrays.asList(longerSignedLicense, shortedSignedLicense);
|
||||||
|
|
||||||
// put license
|
// put license
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(actualLicenses);
|
.setLicense(actualLicenses);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get should return only one license (with longer expiry date)
|
// get should return only one license (with longer expiry date)
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
||||||
|
|
||||||
|
@ -157,14 +160,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
List<License> actualLicenses = Arrays.asList(marvelLicense, shieldLicense);
|
List<License> actualLicenses = Arrays.asList(marvelLicense, shieldLicense);
|
||||||
|
|
||||||
// put license
|
// put license
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(actualLicenses);
|
.setLicense(actualLicenses);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get should return both the licenses
|
// get should return both the licenses
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
|
|
||||||
// check license
|
// check license
|
||||||
|
@ -179,14 +182,14 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
List<License> actualLicenses = Arrays.asList(marvelLicense, shortedSignedLicense, longerSignedLicense);
|
List<License> actualLicenses = Arrays.asList(marvelLicense, shortedSignedLicense, longerSignedLicense);
|
||||||
|
|
||||||
// put license
|
// put license
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(actualLicenses);
|
.setLicense(actualLicenses);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get should return both the licenses
|
// get should return both the licenses
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(2));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(2));
|
||||||
|
|
||||||
|
@ -201,25 +204,25 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
List<License> actualLicenses = Arrays.asList(marvelLicense, shieldLicense);
|
List<License> actualLicenses = Arrays.asList(marvelLicense, shieldLicense);
|
||||||
|
|
||||||
// put two licenses
|
// put two licenses
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(actualLicenses);
|
.setLicense(actualLicenses);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// get and check licenses
|
// get and check licenses
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(2));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(2));
|
||||||
|
|
||||||
// delete all licenses
|
// delete all licenses
|
||||||
DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster())
|
DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster(), DeleteLicenseAction.INSTANCE)
|
||||||
.setFeatures(Sets.newHashSet("shield", "marvel"));
|
.setFeatures(Sets.newHashSet("shield", "marvel"));
|
||||||
DeleteLicenseResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get();
|
DeleteLicenseResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get();
|
||||||
assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
|
|
||||||
// get licenses (expected no licenses)
|
// get licenses (expected no licenses)
|
||||||
getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(0));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
@ -231,31 +234,31 @@ public class LicensesTransportTests extends AbstractLicensesIntegrationTests {
|
||||||
List<License> actualLicenses = Arrays.asList(marvelLicense, shieldLicense);
|
List<License> actualLicenses = Arrays.asList(marvelLicense, shieldLicense);
|
||||||
|
|
||||||
// put two licenses
|
// put two licenses
|
||||||
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster())
|
PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE)
|
||||||
.setLicense(actualLicenses);
|
.setLicense(actualLicenses);
|
||||||
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
// delete one license
|
// delete one license
|
||||||
DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster())
|
DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster(), DeleteLicenseAction.INSTANCE)
|
||||||
.setFeatures(Sets.newHashSet("shield"));
|
.setFeatures(Sets.newHashSet("shield"));
|
||||||
DeleteLicenseResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get();
|
DeleteLicenseResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get();
|
||||||
assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
|
|
||||||
// check other license
|
// check other license
|
||||||
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(1));
|
||||||
|
|
||||||
// delete another license
|
// delete another license
|
||||||
deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster())
|
deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder(client().admin().cluster(), DeleteLicenseAction.INSTANCE)
|
||||||
.setFeatures(Sets.newHashSet("marvel"));
|
.setFeatures(Sets.newHashSet("marvel"));
|
||||||
deleteLicenseResponse = deleteLicenseRequestBuilder.get();
|
deleteLicenseResponse = deleteLicenseRequestBuilder.get();
|
||||||
assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
|
|
||||||
// check no license
|
// check no license
|
||||||
getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster()).get();
|
getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get();
|
||||||
assertThat(getLicenseResponse.licenses(), notNullValue());
|
assertThat(getLicenseResponse.licenses(), notNullValue());
|
||||||
assertThat(getLicenseResponse.licenses().size(), equalTo(0));
|
assertThat(getLicenseResponse.licenses().size(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
|
31
pom.xml
31
pom.xml
|
@ -4,6 +4,12 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.elasticsearch</groupId>
|
||||||
|
<artifactId>elasticsearch-parent</artifactId>
|
||||||
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
<artifactId>elasticsearch-license</artifactId>
|
<artifactId>elasticsearch-license</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
@ -16,17 +22,6 @@
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<elasticsearch.version>1.4.0</elasticsearch.version>
|
|
||||||
<lucene.version>4.10.2</lucene.version>
|
|
||||||
<tests.jvms>auto</tests.jvms>
|
|
||||||
<tests.shuffle>true</tests.shuffle>
|
|
||||||
<tests.output>onerror</tests.output>
|
|
||||||
<tests.bwc.path>${project.basedir}/backwards</tests.bwc.path>
|
|
||||||
<es.logger.level>INFO</es.logger.level>
|
|
||||||
<tests.heap.size>512m</tests.heap.size>
|
|
||||||
<tests.topn>5</tests.topn>
|
|
||||||
<execution.hint.file>.local-${project.version}-execution-hints.log</execution.hint.file>
|
|
||||||
<license.basedir combine.self="override">${project.basedir}</license.basedir>
|
<license.basedir combine.self="override">${project.basedir}</license.basedir>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -36,13 +31,11 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.lucene</groupId>
|
<groupId>org.apache.lucene</groupId>
|
||||||
<artifactId>lucene-test-framework</artifactId>
|
<artifactId>lucene-test-framework</artifactId>
|
||||||
<version>${lucene.version}</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
<artifactId>elasticsearch</artifactId>
|
<artifactId>elasticsearch</artifactId>
|
||||||
<version>${elasticsearch.version}</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -61,13 +54,11 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||||
<artifactId>randomizedtesting-runner</artifactId>
|
<artifactId>randomizedtesting-runner</artifactId>
|
||||||
<version>2.1.10</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.17</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -75,7 +66,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
<artifactId>elasticsearch</artifactId>
|
<artifactId>elasticsearch</artifactId>
|
||||||
<version>${elasticsearch.version}</version>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -85,7 +76,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
|
@ -107,15 +97,10 @@
|
||||||
<!-- we skip surefire to work with randomized testing above -->
|
<!-- we skip surefire to work with randomized testing above -->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.16</version>
|
|
||||||
<configuration>
|
|
||||||
<skipTests>true</skipTests>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>de.thetaphi</groupId>
|
<groupId>de.thetaphi</groupId>
|
||||||
<artifactId>forbiddenapis</artifactId>
|
<artifactId>forbiddenapis</artifactId>
|
||||||
<version>1.6.1</version>
|
|
||||||
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
@ -200,7 +185,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
<version>1.3.1</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>enforce-versions</id>
|
<id>enforce-versions</id>
|
||||||
|
@ -278,7 +262,6 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
<groupId>com.carrotsearch.randomizedtesting</groupId>
|
||||||
<artifactId>junit4-maven-plugin</artifactId>
|
<artifactId>junit4-maven-plugin</artifactId>
|
||||||
<version>2.1.2</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>${tests.jvm.argline}</argLine>
|
<argLine>${tests.jvm.argline}</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in New Issue