mirror of
https://github.com/inspec/inspec
synced 2024-11-27 07:00:39 +00:00
f0ca02a1c5
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
23 lines
956 B
Ruby
23 lines
956 B
Ruby
require "helper"
|
|
require "inspec/resource"
|
|
require "inspec/resources/opa_cli"
|
|
|
|
describe "Inspec::Resources::OpaCli" do
|
|
it "verify opa eval query result parsing" do
|
|
resource = load_resource("opa_cli", policy: "example.rego", data: "input.json", query: "data.example.allow")
|
|
_(resource.params["result"][0]["expressions"][0]["value"]).must_equal false
|
|
_(resource.allow).must_equal false
|
|
end
|
|
|
|
it "fails when policy, data or query is nil." do
|
|
resource = load_resource("opa_cli")
|
|
_(resource.resource_failed?).must_equal true
|
|
_(resource.resource_exception_message).must_equal "OPA policy, data and query are mandatory."
|
|
end
|
|
|
|
it "fails when empty string passed for options policy, data or query." do
|
|
resource = load_resource("opa_cli", policy: "", data: "", query: "")
|
|
_(resource.resource_failed?).must_equal true
|
|
_(resource.resource_exception_message).must_equal "OPA policy, data and query are mandatory."
|
|
end
|
|
end
|