inspec 4.7.24 → 4.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/lib/fetchers/git.rb +49 -10
- data/lib/inspec/cli.rb +23 -34
- data/lib/inspec/resources/windows_task.rb +5 -0
- data/lib/inspec/version.rb +1 -1
- data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +7 -8
- data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +18 -6
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +0 -12
- data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +1 -78
- data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +5 -10
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +4 -4
- data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +17 -10
- data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +31 -12
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +106 -69
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +180 -87
- metadata +2 -6
- data/lib/inspec/utils/latest_version.rb +0 -13
- data/lib/plugins/inspec-habitat/templates/habitat/config/inspec_exec_config.json.erb +0 -25
- data/lib/plugins/inspec-habitat/templates/habitat/default.toml.erb +0 -9
- data/lib/plugins/inspec-habitat/templates/habitat/hooks/run.erb +0 -32
@@ -19,10 +19,6 @@ module PluginManagerHelpers
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def setup
|
23
|
-
skip_windows!
|
24
|
-
end
|
25
|
-
|
26
22
|
def copy_in_project_config_dir(fixture_name, dest = nil)
|
27
23
|
src = Dir.glob(File.join(project_config_dirs_path, fixture_name, "*"))
|
28
24
|
dest ||= File.join(project_config_dirs_path, "empty")
|
@@ -54,19 +50,17 @@ end
|
|
54
50
|
class PluginManagerCliHelp < Minitest::Test
|
55
51
|
include CorePluginFunctionalHelper
|
56
52
|
|
57
|
-
def setup
|
58
|
-
skip_windows!
|
59
|
-
end
|
60
|
-
|
61
53
|
# Main inspec help subcommand listing
|
62
54
|
def test_inspec_help_includes_plugin
|
63
55
|
result = run_inspec_process_with_this_plugin("help")
|
56
|
+
skip_windows!
|
64
57
|
assert_includes result.stdout, "inspec plugin"
|
65
58
|
end
|
66
59
|
|
67
60
|
# inspec plugin help subcommand listing
|
68
61
|
def test_inspec_plugin_help_includes_plugin
|
69
62
|
result = run_inspec_process_with_this_plugin("plugin help")
|
63
|
+
skip_windows!
|
70
64
|
assert_includes result.stdout, "inspec plugin list"
|
71
65
|
assert_includes result.stdout, "inspec plugin search"
|
72
66
|
assert_includes result.stdout, "inspec plugin install"
|
@@ -84,20 +78,29 @@ class PluginManagerCliList < Minitest::Test
|
|
84
78
|
|
85
79
|
def test_list_when_no_user_plugins_installed
|
86
80
|
result = run_inspec_process_with_this_plugin("plugin list")
|
87
|
-
|
81
|
+
|
82
|
+
skip_windows!
|
88
83
|
assert_includes result.stdout, "0 plugin(s) total", "Empty list should include zero count"
|
84
|
+
|
85
|
+
assert_exit_code 0, result
|
89
86
|
end
|
90
87
|
|
91
88
|
def test_list_all_when_no_user_plugins_installed
|
92
89
|
result = run_inspec_process_with_this_plugin("plugin list --all")
|
93
|
-
|
90
|
+
|
91
|
+
skip_windows!
|
94
92
|
assert_includes result.stdout, "6 plugin(s) total", "--all list should find six"
|
95
93
|
assert_includes result.stdout, "inspec-plugin-manager-cli", "--all list should find inspec-plugin-manager-cli"
|
96
94
|
assert_includes result.stdout, "habitat", "--all list should find habitat"
|
97
95
|
|
96
|
+
assert_exit_code 0, result
|
97
|
+
|
98
|
+
# TODO: split
|
98
99
|
result = run_inspec_process_with_this_plugin("plugin list -a")
|
99
|
-
|
100
|
+
|
100
101
|
assert_includes result.stdout, "6 plugin(s) total", "-a list should find six"
|
102
|
+
|
103
|
+
assert_exit_code 0, result
|
101
104
|
end
|
102
105
|
|
103
106
|
def test_list_when_gem_and_path_plugins_installed
|
@@ -107,7 +110,8 @@ class PluginManagerCliList < Minitest::Test
|
|
107
110
|
end
|
108
111
|
|
109
112
|
result = run_inspec_process_with_this_plugin("plugin list", pre_run: pre_block)
|
110
|
-
|
113
|
+
|
114
|
+
skip_windows!
|
111
115
|
assert_includes result.stdout, "2 plugin(s) total", "gem+path should show two plugins"
|
112
116
|
|
113
117
|
# Plugin Name Version Via ApiVer
|
@@ -120,6 +124,8 @@ class PluginManagerCliList < Minitest::Test
|
|
120
124
|
assert_match(/\s*inspec-\S+\s+\d+\.\d+\.\d+\s+gem\s+2/, gem_line)
|
121
125
|
path_line = result.stdout.split("\n").grep(/path/).first
|
122
126
|
assert_match(/\s*inspec-\S+\s+src\s+path\s+2/, path_line)
|
127
|
+
|
128
|
+
assert_exit_code 0, result
|
123
129
|
end
|
124
130
|
|
125
131
|
def test_list_when_a_train_plugin_is_installed
|
@@ -129,7 +135,8 @@ class PluginManagerCliList < Minitest::Test
|
|
129
135
|
end
|
130
136
|
|
131
137
|
result = run_inspec_process_with_this_plugin("plugin list", pre_run: pre_block)
|
132
|
-
|
138
|
+
|
139
|
+
skip_windows!
|
133
140
|
assert_includes result.stdout, "1 plugin(s) total", "list train should show one plugins"
|
134
141
|
|
135
142
|
# Plugin Name Version Via ApiVer
|
@@ -142,6 +149,8 @@ class PluginManagerCliList < Minitest::Test
|
|
142
149
|
assert_includes(train_line, "0.1.0")
|
143
150
|
assert_includes(train_line, "gem")
|
144
151
|
assert_includes(train_line, "train-1")
|
152
|
+
|
153
|
+
assert_exit_code 0, result
|
145
154
|
end
|
146
155
|
end
|
147
156
|
|
@@ -160,79 +169,98 @@ class PluginManagerCliSearch < Minitest::Test
|
|
160
169
|
|
161
170
|
def test_search_for_a_real_gem_with_full_name_no_options
|
162
171
|
result = run_inspec_process("plugin search --include-test-fixture inspec-test-fixture")
|
163
|
-
|
172
|
+
|
164
173
|
assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the gem name"
|
165
174
|
assert_includes result.stdout, "1 plugin(s) found", "Search result should find 1 plugin"
|
166
175
|
line = result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
167
176
|
assert_match(/\s*inspec-test-fixture\s+\((\d+\.\d+\.\d+){1}\)/, line, "Plugin line should include name and exactly one version")
|
177
|
+
|
178
|
+
assert_exit_code 0, result
|
168
179
|
end
|
169
180
|
|
170
181
|
def test_search_for_a_real_gem_with_stub_name_no_options
|
171
182
|
result = run_inspec_process("plugin search --include-test-fixture inspec-test-")
|
172
|
-
|
183
|
+
|
173
184
|
assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the gem name"
|
174
185
|
assert_includes result.stdout, "1 plugin(s) found", "Search result should find 1 plugin"
|
175
186
|
|
176
187
|
line = result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
177
188
|
assert_match(/\s*inspec-test-fixture\s+\((\d+\.\d+\.\d+){1}\)/, line, "Plugin line should include name and exactly one version")
|
189
|
+
|
190
|
+
assert_exit_code 0, result
|
178
191
|
end
|
179
192
|
|
180
193
|
def test_search_for_a_real_gem_with_full_name_and_exact_option
|
181
194
|
result = run_inspec_process("plugin search --exact --include-test-fixture inspec-test-fixture")
|
182
|
-
|
195
|
+
|
183
196
|
assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the gem name"
|
184
197
|
assert_includes result.stdout, "1 plugin(s) found", "Search result should find 1 plugin"
|
185
198
|
|
199
|
+
assert_exit_code 0, result
|
200
|
+
|
201
|
+
# TODO: split
|
186
202
|
result = run_inspec_process("plugin search -e --include-test-fixture inspec-test-fixture")
|
187
|
-
|
203
|
+
|
204
|
+
assert_exit_code 0, result
|
188
205
|
end
|
189
206
|
|
190
207
|
def test_search_for_a_real_gem_with_stub_name_and_exact_option
|
191
208
|
result = run_inspec_process("plugin search --exact --include-test-fixture inspec-test-")
|
192
|
-
|
209
|
+
|
193
210
|
assert_includes result.stdout, "0 plugin(s) found", "Search result should find 0 plugins"
|
194
211
|
|
212
|
+
assert_exit_code 2, result
|
213
|
+
|
214
|
+
# TODO: split
|
195
215
|
result = run_inspec_process("plugin search -e --include-test-fixture inspec-test-")
|
196
|
-
|
216
|
+
|
217
|
+
assert_exit_code 2, result
|
197
218
|
end
|
198
219
|
|
199
220
|
def test_search_for_a_real_gem_with_full_name_and_all_option
|
200
221
|
result = run_inspec_process("plugin search --all --include-test-fixture inspec-test-fixture")
|
201
|
-
assert_equal 0, result.exit_status, "Search should exit 0 on a hit"
|
202
222
|
assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the gem name"
|
203
223
|
assert_includes result.stdout, "1 plugin(s) found", "Search result should find 1 plugin"
|
204
224
|
|
205
225
|
line = result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
206
226
|
assert_match(/\s*inspec-test-fixture\s+\((\d+\.\d+\.\d+(,\s)?){2,}\)/, line, "Plugin line should include name and at least two versions")
|
207
227
|
|
228
|
+
assert_exit_code 0, result
|
229
|
+
|
230
|
+
# TODO: split
|
208
231
|
result = run_inspec_process("plugin search -a --include-test-fixture inspec-test-fixture")
|
209
|
-
|
232
|
+
|
233
|
+
assert_exit_code 0, result
|
210
234
|
end
|
211
235
|
|
212
236
|
def test_search_for_a_gem_with_missing_prefix
|
213
237
|
result = run_inspec_process("plugin search --include-test-fixture test-fixture")
|
214
|
-
|
238
|
+
assert_exit_code 1, result
|
215
239
|
assert_includes result.stdout, "All inspec plugins must begin with either 'inspec-' or 'train-'"
|
216
240
|
end
|
217
241
|
|
218
242
|
def test_search_for_a_gem_that_does_not_exist
|
219
243
|
result = run_inspec_process("plugin search --include-test-fixture inspec-test-fixture-nonesuch")
|
220
|
-
|
244
|
+
|
221
245
|
assert_includes result.stdout, "0 plugin(s) found", "Search result should find 0 plugins"
|
246
|
+
|
247
|
+
assert_exit_code 2, result
|
222
248
|
end
|
223
249
|
|
224
250
|
def test_search_for_a_real_gem_with_full_name_no_options_and_train_name
|
225
251
|
result = run_inspec_process("plugin search --include-test-fixture train-test-fixture")
|
226
|
-
|
252
|
+
|
227
253
|
assert_includes result.stdout, "train-test-fixture", "Search result should contain the gem name"
|
228
254
|
assert_includes result.stdout, "1 plugin(s) found", "Search result should find 1 plugin"
|
229
255
|
line = result.stdout.split("\n").grep(/train-test-fixture/).first
|
230
256
|
assert_match(/\s*train-test-fixture\s+\((\d+\.\d+\.\d+){1}\)/, line, "Plugin line should include name and exactly one version")
|
257
|
+
|
258
|
+
assert_exit_code 0, result
|
231
259
|
end
|
232
260
|
|
233
261
|
def test_search_omit_excluded_inspec_plugins
|
234
262
|
result = run_inspec_process("plugin search --include-test-fixture inspec-")
|
235
|
-
|
263
|
+
|
236
264
|
assert_includes result.stdout, "inspec-test-fixture", "Search result should contain the test gem"
|
237
265
|
%w{
|
238
266
|
inspec-core
|
@@ -240,6 +268,8 @@ class PluginManagerCliSearch < Minitest::Test
|
|
240
268
|
}.each do |plugin_name|
|
241
269
|
refute_includes result.stdout, plugin_name, "Search result should not contain excluded gems"
|
242
270
|
end
|
271
|
+
|
272
|
+
assert_exit_code 0, result
|
243
273
|
end
|
244
274
|
|
245
275
|
def test_search_for_a_real_gem_with_full_name_no_options_filter_fixtures
|
@@ -300,11 +330,9 @@ class PluginManagerCliInstall < Minitest::Test
|
|
300
330
|
|
301
331
|
install_result = run_inspec_process_with_this_plugin("plugin install #{fixture_info[:given]}", post_run: list_after_run)
|
302
332
|
|
303
|
-
assert_empty install_result.stderr
|
304
|
-
assert_equal 0, install_result.exit_status, "Exit status should be 0"
|
305
|
-
|
306
333
|
# Check UX messaging
|
307
334
|
success_message = install_result.stdout.split("\n").grep(/installed/).last
|
335
|
+
skip_windows!
|
308
336
|
refute_nil success_message, "Should find a success message at the end"
|
309
337
|
assert_includes success_message, fixture_info[:plugin_name]
|
310
338
|
assert_includes success_message, "plugin installed via source path reference"
|
@@ -319,6 +347,10 @@ class PluginManagerCliInstall < Minitest::Test
|
|
319
347
|
plugin_data = install_result.payload.plugin_data
|
320
348
|
entry = plugin_data["plugins"].detect { |e| e["name"] == fixture_info[:plugin_name] }
|
321
349
|
assert_equal fixture_info[:resolved_path], entry["installation_path"], "Regardless of input, the entry point should be correct."
|
350
|
+
|
351
|
+
assert_empty install_result.stderr
|
352
|
+
|
353
|
+
assert_exit_code 0, install_result
|
322
354
|
end
|
323
355
|
end
|
324
356
|
|
@@ -326,42 +358,48 @@ class PluginManagerCliInstall < Minitest::Test
|
|
326
358
|
bad_path = File.join(project_fixtures_path, "none", "such", "inspec-test-fixture-nonesuch.rb")
|
327
359
|
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
|
328
360
|
|
329
|
-
assert_empty install_result.stderr
|
330
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
331
|
-
|
332
361
|
error_message = install_result.stdout.split("\n").last
|
362
|
+
skip_windows!
|
333
363
|
assert_includes error_message, "No such source code path"
|
334
364
|
assert_includes error_message, "inspec-test-fixture-nonesuch.rb"
|
335
365
|
assert_includes error_message, "installation failed"
|
366
|
+
|
367
|
+
assert_empty install_result.stderr
|
368
|
+
|
369
|
+
assert_exit_code 1, install_result
|
336
370
|
end
|
337
371
|
|
338
372
|
def test_fail_install_from_path_with_wrong_name
|
339
373
|
bad_path = File.join(project_fixtures_path, "plugins", "wrong-name", "lib", "wrong-name.rb")
|
340
374
|
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
|
341
375
|
|
342
|
-
assert_empty install_result.stderr
|
343
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
344
|
-
|
345
376
|
error_message = install_result.stdout.split("\n").last
|
377
|
+
skip_windows!
|
346
378
|
assert_includes error_message, "Invalid plugin name"
|
347
379
|
assert_includes error_message, "wrong-name"
|
348
380
|
assert_includes error_message, "All inspec plugins must begin with either 'inspec-' or 'train-'"
|
349
381
|
assert_includes error_message, "installation failed"
|
382
|
+
|
383
|
+
assert_empty install_result.stderr
|
384
|
+
|
385
|
+
assert_exit_code 1, install_result
|
350
386
|
end
|
351
387
|
|
352
388
|
def test_fail_install_from_path_when_it_is_not_a_plugin
|
353
389
|
bad_path = File.join(project_fixtures_path, "plugins", "inspec-egg-white-omelette", "lib", "inspec-egg-white-omelette.rb")
|
354
390
|
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
|
355
391
|
|
356
|
-
assert_empty install_result.stderr
|
357
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
358
|
-
|
359
392
|
error_message = install_result.stdout.split("\n").last
|
393
|
+
skip_windows!
|
360
394
|
assert_includes error_message, "Does not appear to be a plugin"
|
361
395
|
assert_includes error_message, "inspec-egg-white-omelette"
|
362
396
|
assert_includes error_message, "After probe-loading the supposed plugin, it did not register"
|
363
397
|
assert_includes error_message, "Ensure something inherits from 'Inspec.plugin(2)'"
|
364
398
|
assert_includes error_message, "installation failed"
|
399
|
+
|
400
|
+
assert_empty install_result.stderr
|
401
|
+
|
402
|
+
assert_exit_code 1, install_result
|
365
403
|
end
|
366
404
|
|
367
405
|
def test_fail_install_from_path_when_it_is_already_installed
|
@@ -375,38 +413,41 @@ class PluginManagerCliInstall < Minitest::Test
|
|
375
413
|
end
|
376
414
|
|
377
415
|
install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_path}", pre_run: pre_block)
|
378
|
-
assert_empty install_result.stderr
|
379
|
-
assert_equal 2, install_result.exit_status, "Exit status on second install should be 2"
|
380
416
|
|
381
417
|
error_message = install_result.stdout.split("\n").last
|
418
|
+
skip_windows!
|
382
419
|
assert_includes error_message, "Plugin already installed"
|
383
420
|
assert_includes error_message, "inspec-test-fixture"
|
384
421
|
assert_includes error_message, "Use 'inspec plugin list' to see previously installed plugin"
|
385
422
|
assert_includes error_message, "installation failed"
|
423
|
+
|
424
|
+
assert_empty install_result.stderr
|
425
|
+
|
426
|
+
assert_exit_code 2, install_result
|
386
427
|
end
|
387
428
|
|
388
429
|
def test_fail_install_from_path_when_the_dir_structure_is_wrong
|
389
430
|
bad_path = File.join(project_fixtures_path, "plugins", "inspec-wrong-structure")
|
390
431
|
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
|
391
432
|
|
392
|
-
assert_empty install_result.stderr
|
393
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
394
|
-
|
395
433
|
error_message = install_result.stdout.split("\n").last
|
434
|
+
skip_windows!
|
396
435
|
assert_includes error_message, "Unrecognizable plugin structure"
|
397
436
|
assert_includes error_message, "inspec-wrong-structure"
|
398
437
|
assert_includes error_message, " When installing from a path, please provide the path of the entry point file"
|
399
438
|
assert_includes error_message, "installation failed"
|
439
|
+
|
440
|
+
assert_empty install_result.stderr
|
441
|
+
|
442
|
+
assert_exit_code 1, install_result
|
400
443
|
end
|
401
444
|
|
402
445
|
def test_install_from_gemfile
|
403
446
|
fixture_gemfile_path = File.join(core_fixture_plugins_path, "inspec-test-fixture", "pkg", "inspec-test-fixture-0.1.0.gem")
|
404
447
|
install_result = run_inspec_process_with_this_plugin("plugin install #{fixture_gemfile_path}", post_run: list_after_run)
|
405
448
|
|
406
|
-
assert_empty install_result.stderr
|
407
|
-
assert_equal 0, install_result.exit_status, "Exit status should be 0"
|
408
|
-
|
409
449
|
success_message = install_result.stdout.split("\n").grep(/installed/).last
|
450
|
+
skip_windows!
|
410
451
|
refute_nil success_message, "Should find a success message at the end"
|
411
452
|
assert_includes success_message, "inspec-test-fixture"
|
412
453
|
assert_includes success_message, "0.1.0"
|
@@ -416,24 +457,29 @@ class PluginManagerCliInstall < Minitest::Test
|
|
416
457
|
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
417
458
|
refute_nil itf_line, "inspec-test-fixture should now appear in the output of inspec list"
|
418
459
|
assert_match(/\s*inspec-test-fixture\s+0.1.0\s+gem\s+/, itf_line, "list output should show that it is a gem installation with version")
|
460
|
+
|
461
|
+
assert_empty install_result.stderr
|
462
|
+
|
463
|
+
assert_exit_code 0, install_result
|
419
464
|
end
|
420
465
|
|
421
466
|
def test_fail_install_from_nonexistant_gemfile
|
422
467
|
bad_path = File.join(project_fixtures_path, "none", "such", "inspec-test-fixture-nonesuch-0.3.0.gem")
|
423
468
|
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
|
424
469
|
|
425
|
-
|
426
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
470
|
+
skip_windows!
|
427
471
|
assert_match(/No such plugin gem file .+ - installation failed./, install_result.stdout)
|
472
|
+
|
473
|
+
assert_empty install_result.stderr
|
474
|
+
|
475
|
+
assert_exit_code 1, install_result
|
428
476
|
end
|
429
477
|
|
430
478
|
def test_install_from_rubygems_latest
|
431
479
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture", post_run: list_after_run)
|
432
480
|
|
433
|
-
assert_empty install_result.stderr
|
434
|
-
assert_equal 0, install_result.exit_status, "Exit status should be 0"
|
435
|
-
|
436
481
|
success_message = install_result.stdout.split("\n").grep(/installed/).last
|
482
|
+
skip_windows!
|
437
483
|
refute_nil success_message, "Should find a success message at the end"
|
438
484
|
assert_includes success_message, "inspec-test-fixture"
|
439
485
|
assert_includes success_message, "0.2.0"
|
@@ -443,23 +489,28 @@ class PluginManagerCliInstall < Minitest::Test
|
|
443
489
|
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
444
490
|
refute_nil itf_line, "inspec-test-fixture should now appear in the output of inspec list"
|
445
491
|
assert_match(/\s*inspec-test-fixture\s+0.2.0\s+gem\s+/, itf_line, "list output should show that it is a gem installation with version")
|
492
|
+
|
493
|
+
assert_empty install_result.stderr
|
494
|
+
|
495
|
+
assert_exit_code 0, install_result
|
446
496
|
end
|
447
497
|
|
448
498
|
def test_fail_install_from_nonexistant_remote_rubygem
|
449
499
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture-nonesuch")
|
450
500
|
|
451
|
-
|
452
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
501
|
+
skip_windows!
|
453
502
|
assert_match(/No such plugin gem .+ could be found on rubygems.org - installation failed./, install_result.stdout)
|
503
|
+
|
504
|
+
assert_empty install_result.stderr
|
505
|
+
|
506
|
+
assert_exit_code 1, install_result
|
454
507
|
end
|
455
508
|
|
456
509
|
def test_install_from_rubygems_with_pinned_version
|
457
510
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture -v 0.1.0", post_run: list_after_run)
|
458
511
|
|
459
|
-
assert_empty install_result.stderr
|
460
|
-
assert_equal 0, install_result.exit_status, "Exit status should be 0"
|
461
|
-
|
462
512
|
success_message = install_result.stdout.split("\n").grep(/installed/).last
|
513
|
+
skip_windows!
|
463
514
|
refute_nil success_message, "Should find a success message at the end"
|
464
515
|
assert_includes success_message, "inspec-test-fixture"
|
465
516
|
assert_includes success_message, "0.1.0"
|
@@ -469,32 +520,40 @@ class PluginManagerCliInstall < Minitest::Test
|
|
469
520
|
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
470
521
|
refute_nil itf_line, "inspec-test-fixture should now appear in the output of inspec list"
|
471
522
|
assert_match(/\s*inspec-test-fixture\s+0.1.0\s+gem\s+/, itf_line, "list output should show that it is a gem installation with version")
|
523
|
+
|
524
|
+
assert_empty install_result.stderr
|
525
|
+
|
526
|
+
assert_exit_code 0, install_result
|
472
527
|
end
|
473
528
|
|
474
529
|
def test_fail_install_from_nonexistant_rubygem_version
|
475
530
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture -v 99.99.99")
|
476
531
|
|
477
|
-
assert_empty install_result.stderr
|
478
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
479
|
-
|
480
532
|
fail_message = install_result.stdout.split("\n").grep(/failed/).last
|
533
|
+
skip_windows!
|
481
534
|
refute_nil fail_message, "Should find a failure message at the end"
|
482
535
|
assert_includes fail_message, "inspec-test-fixture"
|
483
536
|
assert_includes fail_message, "99.99.99"
|
484
537
|
assert_includes fail_message, "no such version"
|
485
538
|
assert_includes fail_message, "on rubygems.org"
|
539
|
+
|
540
|
+
assert_empty install_result.stderr
|
541
|
+
|
542
|
+
assert_exit_code 1, install_result
|
486
543
|
end
|
487
544
|
|
488
545
|
def test_refuse_install_when_missing_prefix
|
489
546
|
install_result = run_inspec_process_with_this_plugin("plugin install test-fixture")
|
490
547
|
|
491
|
-
assert_empty install_result.stderr
|
492
|
-
assert_equal 1, install_result.exit_status, "Exit status should be 1"
|
493
|
-
|
494
548
|
fail_message = install_result.stdout.split("\n").grep(/failed/).last
|
549
|
+
skip_windows!
|
495
550
|
refute_nil fail_message, "Should find a failure message at the end"
|
496
551
|
assert_includes fail_message, "test-fixture"
|
497
552
|
assert_includes fail_message, "All inspec plugins must begin with either 'inspec-' or 'train-'"
|
553
|
+
|
554
|
+
assert_empty install_result.stderr
|
555
|
+
|
556
|
+
assert_exit_code 1, install_result
|
498
557
|
end
|
499
558
|
|
500
559
|
def test_refuse_install_when_already_installed_same_version
|
@@ -504,14 +563,17 @@ class PluginManagerCliInstall < Minitest::Test
|
|
504
563
|
end
|
505
564
|
|
506
565
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture", pre_run: pre_block)
|
507
|
-
assert_empty install_result.stderr
|
508
|
-
assert_equal 2, install_result.exit_status, "Exit status should be 2"
|
509
566
|
|
510
567
|
refusal_message = install_result.stdout.split("\n").grep(/refusing/).last
|
568
|
+
skip_windows!
|
511
569
|
refute_nil refusal_message, "Should find a failure message at the end"
|
512
570
|
assert_includes refusal_message, "inspec-test-fixture"
|
513
571
|
assert_includes refusal_message, "0.2.0"
|
514
572
|
assert_includes refusal_message, "Plugin already installed at latest version"
|
573
|
+
|
574
|
+
assert_empty install_result.stderr
|
575
|
+
|
576
|
+
assert_exit_code 2, install_result
|
515
577
|
end
|
516
578
|
|
517
579
|
def test_refuse_install_when_already_installed_can_update
|
@@ -521,25 +583,26 @@ class PluginManagerCliInstall < Minitest::Test
|
|
521
583
|
end
|
522
584
|
|
523
585
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture", pre_run: pre_block)
|
524
|
-
assert_empty install_result.stderr
|
525
|
-
assert_equal 2, install_result.exit_status, "Exit status should be 2"
|
526
586
|
|
527
587
|
refusal_message = install_result.stdout.split("\n").grep(/refusing/).last
|
588
|
+
skip_windows!
|
528
589
|
refute_nil refusal_message, "Should find a failure message at the end"
|
529
590
|
assert_includes refusal_message, "inspec-test-fixture"
|
530
591
|
assert_includes refusal_message, "0.1.0"
|
531
592
|
assert_includes refusal_message, "0.2.0"
|
532
593
|
assert_includes refusal_message, "Update required"
|
533
594
|
assert_includes refusal_message, "inspec plugin update"
|
595
|
+
|
596
|
+
assert_empty install_result.stderr
|
597
|
+
|
598
|
+
assert_exit_code 2, install_result
|
534
599
|
end
|
535
600
|
|
536
601
|
def test_install_from_rubygems_latest_with_train_plugin
|
537
602
|
install_result = run_inspec_process_with_this_plugin("plugin install train-test-fixture", post_run: list_after_run)
|
538
603
|
|
539
|
-
assert_empty install_result.stderr
|
540
|
-
assert_equal 0, install_result.exit_status, "Exit status should be 0"
|
541
|
-
|
542
604
|
success_message = install_result.stdout.split("\n").grep(/installed/).last
|
605
|
+
skip_windows!
|
543
606
|
refute_nil success_message, "Should find a success message at the end"
|
544
607
|
assert_includes success_message, "train-test-fixture"
|
545
608
|
assert_includes success_message, "0.1.0"
|
@@ -549,6 +612,10 @@ class PluginManagerCliInstall < Minitest::Test
|
|
549
612
|
itf_line = list_result.stdout.split("\n").grep(/train-test-fixture/).first
|
550
613
|
refute_nil itf_line, "train-test-fixture should now appear in the output of inspec list"
|
551
614
|
assert_match(/\s*train-test-fixture\s+0.1.0\s+gem\s+/, itf_line, "list output should show that it is a gem installation with version")
|
615
|
+
|
616
|
+
assert_empty install_result.stderr
|
617
|
+
|
618
|
+
assert_exit_code 0, install_result
|
552
619
|
end
|
553
620
|
|
554
621
|
def test_refuse_install_when_plugin_on_exclusion_list
|
@@ -562,17 +629,19 @@ class PluginManagerCliInstall < Minitest::Test
|
|
562
629
|
train-tax-calculator
|
563
630
|
}.each do |plugin_name|
|
564
631
|
install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_name}")
|
565
|
-
assert_empty install_result.stderr
|
566
|
-
assert_equal 2, install_result.exit_status, "Exit status should be 2"
|
567
|
-
|
568
632
|
refusal_message = install_result.stdout
|
569
633
|
refute_nil refusal_message, "Should find a failure message at the end"
|
634
|
+
skip_windows!
|
570
635
|
assert_includes refusal_message, plugin_name
|
571
636
|
assert_includes refusal_message, "Plugin on Exclusion List"
|
572
637
|
assert_includes refusal_message, "refusing to install"
|
573
638
|
assert_includes refusal_message, "Rationale:"
|
574
639
|
assert_includes refusal_message, "etc/plugin_filters.json"
|
575
640
|
assert_includes refusal_message, "github.com/inspec/inspec/issues/new"
|
641
|
+
|
642
|
+
assert_empty install_result.stderr
|
643
|
+
|
644
|
+
assert_exit_code 2, install_result
|
576
645
|
end
|
577
646
|
end
|
578
647
|
|
@@ -581,9 +650,12 @@ class PluginManagerCliInstall < Minitest::Test
|
|
581
650
|
|
582
651
|
install_result = run_inspec_process_with_this_plugin("plugin install inspec-test-fixture -v 0.1.1 --log-level debug")
|
583
652
|
|
584
|
-
|
653
|
+
skip_windows!
|
585
654
|
assert_includes install_result.stdout, "DEBUG"
|
655
|
+
|
586
656
|
assert_includes install_result.stderr, "can't activate rake"
|
657
|
+
|
658
|
+
assert_exit_code 1, install_result
|
587
659
|
end
|
588
660
|
end
|
589
661
|
|
@@ -603,10 +675,9 @@ class PluginManagerCliUpdate < Minitest::Test
|
|
603
675
|
end
|
604
676
|
|
605
677
|
update_result = run_inspec_process_with_this_plugin("plugin update inspec-test-fixture", pre_run: pre_block, post_run: list_after_run)
|
606
|
-
assert_empty update_result.stderr
|
607
|
-
assert_equal 0, update_result.exit_status, "Exit status should be 0"
|
608
678
|
|
609
679
|
success_message = update_result.stdout.split("\n").grep(/updated/).last
|
680
|
+
skip_windows!
|
610
681
|
refute_nil success_message, "Should find a success message at the end"
|
611
682
|
assert_includes success_message, "inspec-test-fixture"
|
612
683
|
assert_includes success_message, "0.1.0"
|
@@ -617,6 +688,10 @@ class PluginManagerCliUpdate < Minitest::Test
|
|
617
688
|
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
618
689
|
refute_nil itf_line, "inspec-test-fixture should appear in the output of inspec list"
|
619
690
|
assert_match(/\s*inspec-test-fixture\s+0.2.0\s+gem\s+/, itf_line, "list output should show that it is a gem installation with version 0.2.0")
|
691
|
+
|
692
|
+
assert_empty update_result.stderr
|
693
|
+
|
694
|
+
assert_exit_code 0, update_result
|
620
695
|
end
|
621
696
|
|
622
697
|
def test_refuse_update_when_already_current
|
@@ -626,22 +701,28 @@ class PluginManagerCliUpdate < Minitest::Test
|
|
626
701
|
end
|
627
702
|
|
628
703
|
update_result = run_inspec_process_with_this_plugin("plugin update inspec-test-fixture", pre_run: pre_block)
|
629
|
-
assert_empty update_result.stderr
|
630
|
-
assert_equal 2, update_result.exit_status, "Exit status should be 2"
|
631
704
|
|
632
705
|
refusal_message = update_result.stdout.split("\n").grep(/refusing/).last
|
706
|
+
skip_windows!
|
633
707
|
refute_nil refusal_message, "Should find a failure message at the end"
|
634
708
|
assert_includes refusal_message, "inspec-test-fixture"
|
635
709
|
assert_includes refusal_message, "0.2.0"
|
636
710
|
assert_includes refusal_message, "Already installed at latest version"
|
711
|
+
|
712
|
+
assert_empty update_result.stderr
|
713
|
+
|
714
|
+
assert_exit_code 2, update_result
|
637
715
|
end
|
638
716
|
|
639
717
|
def test_fail_update_from_nonexistant_gem
|
640
718
|
update_result = run_inspec_process_with_this_plugin("plugin update inspec-test-fixture-nonesuch")
|
641
719
|
|
720
|
+
skip_windows!
|
721
|
+
assert_match(/No such plugin installed:.+ - update failed/, update_result.stdout)
|
722
|
+
|
642
723
|
assert_empty update_result.stderr
|
643
|
-
|
644
|
-
|
724
|
+
|
725
|
+
assert_exit_code 1, update_result
|
645
726
|
end
|
646
727
|
|
647
728
|
def test_fail_update_path
|
@@ -651,14 +732,17 @@ class PluginManagerCliUpdate < Minitest::Test
|
|
651
732
|
end
|
652
733
|
|
653
734
|
update_result = run_inspec_process_with_this_plugin("plugin update inspec-meaning-of-life", pre_run: pre_block)
|
654
|
-
assert_empty update_result.stderr
|
655
|
-
assert_equal 2, update_result.exit_status, "Exit status should be 2"
|
656
735
|
|
657
736
|
refusal_message = update_result.stdout.split("\n").grep(/refusing/).last
|
737
|
+
skip_windows!
|
658
738
|
refute_nil refusal_message, "Should find a failure message at the end"
|
659
739
|
assert_includes refusal_message, "inspec-meaning-of-life"
|
660
740
|
assert_includes refusal_message, "inspec plugin uninstall"
|
661
741
|
assert_includes refusal_message, "Cannot update path-based install"
|
742
|
+
|
743
|
+
assert_empty update_result.stderr
|
744
|
+
|
745
|
+
assert_exit_code 2, update_result
|
662
746
|
end
|
663
747
|
end
|
664
748
|
|
@@ -677,10 +761,9 @@ class PluginManagerCliUninstall < Minitest::Test
|
|
677
761
|
|
678
762
|
# Attempt uninstall
|
679
763
|
uninstall_result = run_inspec_process_with_this_plugin("plugin uninstall inspec-test-fixture", pre_run: pre_block, post_run: list_after_run)
|
680
|
-
assert_empty uninstall_result.stderr
|
681
|
-
assert_equal 0, uninstall_result.exit_status, "Exit status should be 0"
|
682
764
|
|
683
765
|
success_message = uninstall_result.stdout.split("\n").grep(/uninstalled/).last
|
766
|
+
skip_windows!
|
684
767
|
refute_nil success_message, "Should find a success message at the end"
|
685
768
|
assert_includes success_message, "inspec-test-fixture"
|
686
769
|
assert_includes success_message, "0.1.0"
|
@@ -689,6 +772,10 @@ class PluginManagerCliUninstall < Minitest::Test
|
|
689
772
|
list_result = uninstall_result.payload.list_result
|
690
773
|
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
|
691
774
|
assert_nil itf_line, "inspec-test-fixture should not appear in the output of inspec list"
|
775
|
+
|
776
|
+
assert_empty uninstall_result.stderr
|
777
|
+
|
778
|
+
assert_exit_code 0, uninstall_result
|
692
779
|
end
|
693
780
|
|
694
781
|
def test_when_a_path_plugin_can_be_uninstalled
|
@@ -699,10 +786,9 @@ class PluginManagerCliUninstall < Minitest::Test
|
|
699
786
|
end
|
700
787
|
|
701
788
|
uninstall_result = run_inspec_process_with_this_plugin("plugin uninstall inspec-meaning-of-life", pre_run: pre_block, post_run: list_after_run)
|
702
|
-
assert_empty uninstall_result.stderr
|
703
|
-
assert_equal 0, uninstall_result.exit_status, "Exit status should be 0"
|
704
789
|
|
705
790
|
success_message = uninstall_result.stdout.split("\n").grep(/uninstalled/).last
|
791
|
+
skip_windows!
|
706
792
|
refute_nil success_message, "Should find a success message at the end"
|
707
793
|
assert_includes success_message, "inspec-meaning-of-life"
|
708
794
|
assert_includes success_message, "path-based plugin install"
|
@@ -711,14 +797,21 @@ class PluginManagerCliUninstall < Minitest::Test
|
|
711
797
|
list_result = uninstall_result.payload.list_result
|
712
798
|
itf_line = list_result.stdout.split("\n").grep(/inspec-meaning-of-life/).first
|
713
799
|
assert_nil itf_line, "inspec-meaning-of-life should not appear in the output of inspec list"
|
800
|
+
|
801
|
+
assert_empty uninstall_result.stderr
|
802
|
+
|
803
|
+
assert_exit_code 0, uninstall_result
|
714
804
|
end
|
715
805
|
|
716
806
|
def test_fail_uninstall_from_plugin_that_is_not_installed
|
717
807
|
uninstall_result = run_inspec_process_with_this_plugin("plugin uninstall inspec-test-fixture-nonesuch")
|
718
808
|
|
719
|
-
|
720
|
-
assert_equal 1, uninstall_result.exit_status, "Exit status should be 1"
|
809
|
+
skip_windows!
|
721
810
|
refute_includes "Inspec::Plugin::V2::UnInstallError", uninstall_result.stdout # Stacktrace marker
|
722
|
-
assert_match(/No such plugin installed
|
811
|
+
assert_match(/No such plugin installed:.+ - uninstall failed/, uninstall_result.stdout)
|
812
|
+
|
813
|
+
assert_empty uninstall_result.stderr
|
814
|
+
|
815
|
+
assert_exit_code 1, uninstall_result
|
723
816
|
end
|
724
817
|
end
|