mirror of
https://github.com/inspec/inspec
synced 2025-02-18 15:08:44 +00:00
Helps with Customer Bug 236 (see there for repro) Currently, when we run `inspec compliance upload my_profile` it is cached locally in inspec when run. If we update the version in the core code and run another upload, `inspec compliance upload my_profile` again it will run the old cached version instead of running a new copy from automate. The current workaround is to specify the desired version with `inspec exec compliance://my_profile/admin#0.1.1`. The caching happens before we have forward sight into the profile's contents and only the target name. So the text used to generate the cache would be `compliance://my_profile/admin` which does not change version to version. A fix here could simply identify when we are doing a local `inspec exec compliance://` (hitting local profiles does not generate a cache) and skips the cache if there's no version specified. That would eliminate the unexpected behavior. However, it is a breaking change for customers as some current caching taking place would no longer take place. Instead, we have included a `clear_cache` cli method for InSpec, which should assist the core team and other developers in the future when debugging edge case issues in InSpec. Signed-off-by: Nick Schwaderer <nschwaderer@chef.io>
27 lines
678 B
Ruby
27 lines
678 B
Ruby
require "functional/helper"
|
|
require "securerandom"
|
|
|
|
describe "inspec check" do
|
|
include FunctionalHelper
|
|
|
|
parallelize_me!
|
|
|
|
describe "inspec clear_cache" do
|
|
it "clears any existing cache" do
|
|
dirname = File.expand_path("~/.inspec/cache")
|
|
unless File.directory?(dirname)
|
|
FileUtils.mkdir_p(dirname)
|
|
end
|
|
newfile = "#{dirname}/#{SecureRandom.hex(10)}.txt"
|
|
File.write(newfile, SecureRandom.hex(100))
|
|
|
|
assert !Dir.glob(newfile).empty?
|
|
|
|
out = inspec("clear_cache")
|
|
|
|
assert_empty Dir.glob(newfile)
|
|
assert_exit_code 0, out
|
|
_(out.stdout).must_include "== InSpec cache cleared successfully ==\n"
|
|
end
|
|
end
|
|
end
|