-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace bats test by Serverspec tests
- Loading branch information
Showing
38 changed files
with
1,250 additions
and
141 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# encoding: UTF-8 | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem 'serverspec', '~> 2.0' | ||
gem 'infrataster', '~> 0.3.0' | ||
gem 'infrataster-plugin-mysql', '~> 0.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# encoding: UTF-8 | ||
# | ||
# Author:: Xabier de Zuazo (<xabier@zuazo.org>) | ||
# Copyright:: Copyright (c) 2015 Xabier de Zuazo | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require_relative 'spec_helper' | ||
|
||
family = os[:family].downcase | ||
apache = | ||
if %w(centos redhat fedora scientific amazon).include?(family) | ||
'httpd' | ||
else | ||
'apache2' | ||
end | ||
|
||
describe 'apache' do | ||
describe package(apache) do | ||
it { should be_installed } | ||
end | ||
|
||
describe port(80) do | ||
it { should be_listening } | ||
end | ||
|
||
describe port(443) do | ||
it { should be_listening } | ||
end | ||
|
||
describe process(apache) do | ||
it { should be_running } | ||
end | ||
|
||
describe process('nginx') do | ||
it { should_not be_running } | ||
end | ||
|
||
describe server(:web) do | ||
describe http('/') do | ||
it 'runs Apache httpd' do | ||
expect(response['Server']).to include 'Apache' | ||
end | ||
end # http /login.php | ||
end # server web | ||
end # apache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# encoding: UTF-8 | ||
# | ||
# Author:: Xabier de Zuazo (<xabier@zuazo.org>) | ||
# Copyright:: Copyright (c) 2015 Xabier de Zuazo | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require_relative 'spec_helper' | ||
|
||
family = os[:family].downcase | ||
|
||
web_user = | ||
case family | ||
when 'debian', 'ubuntu' | ||
'www-data' | ||
when 'redhat', 'centos', 'fedora', 'scientific', 'amazon' | ||
'apache' | ||
when 'suse', 'opensuse' | ||
'wwwrun' | ||
when 'arch' | ||
'http' | ||
when 'freebsd' | ||
'www' | ||
else | ||
'www-data' | ||
end | ||
|
||
describe 'owncloud cron' do | ||
describe command("crontab -l -u #{web_user}") do | ||
its(:stdout) { should match %r{php -f '.*/owncloud/cron.php'} } | ||
end | ||
end # owncloud cron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# encoding: UTF-8 | ||
# | ||
# Author:: Xabier de Zuazo (<xabier@zuazo.org>) | ||
# Copyright:: Copyright (c) 2015 Xabier de Zuazo | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require_relative 'spec_helper' | ||
|
||
describe 'owncloud email test' do | ||
describe server(:web) do | ||
describe http('http://127.0.0.1/emailtest.php') do | ||
it 'returns OK status' do | ||
expect(response.status).to eq 200 | ||
end | ||
|
||
it 'sends an email' do | ||
sleep(1) | ||
spool_file = | ||
if ::File.exist?('/var/spool/mail/root') | ||
'/var/spool/mail/root' | ||
else | ||
'/var/spool/mail/vagrant' | ||
end | ||
expect(file(spool_file).content).to contain('kitchen-test@') | ||
end | ||
end # http /emailtest.php | ||
end # server web | ||
end # owncloud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# encoding: UTF-8 | ||
# | ||
# Author:: Xabier de Zuazo (<xabier@zuazo.org>) | ||
# Copyright:: Copyright (c) 2015 Xabier de Zuazo | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require_relative 'spec_helper' | ||
require 'json' | ||
|
||
describe 'mysql' do | ||
describe process('mysqld') do | ||
it { should be_running } | ||
end | ||
|
||
describe port(3306) do | ||
it { should be_listening.with('tcp') } | ||
end | ||
|
||
describe server(:db) do | ||
describe mysql_query('SHOW DATABASES') do | ||
it 'includes `ownloud` database' do | ||
databases = results.map { |r| r['Database'] } | ||
expect(databases).to include('owncloud') | ||
end | ||
end | ||
end # server db | ||
end # mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# encoding: UTF-8 | ||
# | ||
# Author:: Xabier de Zuazo (<xabier@zuazo.org>) | ||
# Copyright:: Copyright (c) 2015 Xabier de Zuazo | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require_relative 'spec_helper' | ||
require 'json' | ||
|
||
describe 'owncloud' do | ||
describe server(:web) do | ||
describe http('http://127.0.0.1/') do | ||
it 'returns ownCloud text' do | ||
expect(response.body).to include('ownCloud') | ||
end | ||
end # http / | ||
|
||
describe http('http://127.0.0.1/status.php') do | ||
let(:body_json) { JSON.parse(response.body) } | ||
|
||
it 'returns a JSON body' do | ||
expect { body_json }.to_not raise_error | ||
end | ||
|
||
it 'is installed' do | ||
expect(body_json['installed']).to eq(true) | ||
end | ||
end # http /status.php | ||
|
||
describe http('https://127.0.0.1/', ssl: { verify: false }) do | ||
it 'returns ownCloud text' do | ||
expect(response.body).to include('ownCloud') | ||
end | ||
end # https / | ||
|
||
describe http('http://127.0.0.1/ocs/v1.php/privatedata/getattribute') do | ||
it 'returns 401 status' do | ||
expect(response.status).to eq 401 | ||
end | ||
|
||
it 'returns unauthorised message' do | ||
expect(response.body).to include('<message>Unauthorised</message>') | ||
end | ||
end # https /ocs/v1.php/privatedata/getattribute unauthorised | ||
|
||
describe http( | ||
'http://127.0.0.1/ocs/v1.php/privatedata/getattribute', | ||
basic_auth: %w(test test) | ||
) do | ||
it 'returns OK status' do | ||
expect(response.body).to include('<status>ok</status>') | ||
end | ||
end # https /ocs/v1.php/privatedata/getattribute with basic auth | ||
end # server web | ||
end # owncloud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# encoding: UTF-8 | ||
# | ||
# Author:: Xabier de Zuazo (<xabier@zuazo.org>) | ||
# Copyright:: Copyright (c) 2015 Xabier de Zuazo | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
require 'serverspec' | ||
require 'infrataster/rspec' | ||
require 'infrataster-plugin-mysql' | ||
|
||
# Set backend type | ||
set :backend, :exec | ||
|
||
ENV['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' | ||
|
||
Infrataster::Server.define(:web, '127.0.0.1') | ||
|
||
Infrataster::Server.define( | ||
:db, | ||
'127.0.0.1', | ||
mysql: { user: 'root', password: 'vagrant_root' } | ||
) | ||
|
||
# Infrataster hack to ignore phantomjs SSL errors | ||
Infrataster::Contexts::CapybaraContext.class_eval do | ||
def self.prepare_session | ||
driver = Infrataster::Contexts::CapybaraContext::CAPYBARA_DRIVER_NAME | ||
Capybara.register_driver driver do |app| | ||
Capybara::Poltergeist::Driver.new( | ||
app, | ||
phantomjs_options: %w(--ignore-ssl-errors=true) | ||
) | ||
end | ||
Capybara::Session.new(driver) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# encoding: UTF-8 | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem 'serverspec', '~> 2.0' | ||
gem 'infrataster', '~> 0.3.0' | ||
gem 'infrataster-plugin-mysql', '~> 0.2.0' |
Oops, something went wrong.