--- /dev/null
+#
+# Copyright 2015 whitestar
+#
+# 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.
+#
+
+#grid_chef_repo = 'git://git.osdn.jp/gitroot/metasearch/grid-chef-repo.git'
+
+# for ver. 3.x
+#source 'https://gpm00.grid.example.com:6280'
+source 'https://supermarket.chef.io'
+
+metadata
+
# local cookbooks
# external cookbooks
-depends 'berkshelf-api-server', '>=2.1.1'
+depends 'berkshelf-api-server', '>= 2.1.1'
--- /dev/null
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe Spec:: app_spec
+#
+# Copyright 2015, whitestar
+#
+# 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 'berkshelf-api-server-ya::app' do
+ before {
+ stub_command(%r|cd /opt/berkshelf-api/v\d+\.\d+\.\d+ && /opt/chef/embedded/bin/bundle check|).
+ and_return(true)
+ }
+
+ let(:chef_run) {
+=begin
+ ChefSpec::SoloRunner.new {|node|
+ node.set[:berkshelf_api][:app_host] = '127.0.0.1'
+ }.converge(described_recipe)
+=end
+ ChefSpec::SoloRunner.new(step_into: ['runit_service']) {|node|
+ node.set[:berkshelf_api][:app_host] = '127.0.0.1'
+ }.converge(described_recipe)
+ }
+
+ it 'changes bind address to 127.0.0.1 in /etc/sv/berks-api/run through runit_service LWRP' do
+ expect(chef_run).to \
+ render_file('/etc/sv/berks-api/run').
+ with_content(%r|\s+bin/berks-api -h 127\.0\.0\.1\s+|)
+ end
+end
+
--- /dev/null
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe Spec:: default_spec
+#
+# Copyright 2015, whitestar
+#
+# 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 'berkshelf-api-server-ya::default' do
+=begin
+ subject { ChefSpec::Runner.new.converge(described_recipe) }
+
+ # Write quick specs using `it` blocks with implied subjects
+ it { should do_something('...') }
+
+ # Write full examples using the `expect` syntax
+ it 'does something' do
+ expect(subject).to do_something('...')
+ end
+
+ # Use an explicit subject
+ let(:chef_run) { ChefSpec::Runner.new.converge(described_recipe) }
+
+ it 'does something' do
+ expect(chef_run).to do_something('...')
+ end
+=end
+end
--- /dev/null
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe Spec:: app_spec
+#
+# Copyright 2015, whitestar
+#
+# 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 'berkshelf-api-server-ya::http_proxy' do
+ let(:chef_run) {
+ ChefSpec::SoloRunner.new {|node|
+ node.set[:berkshelf_api][:app_host] = '192.168.1.10'
+ node.set[:berkshelf_api][:proxy][:ssl] = true
+ node.set[:berkshelf_api][:proxy][:ssl_certificate] = '/path/to/server.crt'
+ node.set[:berkshelf_api][:proxy][:ssl_certificate_key] = '/path/to/server.key'
+ }.converge(described_recipe)
+ }
+
+ it 'changes bind address to 192.168.1.10 in /etc/nginx/sites-available/berks-api' do
+ expect(chef_run).to \
+ render_file('/etc/nginx/sites-available/berks-api').
+ with_content(/^\s+server\s+192\.168\.1\.10:/)
+ end
+
+ it 'enables ssl in /etc/nginx/sites-available/berks-api' do
+ expect(chef_run).to \
+ render_file('/etc/nginx/sites-available/berks-api').
+ with_content(/^\s+ssl\s+on;$/)
+ end
+
+ it 'adds ssl_certificate setting in /etc/nginx/sites-available/berks-api' do
+ expect(chef_run).to \
+ render_file('/etc/nginx/sites-available/berks-api').
+ with_content(%r|^\s+ssl_certificate\s+/path/to/server\.crt;$|)
+ end
+
+ it 'adds ssl_certificate_key setting in /etc/nginx/sites-available/berks-api' do
+ expect(chef_run).to \
+ render_file('/etc/nginx/sites-available/berks-api').
+ with_content(%r|^\s+ssl_certificate_key\s+/path/to/server\.key;$|)
+ end
+
+ let(:chef_run_ssl_off) {
+ ChefSpec::SoloRunner.new {|node|
+ node.set[:berkshelf_api][:proxy][:ssl] = false
+ }.converge(described_recipe)
+ }
+
+ it 'disables ssl in /etc/nginx/sites-available/berks-api' do
+ expect(chef_run_ssl_off).to_not \
+ render_file('/etc/nginx/sites-available/berks-api').
+ with_content(/^\s+ssl\s+on;$/)
+ end
+end
+
--- /dev/null
+#
+# Cookbook Name:: berkshelf-api-server-ya
+# Recipe Spec:: spec_helper
+#
+# Copyright 2015, whitestar
+#
+# 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.
+#
+
+# Added by ChefSpec
+require 'chefspec'
+
+# Uncomment to use ChefSpec's Berkshelf extension
+require 'chefspec/berkshelf'
+
+RSpec.configure do |config|
+ # Specify the path for Chef Solo to find cookbooks
+ #config.cookbook_path = '/var/cookbooks'
+
+ # Specify the path for Chef Solo to find roles
+ # config.role_path = '/var/roles'
+
+ # Specify the Chef log_level (default: :warn)
+ # config.log_level = :debug
+
+ # Specify the path to a local JSON file with Ohai data
+ # config.path = 'ohai.json'
+
+ # Specify the operating platform to mock Ohai data from
+ # config.platform = 'ubuntu'
+
+ # Specify the operating version to mock Ohai data from
+ # config.version = '12.04'
+end