Skip to content

Commit

Permalink
Add tests around default value of priority
Browse files Browse the repository at this point in the history
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
  • Loading branch information
clintoncwolfe committed Sep 11, 2019
1 parent 22f59e5 commit bba7d56
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/fixtures/profiles/priority/controls/priority.rb
Expand Up @@ -23,3 +23,17 @@
it { should cmp "value_from_vault" } # Matches when run with vault on high priority
end
end

# This group is intended to be run only with default priority
# A set of inputs that poke the threshold around the default priority of 60
control "priority_check_default" do
describe input("priority_check_threshold_59", value: "value_from_dsl", priority: 59) do
it { should cmp "value_from_vault" } # Default vault = 60 - vault wins
end
describe input("priority_check_threshold_60", value: "value_from_dsl", priority: 60) do
it { should cmp "value_from_vault" } # DSL = 60, vault = 60 - tie - last wins
end
describe input("priority_check_threshold_61", value: "value_from_dsl", priority: 61) do
it { should cmp "value_from_dsl" } # DSL = 61, Vault = 60 - vault wins
end
end
5 changes: 4 additions & 1 deletion test/fixtures/vault/secret/inspec/priority.json
@@ -1,5 +1,8 @@
{
"priority_check_always_vault":"value_from_vault",
"priority_check_dsl_wins":"value_from_vault",
"priority_check_variable_outcome":"value_from_vault"
"priority_check_variable_outcome":"value_from_vault",
"priority_check_threshold_59":"value_from_vault",
"priority_check_threshold_60":"value_from_vault",
"priority_check_threshold_61":"value_from_vault"
}
12 changes: 12 additions & 0 deletions test/integration/inspec_vault_test.rb
Expand Up @@ -43,4 +43,16 @@ def run_priority_test(priority, first_should_pass)
run_priority_test(75, false)
end
end

describe "when run with default priority" do
it "should pass the threshold tests" do
cmd = "exec #{profile_fixtures}/priority --reporter json"
cmd_result = run_inspec_with_vault_plugin(cmd, env: env)
json = JSON.parse(cmd_result.stdout)
results = json.dig("profiles", 0, "controls", 3, "results")
results.each do |rslt|
assert_equal "passed", rslt.dig("status")
end
end
end
end

0 comments on commit bba7d56

Please sign in to comment.