mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
Functional test and fixtures for git fetcher fallback
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
parent
f9d419f219
commit
928cf6f05e
12 changed files with 72 additions and 2 deletions
BIN
test/fixtures/profiles/fetcher-failures/git-deps-on-missing-0.1.0.tar.gz
vendored
Normal file
BIN
test/fixtures/profiles/fetcher-failures/git-deps-on-missing-0.1.0.tar.gz
vendored
Normal file
Binary file not shown.
5
test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/dep-on-missing.rb
vendored
Normal file
5
test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/dep-on-missing.rb
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
control "dep-on-missing-01" do
|
||||||
|
describe "a string" do
|
||||||
|
it { should cmp "a string" }
|
||||||
|
end
|
||||||
|
end
|
1
test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/include-missing.rb
vendored
Normal file
1
test/fixtures/profiles/fetcher-failures/git-deps-on-missing/controls/include-missing.rb
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
include_controls('inspec-test-profile-missing')
|
10
test/fixtures/profiles/fetcher-failures/git-deps-on-missing/inspec.yml
vendored
Normal file
10
test/fixtures/profiles/fetcher-failures/git-deps-on-missing/inspec.yml
vendored
Normal file
|
@ -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
|
5
test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/README.md
vendored
Normal file
5
test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/README.md
vendored
Normal file
|
@ -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.
|
|
@ -0,0 +1 @@
|
||||||
|
include_controls('inspec-test-profile-basic')
|
|
@ -0,0 +1,5 @@
|
||||||
|
control "missing-01" do
|
||||||
|
describe "a string" do
|
||||||
|
it { should cmp "a string" }
|
||||||
|
end
|
||||||
|
end
|
9
test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/inspec.yml
vendored
Normal file
9
test/fixtures/profiles/fetcher-failures/inspec-test-profile-missing-moved/inspec.yml
vendored
Normal file
|
@ -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
|
|
@ -0,0 +1 @@
|
||||||
|
include_controls('git-deps-on-missing')
|
5
test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/local-dep.rb
vendored
Normal file
5
test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/controls/local-dep.rb
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
control "local-dep-01" do
|
||||||
|
describe "a string" do
|
||||||
|
it { should cmp "a string" }
|
||||||
|
end
|
||||||
|
end
|
9
test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/inspec.yml
vendored
Normal file
9
test/fixtures/profiles/fetcher-failures/local-dep-on-bad-git-archive/inspec.yml
vendored
Normal file
|
@ -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
|
|
@ -1,16 +1,16 @@
|
||||||
require "functional/helper"
|
require "functional/helper"
|
||||||
|
|
||||||
describe "the fetchers" do
|
describe "the fetchers" do
|
||||||
parallelize_me!
|
|
||||||
include FunctionalHelper
|
include FunctionalHelper
|
||||||
|
|
||||||
let(:looks_like_a_stacktrace) { %r{lib/inspec/.+\.rb:\d+:in} }
|
let(:looks_like_a_stacktrace) { %r{lib/inspec/.+\.rb:\d+:in} }
|
||||||
let(:invocation) { "exec #{path} --no-create-lockfile" }
|
let(:invocation) { "exec #{path} --no-create-lockfile" }
|
||||||
let(:run_result) { inspec(invocation) }
|
let(:run_result) { inspec(invocation) }
|
||||||
|
let(:fetcher_profiles) { "#{profile_path}/fetcher-failures" }
|
||||||
|
|
||||||
# Refs #4726
|
# Refs #4726
|
||||||
describe "when fetchers fetch a bad dependency" do
|
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)
|
def assert_fetcher_failed_cleanly(run_result, error_regex, profile_location)
|
||||||
_(run_result.stdout).must_be_empty
|
_(run_result.stdout).must_be_empty
|
||||||
|
@ -54,4 +54,23 @@ describe "the fetchers" do
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue