-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of #64850. This PR introduces the concept of "licensed" plugins. Such plugins may only be installed on installations of the default distribution, and this is enforced by the plugin installer. This PR also moves the `quote-aware-fs` plugin to the `x-pack` directory, and marks it as licensed. Note that I didn't move the plugin source under `x-pack/plugin` because all the existing x-pack plugins are actually bundles as modules into the default distribution, whereas the `quota-aware-fs` plugin needs to remain a standalone plugin.
- Loading branch information
1 parent
04d7f6b
commit 1d9d6db
Showing
27 changed files
with
268 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
.../tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallLicensedPluginTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.plugins; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import java.util.Collections; | ||
|
||
import org.elasticsearch.Build; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.cli.ExitCodes; | ||
import org.elasticsearch.cli.MockTerminal; | ||
import org.elasticsearch.cli.UserException; | ||
import org.elasticsearch.test.ESTestCase; | ||
|
||
public class InstallLicensedPluginTests extends ESTestCase { | ||
|
||
/** | ||
* Check that an unlicensed plugin is accepted. | ||
*/ | ||
public void testUnlicensedPlugin() throws Exception { | ||
MockTerminal terminal = new MockTerminal(); | ||
PluginInfo pluginInfo = buildInfo(false); | ||
InstallPluginCommand.checkCanInstallationProceed(terminal, Build.Flavor.OSS, pluginInfo); | ||
} | ||
|
||
/** | ||
* Check that a licensed plugin cannot be installed on OSS. | ||
*/ | ||
public void testInstallPluginCommandOnOss() throws Exception { | ||
MockTerminal terminal = new MockTerminal(); | ||
PluginInfo pluginInfo = buildInfo(true); | ||
final UserException userException = expectThrows( | ||
UserException.class, | ||
() -> InstallPluginCommand.checkCanInstallationProceed(terminal, Build.Flavor.OSS, pluginInfo) | ||
); | ||
|
||
assertThat(userException.exitCode, equalTo(ExitCodes.NOPERM)); | ||
assertThat(terminal.getOutput(), containsString("ERROR: This is a licensed plugin")); | ||
} | ||
|
||
/** | ||
* Check that a licensed plugin cannot be installed when the distribution type is unknown. | ||
*/ | ||
public void testInstallPluginCommandOnUnknownDistribution() throws Exception { | ||
MockTerminal terminal = new MockTerminal(); | ||
PluginInfo pluginInfo = buildInfo(true); | ||
expectThrows( | ||
UserException.class, | ||
() -> InstallPluginCommand.checkCanInstallationProceed(terminal, Build.Flavor.UNKNOWN, pluginInfo) | ||
); | ||
assertThat(terminal.getOutput(), containsString("ERROR: This is a licensed plugin")); | ||
} | ||
|
||
/** | ||
* Check that a licensed plugin can be installed when the distribution type is default. | ||
*/ | ||
public void testInstallPluginCommandOnDefault() throws Exception { | ||
MockTerminal terminal = new MockTerminal(); | ||
PluginInfo pluginInfo = buildInfo(true); | ||
InstallPluginCommand.checkCanInstallationProceed(terminal, Build.Flavor.DEFAULT, pluginInfo); | ||
} | ||
|
||
private PluginInfo buildInfo(boolean isLicensed) { | ||
return new PluginInfo( | ||
"name", | ||
"description", | ||
"version", | ||
Version.CURRENT, | ||
"java version", | ||
"classname", | ||
Collections.emptyList(), | ||
false, | ||
isLicensed | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.