DRY tests
This commit is contained in:
parent
dc05ce251a
commit
cd4fca5109
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
|||
describe 'passbolt_api service' do
|
||||
|
||||
before(:all) do
|
||||
@mysql_image = Docker::Image.create('fromImage' => 'mariadb:latest')
|
||||
@mysql = Docker::Container.create(
|
||||
'Env' => [
|
||||
'MYSQL_ROOT_PASSWORD=test',
|
||||
|
|
@ -16,7 +17,7 @@ describe 'passbolt_api service' do
|
|||
"mysqladmin ping --silent"
|
||||
]
|
||||
},
|
||||
'Image' => 'mariadb')
|
||||
'Image' => @mysql_image.id)
|
||||
@mysql.start
|
||||
|
||||
while @mysql.json['State']['Health']['Status'] != 'healthy'
|
||||
|
|
@ -45,12 +46,10 @@ describe 'passbolt_api service' do
|
|||
@container.kill
|
||||
end
|
||||
|
||||
let(:healthcheck) { 'curl -sk -o /dev/null -w "%{http_code}" -H "Host: passbolt.local" https://localhost/healthcheck/status.json' }
|
||||
let(:serverkey) { 'curl -sk -o /dev/null -w "%{http_code}" -H "Host: passbolt.local" https://localhost/config/gpg/serverkey.asc' }
|
||||
let(:serverkey_private) { 'curl -sk -o /dev/null -w "%{http_code}" -H "Host: passbolt.local" https://localhost/config/gpg/serverkey_private.asc' }
|
||||
let(:tmp) { 'curl -sk -o /dev/null -w "%{http_code}" -H "Host: passbolt.local" https://localhost/tmp/cache/database/empty' }
|
||||
let(:logs) { 'curl -sk -o /dev/null -w "%{http_code}" -H "Host: passbolt.local" https://localhost/logs/error.log' }
|
||||
let(:conf_app) { 'curl -sk -o /dev/null -w "%{http_code}" -H "Host: passbolt.local" https://localhost/conf/app.php' }
|
||||
let(:passbolt_host) { @container.json['NetworkSettings']['IPAddress'] }
|
||||
let(:uri) { "/healthcheck/status.json" }
|
||||
let(:curl) { "curl -sk -o /dev/null -w '%{http_code}' -H 'Host: passbolt.local' https://#{passbolt_host}/#{uri}" }
|
||||
let(:conf_app) { "curl -sk -o /dev/null -w '%{http_code}' -H 'Host: passbolt.local' https://#{passbolt_host}/conf/app.php" }
|
||||
|
||||
describe 'php service' do
|
||||
it 'is running supervised' do
|
||||
|
|
@ -84,37 +83,41 @@ describe 'passbolt_api service' do
|
|||
|
||||
describe 'passbolt status' do
|
||||
it 'returns 200' do
|
||||
expect(command(healthcheck).stdout).to eq '200'
|
||||
expect(command(curl).stdout).to eq '200'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'passbolt serverkey unaccessible' do
|
||||
it 'returns 404' do
|
||||
expect(command(serverkey).stdout).to eq '404'
|
||||
let(:uri) { '/config/gpg/serverkey.asc' }
|
||||
it "returns 404" do
|
||||
expect(command(curl).stdout).to eq '404'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'passbolt serverkey private unaccessible' do
|
||||
let(:uri) { '/config/gpg/serverkey_private.asc' }
|
||||
it 'returns 404' do
|
||||
expect(command(serverkey_private).stdout).to eq '404'
|
||||
expect(command(curl).stdout).to eq '404'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'passbolt tmp folder is unaccessible' do
|
||||
describe 'passbolt conf unaccessible' do
|
||||
let(:uri) { '/config/app.php' }
|
||||
it 'returns 404' do
|
||||
expect(command(tmp).stdout).to eq '404'
|
||||
expect(command(curl).stdout).to eq '404'
|
||||
end
|
||||
end
|
||||
describe 'passbolt tmp folder is unaccessible' do
|
||||
let(:uri) { '/tmp/cache/database/empty' }
|
||||
it 'returns 404' do
|
||||
expect(command(curl).stdout).to eq '404'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'passbolt conf files can not be retrieved' do
|
||||
let(:uri) { '/config/gpg/serverkey_private.asc' }
|
||||
it 'returns 404' do
|
||||
expect(command(conf_app).stdout).to eq '404'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'passbolt error log folder is unaccessible' do
|
||||
it 'returns 404' do
|
||||
expect(command(logs).stdout).to eq '404'
|
||||
expect(command(curl).stdout).to eq '404'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue