From df7efefc9d67af52d309c150b113364a2bfec645 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 9 Oct 2019 00:08:28 -0700 Subject: [PATCH 01/56] mostly a search and replace for gordon -> example Signed-off-by: Miah Johnson --- docs/dsl_inspec.md | 8 ++++---- docs/dsl_resource.md | 14 ++++++------- docs/resources/ssh_config.md.erb | 2 +- docs/resources/sshd_config.md.erb | 2 +- docs/shell.md | 6 +++--- examples/custom-resource/controls/example.rb | 5 ++--- examples/custom-resource/libraries/gordon.rb | 12 +++++------ examples/inheritance/README.md | 4 ++-- examples/inheritance/controls/example.rb | 2 +- examples/profile/controls/gordon.rb | 20 +++++++++---------- examples/profile/libraries/gordon_config.rb | 10 +++++----- lib/plugins/inspec-compliance/README.md | 2 +- test/functional/inspec_exec_json_test.rb | 6 +++--- test/functional/inspec_exec_jsonmin_test.rb | 4 ++-- test/functional/inspec_exec_junit_test.rb | 12 +++++------ test/functional/inspec_exec_test.rb | 4 ++-- test/functional/inspec_shell_test.rb | 8 ++++---- .../profile_a/controls/example.rb | 2 +- .../profile_b/controls/example.rb | 2 +- .../profile_c/libraries/gordon_config.rb | 8 ++++---- .../profile_d/libraries/gordon_config.rb | 8 ++++---- .../resource-namespace/controls/example.rb | 18 ++++++++--------- .../library/controls/filesystem_spec.rb | 4 ++-- .../profiles/library/libraries/gordonlib.rb | 2 +- .../profiles/library/libraries/testlib.rb | 8 ++++---- .../custom-resource/controls/example.rb | 5 ++--- .../custom-resource/libraries/gordon.rb | 7 +++---- .../old-examples/inheritance/README.md | 4 ++-- .../inheritance/controls/example.rb | 2 +- .../old-examples/profile/controls/gordon.rb | 20 +++++++++---------- .../profile/libraries/gordon_config.rb | 10 +++++----- 31 files changed, 108 insertions(+), 113 deletions(-) diff --git a/docs/dsl_inspec.md b/docs/dsl_inspec.md index 688d0a3bf..e8b4cf702 100644 --- a/docs/dsl_inspec.md +++ b/docs/dsl_inspec.md @@ -340,10 +340,10 @@ $ inspec shell Welcome to the interactive InSpec Shell To find out how to use it, type: help -inspec> command('ls /home/gordon/git/inspec/docs').stdout -=> "ctl_inspec.rst\ndsl_inspec.rst\ndsl_resource.rst\n" -inspec> command('ls').stdout.split("\n") -=> ["ctl_inspec.rst", "dsl_inspec.rst", "dsl_resource.rst"] +inspec> command('ls ~/projects/github/inspec/docs').stdout +=> "README.md\nconfig.md\ndev\ndsl_inspec.md\ndsl_resource.md\nglossary.md\nhabitat.md\ninputs.md\ninspec_and_friends.md\nmatchers.md\nmigration.md\nplatforms.md\nplugin_kitchen_inspec.md\nplugins.md\nprofiles.md\nreporters.md\nresources\nshared\nshell.md\nstyle.md\nwaivers.md\n" +inspec> command('ls ~/projects/github/inspec/docs').stdout.split("\n").first +=> "README.md" inspec> help command Name: command diff --git a/docs/dsl_resource.md b/docs/dsl_resource.md index 5b35c516e..a041a7fbe 100644 --- a/docs/dsl_resource.md +++ b/docs/dsl_resource.md @@ -17,7 +17,7 @@ $ tree examples/profile examples/profile ... ├── libraries -│   └── gordon_config.rb +│   └── example_config.rb ``` ## Resource structure @@ -51,8 +51,8 @@ The following example shows a full resource using attributes and methods to provide simple access to a configuration file: ```ruby -class GordonConfig < Inspec.resource(1) - name 'gordon_config' +class ExampleConfig < Inspec.resource(1) + name 'example_config' # Restrict to only run on the below platforms (if none were given, all OS's supported) supports platform_family: 'fedora' @@ -65,14 +65,14 @@ class GordonConfig < Inspec.resource(1) ' example ' - describe gordon_config do + describe example_config do its("signal") { should eq "on" } end ' # Load the configuration file on initialization def initialize(path = nil) - @path = path || '/etc/gordon.conf' + @path = path || '/etc/example.conf' @params = SimpleConfig.new( read_content ) end @@ -90,11 +90,11 @@ class GordonConfig < Inspec.resource(1) # Retrieve the file's contents f.content else - # If the file doesn't exist, skip all tests that use gordon_config + # If the file doesn't exist, skip all tests that use example_config raise Inspec::Exceptions::ResourceSkipped, "Can't read config at #{@path}" end end end ``` -For a full example, see our [example resource](https://github.com/chef/inspec/blob/master/examples/profile/libraries/gordon_config.rb). +For a full example, see our [example resource](https://github.com/chef/inspec/blob/master/examples/profile/libraries/example_config.rb). diff --git a/docs/resources/ssh_config.md.erb b/docs/resources/ssh_config.md.erb index c1e9efc23..579b738bc 100644 --- a/docs/resources/ssh_config.md.erb +++ b/docs/resources/ssh_config.md.erb @@ -54,7 +54,7 @@ The following examples show how to use this Chef InSpec audit resource. end describe ssh_config do - its('SendEnv') { should include('GORDON_CLIENT') } + its('SendEnv') { should include('CI_ENABLE_COVERAGE') } end ### Test SSH configuration diff --git a/docs/resources/sshd_config.md.erb b/docs/resources/sshd_config.md.erb index 20cd3b351..c42ff3178 100644 --- a/docs/resources/sshd_config.md.erb +++ b/docs/resources/sshd_config.md.erb @@ -42,7 +42,7 @@ The following examples show how to use this Chef InSpec audit resource. ### Test which variables may be sent to the server describe sshd_config do - its('AcceptEnv') { should include('GORDON_SERVER') } + its('AcceptEnv') { should include('CI_ENABLE_COVERAGE') } end ### Test for IPv6-only addresses diff --git a/docs/shell.md b/docs/shell.md index acf3f8010..d0c8ed757 100644 --- a/docs/shell.md +++ b/docs/shell.md @@ -48,9 +48,9 @@ $ inspec shell -t docker://container_id # Login to a Docker container. Use resource packs to share custom resources with other Chef InSpec users. A resource pack is an Chef InSpec profile that contains only custom resources and no other controls or tests. -For example, the profile in [`examples/profile`](https://github.com/chef/inspec/tree/master/examples/profile)in the Chef InSpec git repo defines a [`gordon_config` resource](https://github.com/chef/inspec/blob/master/examples/profile/controls/gordon.rb). To use these resources within the Chef InSpec shell, you will need to download and specify them as a dependency. +For example, the profile in [`examples/profile`](https://github.com/chef/inspec/tree/master/examples/profile)in the Chef InSpec git repo defines a [`example_config` resource](https://github.com/chef/inspec/blob/master/examples/profile/controls/example.rb). To use these resources within the Chef InSpec shell, you will need to download and specify them as a dependency. -Once you have local access to the profile, you can use the `gordon_config` custom resource provided in the `examples/profile` GitHub repo in your local environment : +Once you have local access to the profile, you can use the `example_config` custom resource provided in the `examples/profile` GitHub repo in your local environment : ```bash inspec shell --depends examples/profile @@ -59,7 +59,7 @@ inspec shell --depends examples/profile Once inside the shell your resource will be available: ```ruby -inspec> gordon_config +inspec> example_config ``` ## Using Ruby in Chef InSpec shell diff --git a/examples/custom-resource/controls/example.rb b/examples/custom-resource/controls/example.rb index 762839ab8..b934e5de5 100644 --- a/examples/custom-resource/controls/example.rb +++ b/examples/custom-resource/controls/example.rb @@ -1,5 +1,4 @@ -describe gordon do - its('crime_rate') { should be < 5 } +describe example do + its('crime_rate') { should be < 2 } it { should have_a_fabulous_mustache } end - diff --git a/examples/custom-resource/libraries/gordon.rb b/examples/custom-resource/libraries/gordon.rb index a4a90bb56..8b123542f 100644 --- a/examples/custom-resource/libraries/gordon.rb +++ b/examples/custom-resource/libraries/gordon.rb @@ -1,20 +1,18 @@ -class Gordon < Inspec.resource(1) - name "gordon" - +class Example < Inspec.resource(1) + name "example" example " - describe gordon do + describe example do its('crime_rate') { should be < 2 } it { should have_a_fabulous_mustache } end " def crime_rate - # call out ot another custom resource - inspec.batsignal.number_of_sightings + 1 end + def has_a_fabulous_mustache? - # always true true end end diff --git a/examples/inheritance/README.md b/examples/inheritance/README.md index 8baccaf2d..86646808f 100644 --- a/examples/inheritance/README.md +++ b/examples/inheritance/README.md @@ -30,8 +30,8 @@ Version: 1.0.0 Target: local:// - ○ gordon-1.0: Verify the version number of Gordon (1 skipped) - ○ Can't find file "/tmp/gordon/config.yaml" + ○ example-1.0: Verify the version number of Example (1 skipped) + ○ Can't find file "/tmp/example/config.yaml" ✔ File content should match nil ✔ ssh-1: Allow only SSH Protocol 2 ✔ File /bin/sh should be owned by "root" diff --git a/examples/inheritance/controls/example.rb b/examples/inheritance/controls/example.rb index 21c602feb..9d1b27f56 100644 --- a/examples/inheritance/controls/example.rb +++ b/examples/inheritance/controls/example.rb @@ -4,7 +4,7 @@ include_controls 'profile' do skip_control 'tmp-1.0' - control 'gordon-1.0' do + control 'example-1.0' do impact 0.0 end end diff --git a/examples/profile/controls/gordon.rb b/examples/profile/controls/gordon.rb index e9767d69e..e2027d390 100644 --- a/examples/profile/controls/gordon.rb +++ b/examples/profile/controls/gordon.rb @@ -1,24 +1,24 @@ # copyright: 2016, Chef Software, Inc. -title 'Gordon Config Checks' +title 'Example Config Checks' # To pass the test, create the following file # ```bash -# mkdir -p /tmp/gordon -# cat < /tmp/gordon/config.yaml +# mkdir -p /tmp/example +# cat < /tmp/example/config.yaml # version: '1.0' # EOF # ``` -control 'gordon-1.0' do +control 'example-1.0' do impact 'critical' - title 'Verify the version number of Gordon' + title 'Verify the version number of Example' desc 'An optional description...' - tag 'gordon' - ref 'Gordon Requirements 1.0', uri: 'http://...' + tag 'example' + ref 'Example Requirements 1.0', uri: 'http://...' - # Test using the custom gordon_config InSpec resource + # Test using the custom example_config InSpec resource # Find the resource content here: ../libraries/ - describe gordon_config do + describe example_config do it { should exist } its('version') { should eq('1.0') } its('file_size') { should <= 20 } @@ -26,7 +26,7 @@ control 'gordon-1.0' do end # Test the version again to showcase variables - g = gordon_config + g = example_config g_path = g.file_path g_version = g.version describe file(g_path) do diff --git a/examples/profile/libraries/gordon_config.rb b/examples/profile/libraries/gordon_config.rb index fdb69cd35..4015d97e0 100644 --- a/examples/profile/libraries/gordon_config.rb +++ b/examples/profile/libraries/gordon_config.rb @@ -1,18 +1,18 @@ require "yaml" # Custom resource based on the InSpec resource DSL -class GordonConfig < Inspec.resource(1) - name "gordon_config" +class ExampleConfig < Inspec.resource(1) + name "example_config" supports platform: "unix" supports platform: "windows" desc " - Gordon's resource description ... + Example's resource description ... " example " - describe gordon_config do + describe example_config do its('version') { should eq('1.0') } its('file_size') { should > 1 } end @@ -21,7 +21,7 @@ class GordonConfig < Inspec.resource(1) # Load the configuration file on initialization def initialize @params = {} - @path = "/tmp/gordon/config.yaml" + @path = "/tmp/example/config.yaml" @file = inspec.file(@path) unless @file.file? diff --git a/lib/plugins/inspec-compliance/README.md b/lib/plugins/inspec-compliance/README.md index 46db94604..0a247e026 100644 --- a/lib/plugins/inspec-compliance/README.md +++ b/lib/plugins/inspec-compliance/README.md @@ -152,7 +152,7 @@ $ inspec exec compliance://admin/profile Pending: (Failures listed here are expected and do not affect your suite's status) - 1) gordon_config Can't find file "/tmp/gordon/config.yaml" + 1) example_config Can't find file "/tmp/example/config.yaml" # Not yet implemented # ./lib/inspec/runner.rb:157 diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index ca214b020..a6a349a2e 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -120,9 +120,9 @@ describe "inspec exec with json formatter" do let(:controls) { profile["controls"] } let(:ex1) { controls.find { |x| x["id"] == "tmp-1.0" } } let(:ex2) { controls.find { |x| x["id"] =~ /generated/ } } - let(:ex3) { profile["controls"].find { |x| x["id"] == "gordon-1.0" } } + let(:ex3) { profile["controls"].find { |x| x["id"] == "example-1.0" } } let(:check_result) do - ex3["results"].find { |x| x["resource"] == "gordon_config" } + ex3["results"].find { |x| x["resource"] == "example_config" } end it "has only one profile" do @@ -157,7 +157,7 @@ describe "inspec exec with json formatter" do _(groups.sort_by { |x| x["id"] }).must_equal([ { "id" => "controls/example.rb", "title" => "/tmp profile", "controls" => ["tmp-1.0", key] }, - { "id" => "controls/gordon.rb", "title" => "Gordon Config Checks", "controls" => ["gordon-1.0"] }, + { "id" => "controls/example.rb", "title" => "Example Config Checks", "controls" => ["example-1.0"] }, { "id" => "controls/meta.rb", "title" => "SSH Server Configuration", "controls" => ["ssh-1"] }, ]) end diff --git a/test/functional/inspec_exec_jsonmin_test.rb b/test/functional/inspec_exec_jsonmin_test.rb index fa625df44..9c769d2b3 100644 --- a/test/functional/inspec_exec_jsonmin_test.rb +++ b/test/functional/inspec_exec_jsonmin_test.rb @@ -47,7 +47,7 @@ describe "inspec exec" do let(:controls) { json["controls"] } let(:ex1) { controls.find { |x| x["id"] == "tmp-1.0" } } let(:ex2) { controls.find { |x| x["id"] =~ /generated/ } } - let(:ex3) { controls.find { |x| x["id"] == "gordon-1.0" } } + let(:ex3) { controls.find { |x| x["id"] == "example-1.0" } } it "must have 5 examples" do _(json["controls"].length).must_equal 5 @@ -74,7 +74,7 @@ describe "inspec exec" do it "has a skip_message" do _(ex1["skip_message"]).must_be :nil? - _(ex3["skip_message"]).must_equal "Can't find file `/tmp/gordon/config.yaml`" + _(ex3["skip_message"]).must_equal "Can't find file `/tmp/example/config.yaml`" end end diff --git a/test/functional/inspec_exec_junit_test.rb b/test/functional/inspec_exec_junit_test.rb index c124b3a64..7eb9366c2 100644 --- a/test/functional/inspec_exec_junit_test.rb +++ b/test/functional/inspec_exec_junit_test.rb @@ -59,19 +59,19 @@ describe "inspec exec with junit formatter" do _(REXML::XPath.match(suite, "//testcase[@name='File /tmp should be directory']").length).must_equal 2 end - describe 'the testcase named "gordon_config Can\'t find file ..."' do - let(:gordon_yml_tests) { REXML::XPath.match(suite, "//testcase[@classname='profile.gordon-1.0' and @name='gordon_config']") } - let(:first_gordon_test) { gordon_yml_tests.first } + describe 'the testcase named "example_config Can\'t find file ..."' do + let(:example_yml_tests) { REXML::XPath.match(suite, "//testcase[@classname='profile.example-1.0' and @name='example_config']") } + let(:first_example_test) { example_yml_tests.first } it "should be unique" do - _(gordon_yml_tests.length).must_equal 1 + _(example_yml_tests.length).must_equal 1 end it "should be skipped" do if is_windows? - _(first_gordon_test.elements.to_a("//skipped").length).must_equal 2 + _(first_example_test.elements.to_a("//skipped").length).must_equal 2 else - _(first_gordon_test.elements.to_a("//skipped").length).must_equal 1 + _(first_example_test.elements.to_a("//skipped").length).must_equal 1 end end end diff --git a/test/functional/inspec_exec_test.rb b/test/functional/inspec_exec_test.rb index 01ddb434d..9eb93031e 100644 --- a/test/functional/inspec_exec_test.rb +++ b/test/functional/inspec_exec_test.rb @@ -38,8 +38,8 @@ describe "inspec exec" do _(stdout).must_include "\e[38;5;41m ✔ tmp-1.0: Create /tmp directory\e[0m\n" _(stdout).must_include " -\e[38;5;247m ↺ gordon-1.0: Verify the version number of Gordon (1 skipped)\e[0m -\e[38;5;247m ↺ Can't find file `/tmp/gordon/config.yaml`\e[0m +\e[38;5;247m ↺ example-1.0: Verify the version number of Example (1 skipped)\e[0m +\e[38;5;247m ↺ Can't find file `/tmp/example/config.yaml`\e[0m " if is_windows? _(stdout).must_include "\e[38;5;247m ↺ ssh-1: Allow only SSH Protocol 2\e[0m\n" diff --git a/test/functional/inspec_shell_test.rb b/test/functional/inspec_shell_test.rb index 82f882c27..be1b64f64 100644 --- a/test/functional/inspec_shell_test.rb +++ b/test/functional/inspec_shell_test.rb @@ -19,9 +19,9 @@ describe "inspec shell tests" do end it "loads a dependency" do - res = inspec("shell -c 'gordon_config' --depends #{example_profile}") + res = inspec("shell -c 'example_config' --depends #{example_profile}") - _(res.stdout.chop).must_equal "gordon_config" + _(res.stdout.chop).must_equal "example_config" _(res.stderr).must_equal "" @@ -171,10 +171,10 @@ describe "inspec shell tests" do end it "loads a dependency" do - cmd = "echo 'gordon_config' | #{exec_inspec} shell --depends #{example_profile}" + cmd = "echo 'example_config' | #{exec_inspec} shell --depends #{example_profile}" res = CMD.run_command(cmd) - _(res.stdout).must_include "=> gordon_config" + _(res.stdout).must_include "=> example_config" assert_exit_code 0, res end diff --git a/test/unit/mock/profiles/dependencies/profile_a/controls/example.rb b/test/unit/mock/profiles/dependencies/profile_a/controls/example.rb index c159d457b..c91709945 100644 --- a/test/unit/mock/profiles/dependencies/profile_a/controls/example.rb +++ b/test/unit/mock/profiles/dependencies/profile_a/controls/example.rb @@ -20,7 +20,7 @@ control 'profilea-1' do # A unique ID for this control end control 'profilea-2' do - describe gordon_config do + describe example_config do its('version') { should eq('1.0') } end end diff --git a/test/unit/mock/profiles/dependencies/profile_b/controls/example.rb b/test/unit/mock/profiles/dependencies/profile_b/controls/example.rb index 89a9ab022..5a3b66228 100644 --- a/test/unit/mock/profiles/dependencies/profile_b/controls/example.rb +++ b/test/unit/mock/profiles/dependencies/profile_b/controls/example.rb @@ -14,7 +14,7 @@ control 'profileb-1' do # A unique ID for this control end control 'profileb-2' do - describe gordon_config do + describe example_config do its('version') { should eq('2.0') } end end diff --git a/test/unit/mock/profiles/dependencies/profile_c/libraries/gordon_config.rb b/test/unit/mock/profiles/dependencies/profile_c/libraries/gordon_config.rb index cecf89512..52cfe84d8 100644 --- a/test/unit/mock/profiles/dependencies/profile_c/libraries/gordon_config.rb +++ b/test/unit/mock/profiles/dependencies/profile_c/libraries/gordon_config.rb @@ -1,10 +1,10 @@ -class GordonConfig < Inspec.resource(1) - name 'gordon_config' +class ExampleConfig < Inspec.resource(1) + name 'example_config' - desc "Gordon's resource description ..." + desc "Example's resource description ..." example " - describe gordon_config do + describe example_config do its('version') { should eq('1.0') } end " diff --git a/test/unit/mock/profiles/dependencies/profile_d/libraries/gordon_config.rb b/test/unit/mock/profiles/dependencies/profile_d/libraries/gordon_config.rb index 8b033559f..197e968e0 100644 --- a/test/unit/mock/profiles/dependencies/profile_d/libraries/gordon_config.rb +++ b/test/unit/mock/profiles/dependencies/profile_d/libraries/gordon_config.rb @@ -1,10 +1,10 @@ -class GordonConfig < Inspec.resource(1) - name 'gordon_config' +class ExampleConfig < Inspec.resource(1) + name 'example_config' - desc "Gordon's resource description ..." + desc "Example's resource description ..." example " - describe gordon_config do + describe example_config do its('version') { should eq('2.0') } end " diff --git a/test/unit/mock/profiles/dependencies/resource-namespace/controls/example.rb b/test/unit/mock/profiles/dependencies/resource-namespace/controls/example.rb index a4b9965f1..f5d9cef80 100644 --- a/test/unit/mock/profiles/dependencies/resource-namespace/controls/example.rb +++ b/test/unit/mock/profiles/dependencies/resource-namespace/controls/example.rb @@ -1,26 +1,26 @@ # copyright: 2015, The Authors -require_resource(profile: 'profile_c', resource: 'gordon_config', as: 'gordy_config') +require_resource(profile: 'profile_c', resource: 'example_config', as: 'placeholder_config') -describe gordy_config do +describe placeholder_config do its('version') { should eq('1.0') } end -control 'whichgordon' do - describe gordy_config do +control 'whichexample' do + describe placeholder_config do its('version') { should eq('1.0') } end - describe gordon_config do + describe example_config do its('version') { should eq('2.0') } end - describe gordy_config do - its('version') { should eq(gordy_config.version) } + describe placeholder_config do + its('version') { should eq(placeholder_config.version) } end - describe gordon_config do - its('version') { should eq(gordon_config.version) } + describe example_config do + its('version') { should eq(example_config.version) } end end diff --git a/test/unit/mock/profiles/library/controls/filesystem_spec.rb b/test/unit/mock/profiles/library/controls/filesystem_spec.rb index 2f4c7a957..526181309 100644 --- a/test/unit/mock/profiles/library/controls/filesystem_spec.rb +++ b/test/unit/mock/profiles/library/controls/filesystem_spec.rb @@ -1,5 +1,5 @@ # copyright: 2015, Chef Software, Inc - -describe gordon do + +describe example do it { should be_enabled } end diff --git a/test/unit/mock/profiles/library/libraries/gordonlib.rb b/test/unit/mock/profiles/library/libraries/gordonlib.rb index f8df1ae16..cf0183fac 100644 --- a/test/unit/mock/profiles/library/libraries/gordonlib.rb +++ b/test/unit/mock/profiles/library/libraries/gordonlib.rb @@ -1,2 +1,2 @@ -module GordonLib +module ExampleLib end diff --git a/test/unit/mock/profiles/library/libraries/testlib.rb b/test/unit/mock/profiles/library/libraries/testlib.rb index 4f9e75dbe..469f54d85 100644 --- a/test/unit/mock/profiles/library/libraries/testlib.rb +++ b/test/unit/mock/profiles/library/libraries/testlib.rb @@ -1,11 +1,11 @@ # Library resource -require 'gordonlib' +require 'examplelib' require 'hashie' -class Gordon < Inspec.resource(1) - name 'gordon' - include GordonLib +class Example < Inspec.resource(1) + name 'example' + include ExampleLib def enabled? true end diff --git a/test/unit/mock/profiles/old-examples/custom-resource/controls/example.rb b/test/unit/mock/profiles/old-examples/custom-resource/controls/example.rb index 762839ab8..b934e5de5 100644 --- a/test/unit/mock/profiles/old-examples/custom-resource/controls/example.rb +++ b/test/unit/mock/profiles/old-examples/custom-resource/controls/example.rb @@ -1,5 +1,4 @@ -describe gordon do - its('crime_rate') { should be < 5 } +describe example do + its('crime_rate') { should be < 2 } it { should have_a_fabulous_mustache } end - diff --git a/test/unit/mock/profiles/old-examples/custom-resource/libraries/gordon.rb b/test/unit/mock/profiles/old-examples/custom-resource/libraries/gordon.rb index 30654c05a..2dcc7b146 100644 --- a/test/unit/mock/profiles/old-examples/custom-resource/libraries/gordon.rb +++ b/test/unit/mock/profiles/old-examples/custom-resource/libraries/gordon.rb @@ -1,8 +1,8 @@ -class Gordon < Inspec.resource(1) - name 'gordon' +class Example < Inspec.resource(1) + name 'example' example " - describe gordon do + describe example do its('crime_rate') { should be < 2 } it { should have_a_fabulous_mustache } end @@ -18,4 +18,3 @@ class Gordon < Inspec.resource(1) true end end - diff --git a/test/unit/mock/profiles/old-examples/inheritance/README.md b/test/unit/mock/profiles/old-examples/inheritance/README.md index 8baccaf2d..86646808f 100644 --- a/test/unit/mock/profiles/old-examples/inheritance/README.md +++ b/test/unit/mock/profiles/old-examples/inheritance/README.md @@ -30,8 +30,8 @@ Version: 1.0.0 Target: local:// - ○ gordon-1.0: Verify the version number of Gordon (1 skipped) - ○ Can't find file "/tmp/gordon/config.yaml" + ○ example-1.0: Verify the version number of Example (1 skipped) + ○ Can't find file "/tmp/example/config.yaml" ✔ File content should match nil ✔ ssh-1: Allow only SSH Protocol 2 ✔ File /bin/sh should be owned by "root" diff --git a/test/unit/mock/profiles/old-examples/inheritance/controls/example.rb b/test/unit/mock/profiles/old-examples/inheritance/controls/example.rb index 21c602feb..9d1b27f56 100644 --- a/test/unit/mock/profiles/old-examples/inheritance/controls/example.rb +++ b/test/unit/mock/profiles/old-examples/inheritance/controls/example.rb @@ -4,7 +4,7 @@ include_controls 'profile' do skip_control 'tmp-1.0' - control 'gordon-1.0' do + control 'example-1.0' do impact 0.0 end end diff --git a/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb b/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb index e9767d69e..e2027d390 100644 --- a/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb +++ b/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb @@ -1,24 +1,24 @@ # copyright: 2016, Chef Software, Inc. -title 'Gordon Config Checks' +title 'Example Config Checks' # To pass the test, create the following file # ```bash -# mkdir -p /tmp/gordon -# cat < /tmp/gordon/config.yaml +# mkdir -p /tmp/example +# cat < /tmp/example/config.yaml # version: '1.0' # EOF # ``` -control 'gordon-1.0' do +control 'example-1.0' do impact 'critical' - title 'Verify the version number of Gordon' + title 'Verify the version number of Example' desc 'An optional description...' - tag 'gordon' - ref 'Gordon Requirements 1.0', uri: 'http://...' + tag 'example' + ref 'Example Requirements 1.0', uri: 'http://...' - # Test using the custom gordon_config InSpec resource + # Test using the custom example_config InSpec resource # Find the resource content here: ../libraries/ - describe gordon_config do + describe example_config do it { should exist } its('version') { should eq('1.0') } its('file_size') { should <= 20 } @@ -26,7 +26,7 @@ control 'gordon-1.0' do end # Test the version again to showcase variables - g = gordon_config + g = example_config g_path = g.file_path g_version = g.version describe file(g_path) do diff --git a/test/unit/mock/profiles/old-examples/profile/libraries/gordon_config.rb b/test/unit/mock/profiles/old-examples/profile/libraries/gordon_config.rb index 1afe167ff..ae56d7ab0 100644 --- a/test/unit/mock/profiles/old-examples/profile/libraries/gordon_config.rb +++ b/test/unit/mock/profiles/old-examples/profile/libraries/gordon_config.rb @@ -1,18 +1,18 @@ require 'yaml' # Custom resource based on the InSpec resource DSL -class GordonConfig < Inspec.resource(1) - name 'gordon_config' +class ExampleConfig < Inspec.resource(1) + name 'example_config' supports platform: 'unix' supports platform: 'windows' desc " - Gordon's resource description ... + Example's resource description ... " example " - describe gordon_config do + describe example_config do its('version') { should eq('1.0') } its('file_size') { should > 1 } end @@ -21,7 +21,7 @@ class GordonConfig < Inspec.resource(1) # Load the configuration file on initialization def initialize @params = {} - @path = '/tmp/gordon/config.yaml' + @path = '/tmp/example/config.yaml' @file = inspec.file(@path) unless @file.file? From a40ec993e8537a59a4022c2e9322028baf476959 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 9 Oct 2019 00:19:36 -0700 Subject: [PATCH 02/56] Rename files to remove references to gordon Signed-off-by: Miah Johnson --- .../libraries/{gordon.rb => example.rb} | 0 examples/profile/controls/example-tmp.rb | 23 +++++++++ examples/profile/controls/example.rb | 48 ++++++++++++------- examples/profile/controls/gordon.rb | 35 -------------- .../{gordon_config.rb => example_config.rb} | 0 .../{gordon_config.rb => example_config.rb} | 0 .../{gordon_config.rb => example_config.rb} | 0 .../libraries/{gordonlib.rb => examplelib.rb} | 0 .../libraries/{gordon.rb => example.rb} | 0 .../profile/controls/example-tmp.rb | 23 +++++++++ .../old-examples/profile/controls/example.rb | 48 ++++++++++++------- .../old-examples/profile/controls/gordon.rb | 35 -------------- .../{gordon_config.rb => example_config.rb} | 0 13 files changed, 106 insertions(+), 106 deletions(-) rename examples/custom-resource/libraries/{gordon.rb => example.rb} (100%) create mode 100644 examples/profile/controls/example-tmp.rb delete mode 100644 examples/profile/controls/gordon.rb rename examples/profile/libraries/{gordon_config.rb => example_config.rb} (100%) rename test/unit/mock/profiles/dependencies/profile_c/libraries/{gordon_config.rb => example_config.rb} (100%) rename test/unit/mock/profiles/dependencies/profile_d/libraries/{gordon_config.rb => example_config.rb} (100%) rename test/unit/mock/profiles/library/libraries/{gordonlib.rb => examplelib.rb} (100%) rename test/unit/mock/profiles/old-examples/custom-resource/libraries/{gordon.rb => example.rb} (100%) create mode 100644 test/unit/mock/profiles/old-examples/profile/controls/example-tmp.rb delete mode 100644 test/unit/mock/profiles/old-examples/profile/controls/gordon.rb rename test/unit/mock/profiles/old-examples/profile/libraries/{gordon_config.rb => example_config.rb} (100%) diff --git a/examples/custom-resource/libraries/gordon.rb b/examples/custom-resource/libraries/example.rb similarity index 100% rename from examples/custom-resource/libraries/gordon.rb rename to examples/custom-resource/libraries/example.rb diff --git a/examples/profile/controls/example-tmp.rb b/examples/profile/controls/example-tmp.rb new file mode 100644 index 000000000..e0806fd82 --- /dev/null +++ b/examples/profile/controls/example-tmp.rb @@ -0,0 +1,23 @@ +# copyright: 2015, Chef Software, Inc. + +title '/tmp profile' + +# you add controls here +control "tmp-1.0" do # A unique ID for this control + impact 0.7 # The criticality, if this control fails. + title "Create /tmp directory" # A human-readable title + desc "An optional description..." # Describe why this is needed + desc "label", "An optional description with a label" # Pair a part of the description with a label + tag data: "temp data" # A tag allows you to associate key information + tag "security" # to the test + ref "Document A-12", url: 'http://...' # Additional references + + describe file('/tmp') do # The actual test + it { should be_directory } + end +end + +# you can also use plain tests +describe file('/tmp') do + it { should be_directory } +end diff --git a/examples/profile/controls/example.rb b/examples/profile/controls/example.rb index e0806fd82..e2027d390 100644 --- a/examples/profile/controls/example.rb +++ b/examples/profile/controls/example.rb @@ -1,23 +1,35 @@ -# copyright: 2015, Chef Software, Inc. +# copyright: 2016, Chef Software, Inc. -title '/tmp profile' +title 'Example Config Checks' -# you add controls here -control "tmp-1.0" do # A unique ID for this control - impact 0.7 # The criticality, if this control fails. - title "Create /tmp directory" # A human-readable title - desc "An optional description..." # Describe why this is needed - desc "label", "An optional description with a label" # Pair a part of the description with a label - tag data: "temp data" # A tag allows you to associate key information - tag "security" # to the test - ref "Document A-12", url: 'http://...' # Additional references +# To pass the test, create the following file +# ```bash +# mkdir -p /tmp/example +# cat < /tmp/example/config.yaml +# version: '1.0' +# EOF +# ``` +control 'example-1.0' do + impact 'critical' + title 'Verify the version number of Example' + desc 'An optional description...' + tag 'example' + ref 'Example Requirements 1.0', uri: 'http://...' - describe file('/tmp') do # The actual test - it { should be_directory } + # Test using the custom example_config InSpec resource + # Find the resource content here: ../libraries/ + describe example_config do + it { should exist } + its('version') { should eq('1.0') } + its('file_size') { should <= 20 } + its('comma_count') { should eq 0 } + end + + # Test the version again to showcase variables + g = example_config + g_path = g.file_path + g_version = g.version + describe file(g_path) do + its('content') { should match g_version } end end - -# you can also use plain tests -describe file('/tmp') do - it { should be_directory } -end diff --git a/examples/profile/controls/gordon.rb b/examples/profile/controls/gordon.rb deleted file mode 100644 index e2027d390..000000000 --- a/examples/profile/controls/gordon.rb +++ /dev/null @@ -1,35 +0,0 @@ -# copyright: 2016, Chef Software, Inc. - -title 'Example Config Checks' - -# To pass the test, create the following file -# ```bash -# mkdir -p /tmp/example -# cat < /tmp/example/config.yaml -# version: '1.0' -# EOF -# ``` -control 'example-1.0' do - impact 'critical' - title 'Verify the version number of Example' - desc 'An optional description...' - tag 'example' - ref 'Example Requirements 1.0', uri: 'http://...' - - # Test using the custom example_config InSpec resource - # Find the resource content here: ../libraries/ - describe example_config do - it { should exist } - its('version') { should eq('1.0') } - its('file_size') { should <= 20 } - its('comma_count') { should eq 0 } - end - - # Test the version again to showcase variables - g = example_config - g_path = g.file_path - g_version = g.version - describe file(g_path) do - its('content') { should match g_version } - end -end diff --git a/examples/profile/libraries/gordon_config.rb b/examples/profile/libraries/example_config.rb similarity index 100% rename from examples/profile/libraries/gordon_config.rb rename to examples/profile/libraries/example_config.rb diff --git a/test/unit/mock/profiles/dependencies/profile_c/libraries/gordon_config.rb b/test/unit/mock/profiles/dependencies/profile_c/libraries/example_config.rb similarity index 100% rename from test/unit/mock/profiles/dependencies/profile_c/libraries/gordon_config.rb rename to test/unit/mock/profiles/dependencies/profile_c/libraries/example_config.rb diff --git a/test/unit/mock/profiles/dependencies/profile_d/libraries/gordon_config.rb b/test/unit/mock/profiles/dependencies/profile_d/libraries/example_config.rb similarity index 100% rename from test/unit/mock/profiles/dependencies/profile_d/libraries/gordon_config.rb rename to test/unit/mock/profiles/dependencies/profile_d/libraries/example_config.rb diff --git a/test/unit/mock/profiles/library/libraries/gordonlib.rb b/test/unit/mock/profiles/library/libraries/examplelib.rb similarity index 100% rename from test/unit/mock/profiles/library/libraries/gordonlib.rb rename to test/unit/mock/profiles/library/libraries/examplelib.rb diff --git a/test/unit/mock/profiles/old-examples/custom-resource/libraries/gordon.rb b/test/unit/mock/profiles/old-examples/custom-resource/libraries/example.rb similarity index 100% rename from test/unit/mock/profiles/old-examples/custom-resource/libraries/gordon.rb rename to test/unit/mock/profiles/old-examples/custom-resource/libraries/example.rb diff --git a/test/unit/mock/profiles/old-examples/profile/controls/example-tmp.rb b/test/unit/mock/profiles/old-examples/profile/controls/example-tmp.rb new file mode 100644 index 000000000..02638b4a8 --- /dev/null +++ b/test/unit/mock/profiles/old-examples/profile/controls/example-tmp.rb @@ -0,0 +1,23 @@ +# copyright: 2015, Chef Software, Inc. + +title '/tmp profile' + +# you add controls here +control 'tmp-1.0' do # A unique ID for this control + impact 0.7 # The criticality, if this control fails. + title 'Create /tmp directory' # A human-readable title + desc 'An optional description...' # Describe why this is needed + desc 'label', 'An optional description with a label' # Pair a part of the description with a label + tag data: 'temp data' # A tag allows you to associate key information + tag 'security' # to the test + ref 'Document A-12', url: 'http://...' # Additional references + + describe file('/tmp') do # The actual test + it { should be_directory } + end +end + +# you can also use plain tests +describe file('/tmp') do + it { should be_directory } +end diff --git a/test/unit/mock/profiles/old-examples/profile/controls/example.rb b/test/unit/mock/profiles/old-examples/profile/controls/example.rb index 02638b4a8..e2027d390 100644 --- a/test/unit/mock/profiles/old-examples/profile/controls/example.rb +++ b/test/unit/mock/profiles/old-examples/profile/controls/example.rb @@ -1,23 +1,35 @@ -# copyright: 2015, Chef Software, Inc. +# copyright: 2016, Chef Software, Inc. -title '/tmp profile' +title 'Example Config Checks' -# you add controls here -control 'tmp-1.0' do # A unique ID for this control - impact 0.7 # The criticality, if this control fails. - title 'Create /tmp directory' # A human-readable title - desc 'An optional description...' # Describe why this is needed - desc 'label', 'An optional description with a label' # Pair a part of the description with a label - tag data: 'temp data' # A tag allows you to associate key information - tag 'security' # to the test - ref 'Document A-12', url: 'http://...' # Additional references +# To pass the test, create the following file +# ```bash +# mkdir -p /tmp/example +# cat < /tmp/example/config.yaml +# version: '1.0' +# EOF +# ``` +control 'example-1.0' do + impact 'critical' + title 'Verify the version number of Example' + desc 'An optional description...' + tag 'example' + ref 'Example Requirements 1.0', uri: 'http://...' - describe file('/tmp') do # The actual test - it { should be_directory } + # Test using the custom example_config InSpec resource + # Find the resource content here: ../libraries/ + describe example_config do + it { should exist } + its('version') { should eq('1.0') } + its('file_size') { should <= 20 } + its('comma_count') { should eq 0 } + end + + # Test the version again to showcase variables + g = example_config + g_path = g.file_path + g_version = g.version + describe file(g_path) do + its('content') { should match g_version } end end - -# you can also use plain tests -describe file('/tmp') do - it { should be_directory } -end diff --git a/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb b/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb deleted file mode 100644 index e2027d390..000000000 --- a/test/unit/mock/profiles/old-examples/profile/controls/gordon.rb +++ /dev/null @@ -1,35 +0,0 @@ -# copyright: 2016, Chef Software, Inc. - -title 'Example Config Checks' - -# To pass the test, create the following file -# ```bash -# mkdir -p /tmp/example -# cat < /tmp/example/config.yaml -# version: '1.0' -# EOF -# ``` -control 'example-1.0' do - impact 'critical' - title 'Verify the version number of Example' - desc 'An optional description...' - tag 'example' - ref 'Example Requirements 1.0', uri: 'http://...' - - # Test using the custom example_config InSpec resource - # Find the resource content here: ../libraries/ - describe example_config do - it { should exist } - its('version') { should eq('1.0') } - its('file_size') { should <= 20 } - its('comma_count') { should eq 0 } - end - - # Test the version again to showcase variables - g = example_config - g_path = g.file_path - g_version = g.version - describe file(g_path) do - its('content') { should match g_version } - end -end diff --git a/test/unit/mock/profiles/old-examples/profile/libraries/gordon_config.rb b/test/unit/mock/profiles/old-examples/profile/libraries/example_config.rb similarity index 100% rename from test/unit/mock/profiles/old-examples/profile/libraries/gordon_config.rb rename to test/unit/mock/profiles/old-examples/profile/libraries/example_config.rb From 9e1a380f0a2a3c5a9d730b3e2d05c84a432a9e21 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 9 Oct 2019 00:27:23 -0700 Subject: [PATCH 03/56] Delete extra newline Signed-off-by: Miah Johnson --- examples/custom-resource/libraries/example.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/custom-resource/libraries/example.rb b/examples/custom-resource/libraries/example.rb index 8b123542f..7f14e88d3 100644 --- a/examples/custom-resource/libraries/example.rb +++ b/examples/custom-resource/libraries/example.rb @@ -11,7 +11,6 @@ class Example < Inspec.resource(1) 1 end - def has_a_fabulous_mustache? true end From ae3ee6f657eedcb8c616a6bd2499fb8a8e156115 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 10 Oct 2019 22:47:02 -0700 Subject: [PATCH 04/56] Finish rename of example -> example-tmp.rb Signed-off-by: Miah Johnson --- test/functional/helper.rb | 2 +- test/functional/inspec_exec_json_test.rb | 6 +++--- test/functional/inspec_json_profile_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/functional/helper.rb b/test/functional/helper.rb index 629d6eba5..a22af612e 100644 --- a/test/functional/helper.rb +++ b/test/functional/helper.rb @@ -84,7 +84,7 @@ module FunctionalHelper let(:example_profile) { File.join(examples_path, "profile") } let(:meta_profile) { File.join(examples_path, "meta-profile") } - let(:example_control) { File.join(example_profile, "controls", "example.rb") } + let(:example_control) { File.join(example_profile, "controls", "example-tmp.rb") } let(:inheritance_profile) { File.join(examples_path, "inheritance") } let(:failure_control) { File.join(profile_path, "failures", "controls", "failures.rb") } let(:simple_inheritance) { File.join(profile_path, "simple-inheritance") } diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index a6a349a2e..6aae5cfe7 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -137,7 +137,7 @@ describe "inspec exec with json formatter" do it "has all the metadata" do actual = profile.dup key = actual.delete("controls") - .find { |x| x["id"] =~ /generated from example.rb/ }["id"] + .find { |x| p x; x["id"] =~ /generated from example/ }["id"] groups = actual.delete("groups") _(actual).must_equal({ "name" => "profile", @@ -156,7 +156,7 @@ describe "inspec exec with json formatter" do }) _(groups.sort_by { |x| x["id"] }).must_equal([ - { "id" => "controls/example.rb", "title" => "/tmp profile", "controls" => ["tmp-1.0", key] }, + { "id" => "controls/example-tmp.rb", "title" => "/tmp profile", "controls" => ["tmp-1.0", key] }, { "id" => "controls/example.rb", "title" => "Example Config Checks", "controls" => ["example-1.0"] }, { "id" => "controls/meta.rb", "title" => "SSH Server Configuration", "controls" => ["ssh-1"] }, ]) @@ -180,7 +180,7 @@ describe "inspec exec with json formatter" do actual = ex1.dup src = actual.delete("source_location") - _(src["ref"]).must_match %r{test/unit/mock/profiles/old-examples/profile/controls/example.rb$} + _(src["ref"]).must_match %r{test/unit/mock/profiles/old-examples/profile/controls/example-tmp.rb$} _(src["line"]).must_equal 6 result = actual.delete("results")[0] diff --git a/test/functional/inspec_json_profile_test.rb b/test/functional/inspec_json_profile_test.rb index 01050f72c..7b74d56dc 100644 --- a/test/functional/inspec_json_profile_test.rb +++ b/test/functional/inspec_json_profile_test.rb @@ -73,7 +73,7 @@ describe "inspec json" do end it "has a source location" do - loc = File.join(example_profile, "/controls/example.rb") + loc = File.join(example_profile, "/controls/example-tmp.rb") _(control["source_location"]["ref"]).must_equal loc _(control["source_location"]["line"]).must_equal 6 end @@ -98,7 +98,7 @@ describe "inspec json" do _(json["controls"].length).must_equal 1 _(json["controls"][0]["id"]).must_equal "tmp-1.0" _(json["groups"].length).must_equal 1 - _(json["groups"][0]["id"]).must_equal "controls/example.rb" + _(json["groups"][0]["id"]).must_equal "controls/example-tmp.rb" end end From 41bc8fd7a0d168d0679f756e09fe48b81dd77aa7 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 10 Oct 2019 23:20:12 -0700 Subject: [PATCH 05/56] Clean up some tests Signed-off-by: Miah Johnson --- test/functional/helper.rb | 8 +++++++- test/functional/inspec_exec_json_test.rb | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/functional/helper.rb b/test/functional/helper.rb index a22af612e..86b469112 100644 --- a/test/functional/helper.rb +++ b/test/functional/helper.rb @@ -206,8 +206,14 @@ module FunctionalHelper if opts[:json] begin - run_result.payload.json = JSON.parse(run_result.stdout) + payload = JSON.parse(run_result.stdout) + + run_result.payload.json = payload rescue JSON::ParserError => e + warn "JSON PARSE ERROR: %s" % [e.message] + warn "OUT: <<%s>>" % [run_result.stdout] + warn "ERR: <<%s>>" % [run_result.stderr] + warn "XIT: %p" % [run_result.exit_status] run_result.payload.json = {} run_result.payload.json_error = e end diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index 6aae5cfe7..95ab26ce2 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -32,6 +32,8 @@ describe "inspec exec with json formatter" do it "can execute a simple file while using end of options after reporter cli option" do out = inspec("exec --no-create-lockfile --reporter json -- " + example_control) data = JSON.parse(out.stdout) + sout = Inspec::Schema.json('exec-json') + schema = JSON.parse(sout) _(JSON::Validator.validate(schema, data)).wont_equal false _(out.stderr).must_equal "" @@ -115,7 +117,8 @@ describe "inspec exec with json formatter" do end describe "execute a profile with json formatting" do - let(:json) { JSON.load(inspec("exec " + example_profile + " --reporter json --no-create-lockfile").stdout) } + let(:raw) { inspec("exec " + example_profile + " --reporter json --no-create-lockfile").stdout } + let(:json) { JSON.load(raw) } let(:profile) { json["profiles"][0] } let(:controls) { profile["controls"] } let(:ex1) { controls.find { |x| x["id"] == "tmp-1.0" } } @@ -134,11 +137,14 @@ describe "inspec exec with json formatter" do _(ex3["impact"]).must_equal 0.9 end + make_my_diffs_pretty! + it "has all the metadata" do actual = profile.dup key = actual.delete("controls") .find { |x| p x; x["id"] =~ /generated from example/ }["id"] groups = actual.delete("groups") + actual.delete("sha256") _(actual).must_equal({ "name" => "profile", "title" => "InSpec Example Profile", @@ -148,8 +154,6 @@ describe "inspec exec with json formatter" do "license" => "Apache-2.0", "summary" => "Demonstrates the use of InSpec Compliance Profile", "version" => "1.0.0", - # TODO: this is brittle and nonsensical - "sha256" => "de67a044d7be7090982740755ff582af1cefaf37261c5adda57b9502ffefc973", "supports" => [{ "platform-family" => "unix" }, { "platform-family" => "windows" }], "status" => "loaded", "attributes" => [], From 301905e8dec286e5d57a70fd79fbedaa7eb7272e Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Fri, 11 Oct 2019 00:02:49 -0700 Subject: [PATCH 06/56] b0rk b0rk Signed-off-by: Miah Johnson --- test/functional/inspec_exec_json_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index 95ab26ce2..808e7bba3 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -32,7 +32,7 @@ describe "inspec exec with json formatter" do it "can execute a simple file while using end of options after reporter cli option" do out = inspec("exec --no-create-lockfile --reporter json -- " + example_control) data = JSON.parse(out.stdout) - sout = Inspec::Schema.json('exec-json') + sout = Inspec::Schema.json("exec-json") schema = JSON.parse(sout) _(JSON::Validator.validate(schema, data)).wont_equal false From c3eb686b5169635c6fcc15342031dd82a4d5e64c Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Fri, 11 Oct 2019 00:37:26 -0700 Subject: [PATCH 07/56] Remove debug Signed-off-by: Miah Johnson --- test/functional/inspec_exec_json_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index 808e7bba3..1d013ec21 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -142,7 +142,7 @@ describe "inspec exec with json formatter" do it "has all the metadata" do actual = profile.dup key = actual.delete("controls") - .find { |x| p x; x["id"] =~ /generated from example/ }["id"] + .find { |x| x["id"] =~ /generated from example/ }["id"] groups = actual.delete("groups") actual.delete("sha256") _(actual).must_equal({ From 4ec9f302b0bca674b27d3b3246f476633db53636 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Tue, 15 Oct 2019 16:50:11 -0700 Subject: [PATCH 08/56] example -> example.tmp Signed-off-by: Miah Johnson --- test/functional/inspec_exec_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/inspec_exec_test.rb b/test/functional/inspec_exec_test.rb index 9eb93031e..27a8f7b6b 100644 --- a/test/functional/inspec_exec_test.rb +++ b/test/functional/inspec_exec_test.rb @@ -341,7 +341,7 @@ Test Summary: 0 successful, 0 failures, 0 skipped let(:out) { inspec("exec " + example_control + " --no-create-lockfile") } it "prints the control results, then the anonymous describe block results" do - _(stdout).must_match(/Profile: tests from .*test.unit.mock.profiles.old-examples.profile.controls.example.rb/) + _(stdout).must_match(/Profile: tests from .*test.unit.mock.profiles.old-examples.profile.controls.example-tmp.rb/) _(stdout).must_include " Version: (not specified) Target: local:// From d48bb56087f20871def5877bc67b02070da2f323 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Tue, 15 Oct 2019 16:51:05 -0700 Subject: [PATCH 09/56] Every other example has the value set to 1, so I changed this for consistency. Signed-off-by: Miah Johnson --- .../old-examples/custom-resource/libraries/batsignal.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/mock/profiles/old-examples/custom-resource/libraries/batsignal.rb b/test/unit/mock/profiles/old-examples/custom-resource/libraries/batsignal.rb index 9c1ab0486..61cb96365 100644 --- a/test/unit/mock/profiles/old-examples/custom-resource/libraries/batsignal.rb +++ b/test/unit/mock/profiles/old-examples/custom-resource/libraries/batsignal.rb @@ -3,7 +3,7 @@ class Batsignal < Inspec.resource(1) example " describe batsignal do - its('number_of_sightings)') { should eq '4' } + its('number_of_sightings)') { should eq '1' } end " @@ -15,6 +15,6 @@ class Batsignal < Inspec.resource(1) def local_command_call # call out to a core resource - inspec.command('echo 4').stdout.to_i + inspec.command('echo 1').stdout.to_i end end From 201d98fd26896b1ead30f4e4463daef7d3c57591 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Fri, 4 Oct 2019 17:06:21 -0700 Subject: [PATCH 10/56] Refactored and added an alternative test mock resource system. test/unit/resources/json_test.rb had the start of a setup to directly instantiate resources. I've refactored that up to helper.rb and extended it with some helper methods so we can directly specify what a resource command should respond with. For many/most of our tests, this should be sufficient. Finally, I switched our yum tests over to use the new setup. This will allow us to address #4517 and extend the tests for centos8 output differences with ease. Ease, folks... ease. Signed-off-by: Ryan Davis Cc: Miah Johnson --- test/helper.rb | 44 ++++++++++++++++++++++++++++++++ test/unit/resources/json_test.rb | 6 +---- test/unit/resources/yum_test.rb | 10 ++++++-- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 819ab062e..04c16732b 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -150,6 +150,50 @@ class Minitest::Test def skip_windows! skip_until 2019, 10, 30, "These have never passed" if windows? end + + ## + # This creates a real resource with default config/backend. + # + # Use this whenever possible. Let's phase out the MockLoader pain. + + def quick_resource(name, *args, &block) + backend = Inspec::Backend.create(Inspec::Config.new) + backend.extend Fake::Backend + + klass = Inspec::Resource.registry[name] + + instance = klass.new(backend, name, *args) + instance.extend Fake::Resource + instance.mock_command(&block) if block + instance + end +end + +module Fake + Command = Struct.new(:stdout, :stderr, :exit_status) + + module Backend + def stdout_file(path) + result(path, nil, 0) + end + + def stderr_file(path) + result(nil, path, 0) + end + + def result(stdout_path, stderr_path, exit) + stdout = stdout_path ? File.read(stdout_path) : "" + stderr = stderr_path ? File.read(stderr_path) : "" + + ::Fake::Command.new(stdout, stderr, 0) + end + end + + module Resource + def mock_command(&block) + inspec.define_singleton_method :command, &block + end + end end class InspecTest < Minitest::Test diff --git a/test/unit/resources/json_test.rb b/test/unit/resources/json_test.rb index 4d6863194..d14980e58 100644 --- a/test/unit/resources/json_test.rb +++ b/test/unit/resources/json_test.rb @@ -94,12 +94,8 @@ describe "Inspec::Resources::JSON" do # stdout:empty, stderr:msg # stdout:empty, stderr:empty - # TODO: abstract and push up def run_json_cmd(cmd) - backend = Inspec::Backend.create(Inspec::Config.new) - klass = Inspec::Resource.registry["json"] - - klass.new(backend, "json", command: cmd) + quick_resource("json", :linux, command: cmd) end # TODO: push up diff --git a/test/unit/resources/yum_test.rb b/test/unit/resources/yum_test.rb index e562ce2b4..bfc965d37 100644 --- a/test/unit/resources/yum_test.rb +++ b/test/unit/resources/yum_test.rb @@ -3,8 +3,14 @@ require "inspec/resource" require "inspec/resources/yum" describe "Inspec::Resources::YumRepo" do + let(:centos7) do + quick_resource("yum") do |cmd| + stdout_file "./test/unit/mock/cmd/yum-repolist-all" + end + end + it "get repository details" do - resource = MockLoader.new(:centos7).load_resource("yum") + resource = centos7 _(resource.repositories).must_equal [{ "id" => "base/7/x86_64", "name" => "CentOS-7 - Base", @@ -61,7 +67,7 @@ describe "Inspec::Resources::YumRepo" do end it "provides methods for retrieving per-repo information" do - resource = MockLoader.new(:centos7).load_resource("yum") + resource = centos7 repo = resource.repo("base/7/x86_64") _(repo.baseurl).must_equal "http://ftp.hosteurope.de/mirror/centos.org/7.1.1503/os/x86_64/ (9 more)" _(repo.expire).must_equal "21600 second(s) (last: Sun Sep 6 10:20:46 2015)" From fc8ea79ad0241955ddcd516f671fe9d230997ffe Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Fri, 4 Oct 2019 17:20:36 -0700 Subject: [PATCH 11/56] Fixed parsing yum output on centos8. * Renamed and added extra test data to distinguish between centos 7 & centos 8. * Renamed and added extra tests to cover centos 8. * Fixed missing repo data by checking at the end if we were still in parse mode. Fixes #4517 Signed-off-by: Ryan Davis Cc: Miah Johnson --- lib/inspec/resources/yum.rb | 3 ++ test/helpers/mock_loader.rb | 8 +-- ...-repolist-all => yum-centos7-repolist-all} | 0 test/unit/mock/cmd/yum-centos8-repolist-all | 50 +++++++++++++++++++ test/unit/resources/yum_test.rb | 21 ++++++-- 5 files changed, 75 insertions(+), 7 deletions(-) rename test/unit/mock/cmd/{yum-repolist-all => yum-centos7-repolist-all} (100%) create mode 100644 test/unit/mock/cmd/yum-centos8-repolist-all diff --git a/lib/inspec/resources/yum.rb b/lib/inspec/resources/yum.rb index 195f59f47..51427dfc2 100644 --- a/lib/inspec/resources/yum.rb +++ b/lib/inspec/resources/yum.rb @@ -70,6 +70,9 @@ module Inspec::Resources repo[repo_key(strip(val[1]))] = strip(val[2]) end end + + @cache.push(repo) if in_repo + @cache end diff --git a/test/helpers/mock_loader.rb b/test/helpers/mock_loader.rb index 2af32b06b..c17ec5401 100644 --- a/test/helpers/mock_loader.rb +++ b/test/helpers/mock_loader.rb @@ -1,11 +1,12 @@ class MockLoader # collects emulation operating systems - OPERATING_SYSTEMS = { + OPERATING_SYSTEMS = { # rubocop:disable Style/MutableConstant alpine: { name: "alpine", family: "alpine", release: "3.6.2", arch: "x86_64" }, arch: { name: "arch", family: "arch", release: nil, arch: nil }, centos5: { name: "centos", family: "redhat", release: "5.11", arch: "x86_64" }, centos6: { name: "centos", family: "redhat", release: "6.6", arch: "x86_64" }, centos7: { name: "centos", family: "redhat", release: "7.1.1503", arch: "x86_64" }, + centos8: { name: "centos", family: "redhat", release: "8.9.10", arch: "x86_64" }, cloudlinux: { name: "cloudlinux", family: "redhat", release: "7.4", arch: "x86_64" }, coreos: { name: "coreos", family: "coreos", release: "1437.0.0", arch: "x86_64" }, debian6: { name: "debian", family: "debian", release: "6", arch: "x86_64" }, @@ -30,7 +31,9 @@ class MockLoader amazon: { name: "amazon", family: "redhat", release: "2015.03", arch: "x86_64" }, amazon2: { name: "amazon", family: "redhat", release: "2", arch: "x86_64" }, undefined: { name: nil, family: nil, release: nil, arch: nil }, - }.freeze + } + + OPERATING_SYSTEMS[:linux] = OPERATING_SYSTEMS[:ubuntu1604] # pass the os identifier to emulate a specific operating system def initialize(os = :ubuntu1404) @@ -209,7 +212,6 @@ class MockLoader "Auditpol /get /subcategory:'User Account Management' /r" => cmd.call("auditpol"), "/sbin/auditctl -l" => cmd.call("auditctl"), "/sbin/auditctl -s" => cmd.call("auditctl-s"), - "yum -v repolist all" => cmd.call("yum-repolist-all"), "dpkg -s curl" => cmd.call("dpkg-s-curl"), "dpkg -s held-package" => cmd.call("dpkg-s-held-package"), "rpm -qi curl" => cmd.call("rpm-qi-curl"), diff --git a/test/unit/mock/cmd/yum-repolist-all b/test/unit/mock/cmd/yum-centos7-repolist-all similarity index 100% rename from test/unit/mock/cmd/yum-repolist-all rename to test/unit/mock/cmd/yum-centos7-repolist-all diff --git a/test/unit/mock/cmd/yum-centos8-repolist-all b/test/unit/mock/cmd/yum-centos8-repolist-all new file mode 100644 index 000000000..bef477cbb --- /dev/null +++ b/test/unit/mock/cmd/yum-centos8-repolist-all @@ -0,0 +1,50 @@ +Config time: 0.006 +Yum version: 3.4.3 +base | 3.6 kB 00:00:00 +epel/x86_64/metalink | 26 kB 00:00:00 +epel | 4.3 kB 00:00:00 +extras | 3.4 kB 00:00:00 +updates | 3.4 kB 00:00:00 +(1/3): epel/x86_64/group_gz | 169 kB 00:00:00 +epel/x86_64/primary_db FAILED +https://ftp.fau.de/epel/7/x86_64/repodata/ccbc93c2ab37b82a6376c9562d2aec27b81112bc3c943e1871f7ed0318fe24b9-primary.sqlite.xz: [Errno 14] HTTPS Error 404 - Not Found +Trying other mirror. +(2/3): epel/x86_64/updateinfo | 349 kB 00:00:00 +(3/3): epel/x86_64/primary_db | 3.5 MB 00:00:04 +Loading mirror speeds from cached hostfile + * base: ftp.hosteurope.de + * epel: ftp-stud.hs-esslingen.de + * extras: mirror.informatik.hs-fulda.de + * updates: mirror.softaculous.com +Setting up Package Sacks +pkgsack time: 0.005 +Repo-id : base/7/x86_64 +Repo-name : CentOS-7 - Base +Repo-status : enabled +Repo-revision: 1427842153 +Repo-updated : Tue Mar 31 22:50:46 2015 +Repo-pkgs : 8652 +Repo-size : 6.3 G +Repo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock +Repo-baseurl : http://ftp.hosteurope.de/mirror/centos.org/7.1.1503/os/x86_64/ (9 more) +Repo-expire : 21600 second(s) (last: Sun Sep 6 10:20:46 2015) +Repo-filename: /etc/yum.repos.d/CentOS-Base.repo + +Repo-id : base-debuginfo/x86_64 +Repo-name : CentOS-7 - Debuginfo +Repo-status : disabled +Repo-baseurl : http://debuginfo.centos.org/7/x86_64/ +Repo-expire : 21600 second(s) (last: Unknown) +Repo-filename: /etc/yum.repos.d/CentOS-Debuginfo.repo + +Repo-id : extras/7/x86_64 +Repo-name : CentOS-7 - Extras +Repo-status : enabled +Repo-revision: 1441314199 +Repo-updated : Thu Sep 3 21:03:33 2015 +Repo-pkgs : 181 +Repo-size : 742 M +Repo-mirrors : http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock +Repo-baseurl : http://mirror.informatik.hs-fulda.de/centos7.1.1503/extras/x86_64/ (9 more) +Repo-expire : 21600 second(s) (last: Sun Sep 6 10:20:48 2015) +Repo-filename: /etc/yum.repos.d/CentOS-Base.repo diff --git a/test/unit/resources/yum_test.rb b/test/unit/resources/yum_test.rb index bfc965d37..028c8843c 100644 --- a/test/unit/resources/yum_test.rb +++ b/test/unit/resources/yum_test.rb @@ -4,13 +4,18 @@ require "inspec/resources/yum" describe "Inspec::Resources::YumRepo" do let(:centos7) do - quick_resource("yum") do |cmd| - stdout_file "./test/unit/mock/cmd/yum-repolist-all" + quick_resource("yum", :centos7) do |cmd| + stdout_file "./test/unit/mock/cmd/yum-centos7-repolist-all" end end - it "get repository details" do - resource = centos7 + let(:centos8) do + quick_resource("yum", :centos8) do |cmd| + stdout_file "./test/unit/mock/cmd/yum-centos8-repolist-all" + end + end + + def assert_repositories(resource) _(resource.repositories).must_equal [{ "id" => "base/7/x86_64", "name" => "CentOS-7 - Base", @@ -66,6 +71,14 @@ describe "Inspec::Resources::YumRepo" do _(extras.to_s).must_equal "YumRepo base-debuginfo/x86_64" end + it "get repository details centos7" do + assert_repositories centos7 + end + + it "get repository details centos8" do + assert_repositories centos8 + end + it "provides methods for retrieving per-repo information" do resource = centos7 repo = resource.repo("base/7/x86_64") From fe34eb7869bab6d2cd8601dbb4b9f5311ed411f3 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Fri, 4 Oct 2019 17:31:50 -0700 Subject: [PATCH 12/56] Moved quick_resource and Fake helpers to test/helpers/resources.rb Signed-off-by: Ryan Davis --- test/helper.rb | 45 +----------------------------- test/helpers/resources.rb | 58 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 44 deletions(-) create mode 100644 test/helpers/resources.rb diff --git a/test/helper.rb b/test/helper.rb index 04c16732b..2885c46d5 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -70,6 +70,7 @@ require "mocha/setup" require "inspec/log" require "inspec/backend" require "helpers/mock_loader" +require "helpers/resources" TMP_CACHE = {} # rubocop: disable Style/MutableConstant @@ -150,50 +151,6 @@ class Minitest::Test def skip_windows! skip_until 2019, 10, 30, "These have never passed" if windows? end - - ## - # This creates a real resource with default config/backend. - # - # Use this whenever possible. Let's phase out the MockLoader pain. - - def quick_resource(name, *args, &block) - backend = Inspec::Backend.create(Inspec::Config.new) - backend.extend Fake::Backend - - klass = Inspec::Resource.registry[name] - - instance = klass.new(backend, name, *args) - instance.extend Fake::Resource - instance.mock_command(&block) if block - instance - end -end - -module Fake - Command = Struct.new(:stdout, :stderr, :exit_status) - - module Backend - def stdout_file(path) - result(path, nil, 0) - end - - def stderr_file(path) - result(nil, path, 0) - end - - def result(stdout_path, stderr_path, exit) - stdout = stdout_path ? File.read(stdout_path) : "" - stderr = stderr_path ? File.read(stderr_path) : "" - - ::Fake::Command.new(stdout, stderr, 0) - end - end - - module Resource - def mock_command(&block) - inspec.define_singleton_method :command, &block - end - end end class InspecTest < Minitest::Test diff --git a/test/helpers/resources.rb b/test/helpers/resources.rb new file mode 100644 index 000000000..4e27b2c7d --- /dev/null +++ b/test/helpers/resources.rb @@ -0,0 +1,58 @@ +class Minitest::Test + ## + # This creates a real resource with default config/backend. + # + # Use this whenever possible. Let's phase out the MockLoader pain. + + def quick_resource(name, platform = :linux, *args, &block) + backend = Inspec::Backend.create(Inspec::Config.new) + backend.extend Fake::Backend + + os = MockLoader::OPERATING_SYSTEMS[platform] + raise "Unknown platform: %p" % [platform] unless os + + # mock.mock_os(@platform) + platform = Train::Platforms.name(os[:name]) + platform.find_family_hierarchy # TODO: remove? UGH! adds platform= + platform.platform = os + # platform.add_platform_methods # TODO: remove? + # TODO: this should have a setter + # TODO: backend.backend is the WORST name + backend.backend.instance_variable_set :@platform, platform + # end mock.mock_os + + klass = Inspec::Resource.registry[name] + + instance = klass.new(backend, name, *args) + instance.extend Fake::Resource + instance.mock_command(&block) if block + instance + end +end + +module Fake + Command = Struct.new(:stdout, :stderr, :exit_status) + + module Backend + def stdout_file(path) + result(path, nil, 0) + end + + def stderr_file(path) + result(nil, path, 0) + end + + def result(stdout_path, stderr_path, exit) + stdout = stdout_path ? File.read(stdout_path) : "" + stderr = stderr_path ? File.read(stderr_path) : "" + + ::Fake::Command.new(stdout, stderr, 0) + end + end + + module Resource + def mock_command(&block) + inspec.define_singleton_method :command, &block + end + end +end From 498cbb7e84c5fbeea10b817eb20e61f72d06dfff Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 18:25:29 -0700 Subject: [PATCH 13/56] Add a test pipeline for habitat builds. Signed-off-by: Miah Johnson --- .expeditor/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 72bc05f34..43e75924e 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -18,6 +18,8 @@ docker_images: pipelines: - habitat/build + - habitat/test: + definition: .expeditor/habitat_test.yml - omnibus/release - omnibus/adhoc: definition: .expeditor/release.omnibus.yml From c1f6df1500dcd6a678dde1c9dfbd952d5c86957f Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 19:55:54 -0700 Subject: [PATCH 14/56] Add windows to build_targets on builder Signed-off-by: Miah Johnson --- .bldr.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bldr.toml b/.bldr.toml index 94467665b..e75ed46b2 100644 --- a/.bldr.toml +++ b/.bldr.toml @@ -1,5 +1,6 @@ [inspec] build_targets = [ + "x86_64-windows", "x86_64-linux", "x86_64-linux-kernel2" -] \ No newline at end of file +] From 002e274d8e01a5c8956b4993011131f1a5544988 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 19:56:47 -0700 Subject: [PATCH 15/56] Pipeline definition for testing habitat builds Signed-off-by: Miah Johnson --- .expeditor/habitat_test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .expeditor/habitat_test.yml diff --git a/.expeditor/habitat_test.yml b/.expeditor/habitat_test.yml new file mode 100644 index 000000000..ebb3ace4d --- /dev/null +++ b/.expeditor/habitat_test.yml @@ -0,0 +1,21 @@ +--- +steps: + +- label: ":linux: Validate Habitat Builds of Chef Infra" + commands: + - /workdir/.expeditor/buildkite/habitat_test.sh + expeditor: + executor: + linux: + privileged: true + single-use: true + +- label: ":windows: Validate Habitat Builds of Chef Infra" + commands: + - /workdir/.expeditor/buildkite/habitat_test.ps1 + expeditor: + executor: + windows: + os-version: 2016 + privileged: true + single-use: true From 544db45c5edad6b370f5600bf321df5341e4e691 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 19:57:45 -0700 Subject: [PATCH 16/56] Untested and probably broken test scripts =) Signed-off-by: Miah Johnson --- .expeditor/buildkite/habitat_test.ps1 | 36 +++++++++++++++++++++++++++ .expeditor/buildkite/habitat_test.sh | 33 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .expeditor/buildkite/habitat_test.ps1 create mode 100644 .expeditor/buildkite/habitat_test.sh diff --git a/.expeditor/buildkite/habitat_test.ps1 b/.expeditor/buildkite/habitat_test.ps1 new file mode 100644 index 000000000..f2df8cb31 --- /dev/null +++ b/.expeditor/buildkite/habitat_test.ps1 @@ -0,0 +1,36 @@ +#!/usr/bin/env powershell + +#Requires -Version 5 + +$env:HAB_ORIGIN = 'ci' +$Plan = 'inspec' + +Write-Host "--- system details" +$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture' +Get-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize + +Write-Host "--- Installing the version of Habitat required" +Install-Habitat --version 0.85.0.20190916 + +Write-Host "--- Generating fake origin key" +hab origin key generate $env:HAB_ORIGIN + +Write-Host "--- Building $Plan" +$project_root = "$(git rev-parse --show-toplevel)" +Set-Location $project_root + +$env:DO_CHECK=$true; hab pkg build . +if (-not $?) { throw "unable to build" } + +. results/last_build.ps1 +if (-not $?) { throw "unable to determine details about this build" } + +Write-Host "--- Installing $pkg_ident" +hab pkg install results/$pkg_artifact +if (-not $?) { throw "unable to install this build" } + +Write-Host "+++ Testing $Plan" +Push-Location $project_root/test/artifact +rake +if (-not $?) { throw "rake failed" } +Pop-Location diff --git a/.expeditor/buildkite/habitat_test.sh b/.expeditor/buildkite/habitat_test.sh new file mode 100644 index 000000000..8d4d4198a --- /dev/null +++ b/.expeditor/buildkite/habitat_test.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -ueo pipefail + +export HAB_ORIGIN='ci' +export PLAN='inspec' + +echo "--- system details" +uname -a + +echo "--- Installing the version of Habitat required" +# Install-Habitat --version 0.85.0.20190916 +# TODO: Install Hab? +hab --version + +echo "--- Generating fake origin key" +hab origin key generate ${HAB_ORIGIN} + +echo "--- Building $PLAN" +project_root="$(git rev-parse --show-toplevel)" +cd "$project_root" + +DO_CHECK=true hab pkg build . + +. results/last_build.sh + +echo "--- Installing $pkg_ident" +hab pkg install "results/$pkg_artifact" + +echo "+++ Testing $PLAN" +pushd "$project_root/test/artifact" +rake +popd From 005bca0f45f0fb26c99d4329973181f30a0d529e Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 20:13:54 -0700 Subject: [PATCH 17/56] copy-pasta Signed-off-by: Miah Johnson --- .expeditor/habitat_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.expeditor/habitat_test.yml b/.expeditor/habitat_test.yml index ebb3ace4d..6b40e5d23 100644 --- a/.expeditor/habitat_test.yml +++ b/.expeditor/habitat_test.yml @@ -1,7 +1,7 @@ --- steps: -- label: ":linux: Validate Habitat Builds of Chef Infra" +- label: ":linux: Validate Habitat Builds of Chef InSpec" commands: - /workdir/.expeditor/buildkite/habitat_test.sh expeditor: @@ -10,7 +10,7 @@ steps: privileged: true single-use: true -- label: ":windows: Validate Habitat Builds of Chef Infra" +- label: ":windows: Validate Habitat Builds of Chef InSpec" commands: - /workdir/.expeditor/buildkite/habitat_test.ps1 expeditor: From 6f460b9c3b5c10025081cb14e157bd0e4a3c26df Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 20:57:31 -0700 Subject: [PATCH 18/56] Remove this. It slows things down. Signed-off-by: Miah Johnson --- test/functional/inspec_exec_json_test.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/functional/inspec_exec_json_test.rb b/test/functional/inspec_exec_json_test.rb index 1d013ec21..8e446cf94 100644 --- a/test/functional/inspec_exec_json_test.rb +++ b/test/functional/inspec_exec_json_test.rb @@ -137,8 +137,6 @@ describe "inspec exec with json formatter" do _(ex3["impact"]).must_equal 0.9 end - make_my_diffs_pretty! - it "has all the metadata" do actual = profile.dup key = actual.delete("controls") From 01bea50c43adb72b425a833f3353be79a37dfc7a Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 10 Jul 2019 21:53:55 -0700 Subject: [PATCH 19/56] copy paste plan.sh -> plan.ps1 and change for Powershell Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 habitat/plan.ps1 diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 new file mode 100644 index 000000000..0f6544352 --- /dev/null +++ b/habitat/plan.ps1 @@ -0,0 +1,56 @@ +$pkg_name="inspec" +$pkg_origin="chef" +$pkg_version=$(cat "$PLAN_CONTEXT/../VERSION") +$pkg_description="InSpec is an open-source testing framework for infrastructure + with a human- and machine-readable language for specifying compliance, + security and policy requirements." +$pkg_upstream_url="https://www.inspec.io/" +$pkg_maintainer="The Habitat Maintainers " +$pkg_license=('Apache-2.0') +$pkg_deps=@( + "core/coreutils", + "core/cacerts", + "core/git", + "core/ruby", + "core/bash" +) +$pkg_build_deps=@( + "core/gcc", + "core/make", + "core/readline", + "core/sed" +) +$pkg_bin_dirs=@("bin") + +do_setup_environment() { + build_line 'Setting GEM_HOME="$pkg_prefix/lib"' + export GEM_HOME="$pkg_prefix/lib" + + build_line "Setting GEM_PATH=$GEM_HOME" + export GEM_PATH="$GEM_HOME" +} + +function Invoke-Unpack { + mkdir "$HAB_CACHE_SRC_PATH/$pkg_dirname" + Copy-Item "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" -Recurse +} + +function Invoke-Build { + Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + gem build inspec.gemspec + Pop-Location + Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin" + gem build inspec-bin.gemspec + Pop-Location +} + +function Invoke-Install { + # MUST install inspec first because inspec-bin depends on it via gemspec + Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/" + gem install inspec-*.gem --no-document + Pop-Location + + Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin" + gem install inspec-bin*.gem --no-document + Pop-Location +} \ No newline at end of file From e9cca66b1ceab20051870c83831dec3cc79036b6 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 10 Jul 2019 21:59:30 -0700 Subject: [PATCH 20/56] basics Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 8 -------- 1 file changed, 8 deletions(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 0f6544352..381e81a5d 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -22,14 +22,6 @@ $pkg_build_deps=@( ) $pkg_bin_dirs=@("bin") -do_setup_environment() { - build_line 'Setting GEM_HOME="$pkg_prefix/lib"' - export GEM_HOME="$pkg_prefix/lib" - - build_line "Setting GEM_PATH=$GEM_HOME" - export GEM_PATH="$GEM_HOME" -} - function Invoke-Unpack { mkdir "$HAB_CACHE_SRC_PATH/$pkg_dirname" Copy-Item "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" -Recurse From 1b41dfb12e6a69864e82ebb4519f4cefe822e3ef Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 10 Jul 2019 22:08:51 -0700 Subject: [PATCH 21/56] wip? Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 381e81a5d..2005f230a 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -1,5 +1,5 @@ $pkg_name="inspec" -$pkg_origin="chef" +$pkg_origin="miah" $pkg_version=$(cat "$PLAN_CONTEXT/../VERSION") $pkg_description="InSpec is an open-source testing framework for infrastructure with a human- and machine-readable language for specifying compliance, From aa87212e9fc12e3ccd1257038fefb13c0df6a0a4 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Mon, 16 Sep 2019 17:46:35 -0700 Subject: [PATCH 22/56] Basically cargo-copy https://github.com/chef/chef/blob/habiwindochef/habitat/plan.ps1 Thanks @robbkidd =) Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 106 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 28 deletions(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 2005f230a..263d0bfb9 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -1,48 +1,98 @@ $pkg_name="inspec" $pkg_origin="miah" $pkg_version=$(cat "$PLAN_CONTEXT/../VERSION") +$pkg_revision="1" $pkg_description="InSpec is an open-source testing framework for infrastructure with a human- and machine-readable language for specifying compliance, security and policy requirements." $pkg_upstream_url="https://www.inspec.io/" $pkg_maintainer="The Habitat Maintainers " $pkg_license=('Apache-2.0') + $pkg_deps=@( - "core/coreutils", - "core/cacerts", - "core/git", - "core/ruby", - "core/bash" -) -$pkg_build_deps=@( - "core/gcc", - "core/make", - "core/readline", - "core/sed" + "core/cacerts" + "robbkidd/ruby-plus-devkit/2.6.3" ) $pkg_bin_dirs=@("bin") +$project_root= (Resolve-Path "$PLAN_CONTEXT/../").Path -function Invoke-Unpack { - mkdir "$HAB_CACHE_SRC_PATH/$pkg_dirname" - Copy-Item "$PLAN_CONTEXT"/.. "$HAB_CACHE_SRC_PATH/$pkg_dirname/" -Recurse +function Invoke-SetupEnvironment { + Push-RuntimeEnv -IsPath GEM_PATH "$pkg_prefix/vendor" + + Set-RuntimeEnv APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH + Set-RuntimeEnv -IsPath SSL_CERT_FILE "$(Get-HabPackagePath cacerts)/ssl/cert.pem" + Set-RuntimeEnv LANG "en_US.UTF-8" + Set-RuntimeEnv LC_CTYPE "en_US.UTF-8" } function Invoke-Build { - Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/" - gem build inspec.gemspec - Pop-Location - Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin" - gem build inspec-bin.gemspec - Pop-Location + try { + Push-Location $project_root + $env:GEM_HOME = "$HAB_CACHE_SRC_PATH/$pkg_dirname/vendor" + + Write-BuildLine " ** Configuring bundler for this build environment" + bundle config --local without integration deploy maintenance + bundle config --local jobs 4 + + Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies" + bundle install + Write-BuildLine " ** Running the inspec project's 'rake install' to install the path-based gems so they look like any other installed gem." + bundle exec rake install # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler + Write-BuildLine " ** Also 'rake install' any gem sourced as a git reference." + foreach($git_gem in (Get-ChildItem "$env:GEM_HOME/bundler/gems")) { + try { + Push-Location $git_gem + Write-BuildLine " -- and $git_gem too" + rake install # this needs to NOT be 'bundle exec'd else bundler complains about dev deps not being installed + } finally { + Pop-Location + } + } + } finally { + Pop-Location + } } function Invoke-Install { - # MUST install inspec first because inspec-bin depends on it via gemspec - Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/" - gem install inspec-*.gem --no-document - Pop-Location + Write-BuildLine "** Copy built & cached gems to install directory" + Copy-Item -Path "$HAB_CACHE_SRC_PATH/$pkg_dirname/*" -Destination $pkg_prefix -Recurse -Force -Exclude @("gem_make.out", "mkmf.log", "Makefile") - Push-Location "$HAB_CACHE_SRC_PATH/$pkg_dirname/inspec-bin" - gem install inspec-bin*.gem --no-document - Pop-Location -} \ No newline at end of file + try { + Push-Location $pkg_prefix + bundle config --local gemfile $project_root/Gemfile + foreach($gem in ("inspec-bin", "inspec")) { + Write-BuildLine "** generating binstubs for $gem with precise version pins" + Invoke-Expression -Command "appbundler.bat $project_root $pkg_prefix/bin $gem" + } + Remove-StudioPathFrom -File $pkg_prefix/vendor/gems/inspec-$pkg_version*/Gemfile + } finally { + Pop-Location + # forget about the build bundle config + Remove-Item $pkg_prefix/.bundle -Recurse -Force + } +} + +function Invoke-After { + # Trim the fat before packaging + + # We don't need the cache of downloaded .gem files ... + Remove-Item $pkg_prefix/vendor/cache -Recurse -Force + # ... or bundler's cache of git-ref'd gems + Remove-Item $pkg_prefix/vendor/bundler -Recurse -Force + + # We don't need the gem docs. + Remove-Item $pkg_prefix/vendor/doc -Recurse -Force + # We don't need to ship the test suites for every gem dependency, + # only inspec's for package verification. + Get-ChildItem $pkg_prefix/vendor/gems -Filter "spec" -Directory -Recurse -Depth 1 ` + | Where-Object -FilterScript { $_.FullName -notlike "*inspec*" } ` + | Remove-Item -Recurse -Force +} +function Remove-StudioPathFrom { + Param( + [Parameter(Mandatory=$true)] + [String] + $File + ) + (Get-Content $File) -replace ($env:FS_ROOT -replace "\\","/"),"" | Set-Content $File +} From 9f9dc504f03a905b86bc850c24155f998ac28c58 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Mon, 16 Sep 2019 18:23:34 -0700 Subject: [PATCH 23/56] Add Rakefile to inspec-bin to allow `rake install` to function. Without the Rakefile `rake install` looped forever. Signed-off-by: Miah Johnson --- inspec-bin/Rakefile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 inspec-bin/Rakefile diff --git a/inspec-bin/Rakefile b/inspec-bin/Rakefile new file mode 100644 index 000000000..f7703a3a3 --- /dev/null +++ b/inspec-bin/Rakefile @@ -0,0 +1,10 @@ +Bundler::GemHelper.install_tasks(name: "inspec-bin") + +desc "force install the inspec-bin gem" +task "install:force" do + sh "gem build -V inspec-bin.gemspec" + built_gem_path = Dir["inspec-bin-*.gem"].sort_by { |f| File.mtime(f) }.last + FileUtils.mkdir_p("pkg") unless Dir.exist?("pkg") + FileUtils.mv(built_gem_path, "pkg") + sh "gem install -f pkg/#{built_gem_path}" +end From 76cf8aafea1c4d8a7bc7bb2f292af7952de52497 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Tue, 17 Sep 2019 16:09:54 -0700 Subject: [PATCH 24/56] We have no gems using a git reference. This stacktraces during build. Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 263d0bfb9..7454241f3 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -38,16 +38,6 @@ function Invoke-Build { bundle install Write-BuildLine " ** Running the inspec project's 'rake install' to install the path-based gems so they look like any other installed gem." bundle exec rake install # this needs to be 'bundle exec'd because a Rakefile makes reference to Bundler - Write-BuildLine " ** Also 'rake install' any gem sourced as a git reference." - foreach($git_gem in (Get-ChildItem "$env:GEM_HOME/bundler/gems")) { - try { - Push-Location $git_gem - Write-BuildLine " -- and $git_gem too" - rake install # this needs to NOT be 'bundle exec'd else bundler complains about dev deps not being installed - } finally { - Pop-Location - } - } } finally { Pop-Location } From 0ca4e66bc64dfbece287ec1c9c418735ea7d73df Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Tue, 17 Sep 2019 16:52:31 -0700 Subject: [PATCH 25/56] Add vendor/bin to pkg directories, should let us get appbundler. Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 7454241f3..36a1710ad 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -13,7 +13,8 @@ $pkg_deps=@( "core/cacerts" "robbkidd/ruby-plus-devkit/2.6.3" ) -$pkg_bin_dirs=@("bin") +$pkg_bin_dirs=@("bin" + "vendor/bin") $project_root= (Resolve-Path "$PLAN_CONTEXT/../").Path function Invoke-SetupEnvironment { From 8b9bb3983aa4edd55ee2fad140b719008096f026 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Tue, 17 Sep 2019 16:57:52 -0700 Subject: [PATCH 26/56] Shouldn't have a cache of git-ref'd gems as we dont have any. Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 36a1710ad..ed0dd34b4 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -68,8 +68,6 @@ function Invoke-After { # We don't need the cache of downloaded .gem files ... Remove-Item $pkg_prefix/vendor/cache -Recurse -Force - # ... or bundler's cache of git-ref'd gems - Remove-Item $pkg_prefix/vendor/bundler -Recurse -Force # We don't need the gem docs. Remove-Item $pkg_prefix/vendor/doc -Recurse -Force From 4544ff30aa4fad43e547c5aa72ef0dc9342242ac Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 18 Sep 2019 16:52:34 -0700 Subject: [PATCH 27/56] Add a very simple test for Windows Habitat builds. Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 4 ++++ test/artifact/README.md | 5 +++++ test/artifact/inspec_detect_test.rb | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 test/artifact/README.md create mode 100644 test/artifact/inspec_detect_test.rb diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index ed0dd34b4..94c453975 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -63,6 +63,10 @@ function Invoke-Install { } } +function Invoke-Verify { + rake test/artifact +} + function Invoke-After { # Trim the fat before packaging diff --git a/test/artifact/README.md b/test/artifact/README.md new file mode 100644 index 000000000..1a5eb3d97 --- /dev/null +++ b/test/artifact/README.md @@ -0,0 +1,5 @@ +# InSpec Artifact test suite + +A minimal set of tests to validate functionality after 'build'. + +Execute this after building InSpec artifacts with omnibus, habitat, or another system. diff --git a/test/artifact/inspec_detect_test.rb b/test/artifact/inspec_detect_test.rb new file mode 100644 index 000000000..68e5c7633 --- /dev/null +++ b/test/artifact/inspec_detect_test.rb @@ -0,0 +1,12 @@ +require "minitest/autorun" + +class TestArtifactDetect < Minitest::Test + def test_detect + out, err = capture_subprocess_io { + assert system("inspec detect --no-color") + } + + assert_match %r%Platform Details%, out + assert_empty + end err +end From 9543ed8ecc960f21842839a48a8a35cc39038e23 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 18 Sep 2019 17:11:14 -0700 Subject: [PATCH 28/56] Add a Rakefile as our main Rakefile also requires 'train' Signed-off-by: Miah Johnson --- test/artifact/Rakefile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 test/artifact/Rakefile diff --git a/test/artifact/Rakefile b/test/artifact/Rakefile new file mode 100644 index 000000000..98f42fc5e --- /dev/null +++ b/test/artifact/Rakefile @@ -0,0 +1,5 @@ +require "rake/testtask" + +Rake::TestTask.new(:default) do |t| + t.test_files = Dir["test/artifact/*_test.rb"].sort +end From d7487ed70a00088eb144d69288a3b9d4fa82e1f9 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 18 Sep 2019 17:12:43 -0700 Subject: [PATCH 29/56] Execute the correct rake task Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 94c453975..b1fd1e85e 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -64,7 +64,9 @@ function Invoke-Install { } function Invoke-Verify { - rake test/artifact + Push-Location $project_root/test/artfifact + rake + Pop-Location } function Invoke-After { From d3cfb38dc2317effbef51a4537627e82db323a2a Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 18 Sep 2019 17:14:02 -0700 Subject: [PATCH 30/56] Invoke-Check is used for testing.. Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index b1fd1e85e..75d319626 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -63,7 +63,7 @@ function Invoke-Install { } } -function Invoke-Verify { +function Invoke-Check { Push-Location $project_root/test/artfifact rake Pop-Location From 0589e2edc92163968f9ce64a5e9d8a5343a53ca5 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 18 Sep 2019 17:36:07 -0700 Subject: [PATCH 31/56] hooked on phonics worked for me! Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 75d319626..a990e77c2 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -64,7 +64,7 @@ function Invoke-Install { } function Invoke-Check { - Push-Location $project_root/test/artfifact + Push-Location $project_root/test/artifact rake Pop-Location } From 46e7b00addf42f67e55ca2844b21fc399e82d5e4 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 18 Sep 2019 18:19:51 -0700 Subject: [PATCH 32/56] Fix Rakefile and wtf Signed-off-by: Miah Johnson --- test/artifact/Rakefile | 6 ++++-- test/artifact/inspec_detect_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/artifact/Rakefile b/test/artifact/Rakefile index 98f42fc5e..d69be4fb3 100644 --- a/test/artifact/Rakefile +++ b/test/artifact/Rakefile @@ -1,5 +1,7 @@ require "rake/testtask" -Rake::TestTask.new(:default) do |t| - t.test_files = Dir["test/artifact/*_test.rb"].sort +Rake::TestTask.new(:test) do |t| + t.test_files = FileList["*_test.rb"].sort end + +task default: :test diff --git a/test/artifact/inspec_detect_test.rb b/test/artifact/inspec_detect_test.rb index 68e5c7633..50870398b 100644 --- a/test/artifact/inspec_detect_test.rb +++ b/test/artifact/inspec_detect_test.rb @@ -7,6 +7,6 @@ class TestArtifactDetect < Minitest::Test } assert_match %r%Platform Details%, out - assert_empty - end err + assert_empty err + end end From ff7891132a969100883604302417cdfee052e335 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 20:25:54 -0700 Subject: [PATCH 33/56] Cleanup plan before merge Signed-off-by: Miah Johnson --- habitat/plan.ps1 | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index a990e77c2..20289a7a1 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -1,17 +1,17 @@ $pkg_name="inspec" -$pkg_origin="miah" -$pkg_version=$(cat "$PLAN_CONTEXT/../VERSION") +$pkg_origin="chef" +$pkg_version=$(Get-Content "$PLAN_CONTEXT/../VERSION") $pkg_revision="1" $pkg_description="InSpec is an open-source testing framework for infrastructure with a human- and machine-readable language for specifying compliance, security and policy requirements." $pkg_upstream_url="https://www.inspec.io/" -$pkg_maintainer="The Habitat Maintainers " +$pkg_maintainer="The Chef Maintainers " $pkg_license=('Apache-2.0') $pkg_deps=@( "core/cacerts" - "robbkidd/ruby-plus-devkit/2.6.3" + "robbkidd/ruby-plus-devkit" ) $pkg_bin_dirs=@("bin" "vendor/bin") @@ -63,18 +63,9 @@ function Invoke-Install { } } -function Invoke-Check { - Push-Location $project_root/test/artifact - rake - Pop-Location -} - function Invoke-After { - # Trim the fat before packaging - # We don't need the cache of downloaded .gem files ... Remove-Item $pkg_prefix/vendor/cache -Recurse -Force - # We don't need the gem docs. Remove-Item $pkg_prefix/vendor/doc -Recurse -Force # We don't need to ship the test suites for every gem dependency, @@ -83,6 +74,7 @@ function Invoke-After { | Where-Object -FilterScript { $_.FullName -notlike "*inspec*" } ` | Remove-Item -Recurse -Force } + function Remove-StudioPathFrom { Param( [Parameter(Mandatory=$true)] From 6e88b3ceb9dc1c33065550843e29123ecebd6719 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 20:38:37 -0700 Subject: [PATCH 34/56] Fix rubocop warnings Signed-off-by: Miah Johnson --- test/artifact/inspec_detect_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/artifact/inspec_detect_test.rb b/test/artifact/inspec_detect_test.rb index 50870398b..61f066b25 100644 --- a/test/artifact/inspec_detect_test.rb +++ b/test/artifact/inspec_detect_test.rb @@ -2,11 +2,11 @@ require "minitest/autorun" class TestArtifactDetect < Minitest::Test def test_detect - out, err = capture_subprocess_io { + out, err = capture_subprocess_io do assert system("inspec detect --no-color") - } + end - assert_match %r%Platform Details%, out + assert_match %r{/Platform Details/}, out assert_empty err end end From 97a258ae69d90f6e44c0a3b60e37c64f9772bbff Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 11 Sep 2019 15:56:29 -0700 Subject: [PATCH 35/56] Use a more obvious directory structure for kitchen testing Signed-off-by: Miah Johnson --- .../cookbooks/os_prepare/attributes/default.rb | 0 .../cookbooks/os_prepare/files/empty.iso | Bin .../cookbooks/os_prepare/files/example.csv | 0 .../cookbooks/os_prepare/files/example.ini | 0 .../cookbooks/os_prepare/files/example.json | 0 .../cookbooks/os_prepare/files/example.toml | 0 .../cookbooks/os_prepare/files/example.xml | 0 .../cookbooks/os_prepare/files/example.yml | 0 .../cookbooks/os_prepare/files/httpd.conf | 0 test/{ => kitchen}/cookbooks/os_prepare/metadata.rb | 0 .../os_prepare/recipes/_runit_service_centos.rb | 0 .../os_prepare/recipes/_upstart_service_centos.rb | 0 .../cookbooks/os_prepare/recipes/apache.rb | 0 .../cookbooks/os_prepare/recipes/apt.rb | 0 .../cookbooks/os_prepare/recipes/auditctl.rb | 0 .../cookbooks/os_prepare/recipes/default.rb | 0 .../cookbooks/os_prepare/recipes/dh_params.rb | 0 .../cookbooks/os_prepare/recipes/docker_host.rb | 0 .../cookbooks/os_prepare/recipes/file.rb | 0 .../cookbooks/os_prepare/recipes/find_files.rb | 0 .../cookbooks/os_prepare/recipes/iis.rb | 0 .../cookbooks/os_prepare/recipes/iptables.rb | 0 .../os_prepare/recipes/json_yaml_csv_ini_xml.rb | 0 .../cookbooks/os_prepare/recipes/mount.rb | 0 .../cookbooks/os_prepare/recipes/os_env.rb | 0 .../cookbooks/os_prepare/recipes/package.rb | 0 .../cookbooks/os_prepare/recipes/postgres.rb | 0 .../cookbooks/os_prepare/recipes/registry_key.rb | 0 .../cookbooks/os_prepare/recipes/service.rb | 0 .../cookbooks/os_prepare/recipes/ssh.rb | 0 .../cookbooks/os_prepare/recipes/x509.rb | 0 .../os_prepare/templates/sv-default-svlog-run.erb | 0 32 files changed, 0 insertions(+), 0 deletions(-) rename test/{ => kitchen}/cookbooks/os_prepare/attributes/default.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/empty.iso (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/example.csv (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/example.ini (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/example.json (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/example.toml (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/example.xml (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/example.yml (100%) rename test/{ => kitchen}/cookbooks/os_prepare/files/httpd.conf (100%) rename test/{ => kitchen}/cookbooks/os_prepare/metadata.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/_runit_service_centos.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/_upstart_service_centos.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/apache.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/apt.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/auditctl.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/default.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/dh_params.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/docker_host.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/file.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/find_files.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/iis.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/iptables.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/json_yaml_csv_ini_xml.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/mount.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/os_env.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/package.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/postgres.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/registry_key.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/service.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/ssh.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/recipes/x509.rb (100%) rename test/{ => kitchen}/cookbooks/os_prepare/templates/sv-default-svlog-run.erb (100%) diff --git a/test/cookbooks/os_prepare/attributes/default.rb b/test/kitchen/cookbooks/os_prepare/attributes/default.rb similarity index 100% rename from test/cookbooks/os_prepare/attributes/default.rb rename to test/kitchen/cookbooks/os_prepare/attributes/default.rb diff --git a/test/cookbooks/os_prepare/files/empty.iso b/test/kitchen/cookbooks/os_prepare/files/empty.iso similarity index 100% rename from test/cookbooks/os_prepare/files/empty.iso rename to test/kitchen/cookbooks/os_prepare/files/empty.iso diff --git a/test/cookbooks/os_prepare/files/example.csv b/test/kitchen/cookbooks/os_prepare/files/example.csv similarity index 100% rename from test/cookbooks/os_prepare/files/example.csv rename to test/kitchen/cookbooks/os_prepare/files/example.csv diff --git a/test/cookbooks/os_prepare/files/example.ini b/test/kitchen/cookbooks/os_prepare/files/example.ini similarity index 100% rename from test/cookbooks/os_prepare/files/example.ini rename to test/kitchen/cookbooks/os_prepare/files/example.ini diff --git a/test/cookbooks/os_prepare/files/example.json b/test/kitchen/cookbooks/os_prepare/files/example.json similarity index 100% rename from test/cookbooks/os_prepare/files/example.json rename to test/kitchen/cookbooks/os_prepare/files/example.json diff --git a/test/cookbooks/os_prepare/files/example.toml b/test/kitchen/cookbooks/os_prepare/files/example.toml similarity index 100% rename from test/cookbooks/os_prepare/files/example.toml rename to test/kitchen/cookbooks/os_prepare/files/example.toml diff --git a/test/cookbooks/os_prepare/files/example.xml b/test/kitchen/cookbooks/os_prepare/files/example.xml similarity index 100% rename from test/cookbooks/os_prepare/files/example.xml rename to test/kitchen/cookbooks/os_prepare/files/example.xml diff --git a/test/cookbooks/os_prepare/files/example.yml b/test/kitchen/cookbooks/os_prepare/files/example.yml similarity index 100% rename from test/cookbooks/os_prepare/files/example.yml rename to test/kitchen/cookbooks/os_prepare/files/example.yml diff --git a/test/cookbooks/os_prepare/files/httpd.conf b/test/kitchen/cookbooks/os_prepare/files/httpd.conf similarity index 100% rename from test/cookbooks/os_prepare/files/httpd.conf rename to test/kitchen/cookbooks/os_prepare/files/httpd.conf diff --git a/test/cookbooks/os_prepare/metadata.rb b/test/kitchen/cookbooks/os_prepare/metadata.rb similarity index 100% rename from test/cookbooks/os_prepare/metadata.rb rename to test/kitchen/cookbooks/os_prepare/metadata.rb diff --git a/test/cookbooks/os_prepare/recipes/_runit_service_centos.rb b/test/kitchen/cookbooks/os_prepare/recipes/_runit_service_centos.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/_runit_service_centos.rb rename to test/kitchen/cookbooks/os_prepare/recipes/_runit_service_centos.rb diff --git a/test/cookbooks/os_prepare/recipes/_upstart_service_centos.rb b/test/kitchen/cookbooks/os_prepare/recipes/_upstart_service_centos.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/_upstart_service_centos.rb rename to test/kitchen/cookbooks/os_prepare/recipes/_upstart_service_centos.rb diff --git a/test/cookbooks/os_prepare/recipes/apache.rb b/test/kitchen/cookbooks/os_prepare/recipes/apache.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/apache.rb rename to test/kitchen/cookbooks/os_prepare/recipes/apache.rb diff --git a/test/cookbooks/os_prepare/recipes/apt.rb b/test/kitchen/cookbooks/os_prepare/recipes/apt.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/apt.rb rename to test/kitchen/cookbooks/os_prepare/recipes/apt.rb diff --git a/test/cookbooks/os_prepare/recipes/auditctl.rb b/test/kitchen/cookbooks/os_prepare/recipes/auditctl.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/auditctl.rb rename to test/kitchen/cookbooks/os_prepare/recipes/auditctl.rb diff --git a/test/cookbooks/os_prepare/recipes/default.rb b/test/kitchen/cookbooks/os_prepare/recipes/default.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/default.rb rename to test/kitchen/cookbooks/os_prepare/recipes/default.rb diff --git a/test/cookbooks/os_prepare/recipes/dh_params.rb b/test/kitchen/cookbooks/os_prepare/recipes/dh_params.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/dh_params.rb rename to test/kitchen/cookbooks/os_prepare/recipes/dh_params.rb diff --git a/test/cookbooks/os_prepare/recipes/docker_host.rb b/test/kitchen/cookbooks/os_prepare/recipes/docker_host.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/docker_host.rb rename to test/kitchen/cookbooks/os_prepare/recipes/docker_host.rb diff --git a/test/cookbooks/os_prepare/recipes/file.rb b/test/kitchen/cookbooks/os_prepare/recipes/file.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/file.rb rename to test/kitchen/cookbooks/os_prepare/recipes/file.rb diff --git a/test/cookbooks/os_prepare/recipes/find_files.rb b/test/kitchen/cookbooks/os_prepare/recipes/find_files.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/find_files.rb rename to test/kitchen/cookbooks/os_prepare/recipes/find_files.rb diff --git a/test/cookbooks/os_prepare/recipes/iis.rb b/test/kitchen/cookbooks/os_prepare/recipes/iis.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/iis.rb rename to test/kitchen/cookbooks/os_prepare/recipes/iis.rb diff --git a/test/cookbooks/os_prepare/recipes/iptables.rb b/test/kitchen/cookbooks/os_prepare/recipes/iptables.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/iptables.rb rename to test/kitchen/cookbooks/os_prepare/recipes/iptables.rb diff --git a/test/cookbooks/os_prepare/recipes/json_yaml_csv_ini_xml.rb b/test/kitchen/cookbooks/os_prepare/recipes/json_yaml_csv_ini_xml.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/json_yaml_csv_ini_xml.rb rename to test/kitchen/cookbooks/os_prepare/recipes/json_yaml_csv_ini_xml.rb diff --git a/test/cookbooks/os_prepare/recipes/mount.rb b/test/kitchen/cookbooks/os_prepare/recipes/mount.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/mount.rb rename to test/kitchen/cookbooks/os_prepare/recipes/mount.rb diff --git a/test/cookbooks/os_prepare/recipes/os_env.rb b/test/kitchen/cookbooks/os_prepare/recipes/os_env.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/os_env.rb rename to test/kitchen/cookbooks/os_prepare/recipes/os_env.rb diff --git a/test/cookbooks/os_prepare/recipes/package.rb b/test/kitchen/cookbooks/os_prepare/recipes/package.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/package.rb rename to test/kitchen/cookbooks/os_prepare/recipes/package.rb diff --git a/test/cookbooks/os_prepare/recipes/postgres.rb b/test/kitchen/cookbooks/os_prepare/recipes/postgres.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/postgres.rb rename to test/kitchen/cookbooks/os_prepare/recipes/postgres.rb diff --git a/test/cookbooks/os_prepare/recipes/registry_key.rb b/test/kitchen/cookbooks/os_prepare/recipes/registry_key.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/registry_key.rb rename to test/kitchen/cookbooks/os_prepare/recipes/registry_key.rb diff --git a/test/cookbooks/os_prepare/recipes/service.rb b/test/kitchen/cookbooks/os_prepare/recipes/service.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/service.rb rename to test/kitchen/cookbooks/os_prepare/recipes/service.rb diff --git a/test/cookbooks/os_prepare/recipes/ssh.rb b/test/kitchen/cookbooks/os_prepare/recipes/ssh.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/ssh.rb rename to test/kitchen/cookbooks/os_prepare/recipes/ssh.rb diff --git a/test/cookbooks/os_prepare/recipes/x509.rb b/test/kitchen/cookbooks/os_prepare/recipes/x509.rb similarity index 100% rename from test/cookbooks/os_prepare/recipes/x509.rb rename to test/kitchen/cookbooks/os_prepare/recipes/x509.rb diff --git a/test/cookbooks/os_prepare/templates/sv-default-svlog-run.erb b/test/kitchen/cookbooks/os_prepare/templates/sv-default-svlog-run.erb similarity index 100% rename from test/cookbooks/os_prepare/templates/sv-default-svlog-run.erb rename to test/kitchen/cookbooks/os_prepare/templates/sv-default-svlog-run.erb From e8ae9012ea9c0cd51cdcbe1a9018cd7319dfdcb7 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 11 Sep 2019 15:57:29 -0700 Subject: [PATCH 36/56] Move inspec-verify kitchen tests into more obvious directory Signed-off-by: Miah Johnson --- .../policies}/default/controls/_debug_spec.rb | 0 .../policies}/default/controls/apache_conf_spec.rb | 0 .../policies}/default/controls/apt_spec.rb | 0 .../policies}/default/controls/audit_spec.rb | 0 .../policies}/default/controls/cmp_matcher_spec.rb | 0 .../policies}/default/controls/csv_spec.rb | 0 .../policies}/default/controls/dh_params_spec.rb | 0 .../policies}/default/controls/docker_spec.rb | 0 .../policies}/default/controls/etc_group_spec.rb | 0 .../policies}/default/controls/file_spec.rb | 0 .../policies}/default/controls/filesystem.rb | 0 .../policies}/default/controls/group_spec.rb | 0 .../policies}/default/controls/iis_site_spec.rb | 0 .../policies}/default/controls/ini_spec.rb | 0 .../policies}/default/controls/ip6tables_spec.rb | 0 .../policies}/default/controls/iptables_spec.rb | 0 .../policies}/default/controls/json_spec.rb | 0 .../policies}/default/controls/kernel_module_spec.rb | 0 .../policies}/default/controls/kernel_parameter_spec.rb | 0 .../policies}/default/controls/matcher_test.rb | 0 .../policies}/default/controls/mount_spec.rb | 0 .../policies}/default/controls/mssql_session_spec.rb | 0 .../policies}/default/controls/os_env_spec.rb | 0 .../{integration => kitchen/policies}/default/controls/os_spec.rb | 0 .../policies}/default/controls/package_spec.rb | 0 .../policies}/default/controls/port_spec.rb | 0 .../policies}/default/controls/postgres_session_spec.rb | 0 .../policies}/default/controls/powershell_spec.rb | 0 .../policies}/default/controls/registry_key_spec.rb | 0 .../policies}/default/controls/secpol_spec.rb | 0 .../policies}/default/controls/security_identifier_spec.rb | 0 .../policies}/default/controls/service_spec.rb | 0 .../policies}/default/controls/toml_spec.rb | 0 .../policies}/default/controls/user_spec.rb | 0 .../policies}/default/controls/vbscript_spec.rb | 0 .../policies}/default/controls/virtualization_spec.rb | 0 .../policies}/default/controls/windows_hotfix_spec.rb | 0 .../policies}/default/controls/windows_task_spec.rb | 0 .../policies}/default/controls/wmi_spec.rb | 0 .../policies}/default/controls/x509_spec.rb | 0 .../policies}/default/controls/xml_spec.rb | 0 .../policies}/default/controls/yaml_spec.rb | 0 test/{integration => kitchen/policies}/default/inspec.yml | 0 43 files changed, 0 insertions(+), 0 deletions(-) rename test/{integration => kitchen/policies}/default/controls/_debug_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/apache_conf_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/apt_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/audit_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/cmp_matcher_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/csv_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/dh_params_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/docker_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/etc_group_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/file_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/filesystem.rb (100%) rename test/{integration => kitchen/policies}/default/controls/group_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/iis_site_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/ini_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/ip6tables_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/iptables_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/json_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/kernel_module_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/kernel_parameter_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/matcher_test.rb (100%) rename test/{integration => kitchen/policies}/default/controls/mount_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/mssql_session_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/os_env_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/os_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/package_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/port_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/postgres_session_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/powershell_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/registry_key_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/secpol_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/security_identifier_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/service_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/toml_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/user_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/vbscript_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/virtualization_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/windows_hotfix_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/windows_task_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/wmi_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/x509_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/xml_spec.rb (100%) rename test/{integration => kitchen/policies}/default/controls/yaml_spec.rb (100%) rename test/{integration => kitchen/policies}/default/inspec.yml (100%) diff --git a/test/integration/default/controls/_debug_spec.rb b/test/kitchen/policies/default/controls/_debug_spec.rb similarity index 100% rename from test/integration/default/controls/_debug_spec.rb rename to test/kitchen/policies/default/controls/_debug_spec.rb diff --git a/test/integration/default/controls/apache_conf_spec.rb b/test/kitchen/policies/default/controls/apache_conf_spec.rb similarity index 100% rename from test/integration/default/controls/apache_conf_spec.rb rename to test/kitchen/policies/default/controls/apache_conf_spec.rb diff --git a/test/integration/default/controls/apt_spec.rb b/test/kitchen/policies/default/controls/apt_spec.rb similarity index 100% rename from test/integration/default/controls/apt_spec.rb rename to test/kitchen/policies/default/controls/apt_spec.rb diff --git a/test/integration/default/controls/audit_spec.rb b/test/kitchen/policies/default/controls/audit_spec.rb similarity index 100% rename from test/integration/default/controls/audit_spec.rb rename to test/kitchen/policies/default/controls/audit_spec.rb diff --git a/test/integration/default/controls/cmp_matcher_spec.rb b/test/kitchen/policies/default/controls/cmp_matcher_spec.rb similarity index 100% rename from test/integration/default/controls/cmp_matcher_spec.rb rename to test/kitchen/policies/default/controls/cmp_matcher_spec.rb diff --git a/test/integration/default/controls/csv_spec.rb b/test/kitchen/policies/default/controls/csv_spec.rb similarity index 100% rename from test/integration/default/controls/csv_spec.rb rename to test/kitchen/policies/default/controls/csv_spec.rb diff --git a/test/integration/default/controls/dh_params_spec.rb b/test/kitchen/policies/default/controls/dh_params_spec.rb similarity index 100% rename from test/integration/default/controls/dh_params_spec.rb rename to test/kitchen/policies/default/controls/dh_params_spec.rb diff --git a/test/integration/default/controls/docker_spec.rb b/test/kitchen/policies/default/controls/docker_spec.rb similarity index 100% rename from test/integration/default/controls/docker_spec.rb rename to test/kitchen/policies/default/controls/docker_spec.rb diff --git a/test/integration/default/controls/etc_group_spec.rb b/test/kitchen/policies/default/controls/etc_group_spec.rb similarity index 100% rename from test/integration/default/controls/etc_group_spec.rb rename to test/kitchen/policies/default/controls/etc_group_spec.rb diff --git a/test/integration/default/controls/file_spec.rb b/test/kitchen/policies/default/controls/file_spec.rb similarity index 100% rename from test/integration/default/controls/file_spec.rb rename to test/kitchen/policies/default/controls/file_spec.rb diff --git a/test/integration/default/controls/filesystem.rb b/test/kitchen/policies/default/controls/filesystem.rb similarity index 100% rename from test/integration/default/controls/filesystem.rb rename to test/kitchen/policies/default/controls/filesystem.rb diff --git a/test/integration/default/controls/group_spec.rb b/test/kitchen/policies/default/controls/group_spec.rb similarity index 100% rename from test/integration/default/controls/group_spec.rb rename to test/kitchen/policies/default/controls/group_spec.rb diff --git a/test/integration/default/controls/iis_site_spec.rb b/test/kitchen/policies/default/controls/iis_site_spec.rb similarity index 100% rename from test/integration/default/controls/iis_site_spec.rb rename to test/kitchen/policies/default/controls/iis_site_spec.rb diff --git a/test/integration/default/controls/ini_spec.rb b/test/kitchen/policies/default/controls/ini_spec.rb similarity index 100% rename from test/integration/default/controls/ini_spec.rb rename to test/kitchen/policies/default/controls/ini_spec.rb diff --git a/test/integration/default/controls/ip6tables_spec.rb b/test/kitchen/policies/default/controls/ip6tables_spec.rb similarity index 100% rename from test/integration/default/controls/ip6tables_spec.rb rename to test/kitchen/policies/default/controls/ip6tables_spec.rb diff --git a/test/integration/default/controls/iptables_spec.rb b/test/kitchen/policies/default/controls/iptables_spec.rb similarity index 100% rename from test/integration/default/controls/iptables_spec.rb rename to test/kitchen/policies/default/controls/iptables_spec.rb diff --git a/test/integration/default/controls/json_spec.rb b/test/kitchen/policies/default/controls/json_spec.rb similarity index 100% rename from test/integration/default/controls/json_spec.rb rename to test/kitchen/policies/default/controls/json_spec.rb diff --git a/test/integration/default/controls/kernel_module_spec.rb b/test/kitchen/policies/default/controls/kernel_module_spec.rb similarity index 100% rename from test/integration/default/controls/kernel_module_spec.rb rename to test/kitchen/policies/default/controls/kernel_module_spec.rb diff --git a/test/integration/default/controls/kernel_parameter_spec.rb b/test/kitchen/policies/default/controls/kernel_parameter_spec.rb similarity index 100% rename from test/integration/default/controls/kernel_parameter_spec.rb rename to test/kitchen/policies/default/controls/kernel_parameter_spec.rb diff --git a/test/integration/default/controls/matcher_test.rb b/test/kitchen/policies/default/controls/matcher_test.rb similarity index 100% rename from test/integration/default/controls/matcher_test.rb rename to test/kitchen/policies/default/controls/matcher_test.rb diff --git a/test/integration/default/controls/mount_spec.rb b/test/kitchen/policies/default/controls/mount_spec.rb similarity index 100% rename from test/integration/default/controls/mount_spec.rb rename to test/kitchen/policies/default/controls/mount_spec.rb diff --git a/test/integration/default/controls/mssql_session_spec.rb b/test/kitchen/policies/default/controls/mssql_session_spec.rb similarity index 100% rename from test/integration/default/controls/mssql_session_spec.rb rename to test/kitchen/policies/default/controls/mssql_session_spec.rb diff --git a/test/integration/default/controls/os_env_spec.rb b/test/kitchen/policies/default/controls/os_env_spec.rb similarity index 100% rename from test/integration/default/controls/os_env_spec.rb rename to test/kitchen/policies/default/controls/os_env_spec.rb diff --git a/test/integration/default/controls/os_spec.rb b/test/kitchen/policies/default/controls/os_spec.rb similarity index 100% rename from test/integration/default/controls/os_spec.rb rename to test/kitchen/policies/default/controls/os_spec.rb diff --git a/test/integration/default/controls/package_spec.rb b/test/kitchen/policies/default/controls/package_spec.rb similarity index 100% rename from test/integration/default/controls/package_spec.rb rename to test/kitchen/policies/default/controls/package_spec.rb diff --git a/test/integration/default/controls/port_spec.rb b/test/kitchen/policies/default/controls/port_spec.rb similarity index 100% rename from test/integration/default/controls/port_spec.rb rename to test/kitchen/policies/default/controls/port_spec.rb diff --git a/test/integration/default/controls/postgres_session_spec.rb b/test/kitchen/policies/default/controls/postgres_session_spec.rb similarity index 100% rename from test/integration/default/controls/postgres_session_spec.rb rename to test/kitchen/policies/default/controls/postgres_session_spec.rb diff --git a/test/integration/default/controls/powershell_spec.rb b/test/kitchen/policies/default/controls/powershell_spec.rb similarity index 100% rename from test/integration/default/controls/powershell_spec.rb rename to test/kitchen/policies/default/controls/powershell_spec.rb diff --git a/test/integration/default/controls/registry_key_spec.rb b/test/kitchen/policies/default/controls/registry_key_spec.rb similarity index 100% rename from test/integration/default/controls/registry_key_spec.rb rename to test/kitchen/policies/default/controls/registry_key_spec.rb diff --git a/test/integration/default/controls/secpol_spec.rb b/test/kitchen/policies/default/controls/secpol_spec.rb similarity index 100% rename from test/integration/default/controls/secpol_spec.rb rename to test/kitchen/policies/default/controls/secpol_spec.rb diff --git a/test/integration/default/controls/security_identifier_spec.rb b/test/kitchen/policies/default/controls/security_identifier_spec.rb similarity index 100% rename from test/integration/default/controls/security_identifier_spec.rb rename to test/kitchen/policies/default/controls/security_identifier_spec.rb diff --git a/test/integration/default/controls/service_spec.rb b/test/kitchen/policies/default/controls/service_spec.rb similarity index 100% rename from test/integration/default/controls/service_spec.rb rename to test/kitchen/policies/default/controls/service_spec.rb diff --git a/test/integration/default/controls/toml_spec.rb b/test/kitchen/policies/default/controls/toml_spec.rb similarity index 100% rename from test/integration/default/controls/toml_spec.rb rename to test/kitchen/policies/default/controls/toml_spec.rb diff --git a/test/integration/default/controls/user_spec.rb b/test/kitchen/policies/default/controls/user_spec.rb similarity index 100% rename from test/integration/default/controls/user_spec.rb rename to test/kitchen/policies/default/controls/user_spec.rb diff --git a/test/integration/default/controls/vbscript_spec.rb b/test/kitchen/policies/default/controls/vbscript_spec.rb similarity index 100% rename from test/integration/default/controls/vbscript_spec.rb rename to test/kitchen/policies/default/controls/vbscript_spec.rb diff --git a/test/integration/default/controls/virtualization_spec.rb b/test/kitchen/policies/default/controls/virtualization_spec.rb similarity index 100% rename from test/integration/default/controls/virtualization_spec.rb rename to test/kitchen/policies/default/controls/virtualization_spec.rb diff --git a/test/integration/default/controls/windows_hotfix_spec.rb b/test/kitchen/policies/default/controls/windows_hotfix_spec.rb similarity index 100% rename from test/integration/default/controls/windows_hotfix_spec.rb rename to test/kitchen/policies/default/controls/windows_hotfix_spec.rb diff --git a/test/integration/default/controls/windows_task_spec.rb b/test/kitchen/policies/default/controls/windows_task_spec.rb similarity index 100% rename from test/integration/default/controls/windows_task_spec.rb rename to test/kitchen/policies/default/controls/windows_task_spec.rb diff --git a/test/integration/default/controls/wmi_spec.rb b/test/kitchen/policies/default/controls/wmi_spec.rb similarity index 100% rename from test/integration/default/controls/wmi_spec.rb rename to test/kitchen/policies/default/controls/wmi_spec.rb diff --git a/test/integration/default/controls/x509_spec.rb b/test/kitchen/policies/default/controls/x509_spec.rb similarity index 100% rename from test/integration/default/controls/x509_spec.rb rename to test/kitchen/policies/default/controls/x509_spec.rb diff --git a/test/integration/default/controls/xml_spec.rb b/test/kitchen/policies/default/controls/xml_spec.rb similarity index 100% rename from test/integration/default/controls/xml_spec.rb rename to test/kitchen/policies/default/controls/xml_spec.rb diff --git a/test/integration/default/controls/yaml_spec.rb b/test/kitchen/policies/default/controls/yaml_spec.rb similarity index 100% rename from test/integration/default/controls/yaml_spec.rb rename to test/kitchen/policies/default/controls/yaml_spec.rb diff --git a/test/integration/default/inspec.yml b/test/kitchen/policies/default/inspec.yml similarity index 100% rename from test/integration/default/inspec.yml rename to test/kitchen/policies/default/inspec.yml From e298f0f44b1d6052b24388cc53c2a4c7015311fc Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 11 Sep 2019 16:44:42 -0700 Subject: [PATCH 37/56] move find_files inspec policy to kitchen directory Signed-off-by: Miah Johnson --- test/{integration => kitchen/policies}/find_files/README.md | 0 .../policies}/find_files/controls/find_files_spec.rb | 0 test/{integration => kitchen/policies}/find_files/inspec.yml | 0 .../policies}/find_files/libraries/find_files.rb | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename test/{integration => kitchen/policies}/find_files/README.md (100%) rename test/{integration => kitchen/policies}/find_files/controls/find_files_spec.rb (100%) rename test/{integration => kitchen/policies}/find_files/inspec.yml (100%) rename test/{integration => kitchen/policies}/find_files/libraries/find_files.rb (100%) diff --git a/test/integration/find_files/README.md b/test/kitchen/policies/find_files/README.md similarity index 100% rename from test/integration/find_files/README.md rename to test/kitchen/policies/find_files/README.md diff --git a/test/integration/find_files/controls/find_files_spec.rb b/test/kitchen/policies/find_files/controls/find_files_spec.rb similarity index 100% rename from test/integration/find_files/controls/find_files_spec.rb rename to test/kitchen/policies/find_files/controls/find_files_spec.rb diff --git a/test/integration/find_files/inspec.yml b/test/kitchen/policies/find_files/inspec.yml similarity index 100% rename from test/integration/find_files/inspec.yml rename to test/kitchen/policies/find_files/inspec.yml diff --git a/test/integration/find_files/libraries/find_files.rb b/test/kitchen/policies/find_files/libraries/find_files.rb similarity index 100% rename from test/integration/find_files/libraries/find_files.rb rename to test/kitchen/policies/find_files/libraries/find_files.rb From 46a2e17ffcc751ff1aeb4baa70e466bf6af4faca Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 11 Sep 2019 17:00:14 -0700 Subject: [PATCH 38/56] Update directory in kitchen configuration files Signed-off-by: Miah Johnson --- kitchen.chef.yml | 2 +- kitchen.vagrant.yml | 4 ++-- kitchen.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kitchen.chef.yml b/kitchen.chef.yml index a0ba0af14..1b9ea9e10 100644 --- a/kitchen.chef.yml +++ b/kitchen.chef.yml @@ -11,7 +11,7 @@ verifier: lifecycle: pre_converge: - - local: gem build inspec-core.gemspec --output test/cookbooks/os_prepare/files/inspec-core-local.gem + - local: gem build inspec-core.gemspec --output test/kitchen/cookbooks/os_prepare/files/inspec-core-local.gem platforms: # The following (private) boxes are shared via VagrantCloud and are only diff --git a/kitchen.vagrant.yml b/kitchen.vagrant.yml index 684e3251b..7f42867f9 100644 --- a/kitchen.vagrant.yml +++ b/kitchen.vagrant.yml @@ -11,7 +11,7 @@ verifier: lifecycle: pre_converge: - - local: gem build inspec-core.gemspec --output test/cookbooks/os_prepare/files/inspec-core-local.gem + - local: gem build inspec-core.gemspec --output test/kitchen/cookbooks/os_prepare/files/inspec-core-local.gem platforms: - name: centos-6 @@ -35,6 +35,6 @@ suites: - recipe[os_prepare::find_files] verifier: inspec_tests: - - test/integration/find_files + - test/kitchen/policies/find_files excludes: - freebsd-11 diff --git a/kitchen.yml b/kitchen.yml index 4d5894fe3..342ec1233 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -9,7 +9,7 @@ transport: lifecycle: pre_converge: - - local: gem build inspec-core.gemspec --output test/cookbooks/os_prepare/files/inspec-core-local.gem + - local: gem build inspec-core.gemspec --output test/kitchen/cookbooks/os_prepare/files/inspec-core-local.gem provisioner: name: dokken @@ -106,7 +106,7 @@ suites: - recipe[audit] verifier: inspec_tests: - - test/integration/default + - test/kitchen/policies/default attributes: audit: attributes: From 633a1a1d79c6a9561f327f67e09d7eccfe75107e Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 11 Sep 2019 18:43:45 -0700 Subject: [PATCH 39/56] Add pipeline to manage test kitchen builds and a trigger Signed-off-by: Miah Johnson --- .expeditor/config.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 72bc05f34..e12f10bce 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -44,6 +44,9 @@ pipelines: - www/deploy: description: Deploy website to inspec.io definition: .expeditor/wwwdeploy.yml + - verify/resources: + description: Test core resources with test-kitchen. + definition: .expeditor/verify.resources.yml - integration/libraries: description: Integration with plugins, gems, resource packs. definition: .expeditor/integration.libraries.yml @@ -164,3 +167,7 @@ subscriptions: only_if_team_member: - inspec/owners - inspec/inspec-core-team + - post_github_comment:.expeditor/templates/pull_request.mustache + - workload: buildkite_build_passed:{{agent_id}}:verify:* + actions: + - trigger_pipeline:verify/resources From e2e6042cf2477b6eff635c5c0aec3e9e265604af Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Fri, 13 Sep 2019 10:19:54 -0700 Subject: [PATCH 40/56] Split up kitchen suites by resource type. Signed-off-by: Miah Johnson --- kitchen.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kitchen.yml b/kitchen.yml index 342ec1233..9834a9e50 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -100,13 +100,13 @@ platforms: - RUN /usr/bin/apt-get update -y suites: -- name: default +- name: resources-core run_list: - recipe[os_prepare] - recipe[audit] verifier: inspec_tests: - - test/kitchen/policies/default + - test/kitchen/policies/resources-core attributes: audit: attributes: @@ -122,3 +122,7 @@ suites: osprepare: docker: true application: false + +- name: resources-database +- name: resources-unix +- name: resources-windows From 216da3f90a573870bbbd3b39c9bd73e354d60b10 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 22:26:35 -0700 Subject: [PATCH 41/56] Let codeclimate ignore our test files. Signed-off-by: Miah Johnson --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index fe1ecf824..a4d721d7c 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -26,3 +26,4 @@ plugins: enabled: true exclude_patterns: - "www/source/javascripts/" + - "test/kitchen" From 87b9d569ca68bf8ad58f664080556f6b77dd3817 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 22:27:45 -0700 Subject: [PATCH 42/56] Allow rubocop to ignore our test-kitchen files Signed-off-by: Miah Johnson --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 15f433377..829aee7d3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,6 @@ AllCops: Exclude: + - 'test/kitchen/**/*' - 'test/integration/**/controls/**/*.rb' - 'test/unit/mock/profiles/**/*.rb' - 'test/unit/mock/config_dirs/**/*.rb' From 227a97991d82b63079437bd4b4afb881e7a61a2f Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Wed, 16 Oct 2019 22:53:05 -0700 Subject: [PATCH 43/56] Add blank pipeline to allow iteration in next PR Signed-off-by: Miah Johnson --- .expeditor/verify.resources.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .expeditor/verify.resources.yml diff --git a/.expeditor/verify.resources.yml b/.expeditor/verify.resources.yml new file mode 100644 index 000000000..e69de29bb From 427d8dbac07802d3ac4f65634e3918f1dc226fde Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 17 Oct 2019 10:41:59 -0700 Subject: [PATCH 44/56] By not declaring a version we get the default, which is 2019. Signed-off-by: Miah Johnson --- .expeditor/habitat_test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.expeditor/habitat_test.yml b/.expeditor/habitat_test.yml index 6b40e5d23..45be69972 100644 --- a/.expeditor/habitat_test.yml +++ b/.expeditor/habitat_test.yml @@ -16,6 +16,5 @@ steps: expeditor: executor: windows: - os-version: 2016 privileged: true single-use: true From 0542ac5b30cd218b976e396921bf153d47e842c9 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Thu, 17 Oct 2019 19:39:13 +0000 Subject: [PATCH 45/56] Bump version to 4.18.3 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 7 ++++--- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 946a02ad8..3cb5ebebc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,17 @@ # Change Log - -## [v4.18.2](https://github.com/inspec/inspec/tree/v4.18.2) (2019-10-15) + +## [v4.18.3](https://github.com/inspec/inspec/tree/v4.18.3) (2019-10-17) #### Merged Pull Requests -- Telemetry: add chef-core [#4569](https://github.com/inspec/inspec/pull/4569) ([clintoncwolfe](https://github.com/clintoncwolfe)) +- Goodbye Gordon! [#4577](https://github.com/inspec/inspec/pull/4577) ([miah](https://github.com/miah)) ### Changes since 4.18.0 release #### Merged Pull Requests +- Goodbye Gordon! [#4577](https://github.com/inspec/inspec/pull/4577) ([miah](https://github.com/miah)) - Telemetry: add chef-core [#4569](https://github.com/inspec/inspec/pull/4569) ([clintoncwolfe](https://github.com/clintoncwolfe)) #### Bug Fixes diff --git a/VERSION b/VERSION index e9c8cf37f..5255dcf3b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.18.2 \ No newline at end of file +4.18.3 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index 3801b67ba..abee590f1 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.18.2".freeze + VERSION = "4.18.3".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index bfc67103e..f7f1aa394 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.18.2".freeze + VERSION = "4.18.3".freeze end From 344d99f5104f1d76dc15dd0163c6642b72737d66 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Thu, 17 Oct 2019 19:49:55 +0000 Subject: [PATCH 46/56] Bump version to 4.18.4 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 7 ++++--- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cb5ebebc..593dda1f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,17 @@ # Change Log - -## [v4.18.3](https://github.com/inspec/inspec/tree/v4.18.3) (2019-10-17) + +## [v4.18.4](https://github.com/inspec/inspec/tree/v4.18.4) (2019-10-17) #### Merged Pull Requests -- Goodbye Gordon! [#4577](https://github.com/inspec/inspec/pull/4577) ([miah](https://github.com/miah)) +- Re-organize test-kitchen files. Add BK Pipeline [#4601](https://github.com/inspec/inspec/pull/4601) ([miah](https://github.com/miah)) ### Changes since 4.18.0 release #### Merged Pull Requests +- Re-organize test-kitchen files. Add BK Pipeline [#4601](https://github.com/inspec/inspec/pull/4601) ([miah](https://github.com/miah)) - Goodbye Gordon! [#4577](https://github.com/inspec/inspec/pull/4577) ([miah](https://github.com/miah)) - Telemetry: add chef-core [#4569](https://github.com/inspec/inspec/pull/4569) ([clintoncwolfe](https://github.com/clintoncwolfe)) diff --git a/VERSION b/VERSION index 5255dcf3b..faaadf202 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.18.3 \ No newline at end of file +4.18.4 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index abee590f1..c7d7d3422 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.18.3".freeze + VERSION = "4.18.4".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index f7f1aa394..033285f5a 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.18.3".freeze + VERSION = "4.18.4".freeze end From 406d9e4d59c37973df7830a7684b3cdafec70469 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 17 Oct 2019 12:57:03 -0700 Subject: [PATCH 47/56] We only need to install a specific hab version on Windows Signed-off-by: Miah Johnson --- .expeditor/buildkite/habitat_test.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.expeditor/buildkite/habitat_test.sh b/.expeditor/buildkite/habitat_test.sh index 8d4d4198a..41a152175 100644 --- a/.expeditor/buildkite/habitat_test.sh +++ b/.expeditor/buildkite/habitat_test.sh @@ -8,11 +8,6 @@ export PLAN='inspec' echo "--- system details" uname -a -echo "--- Installing the version of Habitat required" -# Install-Habitat --version 0.85.0.20190916 -# TODO: Install Hab? -hab --version - echo "--- Generating fake origin key" hab origin key generate ${HAB_ORIGIN} From cb001d8654116172b449c2d7421348b5de395501 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 17 Oct 2019 14:26:51 -0700 Subject: [PATCH 48/56] Empty resources yml until I build it. Signed-off-by: Miah Johnson --- .expeditor/verify.resources.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.expeditor/verify.resources.yml b/.expeditor/verify.resources.yml index e69de29bb..792d60054 100644 --- a/.expeditor/verify.resources.yml +++ b/.expeditor/verify.resources.yml @@ -0,0 +1 @@ +# From 4a56b005250fa8d726351884471f0052eccd9e5e Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Thu, 17 Oct 2019 21:28:57 +0000 Subject: [PATCH 49/56] Update CHANGELOG.md with details from pull request #4610 Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 593dda1f0..17b8336ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,17 @@ # Change Log - -## [v4.18.4](https://github.com/inspec/inspec/tree/v4.18.4) (2019-10-17) + +## Unreleased #### Merged Pull Requests -- Re-organize test-kitchen files. Add BK Pipeline [#4601](https://github.com/inspec/inspec/pull/4601) ([miah](https://github.com/miah)) +- Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) ### Changes since 4.18.0 release #### Merged Pull Requests +- Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) - Re-organize test-kitchen files. Add BK Pipeline [#4601](https://github.com/inspec/inspec/pull/4601) ([miah](https://github.com/miah)) - Goodbye Gordon! [#4577](https://github.com/inspec/inspec/pull/4577) ([miah](https://github.com/miah)) - Telemetry: add chef-core [#4569](https://github.com/inspec/inspec/pull/4569) ([clintoncwolfe](https://github.com/clintoncwolfe)) From 8968f89d5dad7e4303faf92c043b25a47e7d6aa0 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 17 Oct 2019 14:37:14 -0700 Subject: [PATCH 50/56] Dont trigger yet Signed-off-by: Miah Johnson --- .expeditor/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 732e377e0..9512b9a5b 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -170,6 +170,3 @@ subscriptions: - inspec/owners - inspec/inspec-core-team - post_github_comment:.expeditor/templates/pull_request.mustache - - workload: buildkite_build_passed:{{agent_id}}:verify:* - actions: - - trigger_pipeline:verify/resources From ab0fa7aa38ad010248b5f4540dc8b025b7adff79 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Thu, 17 Oct 2019 21:42:14 +0000 Subject: [PATCH 51/56] Update CHANGELOG.md with details from pull request #4611 Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b8336ee..42e32ea92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## Unreleased #### Merged Pull Requests +- Dont trigger yet [#4611](https://github.com/inspec/inspec/pull/4611) ([miah](https://github.com/miah)) - Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) @@ -11,6 +12,7 @@ ### Changes since 4.18.0 release #### Merged Pull Requests +- Dont trigger yet [#4611](https://github.com/inspec/inspec/pull/4611) ([miah](https://github.com/miah)) - Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) - Re-organize test-kitchen files. Add BK Pipeline [#4601](https://github.com/inspec/inspec/pull/4601) ([miah](https://github.com/miah)) - Goodbye Gordon! [#4577](https://github.com/inspec/inspec/pull/4577) ([miah](https://github.com/miah)) From 23f31a0a723b4152df397ec771de87844f53b8f9 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Thu, 17 Oct 2019 14:55:58 -0700 Subject: [PATCH 52/56] Use a good profile with inspec check test Signed-off-by: Miah Johnson --- test/functional/helper.rb | 2 -- test/functional/inspec_check_test.rb | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/functional/helper.rb b/test/functional/helper.rb index 86b469112..563b1c003 100644 --- a/test/functional/helper.rb +++ b/test/functional/helper.rb @@ -80,8 +80,6 @@ module FunctionalHelper let(:mock_path) { File.join(repo_path, "test", "unit", "mock") } let(:profile_path) { File.join(mock_path, "profiles") } let(:examples_path) { File.join(profile_path, "old-examples") } - let(:integration_test_path) { File.join(repo_path, "test", "integration", "default") } - let(:example_profile) { File.join(examples_path, "profile") } let(:meta_profile) { File.join(examples_path, "meta-profile") } let(:example_control) { File.join(example_profile, "controls", "example-tmp.rb") } diff --git a/test/functional/inspec_check_test.rb b/test/functional/inspec_check_test.rb index a324fe045..74143857d 100644 --- a/test/functional/inspec_check_test.rb +++ b/test/functional/inspec_check_test.rb @@ -60,8 +60,8 @@ describe "inspec check" do Dir.mktmpdir do |tmpdir| cache_dir = File.join(tmpdir, "inspec_check_test_cache") _(File.exist?(cache_dir)).must_equal false - - out = inspec("check " + integration_test_path + " --vendor-cache " + cache_dir) + good_profile_path = File.join(repo_path, "test/unit/mock/profiles/complete-profile") + out = inspec("check #{good_profile_path} --vendor-cache #{cache_dir}") _(File.exist?(cache_dir)).must_equal true assert_exit_code 0, out From c7909b7dd7b5263ed0aa3c0f4cff0ba7a8362e30 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Thu, 17 Oct 2019 22:19:39 +0000 Subject: [PATCH 53/56] Bump version to 4.18.5 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 6 ++++-- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42e32ea92..a0a42c82a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Change Log - -## Unreleased + +## [v4.18.5](https://github.com/inspec/inspec/tree/v4.18.5) (2019-10-17) #### Merged Pull Requests +- Use a good profile with inspec check test [#4612](https://github.com/inspec/inspec/pull/4612) ([miah](https://github.com/miah)) - Dont trigger yet [#4611](https://github.com/inspec/inspec/pull/4611) ([miah](https://github.com/miah)) - Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) @@ -12,6 +13,7 @@ ### Changes since 4.18.0 release #### Merged Pull Requests +- Use a good profile with inspec check test [#4612](https://github.com/inspec/inspec/pull/4612) ([miah](https://github.com/miah)) - Dont trigger yet [#4611](https://github.com/inspec/inspec/pull/4611) ([miah](https://github.com/miah)) - Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) - Re-organize test-kitchen files. Add BK Pipeline [#4601](https://github.com/inspec/inspec/pull/4601) ([miah](https://github.com/miah)) diff --git a/VERSION b/VERSION index faaadf202..3c6cd2e55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.18.4 \ No newline at end of file +4.18.5 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index c7d7d3422..0fe7a7269 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.18.4".freeze + VERSION = "4.18.5".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index 033285f5a..9f44faecc 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.18.4".freeze + VERSION = "4.18.5".freeze end From 689231aa9eb4abccf184f43b6fdfc908a1d37b98 Mon Sep 17 00:00:00 2001 From: Ryan Davis Date: Thu, 17 Oct 2019 13:56:57 -0700 Subject: [PATCH 54/56] Fixing hamburger and unclickable download buttons / search boxen. Signed-off-by: Ryan Davis Paired: @seajamied --- www/source/stylesheets/_homepage.scss | 1 - www/source/stylesheets/_nav.scss | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/www/source/stylesheets/_homepage.scss b/www/source/stylesheets/_homepage.scss index 5a0d74119..499f58ca3 100644 --- a/www/source/stylesheets/_homepage.scss +++ b/www/source/stylesheets/_homepage.scss @@ -3,7 +3,6 @@ header { width: auto; height: auto; - z-index: -1; } .short-bg { diff --git a/www/source/stylesheets/_nav.scss b/www/source/stylesheets/_nav.scss index 4e28fbd0f..3e8e2da11 100644 --- a/www/source/stylesheets/_nav.scss +++ b/www/source/stylesheets/_nav.scss @@ -2,6 +2,8 @@ width: 100%; max-width: 100%; background: $color_white; + z-index: 999; + position: relative; } .main-nav--logo { From a0ef46ccf4124b3013d1ba8bc48209ae991a5977 Mon Sep 17 00:00:00 2001 From: Miah Johnson Date: Fri, 18 Oct 2019 12:11:02 -0700 Subject: [PATCH 55/56] Stop using reserved pipelines with default triggers. The pipeline prefixes: deploy, habitat, omnibus, and verify all have default triggers associtated with them. https://expeditor.chef.io/docs/reference/configuration/#pipelines Signed-off-by: Miah Johnson --- .expeditor/{habitat_test.yml => artifact.habitat.yml} | 4 ++-- .../{habitat_test.ps1 => artifact.habitat.test.ps1} | 0 .../{habitat_test.sh => artifact.habitat.test.sh} | 0 .expeditor/config.yml | 10 +++++----- ...{verify.resources.yml => integration.resources.yml} | 0 5 files changed, 7 insertions(+), 7 deletions(-) rename .expeditor/{habitat_test.yml => artifact.habitat.yml} (73%) rename .expeditor/buildkite/{habitat_test.ps1 => artifact.habitat.test.ps1} (100%) rename .expeditor/buildkite/{habitat_test.sh => artifact.habitat.test.sh} (100%) rename .expeditor/{verify.resources.yml => integration.resources.yml} (100%) diff --git a/.expeditor/habitat_test.yml b/.expeditor/artifact.habitat.yml similarity index 73% rename from .expeditor/habitat_test.yml rename to .expeditor/artifact.habitat.yml index 45be69972..44485d4b7 100644 --- a/.expeditor/habitat_test.yml +++ b/.expeditor/artifact.habitat.yml @@ -3,7 +3,7 @@ steps: - label: ":linux: Validate Habitat Builds of Chef InSpec" commands: - - /workdir/.expeditor/buildkite/habitat_test.sh + - /workdir/.expeditor/buildkite/artifact.habitat.test.sh expeditor: executor: linux: @@ -12,7 +12,7 @@ steps: - label: ":windows: Validate Habitat Builds of Chef InSpec" commands: - - /workdir/.expeditor/buildkite/habitat_test.ps1 + - /workdir/.expeditor/buildkite/artifact.habitat.test.ps1 expeditor: executor: windows: diff --git a/.expeditor/buildkite/habitat_test.ps1 b/.expeditor/buildkite/artifact.habitat.test.ps1 similarity index 100% rename from .expeditor/buildkite/habitat_test.ps1 rename to .expeditor/buildkite/artifact.habitat.test.ps1 diff --git a/.expeditor/buildkite/habitat_test.sh b/.expeditor/buildkite/artifact.habitat.test.sh similarity index 100% rename from .expeditor/buildkite/habitat_test.sh rename to .expeditor/buildkite/artifact.habitat.test.sh diff --git a/.expeditor/config.yml b/.expeditor/config.yml index 9512b9a5b..9daabefcc 100644 --- a/.expeditor/config.yml +++ b/.expeditor/config.yml @@ -18,8 +18,6 @@ docker_images: pipelines: - habitat/build - - habitat/test: - definition: .expeditor/habitat_test.yml - omnibus/release - omnibus/adhoc: definition: .expeditor/release.omnibus.yml @@ -35,7 +33,6 @@ pipelines: - N: 5 - coverage: description: Generate test coverage report - public: true env: - CI_ENABLE_COVERAGE: true - LANG: "C.UTF-8" @@ -46,9 +43,9 @@ pipelines: - www/deploy: description: Deploy website to inspec.io definition: .expeditor/wwwdeploy.yml - - verify/resources: + - integration/resources: description: Test core resources with test-kitchen. - definition: .expeditor/verify.resources.yml + definition: .expeditor/integration.resources.yml - integration/libraries: description: Integration with plugins, gems, resource packs. definition: .expeditor/integration.libraries.yml @@ -61,6 +58,9 @@ pipelines: - integration/automate: description: Integration with Chef Automate definition: .expeditor/integration.automate.yml + - artifact/habitat: + description: Execute tests against the habitat artifact + definition: .expeditor/artifact.habitat.yml schedules: - name: integration_schedule diff --git a/.expeditor/verify.resources.yml b/.expeditor/integration.resources.yml similarity index 100% rename from .expeditor/verify.resources.yml rename to .expeditor/integration.resources.yml From cf4f5509dccf938a8ca1297a15d1baa72d521474 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Fri, 18 Oct 2019 20:37:00 +0000 Subject: [PATCH 56/56] Bump version to 4.18.6 by Chef Expeditor Obvious fix; these changes are the result of automation not creative thinking. --- CHANGELOG.md | 9 ++++----- VERSION | 2 +- inspec-bin/lib/inspec-bin/version.rb | 2 +- lib/inspec/version.rb | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a42c82a..6722bab6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,17 @@ # Change Log - -## [v4.18.5](https://github.com/inspec/inspec/tree/v4.18.5) (2019-10-17) + +## [v4.18.6](https://github.com/inspec/inspec/tree/v4.18.6) (2019-10-18) #### Merged Pull Requests -- Use a good profile with inspec check test [#4612](https://github.com/inspec/inspec/pull/4612) ([miah](https://github.com/miah)) -- Dont trigger yet [#4611](https://github.com/inspec/inspec/pull/4611) ([miah](https://github.com/miah)) -- Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) +- Refactored and added an alternative test mock resource system. [#4566](https://github.com/inspec/inspec/pull/4566) ([zenspider](https://github.com/zenspider)) ### Changes since 4.18.0 release #### Merged Pull Requests +- Refactored and added an alternative test mock resource system. [#4566](https://github.com/inspec/inspec/pull/4566) ([zenspider](https://github.com/zenspider)) - Use a good profile with inspec check test [#4612](https://github.com/inspec/inspec/pull/4612) ([miah](https://github.com/miah)) - Dont trigger yet [#4611](https://github.com/inspec/inspec/pull/4611) ([miah](https://github.com/miah)) - Empty resources yml until I build it. [#4610](https://github.com/inspec/inspec/pull/4610) ([miah](https://github.com/miah)) diff --git a/VERSION b/VERSION index 3c6cd2e55..87e0b90ab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.18.5 \ No newline at end of file +4.18.6 \ No newline at end of file diff --git a/inspec-bin/lib/inspec-bin/version.rb b/inspec-bin/lib/inspec-bin/version.rb index 0fe7a7269..26bec592b 100644 --- a/inspec-bin/lib/inspec-bin/version.rb +++ b/inspec-bin/lib/inspec-bin/version.rb @@ -1,5 +1,5 @@ # This file managed by automation - do not edit manually module InspecBin INSPECBIN_ROOT = File.expand_path("../..", __FILE__) - VERSION = "4.18.5".freeze + VERSION = "4.18.6".freeze end diff --git a/lib/inspec/version.rb b/lib/inspec/version.rb index 9f44faecc..24ed18c5e 100644 --- a/lib/inspec/version.rb +++ b/lib/inspec/version.rb @@ -1,3 +1,3 @@ module Inspec - VERSION = "4.18.5".freeze + VERSION = "4.18.6".freeze end