2020-12-18 16:49:35 +00:00
|
|
|
require_relative "../../../shared/core_plugin_test_helper"
|
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
|
2021-04-30 11:49:33 +00:00
|
|
|
|
|
|
|
## testing automate command for compliances
|
|
|
|
|
|
|
|
def test_help_output_using_automate_cmd
|
|
|
|
out = run_inspec_process("automate help")
|
|
|
|
|
|
|
|
assert_includes out.stdout, "inspec automate exec PROFILE"
|
|
|
|
|
|
|
|
assert_exit_code 0, out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_logout_command_using_automate_cmd
|
|
|
|
out = run_inspec_process("automate logout")
|
|
|
|
|
|
|
|
assert_includes out.stdout, ""
|
|
|
|
|
|
|
|
assert_exit_code 0, out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_error_login_with_invalid_url_using_automate_cmd
|
|
|
|
out = run_inspec_process("automate login")
|
|
|
|
|
|
|
|
assert_includes out.stderr, 'ERROR: "inspec automate login" was called with no arguments'
|
|
|
|
|
|
|
|
assert_exit_code 1, out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_profile_list_without_auth_using_automate_cmd
|
|
|
|
out = run_inspec_process("automate profiles")
|
|
|
|
|
|
|
|
assert_includes out.stdout, "You need to login first with `inspec automate login`"
|
|
|
|
|
|
|
|
assert_exit_code 0, out # TODO: make this error
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_error_upload_without_args_using_automate_cmd
|
|
|
|
out = run_inspec_process("automate upload")
|
|
|
|
|
|
|
|
assert_includes out.stderr, 'ERROR: "inspec automate upload" was called with no arguments'
|
|
|
|
|
|
|
|
assert_exit_code 1, out
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_error_upload_with_fake_path_using_automate_cmd
|
|
|
|
out = run_inspec_process("automate upload /path/to/dir")
|
|
|
|
|
|
|
|
assert_includes out.stdout, "You need to login first with `inspec automate login`"
|
|
|
|
|
|
|
|
assert_exit_code 0, out # TODO: make this error
|
|
|
|
end
|
2018-10-04 18:31:39 +00:00
|
|
|
end
|