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
# Monitoring settings
#
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
......
......@@ -10,7 +10,7 @@ describe HealthCheckController do
let(:not_whitelisted_ip) { '127.0.0.2' }
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')
end
......@@ -22,19 +22,23 @@ describe HealthCheckController do
it 'returns a not found page' do
get :index
expect(response).to be_not_found
end
context 'when services are accessed with token' do
it 'supports passing the token in the header' do
request.headers['TOKEN'] = token
get :index
expect(response).to be_success
expect(response.content_type).to eq 'text/plain'
end
it 'supports successful plaintest response' do
get :index, token: token
expect(response).to be_success
expect(response.content_type).to eq 'text/plain'
end
......@@ -50,12 +54,14 @@ describe HealthCheckController do
it 'supports successful plaintest response' do
get :index
expect(response).to be_success
expect(response.content_type).to eq 'text/plain'
end
it 'supports successful json response' do
get :index, format: :json
expect(response).to be_success
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be true
......@@ -63,6 +69,7 @@ describe HealthCheckController do
it 'supports successful xml response' do
get :index, format: :xml
expect(response).to be_success
expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be true
......@@ -70,6 +77,7 @@ describe HealthCheckController do
it 'supports successful responses for specific checks' do
get :index, checks: 'email', format: :json
expect(response).to be_success
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be true
......@@ -79,6 +87,7 @@ describe HealthCheckController do
context 'when a service is down but NO access token' do
it 'returns a not found page' do
get :index
expect(response).to be_not_found
end
end
......@@ -92,6 +101,7 @@ describe HealthCheckController do
it 'supports failure plaintest response' do
get :index
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'text/plain'
expect(response.body).to include('The server is on fire')
......@@ -99,6 +109,7 @@ describe HealthCheckController do
it 'supports failure json response' do
get :index, format: :json
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false
......@@ -107,6 +118,7 @@ describe HealthCheckController do
it 'supports failure xml response' do
get :index, format: :xml
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/xml'
expect(xml_response['healthy']).to be false
......@@ -115,6 +127,7 @@ describe HealthCheckController do
it 'supports failure responses for specific checks' do
get :index, checks: 'email', format: :json
expect(response).to have_http_status(500)
expect(response.content_type).to eq 'application/json'
expect(json_response['healthy']).to be false
......
......@@ -8,7 +8,7 @@ describe HealthController do
let(:not_whitelisted_ip) { '127.0.0.2' }
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')
end
......@@ -20,6 +20,7 @@ describe HealthController do
it 'returns proper response' do
get :readiness
expect(json_response['db_check']['status']).to eq('ok')
expect(json_response['redis_check']['status']).to eq('ok')
expect(json_response['fs_shards_check']['status']).to eq('ok')
......@@ -34,6 +35,7 @@ describe HealthController do
it 'returns proper response' do
get :readiness
expect(response.status).to eq(404)
end
end
......@@ -47,6 +49,7 @@ describe HealthController do
it 'returns proper response' do
get :liveness
expect(json_response['db_check']['status']).to eq('ok')
expect(json_response['redis_check']['status']).to eq('ok')
expect(json_response['fs_shards_check']['status']).to eq('ok')
......@@ -60,6 +63,7 @@ describe HealthController do
it 'returns proper response' do
get :liveness
expect(response.status).to eq(404)
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