Class: PluginManagerCliInstall
Overview
—————————————————————————————–#
inspec plugin install
—————————————————————————————–#
Constant Summary
CorePluginFunctionalHelper::TRAIN_CONNECTION
Instance Method Summary
collapse
__find_plugin_path_from_caller, __make_empty_plugin_file_data_structure, __make_plugin_file_data_structure_with_path, run_inspec_process, run_inspec_process_with_this_plugin
#clear_empty_config_dir, #copy_in_core_config_dir, #copy_in_project_config_dir, #teardown
Instance Method Details
#test_error_install_with_debug_enabled ⇒ Object
571
572
573
574
575
576
577
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 571
def test_error_install_with_debug_enabled
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture -v 0.1.1 --log-level debug')
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
assert_includes install_result.stdout, 'DEBUG'
assert_includes install_result.stderr, "can't activate rake"
end
|
#test_fail_install_from_nonexistant_gemfile ⇒ Object
412
413
414
415
416
417
418
419
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 412
def test_fail_install_from_nonexistant_gemfile
bad_path = File.join(project_fixtures_path, 'none', 'such', 'inspec-test-fixture-nonesuch-0.3.0.gem')
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
assert_match(/No such plugin gem file .+ - installation failed./, install_result.stdout)
end
|
#test_fail_install_from_nonexistant_path ⇒ Object
316
317
318
319
320
321
322
323
324
325
326
327
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 316
def test_fail_install_from_nonexistant_path
bad_path = File.join(project_fixtures_path, 'none', 'such', 'inspec-test-fixture-nonesuch.rb')
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
error_message = install_result.stdout.split("\n").last
assert_includes error_message, "No such source code path"
assert_includes error_message, 'inspec-test-fixture-nonesuch.rb'
assert_includes error_message, 'installation failed'
end
|
#test_fail_install_from_nonexistant_remote_rubygem ⇒ Object
439
440
441
442
443
444
445
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 439
def test_fail_install_from_nonexistant_remote_rubygem
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture-nonesuch')
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
assert_match(/No such plugin gem .+ could be found on rubygems.org - installation failed./, install_result.stdout)
end
|
#test_fail_install_from_nonexistant_rubygem_version ⇒ Object
465
466
467
468
469
470
471
472
473
474
475
476
477
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 465
def test_fail_install_from_nonexistant_rubygem_version
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture -v 99.99.99')
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
fail_message = install_result.stdout.split("\n").grep(/failed/).last
refute_nil fail_message, 'Should find a failure message at the end'
assert_includes fail_message, 'inspec-test-fixture'
assert_includes fail_message, '99.99.99'
assert_includes fail_message, 'no such version'
assert_includes fail_message, 'on rubygems.org'
end
|
#test_fail_install_from_path_when_it_is_already_installed ⇒ Object
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 358
def test_fail_install_from_path_when_it_is_already_installed
plugin_path = File.join(core_fixture_plugins_path, 'inspec-test-fixture', 'lib', 'inspec-test-fixture.rb')
pre_block = Proc.new do |plugin_data, _tmp_dir|
plugin_data["plugins"] << {
"name" => "inspec-test-fixture",
"installation_type" => "path",
"installation_path" => plugin_path,
}
end
install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_path}", pre_run: pre_block)
assert_empty install_result.stderr
assert_equal 2, install_result.exit_status, 'Exit status on second install should be 2'
error_message = install_result.stdout.split("\n").last
assert_includes error_message, "Plugin already installed"
assert_includes error_message, 'inspec-test-fixture'
assert_includes error_message, "Use 'inspec plugin list' to see previously installed plugin"
assert_includes error_message, 'installation failed'
end
|
#test_fail_install_from_path_when_it_is_not_a_plugin ⇒ Object
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 343
def test_fail_install_from_path_when_it_is_not_a_plugin
bad_path = File.join(project_fixtures_path, 'plugins', 'inspec-egg-white-omelette', 'lib', 'inspec-egg-white-omelette.rb')
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
error_message = install_result.stdout.split("\n").last
assert_includes error_message, "Does not appear to be a plugin"
assert_includes error_message, 'inspec-egg-white-omelette'
assert_includes error_message, "After probe-loading the supposed plugin, it did not register"
assert_includes error_message, "Ensure something inherits from 'Inspec.plugin(2)'"
assert_includes error_message, 'installation failed'
end
|
#test_fail_install_from_path_when_the_dir_structure_is_wrong ⇒ Object
379
380
381
382
383
384
385
386
387
388
389
390
391
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 379
def test_fail_install_from_path_when_the_dir_structure_is_wrong
bad_path = File.join(project_fixtures_path, 'plugins', 'inspec-wrong-structure')
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
error_message = install_result.stdout.split("\n").last
assert_includes error_message, "Unrecognizable plugin structure"
assert_includes error_message, 'inspec-wrong-structure'
assert_includes error_message, ' When installing from a path, please provide the path of the entry point file'
assert_includes error_message, 'installation failed'
end
|
#test_fail_install_from_path_with_wrong_name ⇒ Object
329
330
331
332
333
334
335
336
337
338
339
340
341
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 329
def test_fail_install_from_path_with_wrong_name
bad_path = File.join(project_fixtures_path, 'plugins', 'wrong-name', 'lib', 'wrong-name.rb')
install_result = run_inspec_process_with_this_plugin("plugin install #{bad_path}")
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
error_message = install_result.stdout.split("\n").last
assert_includes error_message, "Invalid plugin name"
assert_includes error_message, 'wrong-name'
assert_includes error_message, "All inspec plugins must begin with either 'inspec-' or 'train-'"
assert_includes error_message, 'installation failed'
end
|
#test_install_from_gemfile ⇒ Object
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 393
def test_install_from_gemfile
fixture_gemfile_path = File.join(core_fixture_plugins_path, 'inspec-test-fixture', 'pkg', 'inspec-test-fixture-0.1.0.gem')
install_result = run_inspec_process_with_this_plugin("plugin install #{fixture_gemfile_path}", post_run: list_after_run)
assert_empty install_result.stderr
assert_equal 0, install_result.exit_status, 'Exit status should be 0'
success_message = install_result.stdout.split("\n").grep(/installed/).last
refute_nil success_message, 'Should find a success message at the end'
assert_includes success_message, 'inspec-test-fixture'
assert_includes success_message, '0.1.0'
assert_includes success_message, 'installed from local .gem file'
list_result = install_result.payload.list_result
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
refute_nil itf_line, 'inspec-test-fixture should now appear in the output of inspec list'
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')
end
|
#test_install_from_rubygems_latest ⇒ Object
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 421
def test_install_from_rubygems_latest
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture', post_run: list_after_run)
assert_empty install_result.stderr
assert_equal 0, install_result.exit_status, 'Exit status should be 0'
success_message = install_result.stdout.split("\n").grep(/installed/).last
refute_nil success_message, 'Should find a success message at the end'
assert_includes success_message, 'inspec-test-fixture'
assert_includes success_message, '0.2.0'
assert_includes success_message, 'installed from rubygems.org'
list_result = install_result.payload.list_result
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
refute_nil itf_line, 'inspec-test-fixture should now appear in the output of inspec list'
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')
end
|
#test_install_from_rubygems_latest_with_train_plugin ⇒ Object
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 527
def test_install_from_rubygems_latest_with_train_plugin
install_result = run_inspec_process_with_this_plugin('plugin install train-test-fixture', post_run: list_after_run)
assert_empty install_result.stderr
assert_equal 0, install_result.exit_status, 'Exit status should be 0'
success_message = install_result.stdout.split("\n").grep(/installed/).last
refute_nil success_message, 'Should find a success message at the end'
assert_includes success_message, 'train-test-fixture'
assert_includes success_message, '0.1.0'
assert_includes success_message, 'installed from rubygems.org'
list_result = install_result.payload.list_result
itf_line = list_result.stdout.split("\n").grep(/train-test-fixture/).first
refute_nil itf_line, 'train-test-fixture should now appear in the output of inspec list'
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')
end
|
#test_install_from_rubygems_with_pinned_version ⇒ Object
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 447
def test_install_from_rubygems_with_pinned_version
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture -v 0.1.0', post_run: list_after_run)
assert_empty install_result.stderr
assert_equal 0, install_result.exit_status, 'Exit status should be 0'
success_message = install_result.stdout.split("\n").grep(/installed/).last
refute_nil success_message, 'Should find a success message at the end'
assert_includes success_message, 'inspec-test-fixture'
assert_includes success_message, '0.1.0'
assert_includes success_message, 'installed from rubygems.org'
list_result = install_result.payload.list_result
itf_line = list_result.stdout.split("\n").grep(/inspec-test-fixture/).first
refute_nil itf_line, 'inspec-test-fixture should now appear in the output of inspec list'
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')
end
|
#test_refuse_install_when_already_installed_can_update ⇒ Object
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 508
def test_refuse_install_when_already_installed_can_update
pre_block = Proc.new do |plugin_statefile_data, tmp_dir|
plugin_statefile_data.clear copy_in_core_config_dir('test-fixture-1-float', tmp_dir)
end
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture', pre_run: pre_block)
assert_empty install_result.stderr
assert_equal 2, install_result.exit_status, 'Exit status should be 2'
refusal_message = install_result.stdout.split("\n").grep(/refusing/).last
refute_nil refusal_message, 'Should find a failure message at the end'
assert_includes refusal_message, 'inspec-test-fixture'
assert_includes refusal_message, '0.1.0'
assert_includes refusal_message, '0.2.0'
assert_includes refusal_message, 'Update required'
assert_includes refusal_message, 'inspec plugin update'
end
|
#test_refuse_install_when_already_installed_same_version ⇒ Object
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 491
def test_refuse_install_when_already_installed_same_version
pre_block = Proc.new do |plugin_statefile_data, tmp_dir|
plugin_statefile_data.clear copy_in_core_config_dir('test-fixture-2-float', tmp_dir)
end
install_result = run_inspec_process_with_this_plugin('plugin install inspec-test-fixture', pre_run: pre_block)
assert_empty install_result.stderr
assert_equal 2, install_result.exit_status, 'Exit status should be 2'
refusal_message = install_result.stdout.split("\n").grep(/refusing/).last
refute_nil refusal_message, 'Should find a failure message at the end'
assert_includes refusal_message, 'inspec-test-fixture'
assert_includes refusal_message, '0.2.0'
assert_includes refusal_message, 'Plugin already installed at latest version'
end
|
#test_refuse_install_when_missing_prefix ⇒ Object
479
480
481
482
483
484
485
486
487
488
489
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 479
def test_refuse_install_when_missing_prefix
install_result = run_inspec_process_with_this_plugin('plugin install test-fixture')
assert_empty install_result.stderr
assert_equal 1, install_result.exit_status, 'Exit status should be 1'
fail_message = install_result.stdout.split("\n").grep(/failed/).last
refute_nil fail_message, 'Should find a failure message at the end'
assert_includes fail_message, 'test-fixture'
assert_includes fail_message, "All inspec plugins must begin with either 'inspec-' or 'train-'"
end
|
#test_refuse_install_when_plugin_on_exclusion_list ⇒ Object
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 545
def test_refuse_install_when_plugin_on_exclusion_list
[
'inspec-core',
'inspec-multi-server',
'train-tax-calculator',
].each do |plugin_name|
install_result = run_inspec_process_with_this_plugin("plugin install #{plugin_name}")
assert_empty install_result.stderr
assert_equal 2, install_result.exit_status, 'Exit status should be 2'
refusal_message = install_result.stdout
refute_nil refusal_message, 'Should find a failure message at the end'
assert_includes refusal_message, plugin_name
assert_includes refusal_message, 'Plugin on Exclusion List'
assert_includes refusal_message, 'refusing to install'
assert_includes refusal_message, 'Rationale:'
assert_includes refusal_message, 'etc/plugin_filters.json'
assert_includes refusal_message, 'github.com/inspec/inspec/issues/new'
end
end
|