inspec/test/functional/inspec_exec_automate.rb
Jared Quick 71003cd564
Error cleanly if a reporter errors while rendering (#3280)
* Error cleanly if a reporter error while rendering.
* Add functional test for automate reporter.
* Remove authors.

Signed-off-by: Jared Quick <jquick@chef.io>
2018-08-09 09:18:10 -04:00

36 lines
910 B
Ruby

# encoding: utf-8
require 'functional/helper'
require 'tempfile'
describe 'inspec exec automate' do
include FunctionalHelper
let(:json_file) do
file = Tempfile.new('json.conf')
json = <<~EOF
{
"reporter": {
"automate" : {
"stdout" : false,
"url" : "https://fake_url_a2.com/data-collector/v0/",
"token" : "faketoken123",
"insecure" : true
}
}
}
EOF
file.write(json)
file.close
file.path
end
it 'fails when trying to send a report to a fake url' do
out = inspec('exec ' + example_profile + ' --no-create-lockfile --json-config ' + json_file)
out.stderr.must_equal "Error generating reporter 'automate'\n"
out.exit_status.must_equal 1
stdout = out.stdout.force_encoding(Encoding::UTF_8)
stdout.must_include "ERROR: send_report: POST to /data-collector/v0/"
end
end