Commit 6d60e265 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Add spaces between test phases

+ fix wrong test setup
parent 2f875c40
...@@ -498,7 +498,7 @@ Settings.webpack.dev_server['port'] ||= 3808 ...@@ -498,7 +498,7 @@ Settings.webpack.dev_server['port'] ||= 3808
# Monitoring settings # Monitoring settings
# #
Settings['monitoring'] ||= Settingslogic.new({}) Settings['monitoring'] ||= Settingslogic.new({})
Settings.monitoring['ip_whitelist'] ||= %w{127.0.0.1/8} Settings.monitoring['ip_whitelist'] ||= ['127.0.0.1/8']
# #
# Prometheus metrics settings # Prometheus metrics settings
......
...@@ -10,7 +10,7 @@ describe HealthCheckController do ...@@ -10,7 +10,7 @@ describe HealthCheckController do
let(:not_whitelisted_ip) { '127.0.0.2' } let(:not_whitelisted_ip) { '127.0.0.2' }
before do before do
allow(Settings.monitoring).to receive(:ip_whitelist).and_return([IPAddr.new(whitelisted_ip)]) allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip])
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end end
...@@ -22,19 +22,23 @@ describe HealthCheckController do ...@@ -22,19 +22,23 @@ describe HealthCheckController do
it 'returns a not found page' do it 'returns a not found page' do
get :index get :index
expect(response).to be_not_found expect(response).to be_not_found
end end
context 'when services are accessed with token' do context 'when services are accessed with token' do
it 'supports passing the token in the header' do it 'supports passing the token in the header' do
request.headers['TOKEN'] = token request.headers['TOKEN'] = token
get :index get :index
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
end end
it 'supports successful plaintest response' do it 'supports successful plaintest response' do
get :index, token: token get :index, token: token
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
end end
...@@ -50,12 +54,14 @@ describe HealthCheckController do ...@@ -50,12 +54,14 @@ describe HealthCheckController do
it 'supports successful plaintest response' do it 'supports successful plaintest response' do
get :index get :index
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
end end
it 'supports successful json response' do it 'supports successful json response' do
get :index, format: :json get :index, format: :json
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be true expect(json_response['healthy']).to be true
...@@ -63,6 +69,7 @@ describe HealthCheckController do ...@@ -63,6 +69,7 @@ describe HealthCheckController do
it 'supports successful xml response' do it 'supports successful xml response' do
get :index, format: :xml get :index, format: :xml
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'application/xml' expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be true expect(xml_response['healthy']).to be true
...@@ -70,6 +77,7 @@ describe HealthCheckController do ...@@ -70,6 +77,7 @@ describe HealthCheckController do
it 'supports successful responses for specific checks' do it 'supports successful responses for specific checks' do
get :index, checks: 'email', format: :json get :index, checks: 'email', format: :json
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be true expect(json_response['healthy']).to be true
...@@ -79,6 +87,7 @@ describe HealthCheckController do ...@@ -79,6 +87,7 @@ describe HealthCheckController do
context 'when a service is down but NO access token' do context 'when a service is down but NO access token' do
it 'returns a not found page' do it 'returns a not found page' do
get :index get :index
expect(response).to be_not_found expect(response).to be_not_found
end end
end end
...@@ -92,6 +101,7 @@ describe HealthCheckController do ...@@ -92,6 +101,7 @@ describe HealthCheckController do
it 'supports failure plaintest response' do it 'supports failure plaintest response' do
get :index get :index
expect(response).to have_http_status(500) expect(response).to have_http_status(500)
expect(response.content_type).to eq 'text/plain' expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire') expect(response.body).to include('The server is on fire')
...@@ -99,6 +109,7 @@ describe HealthCheckController do ...@@ -99,6 +109,7 @@ describe HealthCheckController do
it 'supports failure json response' do it 'supports failure json response' do
get :index, format: :json get :index, format: :json
expect(response).to have_http_status(500) expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false expect(json_response['healthy']).to be false
...@@ -107,6 +118,7 @@ describe HealthCheckController do ...@@ -107,6 +118,7 @@ describe HealthCheckController do
it 'supports failure xml response' do it 'supports failure xml response' do
get :index, format: :xml get :index, format: :xml
expect(response).to have_http_status(500) expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/xml' expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be false expect(xml_response['healthy']).to be false
...@@ -115,6 +127,7 @@ describe HealthCheckController do ...@@ -115,6 +127,7 @@ describe HealthCheckController do
it 'supports failure responses for specific checks' do it 'supports failure responses for specific checks' do
get :index, checks: 'email', format: :json get :index, checks: 'email', format: :json
expect(response).to have_http_status(500) expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false expect(json_response['healthy']).to be false
......
...@@ -8,7 +8,7 @@ describe HealthController do ...@@ -8,7 +8,7 @@ describe HealthController do
let(:not_whitelisted_ip) { '127.0.0.2' } let(:not_whitelisted_ip) { '127.0.0.2' }
before do before do
allow(Settings.monitoring).to receive(:ip_whitelist).and_return([IPAddr.new(whitelisted_ip)]) allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip])
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end end
...@@ -20,6 +20,7 @@ describe HealthController do ...@@ -20,6 +20,7 @@ describe HealthController do
it 'returns proper response' do it 'returns proper response' do
get :readiness get :readiness
expect(json_response['db_check']['status']).to eq('ok') expect(json_response['db_check']['status']).to eq('ok')
expect(json_response['redis_check']['status']).to eq('ok') expect(json_response['redis_check']['status']).to eq('ok')
expect(json_response['fs_shards_check']['status']).to eq('ok') expect(json_response['fs_shards_check']['status']).to eq('ok')
...@@ -34,6 +35,7 @@ describe HealthController do ...@@ -34,6 +35,7 @@ describe HealthController do
it 'returns proper response' do it 'returns proper response' do
get :readiness get :readiness
expect(response.status).to eq(404) expect(response.status).to eq(404)
end end
end end
...@@ -47,6 +49,7 @@ describe HealthController do ...@@ -47,6 +49,7 @@ describe HealthController do
it 'returns proper response' do it 'returns proper response' do
get :liveness get :liveness
expect(json_response['db_check']['status']).to eq('ok') expect(json_response['db_check']['status']).to eq('ok')
expect(json_response['redis_check']['status']).to eq('ok') expect(json_response['redis_check']['status']).to eq('ok')
expect(json_response['fs_shards_check']['status']).to eq('ok') expect(json_response['fs_shards_check']['status']).to eq('ok')
...@@ -60,6 +63,7 @@ describe HealthController do ...@@ -60,6 +63,7 @@ describe HealthController do
it 'returns proper response' do it 'returns proper response' do
get :liveness get :liveness
expect(response.status).to eq(404) expect(response.status).to eq(404)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment