inspec 4.18.51 → 4.18.85
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/inspec.gemspec +15 -37
- data/lib/resource_support/aws/aws_resource_mixin.rb +1 -1
- metadata +22 -709
- data/Gemfile +0 -61
- data/LICENSE +0 -14
- data/README.md +0 -474
- data/etc/deprecations.json +0 -125
- data/etc/plugin_filters.json +0 -45
- data/lib/bundles/README.md +0 -3
- data/lib/bundles/inspec-compliance/api.rb +0 -7
- data/lib/bundles/inspec-compliance/configuration.rb +0 -7
- data/lib/bundles/inspec-compliance/http.rb +0 -7
- data/lib/bundles/inspec-compliance/support.rb +0 -7
- data/lib/bundles/inspec-compliance/target.rb +0 -7
- data/lib/bundles/inspec-supermarket.rb +0 -9
- data/lib/bundles/inspec-supermarket/README.md +0 -45
- data/lib/bundles/inspec-supermarket/api.rb +0 -87
- data/lib/bundles/inspec-supermarket/cli.rb +0 -71
- data/lib/bundles/inspec-supermarket/target.rb +0 -31
- data/lib/inspec.rb +0 -30
- data/lib/inspec/archive/tar.rb +0 -25
- data/lib/inspec/archive/zip.rb +0 -15
- data/lib/inspec/backend.rb +0 -101
- data/lib/inspec/base_cli.rb +0 -318
- data/lib/inspec/cached_fetcher.rb +0 -65
- data/lib/inspec/cli.rb +0 -469
- data/lib/inspec/completions/bash.sh.erb +0 -45
- data/lib/inspec/completions/fish.sh.erb +0 -34
- data/lib/inspec/completions/zsh.sh.erb +0 -61
- data/lib/inspec/config.rb +0 -511
- data/lib/inspec/control_eval_context.rb +0 -248
- data/lib/inspec/dependencies/cache.rb +0 -74
- data/lib/inspec/dependencies/dependency_set.rb +0 -93
- data/lib/inspec/dependencies/lockfile.rb +0 -115
- data/lib/inspec/dependencies/requirement.rb +0 -135
- data/lib/inspec/dependencies/resolver.rb +0 -86
- data/lib/inspec/describe_base.rb +0 -53
- data/lib/inspec/dist.rb +0 -20
- data/lib/inspec/dsl.rb +0 -115
- data/lib/inspec/dsl_shared.rb +0 -32
- data/lib/inspec/env_printer.rb +0 -156
- data/lib/inspec/errors.rb +0 -18
- data/lib/inspec/exceptions.rb +0 -11
- data/lib/inspec/expect.rb +0 -42
- data/lib/inspec/fetcher.rb +0 -48
- data/lib/inspec/fetcher/git.rb +0 -211
- data/lib/inspec/fetcher/local.rb +0 -116
- data/lib/inspec/fetcher/mock.rb +0 -34
- data/lib/inspec/fetcher/url.rb +0 -281
- data/lib/inspec/file_provider.rb +0 -318
- data/lib/inspec/formatters.rb +0 -3
- data/lib/inspec/formatters/base.rb +0 -269
- data/lib/inspec/formatters/json_rspec.rb +0 -20
- data/lib/inspec/formatters/show_progress.rb +0 -12
- data/lib/inspec/globals.rb +0 -9
- data/lib/inspec/impact.rb +0 -36
- data/lib/inspec/input.rb +0 -421
- data/lib/inspec/input_dsl_helpers.rb +0 -26
- data/lib/inspec/input_registry.rb +0 -315
- data/lib/inspec/library_eval_context.rb +0 -55
- data/lib/inspec/log.rb +0 -7
- data/lib/inspec/metadata.rb +0 -253
- data/lib/inspec/method_source.rb +0 -20
- data/lib/inspec/objects.rb +0 -14
- data/lib/inspec/objects/control.rb +0 -85
- data/lib/inspec/objects/describe.rb +0 -106
- data/lib/inspec/objects/each_loop.rb +0 -41
- data/lib/inspec/objects/input.rb +0 -49
- data/lib/inspec/objects/list.rb +0 -15
- data/lib/inspec/objects/or_test.rb +0 -45
- data/lib/inspec/objects/ruby_helper.rb +0 -13
- data/lib/inspec/objects/tag.rb +0 -32
- data/lib/inspec/objects/test.rb +0 -94
- data/lib/inspec/objects/value.rb +0 -32
- data/lib/inspec/plugin/v1.rb +0 -2
- data/lib/inspec/plugin/v1/plugin_types/cli.rb +0 -22
- data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +0 -83
- data/lib/inspec/plugin/v1/plugin_types/resource.rb +0 -176
- data/lib/inspec/plugin/v1/plugin_types/secret.rb +0 -11
- data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +0 -36
- data/lib/inspec/plugin/v1/plugins.rb +0 -59
- data/lib/inspec/plugin/v1/registry.rb +0 -90
- data/lib/inspec/plugin/v2.rb +0 -46
- data/lib/inspec/plugin/v2/activator.rb +0 -40
- data/lib/inspec/plugin/v2/config_file.rb +0 -151
- data/lib/inspec/plugin/v2/filter.rb +0 -96
- data/lib/inspec/plugin/v2/installer.rb +0 -512
- data/lib/inspec/plugin/v2/loader.rb +0 -321
- data/lib/inspec/plugin/v2/plugin_base.rb +0 -112
- data/lib/inspec/plugin/v2/plugin_types/cli.rb +0 -49
- data/lib/inspec/plugin/v2/plugin_types/dsl.rb +0 -11
- data/lib/inspec/plugin/v2/plugin_types/input.rb +0 -34
- data/lib/inspec/plugin/v2/plugin_types/mock.rb +0 -12
- data/lib/inspec/plugin/v2/registry.rb +0 -98
- data/lib/inspec/plugin/v2/status.rb +0 -29
- data/lib/inspec/profile.rb +0 -658
- data/lib/inspec/profile_context.rb +0 -203
- data/lib/inspec/profile_vendor.rb +0 -84
- data/lib/inspec/reporters.rb +0 -73
- data/lib/inspec/reporters/automate.rb +0 -78
- data/lib/inspec/reporters/base.rb +0 -25
- data/lib/inspec/reporters/cli.rb +0 -370
- data/lib/inspec/reporters/json.rb +0 -113
- data/lib/inspec/reporters/json_automate.rb +0 -80
- data/lib/inspec/reporters/json_min.rb +0 -48
- data/lib/inspec/reporters/junit.rb +0 -77
- data/lib/inspec/reporters/yaml.rb +0 -20
- data/lib/inspec/require_loader.rb +0 -29
- data/lib/inspec/resource.rb +0 -114
- data/lib/inspec/resources.rb +0 -130
- data/lib/inspec/resources/aide_conf.rb +0 -153
- data/lib/inspec/resources/apache.rb +0 -47
- data/lib/inspec/resources/apache_conf.rb +0 -156
- data/lib/inspec/resources/apt.rb +0 -151
- data/lib/inspec/resources/audit_policy.rb +0 -64
- data/lib/inspec/resources/auditd.rb +0 -251
- data/lib/inspec/resources/auditd_conf.rb +0 -45
- data/lib/inspec/resources/bash.rb +0 -33
- data/lib/inspec/resources/bond.rb +0 -70
- data/lib/inspec/resources/bridge.rb +0 -125
- data/lib/inspec/resources/bsd_service.rb +0 -2
- data/lib/inspec/resources/chocolatey_package.rb +0 -82
- data/lib/inspec/resources/command.rb +0 -91
- data/lib/inspec/resources/cpan.rb +0 -58
- data/lib/inspec/resources/cran.rb +0 -64
- data/lib/inspec/resources/crontab.rb +0 -173
- data/lib/inspec/resources/csv.rb +0 -56
- data/lib/inspec/resources/dh_params.rb +0 -83
- data/lib/inspec/resources/directory.rb +0 -23
- data/lib/inspec/resources/docker.rb +0 -274
- data/lib/inspec/resources/docker_container.rb +0 -91
- data/lib/inspec/resources/docker_image.rb +0 -84
- data/lib/inspec/resources/docker_object.rb +0 -52
- data/lib/inspec/resources/docker_plugin.rb +0 -64
- data/lib/inspec/resources/docker_service.rb +0 -91
- data/lib/inspec/resources/elasticsearch.rb +0 -165
- data/lib/inspec/resources/etc_fstab.rb +0 -96
- data/lib/inspec/resources/etc_group.rb +0 -157
- data/lib/inspec/resources/etc_hosts.rb +0 -68
- data/lib/inspec/resources/etc_hosts_allow.rb +0 -2
- data/lib/inspec/resources/etc_hosts_allow_deny.rb +0 -114
- data/lib/inspec/resources/etc_hosts_deny.rb +0 -2
- data/lib/inspec/resources/file.rb +0 -339
- data/lib/inspec/resources/filesystem.rb +0 -139
- data/lib/inspec/resources/firewalld.rb +0 -148
- data/lib/inspec/resources/gem.rb +0 -80
- data/lib/inspec/resources/group.rb +0 -2
- data/lib/inspec/resources/groups.rb +0 -241
- data/lib/inspec/resources/grub_conf.rb +0 -230
- data/lib/inspec/resources/host.rb +0 -310
- data/lib/inspec/resources/http.rb +0 -275
- data/lib/inspec/resources/iis_app.rb +0 -101
- data/lib/inspec/resources/iis_app_pool.rb +0 -127
- data/lib/inspec/resources/iis_site.rb +0 -148
- data/lib/inspec/resources/iis_website.rb +0 -2
- data/lib/inspec/resources/inetd_conf.rb +0 -53
- data/lib/inspec/resources/ini.rb +0 -28
- data/lib/inspec/resources/interface.rb +0 -204
- data/lib/inspec/resources/ip6tables.rb +0 -79
- data/lib/inspec/resources/iptables.rb +0 -80
- data/lib/inspec/resources/json.rb +0 -116
- data/lib/inspec/resources/kernel_module.rb +0 -106
- data/lib/inspec/resources/kernel_parameter.rb +0 -54
- data/lib/inspec/resources/key_rsa.rb +0 -66
- data/lib/inspec/resources/ksh.rb +0 -33
- data/lib/inspec/resources/launchd_service.rb +0 -2
- data/lib/inspec/resources/limits_conf.rb +0 -45
- data/lib/inspec/resources/linux_kernel_parameter.rb +0 -2
- data/lib/inspec/resources/login_defs.rb +0 -56
- data/lib/inspec/resources/mount.rb +0 -88
- data/lib/inspec/resources/mssql_session.rb +0 -117
- data/lib/inspec/resources/mysql.rb +0 -81
- data/lib/inspec/resources/mysql_conf.rb +0 -128
- data/lib/inspec/resources/mysql_session.rb +0 -88
- data/lib/inspec/resources/nginx.rb +0 -96
- data/lib/inspec/resources/nginx_conf.rb +0 -232
- data/lib/inspec/resources/noop.rb +0 -9
- data/lib/inspec/resources/npm.rb +0 -68
- data/lib/inspec/resources/ntp_conf.rb +0 -51
- data/lib/inspec/resources/oneget.rb +0 -71
- data/lib/inspec/resources/oracledb_session.rb +0 -149
- data/lib/inspec/resources/os.rb +0 -34
- data/lib/inspec/resources/os_env.rb +0 -86
- data/lib/inspec/resources/package.rb +0 -391
- data/lib/inspec/resources/packages.rb +0 -111
- data/lib/inspec/resources/parse_config.rb +0 -112
- data/lib/inspec/resources/parse_config_file.rb +0 -2
- data/lib/inspec/resources/passwd.rb +0 -73
- data/lib/inspec/resources/pip.rb +0 -132
- data/lib/inspec/resources/platform.rb +0 -112
- data/lib/inspec/resources/port.rb +0 -791
- data/lib/inspec/resources/postfix_conf.rb +0 -35
- data/lib/inspec/resources/postgres.rb +0 -152
- data/lib/inspec/resources/postgres_conf.rb +0 -116
- data/lib/inspec/resources/postgres_hba_conf.rb +0 -86
- data/lib/inspec/resources/postgres_ident_conf.rb +0 -75
- data/lib/inspec/resources/postgres_session.rb +0 -70
- data/lib/inspec/resources/powershell.rb +0 -67
- data/lib/inspec/resources/ppa.rb +0 -2
- data/lib/inspec/resources/processes.rb +0 -219
- data/lib/inspec/resources/rabbitmq_conf.rb +0 -2
- data/lib/inspec/resources/rabbitmq_config.rb +0 -52
- data/lib/inspec/resources/registry_key.rb +0 -296
- data/lib/inspec/resources/runit_service.rb +0 -2
- data/lib/inspec/resources/script.rb +0 -1
- data/lib/inspec/resources/security_identifier.rb +0 -91
- data/lib/inspec/resources/security_policy.rb +0 -182
- data/lib/inspec/resources/service.rb +0 -820
- data/lib/inspec/resources/shadow.rb +0 -150
- data/lib/inspec/resources/ssh_config.rb +0 -98
- data/lib/inspec/resources/sshd_config.rb +0 -2
- data/lib/inspec/resources/ssl.rb +0 -99
- data/lib/inspec/resources/sys_info.rb +0 -119
- data/lib/inspec/resources/systemd_service.rb +0 -2
- data/lib/inspec/resources/sysv_service.rb +0 -2
- data/lib/inspec/resources/toml.rb +0 -30
- data/lib/inspec/resources/upstart_service.rb +0 -2
- data/lib/inspec/resources/user.rb +0 -1
- data/lib/inspec/resources/users.rb +0 -742
- data/lib/inspec/resources/vbscript.rb +0 -67
- data/lib/inspec/resources/virtualization.rb +0 -255
- data/lib/inspec/resources/windows_feature.rb +0 -126
- data/lib/inspec/resources/windows_hotfix.rb +0 -37
- data/lib/inspec/resources/windows_registry_key.rb +0 -2
- data/lib/inspec/resources/windows_task.rb +0 -112
- data/lib/inspec/resources/wmi.rb +0 -109
- data/lib/inspec/resources/x509_certificate.rb +0 -143
- data/lib/inspec/resources/xinetd_conf.rb +0 -103
- data/lib/inspec/resources/xml.rb +0 -48
- data/lib/inspec/resources/yaml.rb +0 -42
- data/lib/inspec/resources/yum.rb +0 -162
- data/lib/inspec/resources/zfs_dataset.rb +0 -62
- data/lib/inspec/resources/zfs_pool.rb +0 -50
- data/lib/inspec/rspec_extensions.rb +0 -116
- data/lib/inspec/rule.rb +0 -389
- data/lib/inspec/runner.rb +0 -333
- data/lib/inspec/runner_mock.rb +0 -37
- data/lib/inspec/runner_rspec.rb +0 -184
- data/lib/inspec/runtime_profile.rb +0 -23
- data/lib/inspec/schema.rb +0 -245
- data/lib/inspec/secrets.rb +0 -15
- data/lib/inspec/secrets/yaml.rb +0 -29
- data/lib/inspec/shell.rb +0 -211
- data/lib/inspec/shell_detector.rb +0 -89
- data/lib/inspec/source_reader.rb +0 -26
- data/lib/inspec/ui.rb +0 -213
- data/lib/inspec/ui_table_helper.rb +0 -12
- data/lib/inspec/utils/command_wrapper.rb +0 -23
- data/lib/inspec/utils/convert.rb +0 -8
- data/lib/inspec/utils/database_helpers.rb +0 -75
- data/lib/inspec/utils/deprecation.rb +0 -6
- data/lib/inspec/utils/deprecation/config_file.rb +0 -109
- data/lib/inspec/utils/deprecation/deprecator.rb +0 -118
- data/lib/inspec/utils/deprecation/errors.rb +0 -14
- data/lib/inspec/utils/deprecation/global_method.rb +0 -9
- data/lib/inspec/utils/enumerable_delegation.rb +0 -7
- data/lib/inspec/utils/erlang_parser.rb +0 -190
- data/lib/inspec/utils/file_reader.rb +0 -24
- data/lib/inspec/utils/filter.rb +0 -461
- data/lib/inspec/utils/filter_array.rb +0 -25
- data/lib/inspec/utils/find_files.rb +0 -44
- data/lib/inspec/utils/hash.rb +0 -37
- data/lib/inspec/utils/json_log.rb +0 -15
- data/lib/inspec/utils/modulator.rb +0 -9
- data/lib/inspec/utils/nginx_parser.rb +0 -101
- data/lib/inspec/utils/object_traversal.rb +0 -47
- data/lib/inspec/utils/parser.rb +0 -277
- data/lib/inspec/utils/pkey_reader.rb +0 -17
- data/lib/inspec/utils/simpleconfig.rb +0 -121
- data/lib/inspec/utils/spdx.rb +0 -10
- data/lib/inspec/utils/spdx.txt +0 -383
- data/lib/inspec/utils/telemetry.rb +0 -3
- data/lib/inspec/utils/telemetry/collector.rb +0 -81
- data/lib/inspec/utils/telemetry/data_series.rb +0 -44
- data/lib/inspec/utils/telemetry/global_methods.rb +0 -22
- data/lib/inspec/version.rb +0 -3
- data/lib/matchers/matchers.rb +0 -341
- data/lib/plugins/README.md +0 -16
- data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +0 -12
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +0 -170
- data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +0 -116
- data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +0 -50
- data/lib/plugins/inspec-compliance/README.md +0 -207
- data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +0 -12
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +0 -362
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +0 -198
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +0 -269
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +0 -103
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +0 -117
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/images/cc-token.png +0 -0
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +0 -34
- data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +0 -146
- data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +0 -53
- data/lib/plugins/inspec-compliance/test/integration/default/cli.rb +0 -91
- data/lib/plugins/inspec-compliance/test/unit/api/login_test.rb +0 -190
- data/lib/plugins/inspec-compliance/test/unit/api_test.rb +0 -386
- data/lib/plugins/inspec-compliance/test/unit/target_test.rb +0 -155
- data/lib/plugins/inspec-habitat/Berksfile +0 -5
- data/lib/plugins/inspec-habitat/README.md +0 -150
- data/lib/plugins/inspec-habitat/kitchen.yml +0 -28
- data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +0 -11
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +0 -41
- data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +0 -265
- data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +0 -6
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/Berksfile +0 -2
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/README.md +0 -3
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/files/hab_setup.exp +0 -28
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/metadata.rb +0 -9
- data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/recipes/default.rb +0 -61
- data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +0 -34
- data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/README.md +0 -3
- data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/controls/inspec_habitat.rb +0 -40
- data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/inspec.yml +0 -10
- data/lib/plugins/inspec-habitat/test/support/example_profile/README.md +0 -3
- data/lib/plugins/inspec-habitat/test/support/example_profile/controls/example.rb +0 -7
- data/lib/plugins/inspec-habitat/test/support/example_profile/inspec.yml +0 -10
- data/lib/plugins/inspec-habitat/test/unit/profile_test.rb +0 -242
- data/lib/plugins/inspec-init/README.md +0 -31
- data/lib/plugins/inspec-init/lib/inspec-init.rb +0 -12
- data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +0 -15
- data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +0 -243
- data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +0 -47
- data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +0 -97
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -11
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE +0 -2
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/README.md +0 -28
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Rakefile +0 -40
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -14
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -62
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -53
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -8
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md +0 -24
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md +0 -12
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +0 -110
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/helper.rb +0 -24
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/README.md +0 -17
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb +0 -67
- data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb +0 -51
- data/lib/plugins/inspec-init/templates/profiles/aws/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/templates/profiles/gcp/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/templates/profiles/os/README.md +0 -3
- data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +0 -18
- data/lib/plugins/inspec-init/templates/profiles/os/inspec.yml +0 -10
- data/lib/plugins/inspec-init/templates/profiles/os/libraries/.gitkeep +0 -0
- data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +0 -184
- data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +0 -121
- data/lib/plugins/inspec-plugin-manager-cli/README.md +0 -6
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +0 -17
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +0 -518
- data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +0 -12
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/config_dirs/empty/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette.rb +0 -2
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-wrong-structure/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name.rb +0 -1
- data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name/.gitkeep +0 -0
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/help_test.rb +0 -23
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb +0 -62
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/install_test.rb +0 -368
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/list_test.rb +0 -101
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/search_test.rb +0 -129
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/uninstall_test.rb +0 -63
- data/lib/plugins/inspec-plugin-manager-cli/test/functional/update_test.rb +0 -84
- data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +0 -77
- data/lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb +0 -39
- data/lib/plugins/shared/core_plugin_test_helper.rb +0 -153
- data/lib/plugins/things-for-train-integration.rb +0 -14
- data/lib/source_readers/flat.rb +0 -36
- data/lib/source_readers/inspec.rb +0 -66
@@ -1,28 +0,0 @@
|
|
1
|
-
# <%= module_name %> Plugin
|
2
|
-
|
3
|
-
This plugin was generated by `inspec init plugin`, and apparently the author, '<%= author_name %>', did not update the README.
|
4
|
-
|
5
|
-
## To Install This Plugin
|
6
|
-
|
7
|
-
Assuming it has been published to RubyGems, you can install this gem using:
|
8
|
-
|
9
|
-
```
|
10
|
-
you@machine $ inspec plugin install <%= plugin_name %>
|
11
|
-
```
|
12
|
-
|
13
|
-
## What This Plugin Does
|
14
|
-
|
15
|
-
No idea.
|
16
|
-
|
17
|
-
## Developing This Plugin
|
18
|
-
|
19
|
-
The generated plugin contains everything a real-world, industrial grade plugin would have, including:
|
20
|
-
|
21
|
-
* an (possibly incomplete) implementation of one or more InSpec Plugin Types
|
22
|
-
* documentation (you are reading it now)
|
23
|
-
* tests, at the unit and functional level
|
24
|
-
* a .gemspec, for packaging and publishing it as a gem
|
25
|
-
* a Gemfile, for managing its dependencies
|
26
|
-
* a Rakefile, for running development tasks
|
27
|
-
* Rubocop linting support for using the base InSpec project rubocop.yml (See Rakefile)
|
28
|
-
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# A Rakefile defines tasks to help maintain your project.
|
2
|
-
# Rake provides several task templates that are useful.
|
3
|
-
|
4
|
-
#------------------------------------------------------------------#
|
5
|
-
# Test Runner Tasks
|
6
|
-
#------------------------------------------------------------------#
|
7
|
-
|
8
|
-
# This task template will make a task named 'test', and run
|
9
|
-
# the tests that it finds.
|
10
|
-
require 'rake/testtask'
|
11
|
-
|
12
|
-
Rake::TestTask.new do |t|
|
13
|
-
t.libs.push 'lib'
|
14
|
-
t.test_files = FileList[
|
15
|
-
'test/unit/*_test.rb',
|
16
|
-
'test/functional/*_test.rb',
|
17
|
-
]
|
18
|
-
t.verbose = true
|
19
|
-
# Ideally, we'd run tests with warnings enabled,
|
20
|
-
# but the dependent gems have many warnings. As this
|
21
|
-
# is an example, let's disable them so the testing
|
22
|
-
# experience is cleaner.
|
23
|
-
t.warning = false
|
24
|
-
end
|
25
|
-
|
26
|
-
#------------------------------------------------------------------#
|
27
|
-
# Code Style Tasks
|
28
|
-
#------------------------------------------------------------------#
|
29
|
-
require 'rubocop/rake_task'
|
30
|
-
|
31
|
-
RuboCop::RakeTask.new(:lint) do |t|
|
32
|
-
# Choices of RuboCop rules to enforce are deeply personal.
|
33
|
-
# Here, we set things up so that your plugin will use the Bundler-installed
|
34
|
-
# inspec gem's copy of the InSpec project's rubocop.yml file (which
|
35
|
-
# is indeed packaged with the inspec gem).
|
36
|
-
require 'inspec/globals'
|
37
|
-
inspec_rubocop_yml = File.join(Inspec.src_root, '.rubocop.yml')
|
38
|
-
|
39
|
-
t.options = ['--display-cop-names', '--config', inspec_rubocop_yml]
|
40
|
-
end
|
data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# This file is known as the "entry point."
|
2
|
-
# This is the file InSpec will try to load if it
|
3
|
-
# thinks your plugin is installed.
|
4
|
-
|
5
|
-
# The *only* thing this file should do is setup the
|
6
|
-
# load path, then load the plugin definition file.
|
7
|
-
|
8
|
-
# Next two lines simply add the path of the gem to the load path.
|
9
|
-
# This is not needed when being loaded as a gem; but when doing
|
10
|
-
# plugin development, you may need it. Either way, it's harmless.
|
11
|
-
libdir = File.dirname(__FILE__)
|
12
|
-
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
13
|
-
|
14
|
-
require '<%= plugin_name %>/plugin'
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'inspec/resource'
|
2
|
-
|
3
|
-
module InspecPlugins::<%= module_name %>
|
4
|
-
# This class will provide the actual CLI implementation.
|
5
|
-
# Its superclass is provided by another call to Inspec.plugin,
|
6
|
-
# this time with two args. The first arg specifies we are requesting
|
7
|
-
# version 2 of the Plugins API. The second says we are making a CLI
|
8
|
-
# Command plugin component, so please make available any DSL needed
|
9
|
-
# for that.
|
10
|
-
# In fact, aside from a some housekeeping DSL methods, most of the
|
11
|
-
# DSL provided is that of Thor. Inspec.plugin(2, :cli_command)
|
12
|
-
# promises to return a class that is a subclass of Thor. So, to add
|
13
|
-
# commands, usage information, and options, use the Thor documentation.
|
14
|
-
class CliCommand < Inspec.plugin(2, :cli_command)
|
15
|
-
# This isn't provided by Thor, but is needed by InSpec so that it can
|
16
|
-
# register the top-level subcommand. That is to say, subcommand_desc
|
17
|
-
# makes `inspec <%= command_name_dashes %> ...` work. Args to sub_command_desc are
|
18
|
-
# a usage message, and a short decription.
|
19
|
-
# These will appear when someone has installed the plugin, and then they
|
20
|
-
# run `inspec help`.
|
21
|
-
# Note: if you want your command (or subcommand) to have dashes in it,
|
22
|
-
# use underscores where you want a dash, and Thor will convert them.
|
23
|
-
# Thor will fail to find a command that is directly named with dashes.
|
24
|
-
subcommand_desc '<%= command_name_snake %> [COMMAND]', 'Your Usage Message Here'
|
25
|
-
|
26
|
-
# The usual rhythm for a Thor CLI file is description, options, command method.
|
27
|
-
# Thor just has you call DSL methods in sequence prior to each command.
|
28
|
-
|
29
|
-
# Let's make a command, 'do_something'. This will then be available
|
30
|
-
# as `inspec <%= command_name_dashes %> do-something
|
31
|
-
# (Change this method name to be something sensible for your plugin.)
|
32
|
-
|
33
|
-
# First, provide a usage / description. This will appear
|
34
|
-
# in `inspec help <%= command_name_dashes %>`.
|
35
|
-
# As this is a usage message, you should write the command as it should appear
|
36
|
-
# to the user (if you want it to have dashes, use dashes)
|
37
|
-
desc 'do-something WHAT [OPTIONS]', 'Does something'
|
38
|
-
|
39
|
-
# Let's include an option, -s, to summarize
|
40
|
-
# Refer to the Thors docs; there is a lot you can do here.
|
41
|
-
option :summary, desc: 'Include a total at the bottom', \
|
42
|
-
type: :boolean, default: true, aliases: [:s]
|
43
|
-
|
44
|
-
# OK, now the actual method itself. If you provide params, you're telling Thor that
|
45
|
-
# you accept CLI arguments after all options have been consumed.
|
46
|
-
# Note again that the method name has an underscore, but when invoked
|
47
|
-
# on the CLI, use a dash.
|
48
|
-
def do_something(what = 'nothing')
|
49
|
-
# The code here will *only* be executed if someone actually
|
50
|
-
# runs `inspec <%= command_name_dashes %> do-something`.
|
51
|
-
|
52
|
-
# `what` will be the command line arg
|
53
|
-
# `options` will be a hash of CLI option values
|
54
|
-
|
55
|
-
# Talk to the user using the `ui` object (see Inspec::UI)
|
56
|
-
# ui.error('Whoops!')
|
57
|
-
|
58
|
-
ui.warning('This is a generated plugin with a default implementation. Edit lib/<%= plugin_name %>/cli_command.rb to make it do what you want.')
|
59
|
-
ui.exit(:success) # or :usage_error
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# Plugin Definition file
|
2
|
-
# The purpose of this file is to declare to InSpec what plugin_types (capabilities)
|
3
|
-
# are included in this plugin, and provide hooks that will load them as needed.
|
4
|
-
|
5
|
-
# It is important that this file load successfully and *quickly*.
|
6
|
-
# Your plugin's functionality may never be used on this InSpec run; so we keep things
|
7
|
-
# fast and light by only loading heavy things when they are needed.
|
8
|
-
|
9
|
-
# Presumably this is light
|
10
|
-
require '<%= plugin_name %>/version'
|
11
|
-
|
12
|
-
# The InspecPlugins namespace is where all plugins should declare themselves.
|
13
|
-
# The 'Inspec' capitalization is used throughout the InSpec source code; yes, it's
|
14
|
-
# strange.
|
15
|
-
module InspecPlugins
|
16
|
-
# Pick a reasonable namespace here for your plugin. A reasonable choice
|
17
|
-
# would be the CamelCase version of your plugin gem name.
|
18
|
-
# <%= plugin_name %> => <%= module_name %>
|
19
|
-
module <%= module_name %>
|
20
|
-
# This simple class handles the plugin definition, so calling it simply Plugin is OK.
|
21
|
-
# Inspec.plugin returns various Classes, intended to be superclasses for various
|
22
|
-
# plugin components. Here, the one-arg form gives you the Plugin Definition superclass,
|
23
|
-
# which mainly gives you access to the hook / plugin_type DSL.
|
24
|
-
# The number '2' says you are asking for version 2 of the plugin API. If there are
|
25
|
-
# future versions, InSpec promises plugin API v2 will work for at least two more InSpec
|
26
|
-
# major versions.
|
27
|
-
class Plugin < ::Inspec.plugin(2)
|
28
|
-
# Internal machine name of the plugin. InSpec will use this in errors, etc.
|
29
|
-
plugin_name :'<%= plugin_name %>'
|
30
|
-
|
31
|
-
# Define a new CLI subcommand.
|
32
|
-
# The argument here will be used to match against the command line args,
|
33
|
-
# and if the user said `inspec list-resources`, this hook will get called.
|
34
|
-
# Notice that you can define multiple hooks with different names, and they
|
35
|
-
# don't have to match the plugin name.
|
36
|
-
|
37
|
-
# We'd like this to be list-resources, but Thor does not support hyphens
|
38
|
-
# see https://github.com/erikhuda/thor/pull/613
|
39
|
-
cli_command :<%= command_name_snake %> do
|
40
|
-
# Calling this hook doesn't mean the subcommand is being executed - just
|
41
|
-
# that we should be ready to do so. So, load the file that defines the
|
42
|
-
# functionality.
|
43
|
-
# For example, InSpec will activate this hook when `inspec help` is
|
44
|
-
# executed, so that this plugin's usage message will be included in the help.
|
45
|
-
require '<%= plugin_name %>/cli_command'
|
46
|
-
|
47
|
-
# Having loaded our functionality, return a class that will let the
|
48
|
-
# CLI engine tap into it.
|
49
|
-
InspecPlugins::<%= module_name %>::CliCommand
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Test Fixtures Area
|
2
|
-
|
3
|
-
In this directory, you would place things that you need during testing. For example, if you were making a plugin that counts the number of controls in a profile, you might have a directory tree like this:
|
4
|
-
|
5
|
-
```
|
6
|
-
fixtures/
|
7
|
-
profiles/
|
8
|
-
zero-controls/
|
9
|
-
inspec.yml
|
10
|
-
controls/
|
11
|
-
twelve-controls/
|
12
|
-
inspec.yml
|
13
|
-
controls/
|
14
|
-
nine.rb
|
15
|
-
three.rb
|
16
|
-
```
|
17
|
-
|
18
|
-
When writing your functional tests, you can point InSpec at the various test fixture profiles, and know that when it points at the zero-controls profile, it should find no controls; and when pointed at the twelve-controls profile, it should find 12.
|
19
|
-
|
20
|
-
## Using test fixtures provided with the `inspec` source code
|
21
|
-
|
22
|
-
InSpec itself ships with many test fixtures - not just profiles, but attribute files, configuration directories, and more. Examine them at [the fixtures directory](https://github.com/inspec/inspec/tree/master/test/fixtures)
|
23
|
-
|
24
|
-
To use them, see the helper.rb file included in the example at test/helper.rb .
|
data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# Functional Testing Area for Plugins
|
2
|
-
|
3
|
-
## What are functional tests?
|
4
|
-
|
5
|
-
Functional tests are tests that verify that your plugin works _as would be seen by a user_. Functional tests generally do not have inside knowledge about the inner workings of the plugin. However a functional test is very interested in changes that your plugin makes to the outside world: exit codes, command output, changes to files on the filesystem, etc.
|
6
|
-
|
7
|
-
To be picked up by the Rake tasks as tests, each test file should end in `_test.rb`.
|
8
|
-
|
9
|
-
## Unit vs Functional Tests
|
10
|
-
|
11
|
-
A practical difference between unit tests and functional tests is that unit tests all run within one process, while functional tests might exercise a CLI plugin by shelling out to an `inspec` invocation in a subprocess, and examining the results.
|
12
|
-
|
@@ -1,110 +0,0 @@
|
|
1
|
-
# Functional Tests for Example Plugin, Resource Lister
|
2
|
-
|
3
|
-
# Functional tests are used to verify the behavior of the plugin are as expected, to a user.
|
4
|
-
# Functional tests generally do not have inside knowledge of how the plugin works.
|
5
|
-
|
6
|
-
# Include our test harness
|
7
|
-
require_relative '../helper'
|
8
|
-
|
9
|
-
# Because InSpec is a Spec-style test suite, we're going to use Minitest::Spec
|
10
|
-
# here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
|
11
|
-
describe 'inspec list-resources core' do
|
12
|
-
# Our helper.rb locates this library from the InSpec install that
|
13
|
-
# Bundler installed for us. If we want its methods, we still must
|
14
|
-
# import it. Including it here will make it available in all child
|
15
|
-
# 'describe' blocks.
|
16
|
-
include CorePluginFunctionalHelper
|
17
|
-
|
18
|
-
# When thinking up scenarios to test, start with the simplest.
|
19
|
-
# Then think of each major feature, and exercise them.
|
20
|
-
# Running combinations of features makes sense if it is very likely,
|
21
|
-
# or a difficult / dangerous case. You can always add more tests
|
22
|
-
# here as users find subtle problems. In fact, having a user submit
|
23
|
-
# a PR that creates a failing functional test is a great way to
|
24
|
-
# capture the reproduction case.
|
25
|
-
# The simplest case:
|
26
|
-
describe "when run without an argument" do
|
27
|
-
|
28
|
-
# run_inspec_process_with_this_plugin is a helper provided by
|
29
|
-
# CoreFunctionalHelper. It makes the InSpec that Bundler installed
|
30
|
-
# think that this plugin we are currently testing is installed as a
|
31
|
-
# user plugin, by writing a plugin config file in a temp dir.
|
32
|
-
# To use it, just provide a command line, minus the word `inspec`.
|
33
|
-
let(:outcome) { run_inspec_process_with_this_plugin("listresources core") }
|
34
|
-
|
35
|
-
# Some tests through here use minitest Expectations, which attach to all
|
36
|
-
# Objects, and begin with 'must' (positive) or 'wont' (negative)
|
37
|
-
# See http://docs.seattlerb.org/minitest/Minitest/Expectations.html
|
38
|
-
it("should exit successfully") { assert_exit_code 0, outcome }
|
39
|
-
it("should be silent on stderr") { outcome.stderr.must_be_empty }
|
40
|
-
|
41
|
-
# A selection of core resources, just spot checking.
|
42
|
-
# This is an example of using Ruby to define sets of tests.
|
43
|
-
['process', 'service', 'user', 'file'].each do |resource_name|
|
44
|
-
it "should mention the '#{resource_name}' resource" do
|
45
|
-
outcome.stdout.must_include(resource_name)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Check for the summary
|
50
|
-
it "should mention the summary" do
|
51
|
-
outcome.stdout.must_include('resources total')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# Test the search pattern feature, in a couple of ways.
|
56
|
-
describe "when run with a search pattern that matches things" do
|
57
|
-
# Notice that the command line is changed here:
|
58
|
-
# "list all resources that have the word user in them"
|
59
|
-
let(:outcome) { run_inspec_process_with_this_plugin("listresources core user") }
|
60
|
-
|
61
|
-
# Should be well-behaved...
|
62
|
-
it("should exit successfully") { assert_exit_code 0, outcome }
|
63
|
-
it("should be silent on stderr") { outcome.stderr.must_be_empty }
|
64
|
-
|
65
|
-
# Here, we want to know it DID match some things, and NOT some others.
|
66
|
-
['user', 'users'].each do |resource_name|
|
67
|
-
it "should mention the '#{resource_name}' resource" do
|
68
|
-
outcome.stdout.must_include(resource_name)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
['process', 'service', 'file'].each do |resource_name|
|
72
|
-
it "should NOT mention the '#{resource_name}' resource" do
|
73
|
-
outcome.stdout.wont_include(resource_name)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
describe "when run with a search pattern that matches nothing" do
|
78
|
-
# Unlikely we'll have a resource with the string 'autogyro' in it.
|
79
|
-
let(:outcome) { run_inspec_process_with_this_plugin("listresources core autogyro") }
|
80
|
-
|
81
|
-
# Should be well-behaved...
|
82
|
-
it("should exit successfully") { assert_exit_code 0, outcome }
|
83
|
-
it("should be silent on stderr") { outcome.stderr.must_be_empty }
|
84
|
-
|
85
|
-
# Output lines should be just two, for the summary.
|
86
|
-
it "should only have two output lines" do
|
87
|
-
outcome.stdout.split("\n").count.must_equal(2)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Check for the summary
|
91
|
-
it "should mention a zero-resource summary" do
|
92
|
-
outcome.stdout.must_include('0 resources total')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# Exercise the summary option, which defaults to 'true'.
|
97
|
-
describe "when run with the no-summary flag" do
|
98
|
-
# Alter the command string to include the no-summary option
|
99
|
-
let(:outcome) { run_inspec_process_with_this_plugin('listresources core --no-summary') }
|
100
|
-
|
101
|
-
# Should be well-behaved...
|
102
|
-
it("should exit successfully") { assert_exit_code 0, outcome }
|
103
|
-
it("should be silent on stderr") { outcome.stderr.must_be_empty }
|
104
|
-
|
105
|
-
# Check for the summary
|
106
|
-
it "should NOT mention summary" do
|
107
|
-
outcome.stdout.wont_include('0 resources total')
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# Test helper file for non-core plugins
|
2
|
-
|
3
|
-
# This file's job is to collect any libraries needed for testing, as well as provide
|
4
|
-
# any utilities to make testing a plugin easier.
|
5
|
-
|
6
|
-
# InSpec core provides a number of such libraries and facilities, in the file
|
7
|
-
# lib/plugins/shared/core_plugin_test_helper.rb . So, one job in this file is
|
8
|
-
# to locate and load that file.
|
9
|
-
require 'inspec/../plugins/shared/core_plugin_test_helper'
|
10
|
-
|
11
|
-
# Also load the InSpec plugin system. We need this so we can unit-test the plugin
|
12
|
-
# classes, which will rely on the plugin system.
|
13
|
-
require 'inspec/plugin/v2'
|
14
|
-
|
15
|
-
# Caution: loading all of InSpec (i.e. require 'inspec') may cause interference with
|
16
|
-
# minitest/spec; one symptom would be appearing to have no tests.
|
17
|
-
# See https://github.com/inspec/inspec/issues/3380
|
18
|
-
|
19
|
-
# You can select from a number of test harnesses. Since InSpec uses Spec-style controls
|
20
|
-
# in profile code, you will probably want to use something like minitest/spec, which provides
|
21
|
-
# Spec-style tests.
|
22
|
-
require 'minitest/autorun' # loads all styles and runs tests automatically
|
23
|
-
|
24
|
-
# You might want to put some debugging tools here. We run tests to find bugs, after all.
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# Unit Testing Area for Plugins
|
2
|
-
|
3
|
-
## What Tests are Provided?
|
4
|
-
|
5
|
-
* plugin_def_test.rb - Would be useful in any plugin. Verifies that the plugin is properly detected and registered.
|
6
|
-
<% if hooks.key?(:cli_command) %>
|
7
|
-
* cli_args_test.rb - Tests the CLI options for a CLI Command plugin
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
## What are Unit Tests?
|
11
|
-
|
12
|
-
Unit tests are tests that verify that the individual components of your plugin work as intended. To be picked up by the Rake tasks as tests, each test file should end in `_test.rb`.
|
13
|
-
|
14
|
-
## Unit vs Functional Tests
|
15
|
-
|
16
|
-
A practical difference between unit tests and functional tests is that unit tests all run within one process, while functional tests might exercise a CLI plugin by shelling out to an inspec command in a subprocess, and examining the results.
|
17
|
-
|
data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# This unit test performs some tests to verify that the command line options for
|
2
|
-
# <%= plugin_name %> are correct.
|
3
|
-
|
4
|
-
# Include our test harness
|
5
|
-
require_relative '../helper'
|
6
|
-
|
7
|
-
# Load the class under test, the CliCommand definition.
|
8
|
-
require '<%= plugin_name %>/cli_command'
|
9
|
-
|
10
|
-
# Because InSpec is a Spec-style test suite, we're going to use Minitest::Spec
|
11
|
-
# here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
|
12
|
-
describe InspecPlugins::<%= module_name %>::CliCommand do
|
13
|
-
|
14
|
-
# When writing tests, you can use `let` to create variables that you
|
15
|
-
# can reference easily.
|
16
|
-
|
17
|
-
# This is the CLI Command implementation class.
|
18
|
-
# It is a subclass of Thor, which is a CLI framework.
|
19
|
-
# This unit test file is mostly about verifying the Thor settings.
|
20
|
-
let(:cli_class) { InspecPlugins::<%= module_name %>::CliCommand }
|
21
|
-
|
22
|
-
# From this point onwards, this test file assumes you did not rename
|
23
|
-
# the provided 'do_something' subcommand. As you implement your plugin,
|
24
|
-
# modify and add to the lines below to test your actual options.
|
25
|
-
|
26
|
-
# This is a Hash of Structs that tells us details of options for the 'do_something' subcommand.
|
27
|
-
let(:do_something_options) { cli_class.all_commands['do_something'].options }
|
28
|
-
|
29
|
-
# To group tests together, you can nest 'describe' in minitest/spec
|
30
|
-
describe 'the do-something subcommand' do
|
31
|
-
|
32
|
-
# Some tests through here use minitest Expectations, which attach to all
|
33
|
-
# Objects, and begin with 'must' (positive) or 'wont' (negative)
|
34
|
-
# See http://docs.seattlerb.org/minitest/Minitest/Expectations.html
|
35
|
-
|
36
|
-
# Option count OK?
|
37
|
-
it "should take one option" do
|
38
|
-
do_something_options.count.must_equal(1)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Summary option
|
42
|
-
describe "the summary option" do
|
43
|
-
it "should be present" do
|
44
|
-
do_something_options.keys.must_include(:summary)
|
45
|
-
end
|
46
|
-
it "should have a description" do
|
47
|
-
do_something_options[:summary].description.wont_be_nil
|
48
|
-
end
|
49
|
-
it "should not be required" do
|
50
|
-
do_something_options[:summary].required.wont_equal(true)
|
51
|
-
end
|
52
|
-
it "should have a single-letter alias" do
|
53
|
-
do_something_options[:summary].aliases.must_include(:s)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Argument count
|
58
|
-
# The 'do-something' command takes one optional argument. According to the
|
59
|
-
# metaprogramming rules of Ruby, the do_something() method should thus have an
|
60
|
-
# arity of -1. See http://ruby-doc.org/core-2.5.1/Method.html#method-i-arity
|
61
|
-
# for how that number is caclulated.
|
62
|
-
it "should take one optional argument" do
|
63
|
-
cli_class.instance_method(:do_something).arity.must_equal(-1)
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|