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
Binary file
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module InspecPlugins
|
2
|
-
module Compliance
|
3
|
-
# is a helper that provides information which version of compliance supports
|
4
|
-
# which feature
|
5
|
-
class Support
|
6
|
-
# for a feature, returns either:
|
7
|
-
# - a version v0: v supports v0 iff v0 <= v
|
8
|
-
# - an array [v0, v1] of two versions: v supports [v0, v1] iff v0 <= v < v1
|
9
|
-
def self.version_with_support(feature)
|
10
|
-
case feature.to_sym
|
11
|
-
when :oidc # open id connect authentication
|
12
|
-
Gem::Version.new("0.16.19")
|
13
|
-
else
|
14
|
-
Gem::Version.new("0.0.0")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# determines if the given version support a certain feature
|
19
|
-
def self.supported?(feature, version)
|
20
|
-
sup = version_with_support(feature)
|
21
|
-
|
22
|
-
if sup.is_a?(Array)
|
23
|
-
Gem::Version.new(version) >= sup[0] &&
|
24
|
-
Gem::Version.new(version) < sup[1]
|
25
|
-
else
|
26
|
-
Gem::Version.new(version) >= sup
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# we do not know the version, therefore we do not know if its possible to use the feature
|
31
|
-
# return if self['version'].nil? || self['version']['version'].nil?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,146 +0,0 @@
|
|
1
|
-
require "uri"
|
2
|
-
require "inspec/fetcher"
|
3
|
-
require "inspec/errors"
|
4
|
-
require "inspec/dist"
|
5
|
-
|
6
|
-
# InSpec Target Helper for Chef Compliance
|
7
|
-
# reuses UrlHelper, but it knows the target server and the access token already
|
8
|
-
# similar to `inspec exec http://localhost:2134/owners/%base%/compliance/%ssh%/tar --user %token%`
|
9
|
-
module InspecPlugins
|
10
|
-
module Compliance
|
11
|
-
class Fetcher < Inspec::Fetcher::Url
|
12
|
-
include Inspec::Dist
|
13
|
-
|
14
|
-
name "compliance"
|
15
|
-
priority 500
|
16
|
-
attr_reader :upstream_sha256
|
17
|
-
|
18
|
-
def initialize(target, opts)
|
19
|
-
super(target, opts)
|
20
|
-
@upstream_sha256 = ""
|
21
|
-
if target.is_a?(Hash) && target.key?(:url)
|
22
|
-
@target = target[:url]
|
23
|
-
@upstream_sha256 = target[:sha256]
|
24
|
-
elsif target.is_a?(String)
|
25
|
-
@target = target
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def sha256
|
30
|
-
upstream_sha256.empty? ? super : upstream_sha256
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.check_compliance_token(uri, config)
|
34
|
-
if config["token"].nil? && config["refresh_token"].nil?
|
35
|
-
if config["server_type"] == "automate"
|
36
|
-
server = "automate"
|
37
|
-
msg = "#{EXEC_NAME} compliance login https://your_automate_server --user USER --ent ENT --dctoken DCTOKEN or --token USERTOKEN"
|
38
|
-
elsif config["server_type"] == "automate2"
|
39
|
-
server = "automate2"
|
40
|
-
msg = "#{EXEC_NAME} compliance login https://your_automate2_server --user USER --token APITOKEN"
|
41
|
-
else
|
42
|
-
server = "compliance"
|
43
|
-
msg = "#{EXEC_NAME} compliance login https://your_compliance_server --user admin --insecure --token 'PASTE TOKEN HERE' "
|
44
|
-
end
|
45
|
-
raise Inspec::FetcherFailure, <<~EOF
|
46
|
-
|
47
|
-
Cannot fetch #{uri} because your #{server} token has not been
|
48
|
-
configured.
|
49
|
-
|
50
|
-
Please login using
|
51
|
-
|
52
|
-
#{msg}
|
53
|
-
EOF
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.get_target_uri(target)
|
58
|
-
if target.is_a?(String) && URI(target).scheme == "compliance"
|
59
|
-
URI(target)
|
60
|
-
elsif target.respond_to?(:key?) && target.key?(:compliance)
|
61
|
-
URI("compliance://#{target[:compliance]}")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.resolve(target)
|
66
|
-
uri = get_target_uri(target)
|
67
|
-
return nil if uri.nil?
|
68
|
-
|
69
|
-
config = InspecPlugins::Compliance::Configuration.new
|
70
|
-
profile = InspecPlugins::Compliance::API.sanitize_profile_name(uri)
|
71
|
-
profile_fetch_url = InspecPlugins::Compliance::API.target_url(config, profile)
|
72
|
-
# we have detailed information available in our lockfile, no need to ask the server
|
73
|
-
if target.respond_to?(:key?) && target.key?(:sha256)
|
74
|
-
profile_checksum = target[:sha256]
|
75
|
-
else
|
76
|
-
check_compliance_token(uri, config)
|
77
|
-
# verifies that the target e.g base/ssh exists
|
78
|
-
# Call profiles directly instead of exist? to capture the results
|
79
|
-
# so we can access the upstream sha256 from the results.
|
80
|
-
_msg, profile_result = InspecPlugins::Compliance::API.profiles(config, profile)
|
81
|
-
if profile_result.empty?
|
82
|
-
raise Inspec::FetcherFailure, "The compliance profile #{profile} was not found on the configured compliance server"
|
83
|
-
else
|
84
|
-
# Guarantee sorting by verison and grab the latest.
|
85
|
-
# If version was specified, it will be the first and only result.
|
86
|
-
# Note we are calling the sha256 as a string, not a symbol since
|
87
|
-
# it was returned as json from the Compliance API.
|
88
|
-
profile_info = profile_result.sort_by { |x| Gem::Version.new(x["version"]) }[0]
|
89
|
-
profile_checksum = profile_info.key?("sha256") ? profile_info["sha256"] : ""
|
90
|
-
end
|
91
|
-
end
|
92
|
-
# We need to pass the token to the fetcher
|
93
|
-
config["token"] = InspecPlugins::Compliance::API.get_token(config)
|
94
|
-
|
95
|
-
# Needed for automate2 post request
|
96
|
-
profile_stub = profile || target[:compliance]
|
97
|
-
config["profile"] = InspecPlugins::Compliance::API.profile_split(profile_stub)
|
98
|
-
|
99
|
-
new({ url: profile_fetch_url, sha256: profile_checksum }, config)
|
100
|
-
rescue URI::Error => _e
|
101
|
-
nil
|
102
|
-
end
|
103
|
-
|
104
|
-
# We want to save compliance: in the lockfile rather than url: to
|
105
|
-
# make sure we go back through the Compliance API handling.
|
106
|
-
def resolved_source
|
107
|
-
@resolved_source ||= {
|
108
|
-
compliance: compliance_profile_name,
|
109
|
-
url: @target,
|
110
|
-
sha256: sha256,
|
111
|
-
}
|
112
|
-
end
|
113
|
-
|
114
|
-
def to_s
|
115
|
-
"#{COMPLIANCE_PRODUCT_NAME} Profile Loader"
|
116
|
-
end
|
117
|
-
|
118
|
-
private
|
119
|
-
|
120
|
-
# determine the owner_id and the profile name from the url
|
121
|
-
def compliance_profile_name
|
122
|
-
m = if InspecPlugins::Compliance::API.is_automate_server_pre_080?(@config)
|
123
|
-
%r{^#{@config['server']}/(?<owner>[^/]+)/(?<id>[^/]+)/tar$}
|
124
|
-
elsif InspecPlugins::Compliance::API.is_automate_server_080_and_later?(@config)
|
125
|
-
%r{^#{@config['server']}/profiles/(?<owner>[^/]+)/(?<id>[^/]+)/tar$}
|
126
|
-
else
|
127
|
-
%r{^#{@config['server']}/owners/(?<owner>[^/]+)/compliance/(?<id>[^/]+)/tar$}
|
128
|
-
end.match(@target)
|
129
|
-
|
130
|
-
if InspecPlugins::Compliance::API.is_automate2_server?(@config)
|
131
|
-
m = {}
|
132
|
-
m[:owner] = @config["profile"][0]
|
133
|
-
m[:id] = @config["profile"][1]
|
134
|
-
end
|
135
|
-
|
136
|
-
if m.nil?
|
137
|
-
raise "Unable to determine compliance profile name. This can be caused by " \
|
138
|
-
"an incorrect server in your configuration. Try to login to compliance " \
|
139
|
-
"via the `#{EXEC_NAME} compliance login` command."
|
140
|
-
end
|
141
|
-
|
142
|
-
"#{m[:owner]}/#{m[:id]}"
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require_relative "../../../shared/core_plugin_test_helper.rb"
|
2
|
-
|
3
|
-
class ComplianceCli < Minitest::Test
|
4
|
-
include CorePluginFunctionalHelper
|
5
|
-
|
6
|
-
def test_help_output
|
7
|
-
out = run_inspec_process("compliance help")
|
8
|
-
|
9
|
-
assert_includes out.stdout, "inspec compliance exec PROFILE"
|
10
|
-
|
11
|
-
assert_exit_code 0, out
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_logout_command
|
15
|
-
out = run_inspec_process("compliance logout")
|
16
|
-
|
17
|
-
assert_includes out.stdout, ""
|
18
|
-
|
19
|
-
assert_exit_code 0, out
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_error_login_with_invalid_url
|
23
|
-
out = run_inspec_process("compliance login")
|
24
|
-
|
25
|
-
assert_includes out.stderr, 'ERROR: "inspec compliance login" was called with no arguments'
|
26
|
-
|
27
|
-
assert_exit_code 1, out
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_profile_list_without_auth
|
31
|
-
out = run_inspec_process("compliance profiles")
|
32
|
-
|
33
|
-
assert_includes out.stdout, "You need to login first with `inspec compliance login`"
|
34
|
-
|
35
|
-
assert_exit_code 0, out # TODO: make this error
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_error_upload_without_args
|
39
|
-
out = run_inspec_process("compliance upload")
|
40
|
-
|
41
|
-
assert_includes out.stderr, 'ERROR: "inspec compliance upload" was called with no arguments'
|
42
|
-
|
43
|
-
assert_exit_code 1, out
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_error_upload_with_fake_path
|
47
|
-
out = run_inspec_process("compliance upload /path/to/dir")
|
48
|
-
|
49
|
-
assert_includes out.stdout, "You need to login first with `inspec compliance login`"
|
50
|
-
|
51
|
-
assert_exit_code 0, out # TODO: make this error
|
52
|
-
end
|
53
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# options
|
2
|
-
inspec_bin = "BUNDLE_GEMFILE=/inspec/Gemfile bundle exec inspec"
|
3
|
-
api_url = "https://0.0.0.0"
|
4
|
-
profile = "/inspec/examples/profile"
|
5
|
-
|
6
|
-
user = command("whoami").stdout.strip
|
7
|
-
pwd = command("pwd").stdout.strip
|
8
|
-
puts "Run test as #{user} in path #{pwd}"
|
9
|
-
|
10
|
-
# TODO: determine tokens automatically, define in kitchen yml
|
11
|
-
access_token = ENV["COMPLIANCE_ACCESSTOKEN"]
|
12
|
-
refresh_token = ENV["COMPLIANCE_REFRESHTOKEN"]
|
13
|
-
|
14
|
-
%w{refresh_token access_token}.each do |type| # rubocop:disable Metrics/BlockLength
|
15
|
-
case type
|
16
|
-
when "access_token"
|
17
|
-
token_options = "--token '#{access_token}'"
|
18
|
-
when "refresh_token"
|
19
|
-
token_options = "--refresh_token '#{refresh_token}'"
|
20
|
-
end
|
21
|
-
|
22
|
-
# verifies that the help command works
|
23
|
-
describe command("#{inspec_bin} compliance help") do
|
24
|
-
its("stdout") { should include "inspec compliance help [COMMAND]" }
|
25
|
-
its("stderr") { should eq "" }
|
26
|
-
its("exit_status") { should eq 0 }
|
27
|
-
end
|
28
|
-
|
29
|
-
# version command fails gracefully when server not configured
|
30
|
-
describe command("#{inspec_bin} compliance version") do
|
31
|
-
its("stdout") { should include "Server configuration information is missing" }
|
32
|
-
its("stderr") { should eq "" }
|
33
|
-
its("exit_status") { should eq 1 }
|
34
|
-
end
|
35
|
-
|
36
|
-
# submitting a wrong token should have an exit of 0
|
37
|
-
describe command("#{inspec_bin} compliance login #{api_url} --insecure --user 'admin' --token 'wrong-token'") do
|
38
|
-
its("stdout") { should include "token stored" }
|
39
|
-
end
|
40
|
-
|
41
|
-
# compliance login --help should give an accurate message for login
|
42
|
-
describe command("#{inspec_bin} compliance login --help") do
|
43
|
-
its("stdout") { should include "inspec compliance login SERVER --insecure --user='USER' --token='TOKEN'" }
|
44
|
-
its("exit_status") { should eq 0 }
|
45
|
-
end
|
46
|
-
|
47
|
-
# profiles command fails gracefully when token/server info is incorrect
|
48
|
-
describe command("#{inspec_bin} compliance profiles") do
|
49
|
-
its("stdout") { should include "401 Unauthorized. Please check your token" }
|
50
|
-
its("stderr") { should eq "" }
|
51
|
-
its("exit_status") { should eq 1 }
|
52
|
-
end
|
53
|
-
|
54
|
-
# login via access token token
|
55
|
-
describe command("#{inspec_bin} compliance login #{api_url} --insecure --user 'admin' #{token_options}") do
|
56
|
-
its("stdout") { should include "token", "stored" }
|
57
|
-
its("stdout") { should_not include "Your server supports --user and --password only" }
|
58
|
-
its("stderr") { should eq "" }
|
59
|
-
its("exit_status") { should eq 0 }
|
60
|
-
end
|
61
|
-
|
62
|
-
# see available resources
|
63
|
-
describe command("#{inspec_bin} compliance profiles") do
|
64
|
-
its("stdout") { should include "base/ssh" }
|
65
|
-
its("stderr") { should eq "" }
|
66
|
-
its("exit_status") { should eq 0 }
|
67
|
-
end
|
68
|
-
|
69
|
-
# upload a compliance profile
|
70
|
-
describe command("#{inspec_bin} compliance upload #{profile} --overwrite") do
|
71
|
-
its("stdout") { should include "Profile is valid" }
|
72
|
-
its("stdout") { should include "Successfully uploaded profile" }
|
73
|
-
its("stdout") { should_not include "error(s)" }
|
74
|
-
its("stderr") { should eq "" }
|
75
|
-
its("exit_status") { should eq 0 }
|
76
|
-
end
|
77
|
-
|
78
|
-
# returns the version of the server
|
79
|
-
describe command("#{inspec_bin} compliance version") do
|
80
|
-
its("stdout") { should include "Chef Compliance version:" }
|
81
|
-
its("stderr") { should eq "" }
|
82
|
-
its("exit_status") { should eq 0 }
|
83
|
-
end
|
84
|
-
|
85
|
-
# logout
|
86
|
-
describe command("#{inspec_bin} compliance logout") do
|
87
|
-
its("stdout") { should include "Successfully logged out" }
|
88
|
-
its("stderr") { should eq "" }
|
89
|
-
its("exit_status") { should eq 0 }
|
90
|
-
end
|
91
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require "mocha/setup"
|
3
|
-
require "webmock/minitest"
|
4
|
-
require_relative "../../../lib/inspec-compliance/api.rb"
|
5
|
-
|
6
|
-
describe InspecPlugins::Compliance::API do
|
7
|
-
let(:automate_options) do
|
8
|
-
{
|
9
|
-
"server" => "https://automate.example.com",
|
10
|
-
"ent" => "automate",
|
11
|
-
"user" => "someone",
|
12
|
-
"token" => "token",
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:compliance_options) do
|
17
|
-
{
|
18
|
-
"server" => "https://compliance.example.com",
|
19
|
-
"user" => "someone",
|
20
|
-
"password" => "password",
|
21
|
-
"token" => "token",
|
22
|
-
"refresh_token" => "refresh_token",
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
let(:fake_config) do
|
27
|
-
class FakeConfig
|
28
|
-
def initialize
|
29
|
-
@config = {}
|
30
|
-
end
|
31
|
-
|
32
|
-
def [](key)
|
33
|
-
@config[key]
|
34
|
-
end
|
35
|
-
|
36
|
-
def []=(key, value)
|
37
|
-
@config[key] = value
|
38
|
-
end
|
39
|
-
|
40
|
-
def clean
|
41
|
-
@config = {}
|
42
|
-
end
|
43
|
-
|
44
|
-
def store
|
45
|
-
nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
FakeConfig.new
|
50
|
-
end
|
51
|
-
|
52
|
-
describe ".login" do
|
53
|
-
describe "when target is a Chef Automate2 server" do
|
54
|
-
before do
|
55
|
-
InspecPlugins::Compliance::API.expects(:determine_server_type).returns(:automate2)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "raises an error if `--user` is missing" do
|
59
|
-
options = automate_options
|
60
|
-
options.delete("user")
|
61
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
62
|
-
_(err.message).must_match(/Please specify a user.*/)
|
63
|
-
_(err.message.lines.length).must_equal(1)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "raises an error if `--token` and `--dctoken` are missing" do
|
67
|
-
options = automate_options
|
68
|
-
options.delete("token")
|
69
|
-
options.delete("dctoken")
|
70
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
71
|
-
_(err.message).must_match(/Please specify a token.*/)
|
72
|
-
_(err.message.lines.length).must_equal(1)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "stores an access token" do
|
76
|
-
stub_request(:get, automate_options["server"] + "/compliance/version")
|
77
|
-
.to_return(status: 200, body: "", headers: {})
|
78
|
-
options = automate_options
|
79
|
-
InspecPlugins::Compliance::Configuration.expects(:new).returns(fake_config)
|
80
|
-
|
81
|
-
InspecPlugins::Compliance::API.login(options)
|
82
|
-
_(fake_config["automate"]["ent"]).must_equal("automate")
|
83
|
-
_(fake_config["automate"]["token_type"]).must_equal("dctoken")
|
84
|
-
_(fake_config["user"]).must_equal("someone")
|
85
|
-
_(fake_config["server"]).must_equal("https://automate.example.com/api/v0")
|
86
|
-
_(fake_config["server_type"]).must_equal("automate2")
|
87
|
-
_(fake_config["token"]).must_equal("token")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "when target is a Chef Automate server" do
|
92
|
-
before do
|
93
|
-
InspecPlugins::Compliance::API.expects(:determine_server_type).returns(:automate)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "raises an error if `--user` is missing" do
|
97
|
-
options = automate_options
|
98
|
-
options.delete("user")
|
99
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
100
|
-
_(err.message).must_match(/Please specify a user.*/)
|
101
|
-
_(err.message.lines.length).must_equal(1)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "raises an error if `--ent` is missing" do
|
105
|
-
options = automate_options
|
106
|
-
options.delete("ent")
|
107
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
108
|
-
_(err.message).must_match(/Please specify an enterprise.*/)
|
109
|
-
_(err.message.lines.length).must_equal(1)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "raises an error if `--token` and `--dctoken` are missing" do
|
113
|
-
options = automate_options
|
114
|
-
options.delete("token")
|
115
|
-
options.delete("dctoken")
|
116
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
117
|
-
_(err.message).must_match(/Please specify a token.*/)
|
118
|
-
_(err.message.lines.length).must_equal(1)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "stores an access token" do
|
122
|
-
stub_request(:get, automate_options["server"] + "/compliance/version")
|
123
|
-
.to_return(status: 200, body: "", headers: {})
|
124
|
-
options = automate_options
|
125
|
-
InspecPlugins::Compliance::Configuration.expects(:new).returns(fake_config)
|
126
|
-
|
127
|
-
InspecPlugins::Compliance::API.login(options)
|
128
|
-
_(fake_config["automate"]["ent"]).must_equal("automate")
|
129
|
-
_(fake_config["automate"]["token_type"]).must_equal("usertoken")
|
130
|
-
_(fake_config["user"]).must_equal("someone")
|
131
|
-
_(fake_config["server"]).must_equal("https://automate.example.com/compliance")
|
132
|
-
_(fake_config["server_type"]).must_equal("automate")
|
133
|
-
_(fake_config["token"]).must_equal("token")
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "when target is a Chef Compliance server" do
|
138
|
-
before do
|
139
|
-
InspecPlugins::Compliance::API.expects(:determine_server_type).returns(:compliance)
|
140
|
-
end
|
141
|
-
|
142
|
-
it "raises an error if `--user` and `--refresh-token` are missing" do
|
143
|
-
options = automate_options
|
144
|
-
options.delete("user")
|
145
|
-
options.delete("refresh_token")
|
146
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
147
|
-
_(err.message).must_match(/Please specify a.*--user.*--refresh-token.*/)
|
148
|
-
_(err.message.lines.length).must_equal(1)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "raises an error if `--user` is present but authentication method missing" do
|
152
|
-
options = automate_options
|
153
|
-
options.delete("password")
|
154
|
-
options.delete("token")
|
155
|
-
options.delete("refresh_token")
|
156
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
157
|
-
_(err.message).must_match(/Please specify.*--password.*--token.*--refresh-token.*/)
|
158
|
-
_(err.message.lines.length).must_equal(1)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "stores an access token" do
|
162
|
-
stub_request(:get, compliance_options["server"] + "/api/version")
|
163
|
-
.to_return(status: 200, body: "", headers: {})
|
164
|
-
options = compliance_options
|
165
|
-
InspecPlugins::Compliance::Configuration.expects(:new).returns(fake_config)
|
166
|
-
|
167
|
-
InspecPlugins::Compliance::API.login(options)
|
168
|
-
_(fake_config["user"]).must_equal("someone")
|
169
|
-
_(fake_config["server"]).must_equal("https://compliance.example.com/api")
|
170
|
-
_(fake_config["server_type"]).must_equal("compliance")
|
171
|
-
_(fake_config["token"]).must_equal("token")
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe "when target is neither a Chef Compliance nor Chef Automate server" do
|
176
|
-
it "raises an error if `https://SERVER` is missing" do
|
177
|
-
options = {}
|
178
|
-
err = _ { InspecPlugins::Compliance::API.login(options) }.must_raise(ArgumentError)
|
179
|
-
_(err.message).must_match(/Please specify a server.*/)
|
180
|
-
_(err.message.lines.length).must_equal(1)
|
181
|
-
end
|
182
|
-
|
183
|
-
it "rasies a `CannotDetermineServerType` error" do
|
184
|
-
InspecPlugins::Compliance::API.expects(:determine_server_type).returns(nil)
|
185
|
-
err = _ { InspecPlugins::Compliance::API.login(automate_options) }.must_raise(StandardError)
|
186
|
-
_(err.message).must_match(/Unable to determine/)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|