use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InternalSettingsPreparerTests method testReplacePromptPlaceholders.
public void testReplacePromptPlaceholders() {
MockTerminal terminal = new MockTerminal();
terminal.addTextInput("text");
terminal.addSecretInput("replaced");
Settings.Builder builder = Settings.builder().put(baseEnvSettings).put("password.replace", InternalSettingsPreparer.SECRET_PROMPT_VALUE).put("dont.replace", "prompt:secret").put("dont.replace2", "_prompt:secret_").put("dont.replace3", "_prompt:text__").put("dont.replace4", "__prompt:text_").put("dont.replace5", "prompt:secret__").put("replace_me", InternalSettingsPreparer.TEXT_PROMPT_VALUE);
Settings settings = InternalSettingsPreparer.prepareEnvironment(builder.build(), terminal).settings();
assertThat(settings.get("password.replace"), equalTo("replaced"));
assertThat(settings.get("replace_me"), equalTo("text"));
// verify other values unchanged
assertThat(settings.get("dont.replace"), equalTo("prompt:secret"));
assertThat(settings.get("dont.replace2"), equalTo("_prompt:secret_"));
assertThat(settings.get("dont.replace3"), equalTo("_prompt:text__"));
assertThat(settings.get("dont.replace4"), equalTo("__prompt:text_"));
assertThat(settings.get("dont.replace5"), equalTo("prompt:secret__"));
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testOfficialPluginsHelpSorted.
public void testOfficialPluginsHelpSorted() throws Exception {
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand() {
@Override
protected boolean addShutdownHook() {
return false;
}
}.main(new String[] { "--help" }, terminal);
try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {
String line = reader.readLine();
// first find the beginning of our list of official plugins
while (line.endsWith("may be installed by name:") == false) {
line = reader.readLine();
}
// now check each line compares greater than the last, until we reach an empty line
String prev = reader.readLine();
line = reader.readLine();
while (line != null && line.trim().isEmpty() == false) {
assertTrue(prev + " < " + line, prev.compareTo(line) < 0);
prev = line;
line = reader.readLine();
}
}
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testQuietFlagEnabled.
public void testQuietFlagEnabled() throws Exception {
MockTerminal terminal = new MockTerminal();
terminal.setVerbosity(Terminal.Verbosity.SILENT);
installPlugin(terminal, false);
assertThat(terminal.getOutput(), not(containsString("100%")));
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method installPlugin.
static MockTerminal installPlugin(String pluginUrl, Path home, boolean jarHellCheck) throws Exception {
Environment env = new Environment(Settings.builder().put("path.home", home).build());
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand() {
@Override
void jarHellCheck(Path candidate, Path pluginsDir) throws Exception {
if (jarHellCheck) {
super.jarHellCheck(candidate, pluginsDir);
}
}
}.execute(terminal, pluginUrl, true, env);
return terminal;
}
use of org.elasticsearch.cli.MockTerminal in project elasticsearch by elastic.
the class InstallPluginCommandTests method testBatchFlag.
public void testBatchFlag() throws Exception {
MockTerminal terminal = new MockTerminal();
installPlugin(terminal, true);
assertThat(terminal.getOutput(), containsString("WARNING: plugin requires additional permissions"));
}
Aggregations