2018-06-19 10:39:16 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
require 'json'
|
|
|
|
|
vars = JSON.parse(File.read('/tmp/vars.json'))
|
|
|
|
|
|
|
|
|
|
shared_examples 'xpack_upgrade::init' do |vars|
|
|
|
|
|
#Test users file, users_roles and roles.yml
|
2019-09-05 10:06:26 +02:00
|
|
|
describe file("/etc/elasticsearch/users_roles") do
|
2018-06-19 10:39:16 +02:00
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
it { should contain 'admin:es_admin' }
|
|
|
|
|
it { should contain 'power_user:testUser' }
|
|
|
|
|
end
|
|
|
|
|
|
2019-09-05 10:06:26 +02:00
|
|
|
describe file("/etc/elasticsearch/users") do
|
2018-06-19 10:39:16 +02:00
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
it { should contain 'testUser:' }
|
|
|
|
|
it { should contain 'es_admin:' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'security roles' do
|
|
|
|
|
it 'should list the security roles' do
|
|
|
|
|
roles = curl_json('http://localhost:9200/_xpack/security/role', username='es_admin', password='changeMeAgain')
|
|
|
|
|
expect(roles.key?('superuser'))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-06-03 14:18:09 +02:00
|
|
|
describe file("/etc/elasticsearch/elasticsearch.yml") do
|
2019-05-09 09:06:02 +02:00
|
|
|
if vars['es_major_version'] == '7.x'
|
|
|
|
|
it { should contain 'security.authc.realms.file.file1.order: 0' }
|
|
|
|
|
it { should contain 'security.authc.realms.native.native1.order: 1' }
|
|
|
|
|
else
|
|
|
|
|
it { should contain 'security.authc.realms.file1.order: 0' }
|
|
|
|
|
it { should contain 'security.authc.realms.file1.type: file' }
|
|
|
|
|
it { should contain 'security.authc.realms.native1.order: 1' }
|
2019-05-29 12:10:11 +02:00
|
|
|
it { should contain 'security.authc.realms.native1.type: native' }
|
2019-05-09 09:06:02 +02:00
|
|
|
end
|
2018-06-19 10:39:16 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#Test contents of role_mapping.yml
|
2019-09-05 10:06:26 +02:00
|
|
|
describe file("/etc/elasticsearch/role_mapping.yml") do
|
2018-06-19 10:39:16 +02:00
|
|
|
it { should be_owned_by 'elasticsearch' }
|
|
|
|
|
it { should contain 'power_user:' }
|
|
|
|
|
it { should contain '- cn=admins,dc=example,dc=com' }
|
|
|
|
|
it { should contain 'user:' }
|
|
|
|
|
it { should contain '- cn=admins,dc=example,dc=com' }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#check accounts are correct i.e. we can auth and they have the correct roles
|
|
|
|
|
describe 'kibana4_server access check' do
|
|
|
|
|
it 'should be reported as version '+vars['es_version'] do
|
|
|
|
|
command = command('curl -s localhost:9200/ -u kibana4_server:changeMe | grep number')
|
|
|
|
|
expect(command.stdout).to match(vars['es_version'])
|
|
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'security users' do
|
|
|
|
|
result = curl_json('http://localhost:9200/_xpack/security/user', username='elastic', password='elasticChanged')
|
|
|
|
|
it 'should have the elastic user' do
|
|
|
|
|
expect(result['elastic']['username']).to eq('elastic')
|
|
|
|
|
expect(result['elastic']['roles']).to eq(['superuser'])
|
|
|
|
|
expect(result['elastic']['enabled']).to eq(true)
|
|
|
|
|
end
|
|
|
|
|
it 'should have the kibana user' do
|
|
|
|
|
expect(result['kibana']['username']).to eq('kibana')
|
|
|
|
|
expect(result['kibana']['roles']).to eq(['kibana_system'])
|
|
|
|
|
expect(result['kibana']['enabled']).to eq(true)
|
|
|
|
|
end
|
|
|
|
|
it 'should have the kibana_server user' do
|
|
|
|
|
expect(result['kibana4_server']['username']).to eq('kibana4_server')
|
|
|
|
|
expect(result['kibana4_server']['roles']).to eq(['kibana4_server'])
|
|
|
|
|
expect(result['kibana4_server']['enabled']).to eq(true)
|
|
|
|
|
end
|
|
|
|
|
it 'should have the logstash user' do
|
|
|
|
|
expect(result['logstash_system']['username']).to eq('logstash_system')
|
|
|
|
|
expect(result['logstash_system']['roles']).to eq(['logstash_system'])
|
|
|
|
|
expect(result['logstash_system']['enabled']).to eq(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'logstash_system access check' do
|
|
|
|
|
it 'should be reported as version '+vars['es_version'] do
|
|
|
|
|
command = command('curl -s localhost:9200/ -u logstash_system:aNewLogstashPassword | grep number')
|
|
|
|
|
expect(command.stdout).to match(vars['es_version'])
|
|
|
|
|
expect(command.exit_status).to eq(0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|