Skip to content

Commit

Permalink
Disable plugincli feature (#101)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
adnapibar authored and peternied committed Mar 13, 2021
1 parent a048a9d commit afd91d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,16 @@ void execute(Terminal terminal, List<String> pluginIds, boolean isBatch, Environ

/** 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(":");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,13 +990,15 @@ public void assertInstallPluginFromUrl(
);
}

@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()
+ ".zip";
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,
Expand All @@ -1007,6 +1009,7 @@ public void testOfficialPluginSnapshot() throws Exception {
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,
Expand All @@ -1026,6 +1029,7 @@ public void testInstallReleaseBuildOfPluginOnSnapshotBuild() {
);
}

@AwaitsFix(bugUrl = "https://github.com/opendistro-for-elasticsearch/search/issues/100")
public void testOfficialPluginStaging() throws Exception {
String url = "https://staging.elastic.co/"
+ Version.CURRENT
Expand All @@ -1035,6 +1039,7 @@ public void testOfficialPluginStaging() throws Exception {
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
Expand All @@ -1044,6 +1049,7 @@ public void testOfficialPlatformPlugin() throws Exception {
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,
Expand All @@ -1055,6 +1061,7 @@ public void testOfficialPlatformPluginSnapshot() throws Exception {
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
Expand Down Expand Up @@ -1099,6 +1106,7 @@ public void testMavenChecksumWithoutFilename() throws Exception {
);
}

@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()
Expand All @@ -1122,6 +1130,7 @@ public void testOfficialChecksumWithoutFilename() throws Exception {
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()
Expand Down Expand Up @@ -1165,6 +1174,7 @@ public void testMavenShaMissing() throws Exception {
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()
Expand All @@ -1188,6 +1198,7 @@ public void testInvalidShaFileMissingFilename() throws Exception {
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()
Expand All @@ -1211,6 +1222,7 @@ public void testInvalidShaFileMismatchFilename() throws Exception {
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()
Expand All @@ -1234,6 +1246,7 @@ public void testInvalidShaFileContainingExtraLine() throws Exception {
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()
Expand Down Expand Up @@ -1276,6 +1289,7 @@ public void testSha1Mismatch() throws Exception {
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/"
Expand Down Expand Up @@ -1311,6 +1325,7 @@ public void testPublicKeyIdMismatchToExpectedPublicKeyId() throws Exception {
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/"
Expand Down

0 comments on commit afd91d7

Please sign in to comment.