2019-06-11 22:24:35 +00:00
|
|
|
require_relative "../../../shared/core_plugin_test_helper.rb"
|
2018-10-04 18:31:39 +00:00
|
|
|
|
2019-04-24 00:21:31 +00:00
|
|
|
class ComplianceCli < Minitest::Test
|
2018-10-04 18:31:39 +00:00
|
|
|
include CorePluginFunctionalHelper
|
|
|
|
|
|
|
|
def test_help_output
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance help")
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_equal out.exit_status, 0
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, "inspec compliance exec PROFILE"
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_logout_command
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance logout")
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_equal out.exit_status, 0
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, ""
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_error_login_with_invalid_url
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance login")
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_equal out.exit_status, 1
|
|
|
|
assert_includes out.stderr, 'ERROR: "inspec compliance login" was called with no arguments'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_profile_list_without_auth
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance profiles")
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_equal out.exit_status, 0 # TODO: make this error
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, "You need to login first with `inspec compliance login`"
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_error_upload_without_args
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance upload")
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_equal out.exit_status, 1
|
|
|
|
assert_includes out.stderr, 'ERROR: "inspec compliance upload" was called with no arguments'
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_error_upload_with_fake_path
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance upload /path/to/dir")
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_equal out.exit_status, 0 # TODO: make this error
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, "You need to login first with `inspec compliance login`"
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|
|
|
|
end
|