use of org.opensearch.cli.UserException in project OpenSearch by opensearch-project.
the class InstallPluginCommandTests method testInvalidShaFileMissingFilename.
public void testInvalidShaFileMissingFilename() throws Exception {
String url = "https://artifacts.opensearch.org/releases/plugins/analysis-icu/" + Build.CURRENT.getQualifiedVersion() + "/analysis-icu-" + Build.CURRENT.getQualifiedVersion() + ".zip";
MessageDigest digest = MessageDigest.getInstance("SHA-512");
UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false, ".sha512", checksum(digest), null, (b, p) -> null));
assertEquals(ExitCodes.IO_ERROR, e.exitCode);
assertTrue(e.getMessage(), e.getMessage().startsWith("Invalid checksum file"));
}
use of org.opensearch.cli.UserException in project OpenSearch by opensearch-project.
the class InstallPluginCommandTests method testSha1Mismatch.
public void testSha1Mismatch() throws Exception {
String url = "https://repo1.maven.org/maven2/mygroup/myplugin/1.0.0/myplugin-1.0.0.zip";
UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("mygroup:myplugin:1.0.0", "myplugin", url, null, false, ".sha1", bytes -> "foobar", null, (b, p) -> null));
assertEquals(ExitCodes.IO_ERROR, e.exitCode);
assertTrue(e.getMessage(), e.getMessage().contains("SHA-1 mismatch, expected foobar"));
}
use of org.opensearch.cli.UserException in project OpenSearch by opensearch-project.
the class InstallPluginCommandTests method testOfficialShaMissing.
public void testOfficialShaMissing() throws Exception {
String url = "https://artifacts.opensearch.org/releases/plugins/analysis-icu/" + Build.CURRENT.getQualifiedVersion() + "/analysis-icu-" + Build.CURRENT.getQualifiedVersion() + ".zip";
MessageDigest digest = MessageDigest.getInstance("SHA-1");
UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false, ".sha1", checksum(digest), null, (b, p) -> null));
assertEquals(ExitCodes.IO_ERROR, e.exitCode);
assertEquals("Plugin checksum missing: " + url + ".sha512", e.getMessage());
}
use of org.opensearch.cli.UserException in project OpenSearch by opensearch-project.
the class InstallPluginCommandTests method testInstallMisspelledOfficialPlugins.
public void testInstallMisspelledOfficialPlugins() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);
UserException e = expectThrows(UserException.class, () -> installPlugin("analysis-smartnc", env.v1()));
assertThat(e.getMessage(), containsString("Unknown plugin analysis-smartnc, did you mean [analysis-smartcn]?"));
e = expectThrows(UserException.class, () -> installPlugin("repository", env.v1()));
assertThat(e.getMessage(), containsString("Unknown plugin repository, did you mean any of [repository-s3, repository-gcs]?"));
e = expectThrows(UserException.class, () -> installPlugin("unknown_plugin", env.v1()));
assertThat(e.getMessage(), containsString("Unknown plugin unknown_plugin"));
}
use of org.opensearch.cli.UserException in project OpenSearch by opensearch-project.
the class InstallPluginCommandTests method testInvalidShaFileContainingExtraLine.
public void testInvalidShaFileContainingExtraLine() throws Exception {
String url = "https://artifacts.opensearch.org/releases/plugins/analysis-icu/" + Build.CURRENT.getQualifiedVersion() + "/analysis-icu-" + Build.CURRENT.getQualifiedVersion() + ".zip";
MessageDigest digest = MessageDigest.getInstance("SHA-512");
UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false, ".sha512", checksumAndString(digest, " analysis-icu-" + Build.CURRENT.getQualifiedVersion() + ".zip\nfoobar"), null, (b, p) -> null));
assertEquals(ExitCodes.IO_ERROR, e.exitCode);
assertTrue(e.getMessage(), e.getMessage().startsWith("Invalid checksum file"));
}
Aggregations