Skip to content

Commit

Permalink
Update tests to pass travs
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pop <[email protected]>
  • Loading branch information
alexpop committed Mar 2, 2020
1 parent dddb495 commit bbfadb8
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
describe 'audit::default' do
context 'When all attributes are default, on an unspecified platform' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '14.04')
runner = ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '18.04')
runner.converge(described_recipe)
end

Expand Down
20 changes: 12 additions & 8 deletions test/cookbooks/test_helper/recipes/force_inspec_core.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
chef_gem 'inspec-core' do
action :nothing
end.run_action(:remove)
compile_time true
action :remove
end

chef_gem 'inspec-core-bin' do
action :nothing
end.run_action(:remove)
compile_time true
action :remove
end

chef_gem 'inspec' do
action :nothing
end.run_action(:remove)
compile_time true
action :remove
end

chef_gem 'inspec-core' do
compile_time true
version '4.3.2'
action :nothing
end.run_action(:install)
action :install
end
20 changes: 12 additions & 8 deletions test/cookbooks/test_helper/recipes/install_inspec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
chef_gem 'inspec-core' do
action :nothing
end.run_action(:remove)
compile_time true
action :remove
end

chef_gem 'inspec-core-bin' do
action :nothing
end.run_action(:remove)
compile_time true
action :remove
end

chef_gem 'inspec' do
action :nothing
end.run_action(:remove)
compile_time true
action :remove
end

chef_gem 'inspec' do
compile_time true
version '1.19.1'
action :nothing
end.run_action(:install)
action :install
end
15 changes: 4 additions & 11 deletions test/cookbooks/test_helper/recipes/setup_waiver_fixture.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@

[
"controls",
"waivers",
].each do |subdir|
directory "#{node["audit"]["profiles"]["waiver-test-profile"]["path"]}/#{subdir}" do
%w(controls waivers).each do |subdir|
directory "#{node['audit']['profiles']['waiver-test-profile']['path']}/#{subdir}" do
recursive true
end
end

[
"inspec.yml",
"controls/waiver-check.rb",
"waivers/waivers.yaml",
].each do |file|
cookbook_file "#{node["audit"]["profiles"]["waiver-test-profile"]["path"]}/#{file}" do
%w(inspec.yml controls/waiver-check.rb waivers/waivers.yaml).each do |file|
cookbook_file "#{node['audit']['profiles']['waiver-test-profile']['path']}/#{file}" do
source "waivers-fixture/#{file}"
end
end
2 changes: 1 addition & 1 deletion test/integration/inspec-attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
results << r
end
end
attribute_control = results.find { |x| x['code_desc'] == 'File /opt/kitchen/cache/attribute-file-exists.test should exist' }
attribute_control = results.find { |x| x['code_desc'] == 'File /opt/kitchen/cache/attribute-file-exists.test is expected to exist' }
attribute_control = {} if attribute_control.nil?

describe 'attribute control' do
Expand Down
8 changes: 4 additions & 4 deletions test/integration/waivers/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# The test fixture has two controls - the first should pass,
# the second should be a skip with a waiver justification

control "the unwaivered control" do
control 'the unwaivered control' do
describe controls[0]['results'][0]['status'] do
it { should cmp "passed" }
it { should cmp 'passed' }
end
end

control "the waivered control" do
control 'the waivered control' do
describe controls[1]['results'][0]['status'] do
it { should cmp "skipped" }
it { should cmp 'skipped' }
end
end
6 changes: 3 additions & 3 deletions test/kitchen-automate/recipes/bootstrap_localhost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
end

# Ensure the node is in the expected state
raise 'Cannot find /tmp/kitchen/client.pem' unless File.exist?('/tmp/kitchen/client.pem')
raise 'Cannot find /home/ec2-user/.ssh/authorized_keys' unless File.exist?('/home/ec2-user/.ssh/authorized_keys')
raise 'Cannot find /tmp/kitchen/client.pem' unless ::File.exist?('/tmp/kitchen/client.pem')
raise 'Cannot find /home/ec2-user/.ssh/authorized_keys' unless ::File.exist?('/home/ec2-user/.ssh/authorized_keys')

# Add a public key to be used for SSH bootstrapping
execute 'Add SSH public key to be used by self bootstrapping' do
Expand All @@ -49,5 +49,5 @@
EOH
live_stream true
action :run
not_if { File.exist?('/etc/chef/client.pem') }
not_if { ::File.exist?('/etc/chef/client.pem') }
end
2 changes: 1 addition & 1 deletion test/kitchen-automate/recipes/configure_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
touch /etc/opscode/chef-server-reconfigured.txt
EOH
action :run
not_if { File.exist?('/etc/opscode/chef-server-reconfigured.txt') }
not_if { ::File.exist?('/etc/opscode/chef-server-reconfigured.txt') }
end
4 changes: 2 additions & 2 deletions test/kitchen-automate/recipes/converge_localhost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
EOH
live_stream true
action :run
only_if { File.exist?('/etc/chef/client.pem') }
only_if { ::File.exist?('/etc/chef/client.pem') }
end

# Create the attributes file to test the 'chef-visibility' collector
Expand Down Expand Up @@ -91,5 +91,5 @@
EOH
live_stream true
action :run
only_if { File.exist?('/etc/chef/client.pem') }
only_if { ::File.exist?('/etc/chef/client.pem') }
end

0 comments on commit bbfadb8

Please sign in to comment.