-
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.
- Loading branch information
Showing
11 changed files
with
1,089 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
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
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,83 @@ | ||
# 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::_apache' do | ||
let(:chef_runner) { ChefSpec::SoloRunner.new } | ||
let(:chef_run) { chef_runner.converge(described_recipe) } | ||
let(:node) { chef_runner.node } | ||
before { stub_command('/usr/sbin/apache2 -t').and_return(true) } | ||
|
||
it 'includes apache2::default recipe' do | ||
expect(chef_run).to include_recipe('apache2::default') | ||
end | ||
|
||
it 'includes apache2::mod_php5 recipe' do | ||
expect(chef_run).to include_recipe('apache2::mod_php5') | ||
end | ||
|
||
context 'apache_site default definition' do | ||
it 'disables default site' do | ||
allow(::File).to receive(:symlink?).and_call_original | ||
allow(::File).to receive(:symlink?) | ||
.with(%r{sites-enabled/default\.conf$}).and_return(true) | ||
expect(chef_run).to run_execute('a2dissite default.conf') | ||
end | ||
end | ||
|
||
context 'web_app owncloud definition' do | ||
it 'creates apache2 site' do | ||
expect(chef_run) | ||
.to create_template(%r{/sites-available/owncloud\.conf$}) | ||
end | ||
end | ||
|
||
context 'with SSL enabled' do | ||
before { node.set['owncloud']['ssl'] = true } | ||
|
||
it 'creates SSL certificate' do | ||
expect(chef_run).to create_file('owncloud.key') | ||
expect(chef_run).to create_file('owncloud.pem') | ||
end | ||
|
||
context 'web_app owncloud-ssl definition' do | ||
it 'creates apache2 site' do | ||
expect(chef_run) | ||
.to create_template(%r{/sites-available/owncloud-ssl\.conf$}) | ||
end | ||
end | ||
end | ||
|
||
context 'with SSL disabled' do | ||
before { node.set['owncloud']['ssl'] = false } | ||
|
||
it 'does not create SSL certificate' do | ||
expect(chef_run).to_not create_file('owncloud.key') | ||
expect(chef_run).to_not create_file('owncloud.pem') | ||
end | ||
|
||
context 'web_app owncloud-ssl definition' do | ||
it 'does not create apache2 site' do | ||
expect(chef_run) | ||
.to_not create_template(%r{/sites-available/owncloud-ssl\.conf$}) | ||
end | ||
end | ||
end | ||
end |
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,114 @@ | ||
# 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::_nginx' do | ||
let(:chef_runner) { ChefSpec::SoloRunner.new } | ||
let(:chef_run) { chef_runner.converge(described_recipe) } | ||
let(:node) { chef_runner.node } | ||
before do | ||
node.set['owncloud']['ssl'] = true | ||
stub_command('which nginx').and_return(true) | ||
stub_command( | ||
'test -d /etc/php5/fpm/pool.d || mkdir -p /etc/php5/fpm/pool.d' | ||
).and_return(true) | ||
allow(::File).to receive(:symlink?).and_call_original | ||
allow(::File).to receive(:exist?).and_call_original | ||
allow(::File).to receive(:exist?).with('/etc/init.d/apache2') | ||
.and_return(true) | ||
end | ||
|
||
it 'includes nginx recipe' do | ||
expect(chef_run).to include_recipe('nginx') | ||
end | ||
|
||
it 'includes owncloud::_php_fpm recipe' do | ||
expect(chef_run).to include_recipe('owncloud::_php_fpm') | ||
end | ||
|
||
it 'disables nginx default site' do | ||
allow(::File).to receive(:symlink?) | ||
.with('/etc/nginx/sites-enabled/default').and_return(true) | ||
expect(chef_run).to run_execute('nxdissite default') | ||
end | ||
|
||
it 'creates owncloud virtualhost' do | ||
expect(chef_run) | ||
.to create_template('/etc/nginx/sites-available/owncloud') | ||
.with_source('nginx_vhost.erb') | ||
.with_mode(00644) | ||
.with_owner('root') | ||
.with_group('root') | ||
end | ||
|
||
context 'owncloud virtualhost resource' do | ||
let(:resource) { chef_run.template('/etc/nginx/sites-available/owncloud') } | ||
|
||
it 'notifies nginx to reload' do | ||
expect(resource).to notify('service[nginx]').to(:reload).delayed | ||
end | ||
end | ||
|
||
it 'enables nginx owncloud site' do | ||
allow(::File).to receive(:symlink?) | ||
.with('/etc/nginx/sites-enabled/owncloud').and_return(false) | ||
expect(chef_run).to run_execute('nxensite owncloud') | ||
end | ||
|
||
context 'with SSL enabled' do | ||
before { node.set['owncloud']['ssl'] = true } | ||
|
||
it 'does not create SSL certificate' do | ||
expect(chef_run).to create_file('owncloud.key') | ||
expect(chef_run).to create_file('owncloud.pem') | ||
end | ||
|
||
it 'creates nginx owncloud-ssl site' do | ||
expect(chef_run) | ||
.to create_template(%r{/sites-available/owncloud-ssl$}) | ||
end | ||
|
||
it 'enables nginx owncloud-ssl site' do | ||
allow(::File).to receive(:symlink?) | ||
.with('/etc/nginx/sites-enabled/owncloud-ssl').and_return(false) | ||
expect(chef_run).to run_execute('nxensite owncloud-ssl') | ||
end | ||
end | ||
|
||
context 'with SSL disabled' do | ||
before { node.set['owncloud']['ssl'] = false } | ||
|
||
it 'does not create SSL certificate' do | ||
expect(chef_run).to_not create_file('owncloud.key') | ||
expect(chef_run).to_not create_file('owncloud.pem') | ||
end | ||
|
||
it 'does not create nginx owncloud-ssl site' do | ||
expect(chef_run) | ||
.to_not create_template(%r{/sites-available/owncloud-ssl$}) | ||
end | ||
|
||
it 'does not enable nginx owncloud-ssl site' do | ||
allow(::File).to receive(:symlink?) | ||
.with('/etc/nginx/sites-enabled/owncloud-ssl').and_return(false) | ||
expect(chef_run).to_not run_execute('nxensite owncloud-ssl') | ||
end | ||
end | ||
end |
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,43 @@ | ||
# 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::_php_fpm' do | ||
let(:chef_runner) { ChefSpec::SoloRunner.new } | ||
let(:chef_run) { chef_runner.converge(described_recipe) } | ||
let(:node) { chef_runner.node } | ||
before do | ||
stub_command( | ||
'test -d /etc/php5/fpm/pool.d || mkdir -p /etc/php5/fpm/pool.d' | ||
).and_return(true) | ||
stub_command('test -d /etc/php-fpm.d || mkdir -p /etc/php-fpm.d') | ||
.and_return(true) | ||
end | ||
|
||
it 'include php-fpm recipe' do | ||
expect(chef_run).to include_recipe('php-fpm') | ||
end | ||
|
||
it 'creates php FPM pool' do | ||
expect(chef_run).to create_template( | ||
"#{node['php-fpm']['pool_conf_dir']}/owncloud.conf" | ||
) | ||
end | ||
end |
Oops, something went wrong.