Disable plugincli feature (#101)

Plugins CLI - disable installing official plugins by name.

Currently the plugin cli allows installation of a plugin by name in which case it downloads the plugin artifacts from the official elastic artifacts repository.

We will enable it once we have the new official artifacts download URL (Tracking Issue: #100)

Signed-off-by: Peter Nied <petern@amazon.com>
This commit is contained in:
Rabi Panda 2021-02-15 10:59:59 -08:00 committed by Peter Nied
parent a048a9d48a
commit afd91d76f9
2 changed files with 25 additions and 5 deletions

View File

@ -279,11 +279,16 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
/** Downloads the plugin and returns the file it was downloaded to. */
private Path download(Terminal terminal, String pluginId, Path tmpDir, boolean isBatch) throws Exception {
if (OFFICIAL_PLUGINS.contains(pluginId)) {
final String url = getElasticUrl(terminal, getStagingHash(), Version.CURRENT, isSnapshot(), pluginId, Platforms.PLATFORM_NAME);
terminal.println("-> Downloading " + pluginId + " from elastic");
return downloadAndValidate(terminal, url, tmpDir, true, isBatch);
}
//
// Disabled installing of plugins by name (https://github.com/opendistro-for-elasticsearch/search/issues/71)
// TODO: Once we have the new artifacts repository URL, We will uncomment this section and update the URLs.
// https://github.com/opendistro-for-elasticsearch/search/issues/100
//
// if (OFFICIAL_PLUGINS.contains(pluginId)) {
// final String url = getElasticUrl(terminal, getStagingHash(), Version.CURRENT, isSnapshot(), pluginId, Platforms.PLATFORM_NAME);
// terminal.println("-> Downloading " + pluginId + " from elastic");
// return downloadAndValidate(terminal, url, tmpDir, true, isBatch);
// }
// now try as maven coordinates, a valid URL would only have a colon and slash
String[] coordinates = pluginId.split(":");

View File

@ -990,6 +990,7 @@ public class InstallPluginCommandTests extends ESTestCase {
);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPlugin() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -997,6 +998,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPluginSnapshot() throws Exception {
String url = String.format(
Locale.ROOT,
@ -1007,6 +1009,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", true);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testInstallReleaseBuildOfPluginOnSnapshotBuild() {
String url = String.format(
Locale.ROOT,
@ -1026,6 +1029,7 @@ public class InstallPluginCommandTests extends ESTestCase {
);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPluginStaging() throws Exception {
String url = "https://staging.elastic.co/"
+ Version.CURRENT
@ -1035,6 +1039,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", false);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPlatformPlugin() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Platforms.PLATFORM_NAME
@ -1044,6 +1049,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPlatformPluginSnapshot() throws Exception {
String url = String.format(
Locale.ROOT,
@ -1055,6 +1061,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", true);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPlatformPluginStaging() throws Exception {
String url = "https://staging.elastic.co/"
+ Version.CURRENT
@ -1099,6 +1106,7 @@ public class InstallPluginCommandTests extends ESTestCase {
);
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialChecksumWithoutFilename() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -1122,6 +1130,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertThat(e.getMessage(), startsWith("Invalid checksum file"));
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialShaMissing() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -1165,6 +1174,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertEquals("Plugin checksum missing: " + url + ".sha1", e.getMessage());
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testInvalidShaFileMissingFilename() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -1188,6 +1198,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertTrue(e.getMessage(), e.getMessage().startsWith("Invalid checksum file"));
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testInvalidShaFileMismatchFilename() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -1211,6 +1222,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertThat(e, hasToString(matches("checksum file at \\[.*\\] is not for this plugin")));
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testInvalidShaFileContainingExtraLine() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -1234,6 +1246,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertTrue(e.getMessage(), e.getMessage().startsWith("Invalid checksum file"));
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testSha512Mismatch() throws Exception {
String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-"
+ Build.CURRENT.getQualifiedVersion()
@ -1276,6 +1289,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertTrue(e.getMessage(), e.getMessage().contains("SHA-1 mismatch, expected foobar"));
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testPublicKeyIdMismatchToExpectedPublicKeyId() throws Exception {
final String icu = "analysis-icu";
final String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/"
@ -1311,6 +1325,7 @@ public class InstallPluginCommandTests extends ESTestCase {
assertThat(e, hasToString(containsString("key id [" + actualID + "] does not match expected key id [" + expectedID + "]")));
}
@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testFailedSignatureVerification() throws Exception {
final String icu = "analysis-icu";
final String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/"