2018-04-11 11:21:15 -04:00
|
|
|
|
2017-09-19 04:07:39 -04:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
# or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
# you may not use this file except in compliance with the Elastic License.
|
|
|
|
|
|
|
|
load $BATS_UTILS/utils.bash
|
|
|
|
load $BATS_UTILS/plugins.bash
|
|
|
|
load $BATS_UTILS/xpack.bash
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
if [ $BATS_TEST_NUMBER == 1 ]; then
|
2018-02-23 11:03:17 -05:00
|
|
|
export PACKAGE_NAME="elasticsearch"
|
2017-09-19 04:07:39 -04:00
|
|
|
clean_before_test
|
|
|
|
install
|
2018-05-29 14:06:14 -04:00
|
|
|
set_debug_logging
|
2017-09-19 04:07:39 -04:00
|
|
|
|
2018-02-14 22:40:51 -05:00
|
|
|
generate_trial_license
|
2017-09-19 04:07:39 -04:00
|
|
|
verify_xpack_installation
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-12 12:49:50 -04:00
|
|
|
if [[ "$BATS_TEST_FILENAME" =~ 30_tar_setup_passwords.bats$ ]]; then
|
2017-09-19 04:07:39 -04:00
|
|
|
load $BATS_UTILS/tar.bash
|
|
|
|
GROUP='TAR SETUP PASSWORD'
|
|
|
|
install() {
|
|
|
|
install_archive
|
|
|
|
verify_archive_installation
|
|
|
|
}
|
|
|
|
export ESHOME=/tmp/elasticsearch
|
|
|
|
export_elasticsearch_paths
|
|
|
|
export ESPLUGIN_COMMAND_USER=elasticsearch
|
|
|
|
else
|
|
|
|
load $BATS_UTILS/packages.bash
|
|
|
|
if is_rpm; then
|
|
|
|
GROUP='RPM SETUP PASSWORD'
|
|
|
|
elif is_dpkg; then
|
|
|
|
GROUP='DEB SETUP PASSWORD'
|
|
|
|
fi
|
|
|
|
export_elasticsearch_paths
|
|
|
|
export ESPLUGIN_COMMAND_USER=root
|
|
|
|
install() {
|
|
|
|
install_package
|
|
|
|
verify_package_installation
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
@test "[$GROUP] test auto generated passwords" {
|
|
|
|
run_elasticsearch_service 0
|
|
|
|
wait_for_xpack
|
|
|
|
|
2018-03-18 13:06:11 -04:00
|
|
|
run sudo -E -u $ESPLUGIN_COMMAND_USER bash <<"SETUP_AUTO"
|
2018-04-11 11:21:15 -04:00
|
|
|
echo 'y' | $ESHOME/bin/elasticsearch-setup-passwords auto
|
2017-09-19 04:07:39 -04:00
|
|
|
SETUP_AUTO
|
|
|
|
echo "$output" > /tmp/setup-passwords-output
|
|
|
|
[ "$status" -eq 0 ] || {
|
2018-05-02 21:09:44 -04:00
|
|
|
echo "Expected x-pack elasticsearch-setup-passwords tool exit code to be zero but got $status"
|
2017-09-19 04:07:39 -04:00
|
|
|
cat /tmp/setup-passwords-output
|
2018-05-02 21:09:44 -04:00
|
|
|
debug_collect_logs
|
2017-09-19 04:07:39 -04:00
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2018-12-27 23:26:46 -05:00
|
|
|
curl -s -XGET localhost:9200 | grep "missing authentication credentials for REST"
|
2017-09-19 04:07:39 -04:00
|
|
|
|
|
|
|
# Disable bash history expansion because passwords can contain "!"
|
|
|
|
set +H
|
|
|
|
|
|
|
|
users=( elastic kibana logstash_system )
|
|
|
|
for user in "${users[@]}"; do
|
|
|
|
grep "Changed password for user $user" /tmp/setup-passwords-output || {
|
2018-04-11 11:21:15 -04:00
|
|
|
echo "Expected x-pack elasticsearch-setup-passwords tool to change password for user [$user]:"
|
2017-09-19 04:07:39 -04:00
|
|
|
cat /tmp/setup-passwords-output
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
password=$(grep "PASSWORD $user = " /tmp/setup-passwords-output | sed "s/PASSWORD $user = //")
|
|
|
|
curl -u "$user:$password" -XGET localhost:9200 | grep "You Know, for Search"
|
|
|
|
|
|
|
|
basic=$(echo -n "$user:$password" | base64)
|
|
|
|
curl -H "Authorization: Basic $basic" -XGET localhost:9200 | grep "You Know, for Search"
|
|
|
|
done
|
|
|
|
set -H
|
|
|
|
|
|
|
|
stop_elasticsearch_service
|
|
|
|
}
|