Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get most test kitchen tests passing in Travis #405

Merged
merged 6 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 38 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,70 @@ branches:
services:
- docker

env:
global:
- CHEF_VERSION=15
- KITCHEN_YAML=kitchen.dokken.yml
- CHEF_LICENSE="accept-no-persist"

before_install:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- CHEF_LICENSE="accept-no-persist" sudo chef gem install webmock
- eval "$(chef shell-init bash)"
- chef --version
- cookstyle --version
- foodcritic --version
- kitchen list

matrix:
include:
# Run the style, unit and chefspec tests
- rvm: 2.6.3
- rvm: 2.6.5
script: rake
# Run integration tests with test-kitchen
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='default-centos-7'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='default-ubuntu-1804'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='missing-profile-no-fail-ubuntu-1804'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE && exit 1 || echo "OK"
env: SUITE=test:integration OS='missing-profile-fail-ubuntu-1804'
- rvm: 2.6.3
script: rake $SUITE
env: SUITE=test:integration OS='chef15-compatible-inspec-ubuntu-1804' CHEF_LICENSE="accept-no-persist"
- rvm: 2.6.3
script: rake $SUITE
env: SUITE=test:integration OS='gem-install-core-version4-centos-7'
- rvm: 2.6.3
script: rake $SUITE
env: SUITE=test:integration OS='gem-install-core-version3-centos-7'
- rvm: 2.6.3
script: rake $SUITE
env: SUITE=test:integration OS='gem-install-core-version4-ubuntu-1804'
- rvm: 2.6.3
script: rake $SUITE
env: SUITE=test:integration OS='gem-install-core-version3-ubuntu-1804'
- rvm: 2.6.3
script: rake $SUITE
env: SUITE=test:integration OS='gem-install-core-version2-ubuntu-1804'
- rvm: 2.6.3

# Next 5 suites are disabled due to an issue with the gem() inspec resource
# see https://github.com/chef-cookbooks/audit/issues/406
#
# - rvm: 2.6.5
# script: rake $SUITE
# env: SUITE=test:integration OS='chef15-compatible-inspec-ubuntu-1804'
# Next 4 suites test running inspec 3 or 4 on audit cookbook. This is only permitted on chef 14 or older.
# - rvm: 2.6.5
# script: rake $SUITE
# env: SUITE=test:integration OS='gem-install-core-version4-centos-7' CHEF_VERSION=14
# - rvm: 2.6.5
# script: rake $SUITE
# env: SUITE=test:integration OS='gem-install-core-version3-centos-7' CHEF_VERSION=14
# - rvm: 2.6.5
# script: rake $SUITE
# env: SUITE=test:integration OS='gem-install-core-version4-ubuntu-1804' CHEF_VERSION=14
# - rvm: 2.6.5
# script: rake $SUITE
# env: SUITE=test:integration OS='gem-install-core-version3-ubuntu-1804' CHEF_VERSION=14

- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='inspec-attributes-ubuntu-1804'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='chef-node-enabled-ubuntu-1804'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='chef-node-disabled-ubuntu-1804'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='hash-centos-7'
- rvm: 2.6.3
- rvm: 2.6.5
script: rake $SUITE
env: SUITE=test:integration OS='hash-ubuntu-1804'
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
#
# Author:: Stephan Renatus <[email protected]>
# Copyright (c) 2016-2019, Chef Software Inc. <[email protected]>
# Copyright:: (c) 2016-2019, Chef Software Inc. <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
3 changes: 1 addition & 2 deletions examples/automate_win/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name 'automate_win'
maintainer 'Chef Software, Inc'
maintainer_email '[email protected]'
license 'Apache-2'
license 'Apache-2.0'
description 'Sample cookbook for configuring Chef Automate direct reporting'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.0'

depends 'chef-client'
2 changes: 1 addition & 1 deletion examples/automate_win/recipes/chef_client_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: automate_win
# Cookbook:: automate_win
# Recipe:: chef_client_config

# Create client.d directory in the chef client folder
Expand Down
2 changes: 1 addition & 1 deletion examples/automate_win/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: automate_win
# Cookbook:: automate_win
# Recipe:: default

include_recipe 'automate_win::chef_client_config'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: automate_ingest
# Cookbook:: automate_ingest
# Spec:: chef_client_config

# THIS IS NOT A WORKING EXAMPLE.
Expand Down
2 changes: 1 addition & 1 deletion examples/automate_win/spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: automate_win
# Cookbook:: automate_win
# Spec:: default

require 'spec_helper'
Expand Down
3 changes: 1 addition & 2 deletions examples/wrapper_audit/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name 'wrapper_audit'
maintainer 'Chef Software, Inc'
maintainer_email '[email protected]'
license 'Apache-2'
license 'Apache-2.0'
description 'Wrapper cookbook that runs Audit cookbook.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.2.0'

# Put whatever operating systems your company supports where you may want
Expand Down
2 changes: 1 addition & 1 deletion examples/wrapper_audit/recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: wrapper_audit
# Cookbook:: wrapper_audit
# Recipe:: default

# This includes statement is to include the chef_client_config recipe in the
Expand Down
2 changes: 1 addition & 1 deletion examples/wrapper_audit/spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: wrapper_audit
# Cookbook:: wrapper_audit
# Spec:: default

require 'spec_helper'
Expand Down
6 changes: 5 additions & 1 deletion libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def load_audit_handler
# taking node['audit'] as parameter so that it can be called from the chef-server fetcher as well
# audit['collector'] is the legacy reporter,
def get_reporters(audit)
if audit.nil?
Chef::Log.warn("node ['audit'] is not defined")
return []
end
if audit['collector']
Chef::Log.warn("node ['audit']['collector'] is deprecated and will be removed from the next major version of the cookbook. Please use node ['audit']['reporter']")
return handle_reporters(audit['collector'])
Expand All @@ -144,4 +148,4 @@ def get_reporters(audit)
end
end

::Chef::Recipe.send(:include, ReportHelpers)
::Chef::DSL::Recipe.send(:include, ReportHelpers)
12 changes: 0 additions & 12 deletions libraries/matchers.rb

This file was deleted.

3 changes: 1 addition & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
maintainer_email '[email protected]'
license 'Apache-2.0'
description 'Allows for fetching and executing compliance profiles, and reporting their results'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '9.0.1'

source_url 'https://github.com/chef-cookbooks/audit'
issues_url 'https://github.com/chef-cookbooks/audit/issues'

chef_version '>= 12.20' if respond_to?(:chef_version)
chef_version '>= 12.20'

supports 'aix'
supports 'amazon'
Expand Down
4 changes: 2 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Recipe:: default
#
# Copyright 2016-2019 Chef Software, Inc.
# Copyright:: 2016-2019 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions recipes/inspec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Recipe:: inspec
#
# Copyright 2016 Chef Software, Inc.
# Copyright:: 2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion resources/inspec_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def uninstall_inspec_gem

def inspec_info
require 'rubygems'
Gem::Specification.find { |s| ['inspec', 'inspec-core'].include?(s.name) }
Gem::Specification.find { |s| %w(inspec inspec-core).include?(s.name) }
rescue LoadError
nil
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/libraries/audit_enforcer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: automate_spec
#
# Copyright 2016 Chef Software, Inc.
# Copyright:: 2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/libraries/automate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: automate_spec
#
# Copyright 2016 Chef Software, Inc.
# Copyright:: 2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/libraries/cs_automate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: cs_automate_spec

require 'spec_helper'
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/libraries/helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: helpers

require 'spec_helper'
Expand All @@ -21,8 +21,8 @@
end

it 'handle_reporters returns array of reporters when given array' do
reporters = ['chef-compliance', 'json-file']
expect(@helpers.handle_reporters(reporters)).to eq(['chef-compliance', 'json-file'])
reporters = %w(chef-compliance json-file)
expect(@helpers.handle_reporters(reporters)).to eq(%w(chef-compliance json-file))
end

it 'handle_reporters returns array of reporters when given string' do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/libraries/json_file_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: json-file

require 'spec_helper'
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8
#
# Cookbook Name:: compliance
# Cookbook:: compliance
# Spec:: default
#
# Copyright 2016 Chef Software, Inc.
# Copyright:: 2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -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 Expand Up @@ -157,7 +157,7 @@
context 'When specifying multiple reporters' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new(platform: 'centos', version: '6.9')
runner.node.override['audit']['collector'] = ['chef-compliance', 'json-file']
runner.node.override['audit']['collector'] = %w(chef-compliance json-file)
runner.node.override['audit']['profiles'] = [
{ 'name': 'linux', 'compliance': 'base/linux' },
{ 'name': 'apache', 'compliance': 'base/apache' },
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/report/audit_report_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: default
#
# Copyright 2016 Chef Software, Inc.
# Copyright:: 2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/report/fetcher_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8
#
# Cookbook Name:: audit
# Cookbook:: audit
# Spec:: fetcher
#
# Copyright 2016 Chef Software, Inc.
# Copyright:: 2016 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -91,10 +91,10 @@
},
'profile' => ['admin', 'linux-baseline', '2.0'],
}

Fetchers::Url.new('non_profile_url', config).send(:http_opts)
mynode.default['audit']['reporter'] = 'chef-server'
ChefServer::Fetcher.target_url('non_profile_url', config).read
}
expect { myproc.call }.to raise_error(RuntimeError)
expect { myproc.call }.to raise_error(Errno::ECONNREFUSED)
end
end
end
4 changes: 2 additions & 2 deletions tasks/changelog.rake
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ begin
config.future_release = "v#{metadata.version}"
config.user = 'chef-cookbooks'
config.project = 'audit'
config.bug_labels = %w{bug Bug Type:\ Bug }
config.enhancement_labels = %w{enhancement Enhancement Type:\ Enhancement }
config.bug_labels = %w(bug Bug Type:\ Bug )
config.enhancement_labels = %w(enhancement Enhancement Type:\ Enhancement )
end
rescue LoadError
puts 'Problem loading gems please install chef and github_changelog_generator'
Expand Down
Loading