diff --git a/.codeclimate.yml b/.codeclimate.yml index 82bbb5b98..fe1ecf824 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -8,6 +8,9 @@ checks: identical-code: config: threshold: 40 # Unfortunately, we have a lot of duplicate code in places like lib/inspec/control_eval_context.rb + method-complexity: # 'Cognitive Complexity' in the UI + config: + threshold: 10 # 5 Default 5 is really tight plugins: fixme: enabled: true diff --git a/docs/profiles.md b/docs/profiles.md index 92a698965..e03d0fadb 100644 --- a/docs/profiles.md +++ b/docs/profiles.md @@ -212,9 +212,7 @@ depends: ### git -A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, and version. The source location is translated into a URL upon resolution. This type of dependency supports version constraints via semantic versioning as git tags. - -For example: +A `git` setting specifies a profile that is located in a git repository, with optional settings for branch, tag, commit, version, and relative_path. The source location is translated into a URL upon resolution. This type of dependency supports version constraints via semantic versioning as git tags. ```YAML depends: @@ -224,6 +222,7 @@ depends: tag: desired_version commit: pinned_commit version: semver_via_tags + relative_path: relative/optional/path/to/profile ``` ### supermarket diff --git a/lib/fetchers/git.rb b/lib/fetchers/git.rb index 61af0f29e..49203a701 100644 --- a/lib/fetchers/git.rb +++ b/lib/fetchers/git.rb @@ -39,28 +39,65 @@ module Fetchers @branch = opts[:branch] @tag = opts[:tag] @ref = opts[:ref] - @remote_url = remote_url + @remote_url = expand_local_path(remote_url) @repo_directory = nil + @relative_path = opts[:relative_path] if opts[:relative_path] && !opts[:relative_path].empty? end - def fetch(dir) - @repo_directory = dir - FileUtils.mkdir_p(dir) unless Dir.exist?(dir) + def expand_local_path(url_or_file_path) + # This paths to local on-disk repos, not relative paths within repos. + # This is especially needed with testing. + + # We could try to do something clever with URI + # processing, but then again, if you passed a relative path + # to an on-disk repo, you probably expect it to exist. + return url_or_file_path unless File.exist?(url_or_file_path) + # It's important to expand this path, because it may be specified + # locally in the metadata files, and when we clone, we will be + # in a temp dir. + File.expand_path(url_or_file_path) + end + + def fetch(destination_path) + @repo_directory = destination_path # Might be the cache, or vendoring, or something else + FileUtils.mkdir_p(destination_path) unless Dir.exist?(destination_path) if cloned? checkout else - Dir.mktmpdir do |tmpdir| - checkout(tmpdir) - Inspec::Log.debug("Checkout of #{resolved_ref} successful. Moving checkout to #{dir}") - FileUtils.cp_r(tmpdir + "/.", @repo_directory) + Dir.mktmpdir do |working_dir| + checkout(working_dir) + if @relative_path + perform_relative_path_fetch(destination_path, working_dir) + else + Inspec::Log.debug("Checkout of #{resolved_ref} successful. " \ + "Moving checkout to #{destination_path}") + FileUtils.cp_r(working_dir + "/.", destination_path) + end end end @repo_directory end + def perform_relative_path_fetch(destination_path, working_dir) + Inspec::Log.debug("Checkout of #{resolved_ref} successful. " \ + "Moving #{@relative_path} to #{destination_path}") + unless File.exist?("#{working_dir}/#{@relative_path}") + # Cleanup the destination path - otherwise we'll have an empty dir + # in the cache, which is enough to confuse the cache reader + # This is a courtesy, assuming we're writing to the cache; if we're + # vendoring to something more complex, don't bother. + FileUtils.rmdir(destination_path) if Dir.empty?(destination_path) + + raise ArgumentError, "Cannot find relative path '#{@relative_path}' " \ + "within profile in git repo specified by '#{@remote_url}'" + end + FileUtils.cp_r("#{working_dir}/#{@relative_path}", destination_path) + end + def cache_key - resolved_ref + return resolved_ref unless @relative_path + OpenSSL::Digest::SHA256.hexdigest(resolved_ref + @relative_path) end def archive_path @@ -68,7 +105,9 @@ module Fetchers end def resolved_source - { git: @remote_url, ref: resolved_ref } + source = { git: @remote_url, ref: resolved_ref } + source[:relative_path] = @relative_path if @relative_path + source end private diff --git a/test/functional/git_fetcher_test.rb b/test/functional/git_fetcher_test.rb new file mode 100644 index 000000000..d5940db6e --- /dev/null +++ b/test/functional/git_fetcher_test.rb @@ -0,0 +1,129 @@ +require "functional/helper" +require "fileutils" +require "tmpdir" + +describe "running profiles with git-based dependencies" do + include FunctionalHelper + let(:git_profiles) { "#{profile_path}/git-fetcher" } + + #======================================================================# + # Git Repo Setup + #======================================================================# + fixture_repos = %w{basic-local git-repo-01} + + before(:all) do + skip_windows! # Right now, this is due to symlinking + + # We need a git repo for some of the profile test fixtures, + # but we can't store those directly in git. + # Here, one approach is to store the .git/ directory under a + # different name and then symlink to its proper name. + fixture_repos.each do |profile_name| + link_src = "#{git_profiles}/#{profile_name}/git-fixture" + link_dst = "#{git_profiles}/#{profile_name}/.git" + FileUtils.ln_sf(link_src, link_dst) # -f to tolerate existing links created during manual testing + end + end + + after(:all) do + fixture_repos.each do |profile_name| + link = "#{git_profiles}/#{profile_name}/.git" + FileUtils.rm(link) + end + end + + #======================================================================# + # Custom Local Assertions + #======================================================================# + def assert_relative_fetch_works(profile_name, expected_profiles, expected_controls) + run_result = run_inspec_process("exec #{git_profiles}/#{profile_name}", json: true) + assert_empty run_result.stderr + run_result.must_have_all_controls_passing + + # Should know about the top-level profile and the child profile + assert_equal expected_profiles, (run_result.payload.json["profiles"].map { |p| p["name"] }) + + controls = run_result.payload.json["profiles"].map { |p| p["controls"] }.flatten.map { |c| c["id"] }.uniq + # Should have controls from the top-level and included child profile + expected_controls.each { |control| assert_includes controls, control } + + # should not have controls from the profile defined at the top of the repo of the child profile + refute_includes controls, "red-dye" + end + + #======================================================================# + # Basic Git Fetching + #======================================================================# + describe "running a profile with a basic local dependency" do + it "should work on a local checkout" do + run_result = run_inspec_process("exec #{git_profiles}/basic-local", json: true) + assert_empty run_result.stderr + run_result.must_have_all_controls_passing + end + end + # describe "running a profile with a basic remote dependency" + + # TODO: move private SSH+git test from inspec_exec_test to here + + #======================================================================# + # Revision Selection + #======================================================================# + # NOTE: test branch, rev, and tag capabilities are (lighty) tested in unit tests + + #======================================================================# + # Relative Path Support + #======================================================================# + + #------------ Happy Cases for Relative Path Support -------------------# + describe "running a profile with a shallow relative path dependency" do + it "should find the relative path profile and execute exactly those controls" do + assert_relative_fetch_works("relative-shallow", %w{relative-shallow child-01}, %w{top-level-01 child-01}) + end + end + + describe "running a profile with a deep relative path dependency" do + it "should find the relative path profile and execute exactly those controls" do + assert_relative_fetch_works("relative-deep", %w{relative-deep child-02}, %w{relative-deep-01 child-02}) + end + end + + describe "running a profile with a combination of relative path dependencies" do + it "should find the relative path profiles and execute exactly those controls" do + assert_relative_fetch_works( + "relative-combo", + %w{relative-combo child-01 child-02}, + %w{relative-combo-01 child-01 child-02} + ) + end + end + + #------------ Edge Cases for Relative Path Support -------------------# + + describe "running a profile with an '' relative path dependency" do + it "should find the top-level profile in the git-referenced child profile and execute that" do + assert_relative_fetch_works("relative-empty", %w{relative-empty basic-local}, %w{relative-empty-01 basic-local-01}) + end + end + + describe "running a profile with an ./ relative path dependency" do + it "should find the top-level profile in the git-referenced child profile and execute that" do + assert_relative_fetch_works("relative-dot-slash", %w{relative-dot-slash basic-local}, %w{relative-dot-slash-01 basic-local-01}) + end + end + + describe "running a profile with a relative path dependency that does not exist" do + it "should fail gracefully" do + run_result = run_inspec_process("exec #{git_profiles}/relative-nonesuch") + assert_empty run_result.stdout + refute_includes run_result.stderr, "Errno::ENOENT" # No ugly file missing error + assert_equal 1, run_result.stderr.lines.count # Not a giant stacktrace + # Spot check important parts of the message + assert_includes run_result.stderr, "Cannot find relative path" + assert_includes run_result.stderr, "no/such/path" # the actual missing path + assert_includes run_result.stderr, "profile in git repo" + # The containing git repo (the only identifier the user will have) + assert_includes run_result.stderr, "test/unit/mock/profiles/git-fetcher/git-repo-01" + assert_exit_code(1, run_result) # General user error + end + end +end diff --git a/test/functional/gitfetcher_test.rb b/test/functional/gitfetcher_test.rb deleted file mode 100644 index 1da7f9ea4..000000000 --- a/test/functional/gitfetcher_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require "functional/helper" -require "fileutils" -require "tmpdir" -require "yaml" - -describe "profiles with git-based dependencies" do - include FunctionalHelper - before(:all) do - @tmpdir = Dir.mktmpdir - @profile_dir = File.join(@tmpdir, "test-profile") - @git_dep_dir = File.join(@tmpdir, "git-dep") - - Dir.chdir(@tmpdir) do - inspec("init profile git-dep") - inspec("init profile test-profile") - end - - Dir.chdir(@git_dep_dir) do - CMD.run_command("git init") - CMD.run_command("git add .") - CMD.run_command("git config user.name \"test\"") - CMD.run_command("git config user.email \"test@yahoo.com\"") - CMD.run_command("git commit -m \"initial commit\" --no-gpg-sign") - CMD.run_command("git commit -m \"another commit\" --allow-empty --no-gpg-sign") - CMD.run_command("git tag antag") - end - - inspec_yml = YAML.load(File.read(File.join(@profile_dir, "inspec.yml"))) - inspec_yml["depends"] = [ - { - "name" => "git-dep", - "git" => @git_dep_dir, - "tag" => "antag", - }, - ] - File.write(File.join(@profile_dir, "inspec.yml"), YAML.dump(inspec_yml)) - end - - after(:all) do - FileUtils.rm_rf(@tmpdir) - end - - it "executes a profile with a git based dependency" do - out = inspec("exec #{@profile_dir} --no-create-lockfile") - - skip_windows! - out.stderr.must_equal "" - - assert_exit_code 0, out - end -end diff --git a/test/functional/inspec_vendor_test.rb b/test/functional/inspec_vendor_test.rb index fb3eef4e2..aff0dc2ce 100644 --- a/test/functional/inspec_vendor_test.rb +++ b/test/functional/inspec_vendor_test.rb @@ -69,7 +69,7 @@ describe "example inheritance profile" do end it "can vendor profile dependencies from git" do - git_depends_path = File.join(profile_path, "git-depends") + git_depends_path = File.join(profile_path, "git-fetcher", "basic") Dir.mktmpdir do |tmpdir| FileUtils.cp_r(git_depends_path + "/.", tmpdir) diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/README.md b/test/unit/mock/profiles/git-fetcher/basic-local/README.md new file mode 100644 index 000000000..1a577de31 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/README.md @@ -0,0 +1 @@ +This is a git repo used as a test fixture. Because we cannot directly store the .git/ directory, it is stored as git-fixture/, and a symlink is created at test runtime. diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/controls/basic-local.rb b/test/unit/mock/profiles/git-fetcher/basic-local/controls/basic-local.rb new file mode 100644 index 000000000..38b63f301 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/controls/basic-local.rb @@ -0,0 +1,5 @@ +control 'basic-local-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/COMMIT_EDITMSG b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/COMMIT_EDITMSG new file mode 100644 index 000000000..718d0a25f --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/COMMIT_EDITMSG @@ -0,0 +1 @@ +Add change only on one branch diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/HEAD b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/config b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/config new file mode 100644 index 000000000..271d6fa51 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/config @@ -0,0 +1,10 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + name = test user + email = test@test.org diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/description b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/index b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/index new file mode 100644 index 000000000..3aa985884 Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/index differ diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/info/exclude b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/HEAD b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/HEAD new file mode 100644 index 000000000..a1ce8a223 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/HEAD @@ -0,0 +1,4 @@ +0000000000000000000000000000000000000000 0e7d2b9c2c5a1372341e36febceab86558439149 test user 1560485536 -0400 commit (initial): Initial commit +0e7d2b9c2c5a1372341e36febceab86558439149 0e7d2b9c2c5a1372341e36febceab86558439149 test user 1560485563 -0400 checkout: moving from master to test-branch +0e7d2b9c2c5a1372341e36febceab86558439149 54d0671d3e2c4a28865a0ecc98863859bd4d7475 test user 1560485674 -0400 commit: Add change only on one branch +54d0671d3e2c4a28865a0ecc98863859bd4d7475 0e7d2b9c2c5a1372341e36febceab86558439149 test user 1560485682 -0400 checkout: moving from test-branch to master diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/refs/heads/master b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/refs/heads/master new file mode 100644 index 000000000..3f84a39cb --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 0e7d2b9c2c5a1372341e36febceab86558439149 test user 1560485536 -0400 commit (initial): Initial commit diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/refs/heads/test-branch b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/refs/heads/test-branch new file mode 100644 index 000000000..d5f96b612 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/logs/refs/heads/test-branch @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 0e7d2b9c2c5a1372341e36febceab86558439149 test user 1560485563 -0400 branch: Created from HEAD +0e7d2b9c2c5a1372341e36febceab86558439149 54d0671d3e2c4a28865a0ecc98863859bd4d7475 test user 1560485674 -0400 commit: Add change only on one branch diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/02/145c02bed66651584950fd3c56a0f8e08495ad b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/02/145c02bed66651584950fd3c56a0f8e08495ad new file mode 100644 index 000000000..b1f7bd879 Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/02/145c02bed66651584950fd3c56a0f8e08495ad differ diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/0e/7d2b9c2c5a1372341e36febceab86558439149 b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/0e/7d2b9c2c5a1372341e36febceab86558439149 new file mode 100644 index 000000000..165073fb2 Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/0e/7d2b9c2c5a1372341e36febceab86558439149 differ diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/26/dec4a490f980527c06528510ed85512fd55e10 b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/26/dec4a490f980527c06528510ed85512fd55e10 new file mode 100644 index 000000000..283de660e --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/26/dec4a490f980527c06528510ed85512fd55e10 @@ -0,0 +1,4 @@ +x +0 D;+n$h{$j+o +] +;-'y6ܐ)+ (5t4lwރVl@@,~^;e&E2W kI \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/38/b63f30119439953105a30b6b54201ccdf161ad b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/38/b63f30119439953105a30b6b54201ccdf161ad new file mode 100644 index 000000000..32b3d0d2f --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/38/b63f30119439953105a30b6b54201ccdf161ad @@ -0,0 +1,2 @@ +xU +0 oT HS.7]McXTY $!YqtYs@a- {# \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/53/7a2ff34c95a18643627a95ae39b1af3f645346 b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/53/7a2ff34c95a18643627a95ae39b1af3f645346 new file mode 100644 index 000000000..14270ee3d Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/53/7a2ff34c95a18643627a95ae39b1af3f645346 differ diff --git a/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/54/d0671d3e2c4a28865a0ecc98863859bd4d7475 b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/54/d0671d3e2c4a28865a0ecc98863859bd4d7475 new file mode 100644 index 000000000..671488c97 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/basic-local/git-fixture/objects/54/d0671d3e2c4a28865a0ecc98863859bd4d7475 @@ -0,0 +1,4 @@ +xQ +0D)J&)QͶl+im0 1554036073 -0400 commit (initial): Add child-01 profile +65dcdc3491c0c138538379f404f2517d968282a7 36f4c4ecd2b870c0d0869c14a3e41dd506e5a887 InSpec Test Fixture 1554036109 -0400 commit: Add child-02 diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/logs/refs/heads/master b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/logs/refs/heads/master new file mode 100644 index 000000000..2626ce40e --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/logs/refs/heads/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 65dcdc3491c0c138538379f404f2517d968282a7 InSpec Test Fixture 1554036073 -0400 commit (initial): Add child-01 profile +65dcdc3491c0c138538379f404f2517d968282a7 36f4c4ecd2b870c0d0869c14a3e41dd506e5a887 InSpec Test Fixture 1554036109 -0400 commit: Add child-02 diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/0c/0abc0b6dc094bf6756b369db878c69f11839c5 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/0c/0abc0b6dc094bf6756b369db878c69f11839c5 new file mode 100644 index 000000000..69749181e Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/0c/0abc0b6dc094bf6756b369db878c69f11839c5 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/16/d0355317bef35f2dc7e71607b5e6df7c812713 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/16/d0355317bef35f2dc7e71607b5e6df7c812713 new file mode 100644 index 000000000..0b4a5004a Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/16/d0355317bef35f2dc7e71607b5e6df7c812713 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/36/f4c4ecd2b870c0d0869c14a3e41dd506e5a887 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/36/f4c4ecd2b870c0d0869c14a3e41dd506e5a887 new file mode 100644 index 000000000..26486e354 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/36/f4c4ecd2b870c0d0869c14a3e41dd506e5a887 @@ -0,0 +1,3 @@ +xK +1 @]~2mAD7k@MR32VGp={_ER)4┣( 55⠵yE -#['s #%ߖ+єWN }v8w- +6=pϣMw`b5Dÿˮ <љ-H8 \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/3d/06a6c531116e47438e0009be37aad4c19eeec1 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/3d/06a6c531116e47438e0009be37aad4c19eeec1 new file mode 100644 index 000000000..22fa52dca Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/3d/06a6c531116e47438e0009be37aad4c19eeec1 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/4e/45530f8d46d447cba28d4a41e55cd5b06c0f72 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/4e/45530f8d46d447cba28d4a41e55cd5b06c0f72 new file mode 100644 index 000000000..55e7ac97d Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/4e/45530f8d46d447cba28d4a41e55cd5b06c0f72 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/65/dcdc3491c0c138538379f404f2517d968282a7 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/65/dcdc3491c0c138538379f404f2517d968282a7 new file mode 100644 index 000000000..a529d9ee7 Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/65/dcdc3491c0c138538379f404f2517d968282a7 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/74/198b01ae86430df0149b4389f112f6a94ba47d b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/74/198b01ae86430df0149b4389f112f6a94ba47d new file mode 100644 index 000000000..b0a8988ac Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/74/198b01ae86430df0149b4389f112f6a94ba47d differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/87/da758286290d2ec7de5d0a748b4db7a5c4eff5 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/87/da758286290d2ec7de5d0a748b4db7a5c4eff5 new file mode 100644 index 000000000..9eb0fd8cc Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/87/da758286290d2ec7de5d0a748b4db7a5c4eff5 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/a6/a86bbacc7daf98fb1155a7ebfca37164f8873f b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/a6/a86bbacc7daf98fb1155a7ebfca37164f8873f new file mode 100644 index 000000000..3253f436f Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/a6/a86bbacc7daf98fb1155a7ebfca37164f8873f differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/b7/923d86b8b8951df0eee505671907a59410a978 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/b7/923d86b8b8951df0eee505671907a59410a978 new file mode 100644 index 000000000..512aea4a7 Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/b7/923d86b8b8951df0eee505671907a59410a978 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/df/e8db2e9636f83a29b42d790c4061f08da60ccd b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/df/e8db2e9636f83a29b42d790c4061f08da60ccd new file mode 100644 index 000000000..9bdf8409c Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/df/e8db2e9636f83a29b42d790c4061f08da60ccd differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e0/a79951d85e314d4f091201bceaeab5001ea8e9 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e0/a79951d85e314d4f091201bceaeab5001ea8e9 new file mode 100644 index 000000000..ef9e9a4c2 Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e0/a79951d85e314d4f091201bceaeab5001ea8e9 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e6/d4da70d17f77ab9276a448633b69de7d253f39 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e6/d4da70d17f77ab9276a448633b69de7d253f39 new file mode 100644 index 000000000..3cb4847fc Binary files /dev/null and b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e6/d4da70d17f77ab9276a448633b69de7d253f39 differ diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e9/dd6fd217cced2639b2ad64319bfd73b28a413a b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e9/dd6fd217cced2639b2ad64319bfd73b28a413a new file mode 100644 index 000000000..154842f2c --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/e9/dd6fd217cced2639b2ad64319bfd73b28a413a @@ -0,0 +1,3 @@ +xMA +0E)hv=ʘu I}.֤+Q(G%aZ\9In6 +;8vL&+CJHGSĂʉ k-8fZ{۴fm}7+ \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/ff/13d726419b64726a7ef787377367d598cbb509 b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/ff/13d726419b64726a7ef787377367d598cbb509 new file mode 100644 index 000000000..8fe1a3a2b --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/objects/ff/13d726419b64726a7ef787377367d598cbb509 @@ -0,0 +1 @@ +xM1 S-;J< ppΖXRh4[ qT#$qZVgb2F!t7R.u0Ɛ9[ T#3F}Ve^ִhWk/:5f \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/refs/heads/master b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/refs/heads/master new file mode 100644 index 000000000..5798ee814 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/git-repo-01/git-fixture/refs/heads/master @@ -0,0 +1 @@ +36f4c4ecd2b870c0d0869c14a3e41dd506e5a887 diff --git a/test/unit/mock/profiles/git-fetcher/git-repo-01/inspec.yml b/test/unit/mock/profiles/git-fetcher/git-repo-01/inspec.yml new file mode 100644 index 000000000..5527619f7 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/git-repo-01/inspec.yml @@ -0,0 +1,2 @@ +name: red-dye +description: A profile designed to detect if controls are accidentally included \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-combo/controls/relative-combo.rb b/test/unit/mock/profiles/git-fetcher/relative-combo/controls/relative-combo.rb new file mode 100644 index 000000000..ed217b6e6 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-combo/controls/relative-combo.rb @@ -0,0 +1,8 @@ +include_controls 'child-01' +include_controls 'child-02' + +control 'relative-combo-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-combo/inspec.yml b/test/unit/mock/profiles/git-fetcher/relative-combo/inspec.yml new file mode 100644 index 000000000..30fe852bd --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-combo/inspec.yml @@ -0,0 +1,14 @@ +name: relative-combo +title: relative-combo +license: Apache-2.0 +summary: A profile that uses git to depend on profiles in deep subdirs +version: 0.1.0 +supports: + platform: os +depends: +- name: child-01 + git: test/unit/mock/profiles/git-fetcher/git-repo-01 + relative_path: child-01 +- name: child-02 + git: test/unit/mock/profiles/git-fetcher/git-repo-01 + relative_path: deeper-path/in/repo/child-02 diff --git a/test/unit/mock/profiles/git-fetcher/relative-deep/controls/relative-deep.rb b/test/unit/mock/profiles/git-fetcher/relative-deep/controls/relative-deep.rb new file mode 100644 index 000000000..5bf65811b --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-deep/controls/relative-deep.rb @@ -0,0 +1,7 @@ +include_controls 'child-02' + +control 'relative-deep-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-deep/inspec.yml b/test/unit/mock/profiles/git-fetcher/relative-deep/inspec.yml new file mode 100644 index 000000000..17e0bca05 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-deep/inspec.yml @@ -0,0 +1,11 @@ +name: relative-deep +title: releative-deep +license: Apache-2.0 +summary: A profile that uses git to depend on profiles in deep subdirs +version: 0.1.0 +supports: + platform: os +depends: +- name: child-02 + git: test/unit/mock/profiles/git-fetcher/git-repo-01 + relative_path: deeper-path/in/repo/child-02 diff --git a/test/unit/mock/profiles/git-fetcher/relative-dot-slash/controls/relative-dot-slash.rb b/test/unit/mock/profiles/git-fetcher/relative-dot-slash/controls/relative-dot-slash.rb new file mode 100644 index 000000000..a893c2bf4 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-dot-slash/controls/relative-dot-slash.rb @@ -0,0 +1,7 @@ +include_controls 'basic-local' + +control 'relative-dot-slash-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-dot-slash/inspec.yml b/test/unit/mock/profiles/git-fetcher/relative-dot-slash/inspec.yml new file mode 100644 index 000000000..1dc08f6c0 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-dot-slash/inspec.yml @@ -0,0 +1,11 @@ +name: relative-dot-slash +title: relative-dot-slash +license: Apache-2.0 +summary: A profile that depends on profiles using an ./ path +version: 0.1.0 +supports: + platform: os +depends: +- name: basic-local + git: test/unit/mock/profiles/git-fetcher/basic-local + relative_path: ./ diff --git a/test/unit/mock/profiles/git-fetcher/relative-empty/controls/relative-empty.rb b/test/unit/mock/profiles/git-fetcher/relative-empty/controls/relative-empty.rb new file mode 100644 index 000000000..60c093c7f --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-empty/controls/relative-empty.rb @@ -0,0 +1,7 @@ +include_controls 'basic-local' + +control 'relative-empty-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-empty/inspec.yml b/test/unit/mock/profiles/git-fetcher/relative-empty/inspec.yml new file mode 100644 index 000000000..418bcdeff --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-empty/inspec.yml @@ -0,0 +1,11 @@ +name: relative-empty +title: relative-empty +license: Apache-2.0 +summary: A profile that depends on profiles using an empty-string path +version: 0.1.0 +supports: + platform: os +depends: +- name: basic-local + git: test/unit/mock/profiles/git-fetcher/basic-local + relative_path: '' diff --git a/test/unit/mock/profiles/git-fetcher/relative-nonesuch/controls/relative-nonesuch.rb b/test/unit/mock/profiles/git-fetcher/relative-nonesuch/controls/relative-nonesuch.rb new file mode 100644 index 000000000..748c26a12 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-nonesuch/controls/relative-nonesuch.rb @@ -0,0 +1,7 @@ +include_controls 'none-such-01' + +control 'relative-nonesuch-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-nonesuch/inspec.yml b/test/unit/mock/profiles/git-fetcher/relative-nonesuch/inspec.yml new file mode 100644 index 000000000..fda4ee7e7 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-nonesuch/inspec.yml @@ -0,0 +1,11 @@ +name: relative-nonesuch +title: relative-nonesuch +license: Apache-2.0 +summary: A profile that depends on a profile with a bad relative path +version: 0.1.0 +supports: + platform: os +depends: +- name: none-such-01 + git: test/unit/mock/profiles/git-fetcher/git-repo-01 + relative_path: no/such/path diff --git a/test/unit/mock/profiles/git-fetcher/relative-shallow/controls/top-level.rb b/test/unit/mock/profiles/git-fetcher/relative-shallow/controls/top-level.rb new file mode 100644 index 000000000..a37f5f89f --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-shallow/controls/top-level.rb @@ -0,0 +1,7 @@ +include_controls 'child-01' + +control 'top-level-01' do + describe 'always-pass' do + it { should cmp 'always-pass'} + end +end \ No newline at end of file diff --git a/test/unit/mock/profiles/git-fetcher/relative-shallow/inspec.yml b/test/unit/mock/profiles/git-fetcher/relative-shallow/inspec.yml new file mode 100644 index 000000000..bee308f11 --- /dev/null +++ b/test/unit/mock/profiles/git-fetcher/relative-shallow/inspec.yml @@ -0,0 +1,11 @@ +name: relative-shallow +title: relative-shallow +license: Apache-2.0 +summary: A profile that depends on profiles that are stored in a repo in subdirs +version: 0.1.0 +supports: + platform: os +depends: +- name: child-01 + git: test/unit/mock/profiles/git-fetcher/git-repo-01 + relative_path: child-01