summaryrefslogtreecommitdiff
path: root/acceptance/fips/test/integration/fips-unit-functional/serverspec/fips-unit-functional_spec.rb
blob: 446261f83f8eaf01bbff6602d834ad009eca6764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require "mixlib/shellout"
require "bundler"

describe "Chef Fips Unit/Functional Specs" do
  def windows?
    if RUBY_PLATFORM =~ /mswin|mingw|windows/
      true
    else
      false
    end
  end

  let(:omnibus_root) do
    if windows?
      "c:/opscode/chef"
    else
      "/opt/chef"
    end
  end

  let(:env) do
    {
      "PATH" => [ "#{omnibus_root}/embedded/bin", ENV["PATH"] ].join(File::PATH_SEPARATOR),
      "BUNDLE_GEMFILE" => "#{omnibus_root}/Gemfile",
      "GEM_PATH" => nil, "GEM_CACHE" => nil, "GEM_HOME" => nil,
      "BUNDLE_IGNORE_CONFIG" => "true",
      "BUNDLE_FROZEN" => "1",
      "CHEF_FIPS" => "1"
    }
  end

  let(:chef_dir) do
    cmd = Mixlib::ShellOut.new("bundle show chef", env: env).run_command
    cmd.error!
    cmd.stdout.chomp
  end

  def run_rspec_test(test)
    Bundler.with_clean_env do
      cmd = Mixlib::ShellOut.new(
        "bundle exec rspec -f documentation -t ~requires_git #{test}",
        env: env, cwd: chef_dir, timeout: 3600
      )
      cmd.run_command.error!
    end
  end

  it "passes the unit specs" do
    run_rspec_test("spec/unit")
  end

  it "passes the functional specs" do
    run_rspec_test("spec/functional")
  end

end