Commit 79a4f2f8 authored by pwelch's avatar pwelch
Browse files

Add ChefSpec Resources and Default Recipe Coverage

- Add ChefSpec Resources to project
- Create ChefSpec coverage for default recipe
parent dd8d0b4b
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.8)
berkshelf (4.0.1)
addressable (~> 2.3.4)
berkshelf-api-client (~> 2.0)
buff-config (~> 1.0)
buff-extensions (~> 1.0)
buff-shell_out (~> 0.1)
celluloid (= 0.16.0)
celluloid-io (~> 0.16.1)
cleanroom (~> 1.0)
faraday (~> 0.9.0)
httpclient (~> 2.6.0)
minitar (~> 0.5.4)
octokit (~> 3.0)
retryable (~> 2.0)
ridley (~> 4.3)
solve (~> 1.1)
thor (~> 0.19)
berkshelf-api-client (2.0.0)
faraday (~> 0.9.1)
httpclient (~> 2.6.0)
buff-config (1.0.1)
buff-extensions (~> 1.0)
varia_model (~> 0.4)
buff-extensions (1.0.0)
buff-ignore (1.1.1)
buff-ruby_engine (0.1.0)
buff-shell_out (0.2.0)
buff-ruby_engine (~> 0.1.0)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
celluloid-io (0.16.2)
celluloid (>= 0.16.0)
nio4r (>= 1.1.0)
chef (12.5.1)
chef-config (= 12.5.1)
chef-zero (~> 4.2, >= 4.2.2)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
ffi-yajl (~> 2.2)
highline (~> 1.6, >= 1.6.9)
mixlib-authentication (~> 1.3)
mixlib-cli (~> 1.4)
mixlib-log (~> 1.3)
mixlib-shellout (~> 2.0)
net-ssh (~> 2.6)
net-ssh-multi (~> 1.1)
ohai (>= 8.6.0.alpha.1, < 9)
plist (~> 3.1.0)
pry (~> 0.9)
rspec-core (~> 3.2)
rspec-expectations (~> 3.2)
rspec-mocks (~> 3.2)
rspec_junit_formatter (~> 0.2.0)
serverspec (~> 2.7)
specinfra (~> 2.10)
syslog-logger (~> 1.6)
chef-config (12.5.1)
mixlib-config (~> 2.0)
mixlib-shellout (~> 2.0)
chef-zero (4.3.2)
ffi-yajl (~> 2.2)
hashie (>= 2.0, < 4.0)
mixlib-log (~> 1.3)
rack
uuidtools (~> 2.1)
chefspec (4.4.0)
chef (>= 11.14)
fauxhai (~> 2.3)
rspec (~> 3.0)
cleanroom (1.0.0)
coderay (1.1.0)
dep-selector-libgecode (1.0.2)
dep_selector (1.0.3)
dep-selector-libgecode (~> 1.0)
ffi (~> 1.9)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
fauxhai (2.3.0)
net-ssh
ohai
ffi (1.9.10)
ffi-yajl (2.2.2)
libyajl2 (~> 1.2)
hashie (3.4.2)
highline (1.7.8)
hitimes (1.2.3)
httpclient (2.6.0.1)
ipaddress (0.8.0)
json (1.8.3)
libyajl2 (1.2.0)
method_source (0.8.2)
mime-types (2.6.2)
minitar (0.5.4)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.5.0)
mixlib-config (2.2.1)
mixlib-log (1.6.0)
mixlib-shellout (2.2.1)
multi_json (1.11.2)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.2.1)
net-ssh (>= 2.6.5)
net-ssh-gateway (>= 1.2.0)
net-telnet (0.1.1)
nio4r (1.1.1)
octokit (3.8.0)
sawyer (~> 0.6.0, >= 0.5.3)
ohai (8.7.0)
chef-config (>= 12.5.0.alpha.1, < 13)
ffi (~> 1.9)
ffi-yajl (~> 2.2)
ipaddress
mime-types (~> 2.0)
mixlib-cli
mixlib-config (~> 2.0)
mixlib-log
mixlib-shellout (~> 2.0)
rake (~> 10.1)
systemu (~> 2.6.4)
wmi-lite (~> 1.0)
plist (3.1.0)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rake (10.4.2)
retryable (2.0.2)
ridley (4.3.2)
addressable
buff-config (~> 1.0)
buff-extensions (~> 1.0)
buff-ignore (~> 1.1)
buff-shell_out (~> 0.1)
celluloid (~> 0.16.0)
celluloid-io (~> 0.16.1)
erubis
faraday (~> 0.9.0)
hashie (>= 2.0.2, < 4.0.0)
httpclient (~> 2.6)
json (>= 1.7.7)
mixlib-authentication (>= 1.3.0)
retryable (~> 2.0)
semverse (~> 1.1)
varia_model (~> 0.4.0)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rspec_junit_formatter (0.2.3)
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
sawyer (0.6.0)
addressable (~> 2.3.5)
faraday (~> 0.8, < 0.10)
semverse (1.2.1)
serverspec (2.24.1)
multi_json
rspec (~> 3.0)
rspec-its
specinfra (~> 2.43)
sfl (2.2)
slop (3.6.0)
solve (1.2.1)
dep_selector (~> 1.0)
semverse (~> 1.1)
specinfra (2.44.1)
net-scp
net-ssh (~> 2.7)
net-telnet
sfl
syslog-logger (1.6.8)
systemu (2.6.5)
thor (0.19.1)
timers (4.0.4)
hitimes
uuidtools (2.1.5)
varia_model (0.4.1)
buff-extensions (~> 1.0)
hashie (>= 2.0.2, < 4.0.0)
wmi-lite (1.0.0)
PLATFORMS
ruby
DEPENDENCIES
berkshelf
chefspec
BUNDLED WITH
1.10.6
require 'rspec/core/rake_task'
# Rspec and ChefSpec
desc 'Run ChefSpec unit tests'
RSpec::Core::RakeTask.new(:spec) do |t, _args|
t.rspec_opts = 'spec/unit'
end
require 'chefspec'
require 'chefspec/berkshelf'
at_exit { ChefSpec::Coverage.report! }
require 'spec_helper'
describe 'ossec::default' do
let(:chef_run) { ChefSpec::ServerRunner.new.converge('ossec::default') }
let(:ossec_dir) { "ossec-hids-#{chef_run.node['ossec']['version']}" }
it 'includes build-essential recipe' do
expect(chef_run).to include_recipe('build-essential')
end
it 'creates ossec remote_file' do
expect(chef_run).to create_remote_file("#{Chef::Config[:file_cache_path]}/#{ossec_dir}.tar.gz").with(
:source => chef_run.node['ossec']['url'],
:checksum => chef_run.node['ossec']['checksum']
)
end
it 'executes untar on ossec tar.gz file' do
expect(chef_run).to run_execute("tar zxvf #{ossec_dir}.tar.gz").with(
:cwd => Chef::Config[:file_cache_path],
:creates => "#{Chef::Config[:file_cache_path]}/#{ossec_dir}"
)
end
it 'creates preloaded-vars.conf template' do
expect(chef_run).to create_template("#{Chef::Config[:file_cache_path]}/#{ossec_dir}/etc/preloaded-vars.conf").with(
:source => "preloaded-vars.conf.erb"
)
end
it 'runs bash install-ossec' do
expect(chef_run).to run_bash('install-ossec')
end
it 'creates ossec-batch-manager.pl template' do
expect(chef_run).to create_template("#{chef_run.node['ossec']['user']['dir']}/bin/ossec-batch-manager.pl").with(
:source => "#{Chef::Config[:file_cache_path]}/#{ossec_dir}/contrib/ossec-batch-manager.pl",
:local => true,
:owner => "root",
:group => "ossec",
:mode => 0755
)
end
it 'creates ossec.conf template' do
expect(chef_run).to create_template("#{chef_run.node['ossec']['user']['dir']}/etc/ossec.conf").with(
:source => "ossec.conf.erb",
:owner => "root",
:group => "ossec",
:mode => 0440
)
end
it 'enables ossec service' do
expect(chef_run).to enable_service('ossec')
end
it 'starts ossec service' do
expect(chef_run).to start_service('ossec')
end
context 'Arch Linux platform' do
let(:chef_run_arch) do
ChefSpec::ServerRunner.new(:platform =>'arch', :version => '3.10.5-1-ARCH').converge('ossec::default')
end
it 'creates ossec.service template' do
expect(chef_run_arch).to create_template('/usr/lib/systemd/system/ossec.service')
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment