File tree 2 files changed +35
-2
lines changed
qa/os/src/test/java/org/elasticsearch/packaging/test
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 16
16
17
17
source " ` dirname " $0 " ` " /elasticsearch-env
18
18
19
+ CHECK_KEYSTORE=true
20
+ DAEMONIZE=false
21
+ for option in " $@ " ; do
22
+ case " $option " in
23
+ -h|--help|-V|--version)
24
+ CHECK_KEYSTORE=false
25
+ ;;
26
+ -d|--daemonize)
27
+ DAEMONIZE=true
28
+ ;;
29
+ esac
30
+ done
31
+
19
32
if [ -z " $ES_TMPDIR " ]; then
20
33
ES_TMPDIR=` " $JAVA " -cp " $ES_CLASSPATH " org.elasticsearch.tools.launchers.TempDirectory`
21
34
fi
24
37
# conflicting GC configurations for the keystore tools
25
38
unset KEYSTORE_PASSWORD
26
39
KEYSTORE_PASSWORD=
27
- if ! echo $* | grep -E -q ' (^-h |-h$| -h |--help$|--help |^-V |-V$| -V |--version$|--version ) ' \
40
+ if [[ $CHECK_KEYSTORE = true ]] \
28
41
&& " ` dirname " $0 " ` " /elasticsearch-keystore has-passwd --silent
29
42
then
30
43
if ! read -s -r -p " Elasticsearch keystore password: " KEYSTORE_PASSWORD ; then
@@ -37,7 +50,7 @@ ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options
37
50
ES_JAVA_OPTS=` export ES_TMPDIR; " $JAVA " -cp " $ES_CLASSPATH " org.elasticsearch.tools.launchers.JvmOptionsParser " $ES_JVM_OPTIONS " `
38
51
39
52
# manual parsing to find out, if process should be detached
40
- if ! echo $* | grep -E ' (^-d |-d$| -d |--daemonize$|--daemonize ) ' > /dev/null ; then
53
+ if [[ $DAEMONIZE = false ]] ; then
41
54
exec \
42
55
" $JAVA " \
43
56
$ES_JAVA_OPTS \
Original file line number Diff line number Diff line change 56
56
import static org .hamcrest .CoreMatchers .containsString ;
57
57
import static org .hamcrest .CoreMatchers .is ;
58
58
import static org .hamcrest .CoreMatchers .notNullValue ;
59
+ import static org .hamcrest .Matchers .startsWith ;
59
60
import static org .junit .Assume .assumeThat ;
60
61
import static org .junit .Assume .assumeTrue ;
61
62
@@ -210,6 +211,25 @@ public void test43WrongKeystorePasswordOnTty() throws Exception {
210
211
assertThat (result .stdout , containsString (ERROR_INCORRECT_PASSWORD ));
211
212
}
212
213
214
+ /**
215
+ * If we have an encrypted keystore, we shouldn't require a password to
216
+ * view help information.
217
+ */
218
+ public void test44EncryptedKeystoreAllowsHelpMessage () throws Exception {
219
+ assumeTrue ("users call elasticsearch directly in archive case" ,
220
+ distribution .isArchive ());
221
+
222
+ String password = "keystorepass" ;
223
+
224
+ rmKeystoreIfExists ();
225
+ createKeystore ();
226
+ setKeystorePassword (password );
227
+
228
+ assertPasswordProtectedKeystore ();
229
+ Shell .Result r = installation .executables ().elasticsearch .run ("--help" );
230
+ assertThat (r .stdout , startsWith ("Starts Elasticsearch" ));
231
+ }
232
+
213
233
public void test50KeystorePasswordFromFile () throws Exception {
214
234
assumeTrue ("only for systemd" , Platforms .isSystemd () && distribution ().isPackage ());
215
235
String password = "!@#$%^&*()|\\ <>/?" ;
You can’t perform that action at this time.
0 commit comments