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")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, "inspec compliance exec PROFILE"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out
|
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")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, ""
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out
|
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")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_includes out.stderr, 'ERROR: "inspec compliance login" was called with no arguments'
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 1, out
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_profile_list_without_auth
|
2019-06-11 22:24:35 +00:00
|
|
|
out = run_inspec_process("compliance profiles")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, "You need to login first with `inspec compliance login`"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out # TODO: make this error
|
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")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2018-10-04 18:31:39 +00:00
|
|
|
assert_includes out.stderr, 'ERROR: "inspec compliance upload" was called with no arguments'
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 1, out
|
2018-10-04 18:31:39 +00:00
|
|
|
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")
|
2019-07-23 01:44:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
assert_includes out.stdout, "You need to login first with `inspec compliance login`"
|
2019-07-23 01:44:43 +00:00
|
|
|
|
|
|
|
assert_exit_code 0, out # TODO: make this error
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|
|
|
|
end
|