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