inspec 4.16.0 → 4.17.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inspec.rb +0 -1
  3. data/lib/inspec/backend.rb +7 -0
  4. data/lib/inspec/base_cli.rb +2 -0
  5. data/lib/inspec/cli.rb +3 -10
  6. data/lib/inspec/config.rb +3 -4
  7. data/lib/inspec/control_eval_context.rb +5 -3
  8. data/lib/inspec/dsl.rb +24 -1
  9. data/lib/inspec/errors.rb +0 -26
  10. data/lib/inspec/file_provider.rb +33 -43
  11. data/lib/inspec/formatters/base.rb +1 -0
  12. data/lib/inspec/impact.rb +2 -0
  13. data/lib/inspec/input.rb +410 -0
  14. data/lib/inspec/input_registry.rb +10 -1
  15. data/lib/inspec/objects.rb +3 -1
  16. data/lib/inspec/objects/input.rb +5 -387
  17. data/lib/inspec/objects/tag.rb +1 -1
  18. data/lib/inspec/plugin/v1/plugin_types/resource.rb +16 -5
  19. data/lib/inspec/plugin/v2/activator.rb +4 -8
  20. data/lib/inspec/plugin/v2/loader.rb +19 -3
  21. data/lib/inspec/profile.rb +1 -1
  22. data/lib/inspec/profile_context.rb +1 -1
  23. data/lib/inspec/reporters/json.rb +70 -88
  24. data/lib/inspec/resource.rb +1 -0
  25. data/lib/inspec/resources.rb +9 -2
  26. data/lib/inspec/resources/aide_conf.rb +4 -0
  27. data/lib/inspec/resources/apt.rb +19 -19
  28. data/lib/inspec/resources/etc_fstab.rb +4 -0
  29. data/lib/inspec/resources/etc_hosts.rb +4 -0
  30. data/lib/inspec/resources/firewalld.rb +4 -0
  31. data/lib/inspec/resources/json.rb +10 -3
  32. data/lib/inspec/resources/mssql_session.rb +1 -1
  33. data/lib/inspec/resources/platform.rb +18 -13
  34. data/lib/inspec/resources/postfix_conf.rb +6 -2
  35. data/lib/inspec/resources/security_identifier.rb +4 -0
  36. data/lib/inspec/resources/sys_info.rb +65 -4
  37. data/lib/inspec/resources/user.rb +1 -0
  38. data/lib/inspec/rule.rb +68 -6
  39. data/lib/inspec/runner.rb +6 -1
  40. data/lib/inspec/runner_rspec.rb +1 -0
  41. data/lib/inspec/shell.rb +8 -1
  42. data/lib/inspec/utils/pkey_reader.rb +1 -1
  43. data/lib/inspec/version.rb +1 -1
  44. data/lib/matchers/matchers.rb +2 -0
  45. data/lib/plugins/inspec-plugin-manager-cli/test/functional/help_test.rb +23 -0
  46. data/lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb +62 -0
  47. data/lib/plugins/inspec-plugin-manager-cli/test/functional/install_test.rb +368 -0
  48. data/lib/plugins/inspec-plugin-manager-cli/test/functional/list_test.rb +101 -0
  49. data/lib/plugins/inspec-plugin-manager-cli/test/functional/search_test.rb +129 -0
  50. data/lib/plugins/inspec-plugin-manager-cli/test/functional/uninstall_test.rb +63 -0
  51. data/lib/plugins/inspec-plugin-manager-cli/test/functional/update_test.rb +84 -0
  52. metadata +11 -3
  53. data/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +0 -845
@@ -1,5 +1,7 @@
1
1
  # copyright: 2015, Vulcano Security GmbH
2
2
 
3
+ require "rspec/matchers"
4
+
3
5
  RSpec::Matchers.define :be_readable do
4
6
  match do |file|
5
7
  file.readable?(@by, @by_user)
@@ -0,0 +1,23 @@
1
+ require_relative "helper"
2
+
3
+ class PluginManagerCliHelp < Minitest::Test
4
+ include CorePluginFunctionalHelper
5
+
6
+ # Main inspec help subcommand listing
7
+ def test_inspec_help_includes_plugin
8
+ result = run_inspec_process_with_this_plugin("help")
9
+ skip_windows!
10
+ assert_includes result.stdout, "inspec plugin"
11
+ end
12
+
13
+ # inspec plugin help subcommand listing
14
+ def test_inspec_plugin_help_includes_plugin
15
+ result = run_inspec_process_with_this_plugin("plugin help")
16
+ skip_windows!
17
+ assert_includes result.stdout, "inspec plugin list"
18
+ assert_includes result.stdout, "inspec plugin search"
19
+ assert_includes result.stdout, "inspec plugin install"
20
+ assert_includes result.stdout, "inspec plugin update"
21
+ assert_includes result.stdout, "inspec plugin uninstall"
22
+ end
23
+ end
@@ -0,0 +1,62 @@
1
+ require "plugins/shared/core_plugin_test_helper"
2
+
3
+ module PluginManagerHelpers
4
+ let(:project_repo_path) { File.expand_path(File.join(__FILE__, "..", "..", "..")) }
5
+ let(:project_fixtures_path) { File.join(project_repo_path, "test", "fixtures") }
6
+ let(:project_config_dirs_path) { File.join(project_fixtures_path, "config_dirs") }
7
+ let(:empty_config_dir_path) { File.join(project_config_dirs_path, "empty") }
8
+
9
+ let(:list_after_run) do
10
+ Proc.new do |run_result, tmp_dir|
11
+ # After installing/uninstalling/whatevering, run list with config in the same dir, and capture it.
12
+ run_result.payload.list_result = parse_plugin_list_lines(
13
+ run_inspec_process("plugin list", env: { INSPEC_CONFIG_DIR: tmp_dir }).stdout
14
+ )
15
+ end
16
+ end
17
+
18
+ def copy_in_project_config_dir(fixture_name, dest = nil)
19
+ src = Dir.glob(File.join(project_config_dirs_path, fixture_name, "*"))
20
+ dest ||= File.join(project_config_dirs_path, "empty")
21
+ src.each { |path| FileUtils.cp_r(path, dest) }
22
+ end
23
+
24
+ def copy_in_core_config_dir(fixture_name, dest = nil)
25
+ src = Dir.glob(File.join(core_config_dir_path, fixture_name, "*"))
26
+ dest ||= File.join(project_config_dirs_path, "empty")
27
+ src.each { |path| FileUtils.cp_r(path, dest) }
28
+ end
29
+
30
+ def clear_empty_config_dir
31
+ Dir.glob(File.join(project_config_dirs_path, "empty", "*")).each do |path|
32
+ next if path.end_with? ".gitkeep"
33
+
34
+ FileUtils.rm_rf(path)
35
+ end
36
+ end
37
+
38
+ def parse_plugin_list_lines(stdout)
39
+ plugins = []
40
+
41
+ stdout.force_encoding("UTF-8").lines.each do |line|
42
+ next if line.strip.empty?
43
+ next if line.include? "─────" # This is some unicode glyphiness
44
+ next if line.include? "Plugin Name"
45
+ next if line.include? "plugin(s) total"
46
+
47
+ parts = line.split(/│/u).map(&:strip!).compact
48
+ plugins << {
49
+ name: parts[0],
50
+ version: parts[1],
51
+ type: parts[2],
52
+ generation: parts[3],
53
+ raw: line,
54
+ }
55
+ end
56
+ plugins
57
+ end
58
+
59
+ def teardown
60
+ clear_empty_config_dir
61
+ end
62
+ end
@@ -0,0 +1,368 @@
1
+ require_relative "helper"
2
+
3
+ class PluginManagerCliInstall < Minitest::Test
4
+ include CorePluginFunctionalHelper # gives us instance methods, like `let` aliases inside test methods
5
+ extend CorePluginFunctionalHelper # gives us class methods, like `let` aliases out here outside test methods
6
+
7
+ parallelize_me!
8
+
9
+ include PluginManagerHelpers
10
+ ruby_abi_version = (Gem.ruby_version.segments[0, 2] << 0).join(".")
11
+ # Test multiple hueristics of the path-mode install.
12
+ # These are all positive tests; they should resolve the entry point to the same path in each case.
13
+ {
14
+ "is_perfect" => {
15
+ given: File.join(core_fixture_plugins_path, "inspec-test-fixture", "lib", "inspec-test-fixture.rb"),
16
+ },
17
+ "refers_to_the_entry_point_with_no_extension" => {
18
+ given: File.join(core_fixture_plugins_path, "inspec-test-fixture", "lib", "inspec-test-fixture"),
19
+ },
20
+ "refers_to_the_src_root_of_a_plugin" => {
21
+ given: File.join(core_fixture_plugins_path, "inspec-test-fixture"),
22
+ },
23
+ "refers_to_a_versioned_gem_install" => {
24
+ given: File.join(core_config_dir_path, "test-fixture-1-float", "gems", ruby_abi_version, "gems", "inspec-test-fixture-0.1.0", "lib", "inspec-test-fixture.rb"),
25
+ resolved_path: File.join(core_config_dir_path, "test-fixture-1-float", "gems", ruby_abi_version, "gems", "inspec-test-fixture-0.1.0", "lib", "inspec-test-fixture.rb"),
26
+ },
27
+ "refers_to_a_versioned_gem_install_missing_extension" => {
28
+ given: File.join(core_config_dir_path, "test-fixture-1-float", "gems", ruby_abi_version, "gems", "inspec-test-fixture-0.1.0", "lib", "inspec-test-fixture"),
29
+ resolved_path: File.join(core_config_dir_path, "test-fixture-1-float", "gems", ruby_abi_version, "gems", "inspec-test-fixture-0.1.0", "lib", "inspec-test-fixture.rb"),
30
+ },
31
+ "refers_to_a_relative_path" => {
32
+ given: File.join("test", "unit", "mock", "plugins", "inspec-test-fixture", "lib", "inspec-test-fixture.rb"),
33
+ },
34
+ "refers_to_a_train_plugin" => {
35
+ given: File.join(core_config_dir_path, "train-test-fixture", "gems", ruby_abi_version, "gems", "train-test-fixture-0.1.0", "lib", "train-test-fixture.rb"),
36
+ plugin_name: "train-test-fixture",
37
+ resolved_path: File.join(core_config_dir_path, "train-test-fixture", "gems", ruby_abi_version, "gems", "train-test-fixture-0.1.0", "lib", "train-test-fixture.rb"),
38
+ },
39
+ }.each do |test_name, fixture_info|
40
+ define_method(("test_install_from_path_when_path_" + test_name).to_sym) do
41
+ fixture_info = {
42
+ plugin_name: "inspec-test-fixture",
43
+ resolved_path: File.join(core_fixture_plugins_path, "inspec-test-fixture", "lib", "inspec-test-fixture.rb"),
44
+ }.merge(fixture_info)
45
+
46
+ install_result = run_inspec_process_with_this_plugin("plugin install #{fixture_info[:given]}", post_run: list_after_run)
47
+
48
+ # Check UX messaging
49
+ success_message = install_result.stdout.split("\n").grep(/installed/).last
50
+ skip_windows!
51
+ assert_empty install_result.stderr
52
+ refute_nil success_message, "Should find a success message at the end"
53
+ assert_includes success_message, fixture_info[:plugin_name]
54
+ assert_includes success_message, "plugin installed via source path reference"
55
+
56
+ # Check round-trip UX via list
57
+ itf_plugin = install_result.payload.list_result.detect { |p| p[:name] == fixture_info[:plugin_name] }
58
+ refute_nil itf_plugin, "plugin name should now appear in the output of inspec list"
59
+ assert_equal "path", itf_plugin[:type], "list output should show that it is a path installation"
60
+
61
+ # Check plugin statefile. Extra important in this case, since all should resolve to the same entry point.
62
+ plugin_data = install_result.payload.plugin_data
63
+ entry = plugin_data["plugins"].detect { |e| e["name"] == fixture_info[:plugin_name] }
64
+ assert_equal fixture_info[:resolved_path], entry["installation_path"], "Regardless of input, the entry point should be correct."
65
+
66
+ assert_exit_code 0, install_result
67
+ end
68
+ end
69
+
70
+ def test_fail_install_from_nonexistant_path
71
+ bad_path = File.join(project_fixtures_path, "none", "such", "inspec-test-fixture-nonesuch.rb")
72
+ install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
73
+ skip_windows!
74
+
75
+ error_message = install_result.stdout
76
+ assert_includes error_message, "No such source code path"
77
+ assert_includes error_message, "inspec-test-fixture-nonesuch.rb"
78
+ assert_includes error_message, "installation failed"
79
+
80
+ assert_empty install_result.stderr
81
+
82
+ assert_exit_code 1, install_result
83
+ end
84
+
85
+ def test_fail_install_from_path_with_wrong_name
86
+ bad_path = File.join(project_fixtures_path, "plugins", "wrong-name", "lib", "wrong-name.rb")
87
+ install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
88
+ skip_windows!
89
+
90
+ error_message = install_result.stdout
91
+ assert_includes error_message, "Invalid plugin name"
92
+ assert_includes error_message, "wrong-name"
93
+ assert_includes error_message, "All inspec plugins must begin with either 'inspec-' or 'train-'"
94
+ assert_includes error_message, "installation failed"
95
+
96
+ assert_empty install_result.stderr
97
+
98
+ assert_exit_code 1, install_result
99
+ end
100
+
101
+ def test_fail_install_from_path_when_it_is_not_a_plugin
102
+ bad_path = File.join(project_fixtures_path, "plugins", "inspec-egg-white-omelette", "lib", "inspec-egg-white-omelette.rb")
103
+ install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
104
+ skip_windows!
105
+
106
+ error_message = install_result.stdout
107
+ assert_includes error_message, "Does not appear to be a plugin"
108
+ assert_includes error_message, "inspec-egg-white-omelette"
109
+ assert_includes error_message, "After probe-loading the supposed plugin, it did not register"
110
+ assert_includes error_message, "Ensure something inherits from 'Inspec.plugin(2)'"
111
+ assert_includes error_message, "installation failed"
112
+
113
+ assert_empty install_result.stderr
114
+
115
+ assert_exit_code 1, install_result
116
+ end
117
+
118
+ def test_fail_install_from_path_when_it_is_already_installed
119
+ plugin_path = File.join(core_fixture_plugins_path, "inspec-test-fixture", "lib", "inspec-test-fixture.rb")
120
+ pre_block = Proc.new do |plugin_data, _tmp_dir|
121
+ plugin_data["plugins"] << {
122
+ "name" => "inspec-test-fixture",
123
+ "installation_type" => "path",
124
+ "installation_path" => plugin_path,
125
+ }
126
+ end
127
+
128
+ install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_path}", pre_run: pre_block)
129
+ skip_windows!
130
+
131
+ error_message = install_result.stdout
132
+ assert_includes error_message, "Plugin already installed"
133
+ assert_includes error_message, "inspec-test-fixture"
134
+ assert_includes error_message, "Use 'inspec plugin list' to see previously installed plugin"
135
+ assert_includes error_message, "installation failed"
136
+
137
+ assert_empty install_result.stderr
138
+
139
+ assert_exit_code 2, install_result
140
+ end
141
+
142
+ def test_fail_install_from_path_when_the_dir_structure_is_wrong
143
+ bad_path = File.join(project_fixtures_path, "plugins", "inspec-wrong-structure")
144
+ install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
145
+ skip_windows!
146
+
147
+ error_message = install_result.stdout
148
+ assert_includes error_message, "Unrecognizable plugin structure"
149
+ assert_includes error_message, "inspec-wrong-structure"
150
+ assert_includes error_message, " When installing from a path, please provide the path of the entry point file"
151
+ assert_includes error_message, "installation failed"
152
+
153
+ assert_empty install_result.stderr
154
+
155
+ assert_exit_code 1, install_result
156
+ end
157
+
158
+ def test_install_from_gemfile
159
+ fixture_gemfile_path = File.join(core_fixture_plugins_path, "inspec-test-fixture", "pkg", "inspec-test-fixture-0.1.0.gem")
160
+ install_result = run_inspec_process_with_this_plugin("plugin install #{fixture_gemfile_path}", post_run: list_after_run)
161
+ skip_windows!
162
+
163
+ success_message = install_result.stdout.split("\n").grep(/installed/).last
164
+ refute_nil success_message, "Should find a success message at the end"
165
+ assert_includes success_message, "installed from local .gem file"
166
+
167
+ itf_plugin = install_result.payload.list_result.detect { |p| p[:name] == "inspec-test-fixture" }
168
+ refute_nil itf_plugin, "plugin name should now appear in the output of inspec list"
169
+ assert_equal "gem (user)", itf_plugin[:type]
170
+ assert_equal "0.1.0", itf_plugin[:version]
171
+
172
+ assert_empty install_result.stderr
173
+ assert_exit_code 0, install_result
174
+ end
175
+
176
+ def test_fail_install_from_nonexistant_gemfile
177
+ bad_path = File.join(project_fixtures_path, "none", "such", "inspec-test-fixture-nonesuch-0.3.0.gem")
178
+ install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
179
+
180
+ skip_windows!
181
+ assert_match(/No such plugin gem file .+ - installation failed./, install_result.stdout)
182
+
183
+ assert_empty install_result.stderr
184
+
185
+ assert_exit_code 1, install_result
186
+ end
187
+
188
+ def test_install_from_rubygems_latest
189
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture", post_run: list_after_run)
190
+ skip_windows!
191
+
192
+ success_message = install_result.stdout.split("\n").grep(/installed/).last
193
+ refute_nil success_message, "Should find a success message at the end"
194
+ assert_includes success_message, "inspec-test-fixture"
195
+ assert_includes success_message, "0.2.0"
196
+ assert_includes success_message, "installed from rubygems.org"
197
+
198
+ itf_plugin = install_result.payload.list_result.detect { |p| p[:name] == "inspec-test-fixture" }
199
+ refute_nil itf_plugin, "plugin name should now appear in the output of inspec list"
200
+ assert_equal "gem (user)", itf_plugin[:type]
201
+ assert_equal "0.2.0", itf_plugin[:version]
202
+
203
+ assert_empty install_result.stderr
204
+ assert_exit_code 0, install_result
205
+ end
206
+
207
+ def test_fail_install_from_nonexistant_remote_rubygem
208
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture-nonesuch")
209
+
210
+ skip_windows!
211
+ assert_match(/No such plugin gem .+ could be found on rubygems.org - installation failed./, install_result.stdout)
212
+
213
+ assert_empty install_result.stderr
214
+
215
+ assert_exit_code 1, install_result
216
+ end
217
+
218
+ def test_install_from_rubygems_with_pinned_version
219
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture -v 0.1.0", post_run: list_after_run)
220
+
221
+ success_message = install_result.stdout.split("\n").grep(/installed/).last
222
+ skip_windows!
223
+ refute_nil success_message, "Should find a success message at the end"
224
+ assert_includes success_message, "inspec-test-fixture"
225
+ assert_includes success_message, "0.1.0"
226
+ assert_includes success_message, "installed from rubygems.org"
227
+
228
+ itf_plugin = install_result.payload.list_result.detect { |p| p[:name] == "inspec-test-fixture" }
229
+ refute_nil itf_plugin, "plugin name should now appear in the output of inspec list"
230
+ assert_equal "gem (user)", itf_plugin[:type]
231
+ assert_equal "0.1.0", itf_plugin[:version]
232
+
233
+ assert_empty install_result.stderr
234
+
235
+ assert_exit_code 0, install_result
236
+ end
237
+
238
+ def test_fail_install_from_nonexistant_rubygem_version
239
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture -v 99.99.99")
240
+
241
+ fail_message = install_result.stdout.split("\n").grep(/failed/).last
242
+ skip_windows!
243
+ refute_nil fail_message, "Should find a failure message at the end"
244
+ assert_includes fail_message, "inspec-test-fixture"
245
+ assert_includes fail_message, "99.99.99"
246
+ assert_includes fail_message, "no such version"
247
+ assert_includes fail_message, "on rubygems.org"
248
+
249
+ assert_empty install_result.stderr
250
+
251
+ assert_exit_code 1, install_result
252
+ end
253
+
254
+ def test_refuse_install_when_missing_prefix
255
+ install_result = run_inspec_process_with_this_plugin("plugin install test-fixture")
256
+
257
+ fail_message = install_result.stdout.split("\n").grep(/failed/).last
258
+ skip_windows!
259
+ refute_nil fail_message, "Should find a failure message at the end"
260
+ assert_includes fail_message, "test-fixture"
261
+ assert_includes fail_message, "All inspec plugins must begin with either 'inspec-' or 'train-'"
262
+
263
+ assert_empty install_result.stderr
264
+
265
+ assert_exit_code 1, install_result
266
+ end
267
+
268
+ def test_refuse_install_when_already_installed_same_version
269
+ pre_block = Proc.new do |plugin_statefile_data, tmp_dir|
270
+ plugin_statefile_data.clear # Signal not to write a file, we'll provide one.
271
+ copy_in_core_config_dir("test-fixture-2-float", tmp_dir)
272
+ end
273
+
274
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture", pre_run: pre_block)
275
+
276
+ refusal_message = install_result.stdout.split("\n").grep(/refusing/).last
277
+ skip_windows!
278
+ refute_nil refusal_message, "Should find a failure message at the end"
279
+ assert_includes refusal_message, "inspec-test-fixture"
280
+ assert_includes refusal_message, "0.2.0"
281
+ assert_includes refusal_message, "Plugin already installed at latest version"
282
+
283
+ assert_empty install_result.stderr
284
+
285
+ assert_exit_code 2, install_result
286
+ end
287
+
288
+ def test_refuse_install_when_already_installed_can_update
289
+ pre_block = Proc.new do |plugin_statefile_data, tmp_dir|
290
+ plugin_statefile_data.clear # Signal not to write a file, we'll provide one.
291
+ copy_in_core_config_dir("test-fixture-1-float", tmp_dir)
292
+ end
293
+
294
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture", pre_run: pre_block)
295
+
296
+ refusal_message = install_result.stdout.split("\n").grep(/refusing/).last
297
+ skip_windows!
298
+ refute_nil refusal_message, "Should find a failure message at the end"
299
+ assert_includes refusal_message, "inspec-test-fixture"
300
+ assert_includes refusal_message, "0.1.0"
301
+ assert_includes refusal_message, "0.2.0"
302
+ assert_includes refusal_message, "Update required"
303
+ assert_includes refusal_message, "inspec plugin update"
304
+
305
+ assert_empty install_result.stderr
306
+
307
+ assert_exit_code 2, install_result
308
+ end
309
+
310
+ def test_install_from_rubygems_latest_with_train_plugin
311
+ install_result = run_inspec_process_with_this_plugin("plugin install train-test-fixture", post_run: list_after_run)
312
+ skip_windows!
313
+
314
+ success_message = install_result.stdout.split("\n").grep(/installed/).last
315
+ refute_nil success_message, "Should find a success message at the end"
316
+ assert_includes success_message, "train-test-fixture"
317
+ assert_includes success_message, "0.1.0"
318
+ assert_includes success_message, "installed from rubygems.org"
319
+
320
+ ttf_plugin = install_result.payload.list_result.detect { |p| p[:name] == "train-test-fixture" }
321
+ refute_nil ttf_plugin, "plugin name should now appear in the output of inspec list"
322
+ assert_equal "gem (user)", ttf_plugin[:type]
323
+ assert_equal "0.1.0", ttf_plugin[:version]
324
+
325
+ assert_empty install_result.stderr
326
+ assert_exit_code 0, install_result
327
+ end
328
+
329
+ def test_refuse_install_when_plugin_on_exclusion_list
330
+ # Here, 'inspec-core', 'inspec-multi-server', and 'train-tax-collector'
331
+ # are the names of real rubygems. They are not InSpec/Train plugins, though,
332
+ # and installing them would be a jam-up.
333
+ # This is configured in 'etc/plugin-filter.json'.
334
+ %w{
335
+ inspec-core
336
+ inspec-multi-server
337
+ train-tax-calculator
338
+ }.each do |plugin_name|
339
+ install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_name}")
340
+ refusal_message = install_result.stdout
341
+ refute_nil refusal_message, "Should find a failure message at the end"
342
+ skip_windows!
343
+ assert_includes refusal_message, plugin_name
344
+ assert_includes refusal_message, "Plugin on Exclusion List"
345
+ assert_includes refusal_message, "refusing to install"
346
+ assert_includes refusal_message, "Rationale:"
347
+ assert_includes refusal_message, "etc/plugin_filters.json"
348
+ assert_includes refusal_message, "github.com/inspec/inspec/issues/new"
349
+
350
+ assert_empty install_result.stderr
351
+
352
+ assert_exit_code 2, install_result
353
+ end
354
+ end
355
+
356
+ def test_error_install_with_debug_enabled
357
+ skip "this test requires bundler to pass" unless defined? ::Bundler
358
+
359
+ install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture -v 0.1.1 --log-level debug")
360
+ skip_windows!
361
+
362
+ assert_includes install_result.stdout, "DEBUG"
363
+
364
+ assert_includes install_result.stderr, "can't activate rake"
365
+
366
+ assert_exit_code 1, install_result
367
+ end
368
+ end