diff --git a/test/fixtures/profiles/fetcher-failures/git-deps-on-missing-0.1.0.tar.gz b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing-0.1.0.tar.gz new file mode 100644 index 000000000..1b2b0bc9d Binary files /dev/null and b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing-0.1.0.tar.gz differ diff --git a/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/dep-on-missing.rb b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/dep-on-missing.rb new file mode 100644 index 000000000..7fda9ce58 --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/dep-on-missing.rb @@ -0,0 +1,5 @@ +control "dep-on-missing-01" do + describe "a string" do + it { should cmp "a string" } + end +end diff --git a/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/include-missing.rb b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/include-missing.rb new file mode 100644 index 000000000..808ac1ad7 --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/include-missing.rb @@ -0,0 +1 @@ +include_controls('inspec-test-profile-missing') diff --git a/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/inspec.yml b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/inspec.yml new file mode 100644 index 000000000..d0320b6db --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/git-deps-on-missing/inspec.yml @@ -0,0 +1,10 @@ +name: git-deps-on-missing +license: Apache-2.0 +summary: An inspec profile that has a git dependency on a profile that was deleted +version: 0.1.0 +supports: + platform: os +depends: + - name: inspec-test-profile-missing + # git requires a leading slash, so rely on ERB to interpolate in the PWD... + git: /<%= Dir.pwd %>/inspec-test-profile-missing diff --git a/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/README.md b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/README.md new file mode 100644 index 000000000..c1d35ab4e --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/README.md @@ -0,0 +1,5 @@ +# inspec-test-profile-missing + +This is a Chef InSpec profile. It is used in the testing of InSpec itself. This profile was inserted into archives, then the name of the repo was changed, so that it would become unfetchable. This allows us to test the fetchers when they cannot resolve a profile. + +This repo is part of the testing material of InSpec itself, and is not intended for public use. No support is provided. diff --git a/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/controls/include-basic.rb b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/controls/include-basic.rb new file mode 100644 index 000000000..38c63a0cf --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/controls/include-basic.rb @@ -0,0 +1 @@ +include_controls('inspec-test-profile-basic') diff --git a/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/controls/missing.rb b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/controls/missing.rb new file mode 100644 index 000000000..2f9fe6c6e --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/controls/missing.rb @@ -0,0 +1,5 @@ +control "missing-01" do + describe "a string" do + it { should cmp "a string" } + end +end diff --git a/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/inspec.yml b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/inspec.yml new file mode 100644 index 000000000..93a53952a --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/inspec.yml @@ -0,0 +1,9 @@ +name: inspec-test-profile-missing +title: InSpec Profile +summary: An InSpec Compliance Profile that will end up unresolvable but archived +version: 0.1.0 +supports: + platform: os +depends: + - name: inspec-test-profile-basic + git: https://github.com/inspec/inspec-test-profile-basic.git diff --git a/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/include-git-dep.rb b/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/include-git-dep.rb new file mode 100644 index 000000000..7cebbb3eb --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/include-git-dep.rb @@ -0,0 +1 @@ +include_controls('git-deps-on-missing') diff --git a/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/local-dep.rb b/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/local-dep.rb new file mode 100644 index 000000000..52a55f5bd --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/local-dep.rb @@ -0,0 +1,5 @@ +control "local-dep-01" do + describe "a string" do + it { should cmp "a string" } + end +end diff --git a/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/inspec.yml b/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/inspec.yml new file mode 100644 index 000000000..41f93b00b --- /dev/null +++ b/test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/inspec.yml @@ -0,0 +1,9 @@ +name: local-dep-on-bad-git-archive +license: Apache-2.0 +summary: A profile that relies on an archive that has an unresolvable git dependency +version: 0.1.0 +supports: + platform: os +depends: + - name: git-deps-on-missing + path: ../git-deps-on-missing-0.1.0.tar.gz diff --git a/test/functional/fetchers_test.rb b/test/functional/fetchers_test.rb index ca618b426..76fe4a6e3 100644 --- a/test/functional/fetchers_test.rb +++ b/test/functional/fetchers_test.rb @@ -1,16 +1,16 @@ require "functional/helper" describe "the fetchers" do - parallelize_me! include FunctionalHelper let(:looks_like_a_stacktrace) { %r{lib/inspec/.+\.rb:\d+:in} } let(:invocation) { "exec #{path} --no-create-lockfile" } let(:run_result) { inspec(invocation) } + let(:fetcher_profiles) { "#{profile_path}/fetcher-failures" } # Refs #4726 describe "when fetchers fetch a bad dependency" do - let(:fetcher_profiles) { "#{profile_path}/fetcher-failures" } + parallelize_me! def assert_fetcher_failed_cleanly(run_result, error_regex, profile_location) _(run_result.stdout).must_be_empty @@ -54,4 +54,23 @@ describe "the fetchers" do end end + + # Refs #4727 + describe "when a archive is available of an unfetchable profile with --airgap" do + + let(:invocation) { "archive #{path} --airgap" } + let(:path) { "#{fetcher_profiles}/local-dep-on-bad-git-archive" } + + def teardown + FileUtils.rm_rf "#{path}/vendor" + FileUtils.rm_rf "#{fetcher_profiles}/local-dep-on-bad-git-archive-0.1.0.tar.gz" + end + + it "should be able to create a new archive wrapping the profile" do + # Cannot be parallelized - must purge cache to test properly + _(run_result.stderr).must_be_empty + _(run_result.stdout).must_include "Finished archive generation" + assert_exit_code(0, run_result) + end + end end