Update tests

This commit is contained in:
pemontto 2019-10-13 16:18:55 +01:00
parent e2ffdce380
commit 7196557c09
No known key found for this signature in database
GPG key ID: EDCB93C3DA1B5DA9
6 changed files with 21 additions and 12 deletions

View file

@ -17,7 +17,7 @@ families = {
family = families[vars['ansible_os_family']] family = families[vars['ansible_os_family']]
es_api_url = "http://localhost:#{vars['es_api_port']}" es_api_url = "#{vars['es_api_scheme']}://localhost:#{vars['es_api_port']}"
username = vars['es_api_basic_auth_username'] username = vars['es_api_basic_auth_username']
password = vars['es_api_basic_auth_password'] password = vars['es_api_basic_auth_password']

View file

@ -19,7 +19,11 @@ def curl_json(uri, username=nil, password=nil)
if username && password if username && password
req.basic_auth username, password req.basic_auth username, password
end end
res = Net::HTTP.start(uri.hostname, uri.port) {|http| res = Net::HTTP.start(
uri.hostname,
uri.port,
:verify_mode => OpenSSL::SSL::VERIFY_NONE
) {|http|
http.request(req) http.request(req)
} }
return JSON.parse(res.body) return JSON.parse(res.body)

View file

@ -2,6 +2,11 @@ require 'spec_helper'
require 'json' require 'json'
vars = JSON.parse(File.read('/tmp/vars.json')) vars = JSON.parse(File.read('/tmp/vars.json'))
es_api_url = "#{vars['es_api_scheme']}://localhost:#{vars['es_api_port']}"
username = vars['es_api_basic_auth_username']
password = vars['es_api_basic_auth_password']
es_security_api = "#{vars['es_security_api']}"
shared_examples 'xpack_upgrade::init' do |vars| shared_examples 'xpack_upgrade::init' do |vars|
#Test users file, users_roles and roles.yml #Test users file, users_roles and roles.yml
describe file("/etc/elasticsearch/users_roles") do describe file("/etc/elasticsearch/users_roles") do
@ -18,7 +23,7 @@ shared_examples 'xpack_upgrade::init' do |vars|
describe 'security roles' do describe 'security roles' do
it 'should list the security roles' do it 'should list the security roles' do
roles = curl_json('http://localhost:9200/_xpack/security/role', username='es_admin', password='changeMeAgain') roles = curl_json("#{es_api_url}/#{es_security_api}/role", username='es_admin', password='changeMeAgain')
expect(roles.key?('superuser')) expect(roles.key?('superuser'))
end end
end end
@ -54,7 +59,7 @@ shared_examples 'xpack_upgrade::init' do |vars|
end end
describe 'security users' do describe 'security users' do
result = curl_json('http://localhost:9200/_xpack/security/user', username='elastic', password='elasticChanged') result = curl_json("#{es_api_url}/#{es_security_api}/user", username='elastic', password='elasticChanged')
it 'should have the elastic user' do it 'should have the elastic user' do
expect(result['elastic']['username']).to eq('elastic') expect(result['elastic']['username']).to eq('elastic')
expect(result['elastic']['roles']).to eq(['superuser']) expect(result['elastic']['roles']).to eq(['superuser'])