chef 17.10.163 → 18.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +25 -21
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
- data/chef.gemspec +33 -27
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/base.rb +20 -2
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/chef_fs/path_utils.rb +7 -9
- data/lib/chef/client.rb +186 -2
- data/lib/chef/compliance/default_attributes.rb +2 -2
- data/lib/chef/compliance/input.rb +1 -1
- data/lib/chef/compliance/profile.rb +1 -1
- data/lib/chef/compliance/profile_collection.rb +0 -1
- data/lib/chef/compliance/runner.rb +6 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +4 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
- data/lib/chef/cookbook/synchronizer.rb +21 -3
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/cookbook_manifest.rb +2 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_collector.rb +14 -0
- data/lib/chef/delayed_evaluator.rb +4 -0
- data/lib/chef/dsl/reader_helpers.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +77 -0
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +0 -1
- data/lib/chef/exceptions.rb +9 -1
- data/lib/chef/file_access_control/windows.rb +4 -1
- data/lib/chef/file_cache.rb +17 -2
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
- data/lib/chef/http/authenticator.rb +253 -3
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
- data/lib/chef/mixin/openssl_helper.rb +1 -16
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute.rb +3 -11
- data/lib/chef/node/attribute_collections.rb +10 -1
- data/lib/chef/node/immutable_collections.rb +17 -6
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/state_tracking.rb +7 -4
- data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
- data/lib/chef/node.rb +23 -1
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/policy_builder/policyfile.rb +8 -0
- data/lib/chef/property.rb +13 -6
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/launchd.rb +2 -1
- data/lib/chef/provider/mount/linux.rb +6 -1
- data/lib/chef/provider/mount/mount.rb +13 -5
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/chocolatey.rb +260 -22
- data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
- data/lib/chef/provider/package/homebrew.rb +6 -9
- data/lib/chef/provider/package/powershell.rb +1 -0
- data/lib/chef/provider/package/rubygems.rb +5 -1
- data/lib/chef/provider/package/snap.rb +3 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/yum/yum_helper.py +3 -3
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -3
- data/lib/chef/provider/powershell_script.rb +96 -6
- data/lib/chef/provider/registry_key.rb +2 -0
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +23 -8
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/service.rb +14 -0
- data/lib/chef/provider/user/aix.rb +5 -0
- data/lib/chef/provider/user/linux.rb +29 -0
- data/lib/chef/provider/user/mac.rb +1 -1
- data/lib/chef/provider/user/windows.rb +5 -0
- data/lib/chef/provider/user.rb +45 -9
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +4 -12
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +21 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +138 -18
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +13 -1
- data/lib/chef/resource/batch.rb +0 -1
- data/lib/chef/resource/bff_package.rb +0 -1
- data/lib/chef/resource/breakpoint.rb +0 -1
- data/lib/chef/resource/build_essential.rb +0 -1
- data/lib/chef/resource/cab_package.rb +0 -1
- data/lib/chef/resource/chef_client_config.rb +12 -14
- data/lib/chef/resource/chef_client_cron.rb +1 -2
- data/lib/chef/resource/chef_client_launchd.rb +2 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -2
- data/lib/chef/resource/chef_handler.rb +0 -1
- data/lib/chef/resource/chef_sleep.rb +1 -3
- data/lib/chef/resource/chef_vault_secret.rb +0 -1
- data/lib/chef/resource/chocolatey_config.rb +0 -1
- data/lib/chef/resource/chocolatey_feature.rb +0 -1
- data/lib/chef/resource/chocolatey_installer.rb +207 -0
- data/lib/chef/resource/chocolatey_package.rb +8 -1
- data/lib/chef/resource/chocolatey_source.rb +0 -1
- data/lib/chef/resource/cookbook_file.rb +0 -1
- data/lib/chef/resource/cron/_cron_shared.rb +0 -1
- data/lib/chef/resource/cron/cron.rb +0 -1
- data/lib/chef/resource/cron/cron_d.rb +15 -1
- data/lib/chef/resource/cron_access.rb +0 -1
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/directory.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +2 -1
- data/lib/chef/resource/dnf_package.rb +0 -1
- data/lib/chef/resource/dpkg_package.rb +0 -1
- data/lib/chef/resource/dsc_resource.rb +0 -1
- data/lib/chef/resource/dsc_script.rb +1 -2
- data/lib/chef/resource/execute.rb +8 -7
- data/lib/chef/resource/file.rb +0 -1
- data/lib/chef/resource/freebsd_package.rb +2 -1
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +25 -2
- data/lib/chef/resource/habitat/habitat_package.rb +0 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/habitat_config.rb +0 -1
- data/lib/chef/resource/habitat_install.rb +2 -2
- data/lib/chef/resource/habitat_service.rb +0 -1
- data/lib/chef/resource/habitat_user_toml.rb +0 -1
- data/lib/chef/resource/homebrew_cask.rb +21 -33
- data/lib/chef/resource/homebrew_package.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +32 -18
- data/lib/chef/resource/homebrew_update.rb +4 -6
- data/lib/chef/resource/hostname.rb +0 -1
- data/lib/chef/resource/http_request.rb +0 -1
- data/lib/chef/resource/ifconfig.rb +0 -1
- data/lib/chef/resource/inspec_input.rb +0 -1
- data/lib/chef/resource/inspec_waiver.rb +0 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
- data/lib/chef/resource/ips_package.rb +0 -1
- data/lib/chef/resource/kernel_module.rb +0 -1
- data/lib/chef/resource/ksh.rb +0 -1
- data/lib/chef/resource/launchd.rb +9 -3
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +0 -1
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_pkg.rb +111 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -4
- data/lib/chef/resource/macosx_service.rb +0 -1
- data/lib/chef/resource/macports_package.rb +2 -1
- data/lib/chef/resource/mdadm.rb +0 -1
- data/lib/chef/resource/mount.rb +0 -1
- data/lib/chef/resource/msu_package.rb +0 -1
- data/lib/chef/resource/notify_group.rb +0 -2
- data/lib/chef/resource/ohai.rb +0 -1
- data/lib/chef/resource/ohai_hint.rb +0 -1
- data/lib/chef/resource/openbsd_package.rb +2 -1
- data/lib/chef/resource/openssl_dhparam.rb +0 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
- data/lib/chef/resource/openssl_x509_crl.rb +0 -2
- data/lib/chef/resource/openssl_x509_request.rb +0 -2
- data/lib/chef/resource/osx_profile.rb +0 -1
- data/lib/chef/resource/package.rb +0 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +0 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +7 -3
- data/lib/chef/resource/portage_package.rb +2 -1
- data/lib/chef/resource/powershell_package.rb +4 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +5 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +6 -1
- data/lib/chef/resource/remote_directory.rb +0 -1
- data/lib/chef/resource/remote_file.rb +0 -1
- data/lib/chef/resource/rhsm_errata.rb +0 -1
- data/lib/chef/resource/rhsm_errata_level.rb +0 -1
- data/lib/chef/resource/rhsm_register.rb +2 -4
- data/lib/chef/resource/rhsm_repo.rb +0 -1
- data/lib/chef/resource/rhsm_subscription.rb +0 -1
- data/lib/chef/resource/route.rb +0 -1
- data/lib/chef/resource/rpm_package.rb +2 -1
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/ruby_block.rb +0 -1
- data/lib/chef/resource/scm/_scm.rb +0 -2
- data/lib/chef/resource/scm/git.rb +0 -2
- data/lib/chef/resource/scm/subversion.rb +0 -2
- data/lib/chef/resource/script.rb +0 -1
- data/lib/chef/resource/selinux/common_helpers.rb +47 -0
- data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
- data/lib/chef/resource/selinux/selinux_default.erb +15 -0
- data/lib/chef/resource/selinux_boolean.rb +101 -0
- data/lib/chef/resource/selinux_fcontext.rb +160 -0
- data/lib/chef/resource/selinux_install.rb +107 -0
- data/lib/chef/resource/selinux_login.rb +129 -0
- data/lib/chef/resource/selinux_module.rb +143 -0
- data/lib/chef/resource/selinux_permissive.rb +64 -0
- data/lib/chef/resource/selinux_port.rb +118 -0
- data/lib/chef/resource/selinux_state.rb +166 -0
- data/lib/chef/resource/selinux_user.rb +137 -0
- data/lib/chef/resource/service.rb +4 -2
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +25 -1
- data/lib/chef/resource/solaris_package.rb +2 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
- data/lib/chef/resource/sudo.rb +37 -3
- data/lib/chef/resource/support/client.erb +2 -2
- data/lib/chef/resource/support/ulimit.erb +40 -0
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +0 -1
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +0 -1
- data/lib/chef/resource/user/aix_user.rb +0 -1
- data/lib/chef/resource/user/linux_user.rb +0 -1
- data/lib/chef/resource/user/mac_user.rb +0 -1
- data/lib/chef/resource/user/pw_user.rb +0 -1
- data/lib/chef/resource/user/solaris_user.rb +0 -1
- data/lib/chef/resource/user/windows_user.rb +0 -1
- data/lib/chef/resource/user.rb +10 -1
- data/lib/chef/resource/user_ulimit.rb +38 -1
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
- data/lib/chef/resource/windows_ad_join.rb +0 -2
- data/lib/chef/resource/windows_audit_policy.rb +0 -2
- data/lib/chef/resource/windows_auto_run.rb +0 -1
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +0 -1
- data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
- data/lib/chef/resource/windows_dfs_folder.rb +0 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
- data/lib/chef/resource/windows_dfs_server.rb +0 -1
- data/lib/chef/resource/windows_dns_record.rb +0 -1
- data/lib/chef/resource/windows_dns_zone.rb +0 -1
- data/lib/chef/resource/windows_env.rb +0 -1
- data/lib/chef/resource/windows_feature.rb +0 -1
- data/lib/chef/resource/windows_feature_dism.rb +0 -1
- data/lib/chef/resource/windows_feature_powershell.rb +0 -1
- data/lib/chef/resource/windows_firewall_profile.rb +0 -2
- data/lib/chef/resource/windows_firewall_rule.rb +0 -1
- data/lib/chef/resource/windows_font.rb +2 -3
- data/lib/chef/resource/windows_package.rb +3 -4
- data/lib/chef/resource/windows_pagefile.rb +0 -2
- data/lib/chef/resource/windows_path.rb +0 -1
- data/lib/chef/resource/windows_printer.rb +0 -1
- data/lib/chef/resource/windows_printer_port.rb +0 -1
- data/lib/chef/resource/windows_script.rb +0 -2
- data/lib/chef/resource/windows_security_policy.rb +2 -3
- data/lib/chef/resource/windows_service.rb +0 -1
- data/lib/chef/resource/windows_share.rb +0 -1
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +0 -1
- data/lib/chef/resource/windows_uac.rb +0 -1
- data/lib/chef/resource/windows_update_settings.rb +0 -1
- data/lib/chef/resource/windows_user_privilege.rb +14 -11
- data/lib/chef/resource/windows_workgroup.rb +0 -1
- data/lib/chef/resource/yum_package.rb +2 -1
- data/lib/chef/resource/yum_repository.rb +4 -1
- data/lib/chef/resource/zypper_package.rb +2 -1
- data/lib/chef/resource/zypper_repository.rb +0 -1
- data/lib/chef/resource.rb +23 -5
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/resource_reporter.rb +4 -0
- data/lib/chef/resources.rb +11 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
- data/lib/chef/util/powershell/ps_credential.rb +10 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +12 -4
- data/lib/chef/win32/security.rb +16 -1
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +26 -42
- data/spec/functional/resource/link_spec.rb +8 -8
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/registry_spec.rb +233 -609
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -1
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +1 -1
- data/spec/functional/resource/zypper_package_spec.rb +12 -0
- data/spec/functional/shell_spec.rb +1 -2
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +0 -3
- data/spec/integration/client/client_spec.rb +88 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +5 -5
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/client/open_ssl_spec.rb +3 -3
- data/spec/integration/compliance/compliance_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +1 -1
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/integration/recipes/use_partial_spec.rb +2 -1
- data/spec/integration/solo/solo_spec.rb +2 -2
- data/spec/spec_helper.rb +7 -4
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/platform_helpers.rb +28 -7
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/tiny_server.rb +5 -2
- data/spec/unit/application/client_spec.rb +0 -10
- data/spec/unit/chef_fs/file_system_spec.rb +2 -0
- data/spec/unit/client_spec.rb +80 -4
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/data_collector_spec.rb +106 -2
- data/spec/unit/delayed_evaluator_spec.rb +35 -0
- data/spec/unit/file_cache_spec.rb +64 -0
- data/spec/unit/http/authenticator_spec.rb +121 -0
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/apt_repository_spec.rb +48 -12
- data/spec/unit/provider/cron_spec.rb +2 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +15 -4
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/apt_spec.rb +18 -13
- data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/powershell_script_spec.rb +100 -4
- data/spec/unit/provider/registry_key_spec.rb +17 -17
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -1
- data/spec/unit/provider/user/windows_spec.rb +1 -0
- data/spec/unit/provider/user_spec.rb +24 -6
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- data/spec/unit/resource/archive_file_spec.rb +1 -1
- data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
- data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_pkg_spec.rb +38 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/rest_resource_spec.rb +381 -0
- data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
- data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
- data/spec/unit/resource/selinux_install_spec.rb +60 -0
- data/spec/unit/resource/selinux_login_spec.rb +73 -0
- data/spec/unit/resource/selinux_module_spec.rb +55 -0
- data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
- data/spec/unit/resource/selinux_port_spec.rb +42 -0
- data/spec/unit/resource/selinux_state_spec.rb +46 -0
- data/spec/unit/resource/selinux_user_spec.rb +92 -0
- data/spec/unit/resource/sysctl_spec.rb +2 -2
- data/spec/unit/resource/user/linux_user_spec.rb +42 -0
- data/spec/unit/resource/yum_repository_spec.rb +4 -0
- data/spec/unit/resource_inspector_spec.rb +36 -0
- data/spec/unit/resource_reporter_spec.rb +57 -3
- data/spec/unit/resource_spec.rb +94 -2
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
- data/tasks/rspec.rb +1 -1
- metadata +126 -44
- data/lib/chef/powershell.rb +0 -81
- data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
- /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
|
@@ -65,12 +65,18 @@ def windows_gte_10?
|
|
|
65
65
|
Gem::Requirement.new(">= 10").satisfied_by?(Gem::Version.new(win32_os_version))
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
def windows_11?
|
|
69
|
+
return false unless windows?
|
|
70
|
+
|
|
71
|
+
Gem::Requirement.new(">= 10.0.22621").satisfied_by?(Gem::Version.new(win32_os_version))
|
|
72
|
+
end
|
|
73
|
+
|
|
68
74
|
def win32_os_version
|
|
69
75
|
@win32_os_version ||= begin
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
wmi = WmiLite::Wmi.new
|
|
77
|
+
host = wmi.first_of("Win32_OperatingSystem")
|
|
78
|
+
host["version"]
|
|
79
|
+
end
|
|
74
80
|
end
|
|
75
81
|
|
|
76
82
|
def windows_powershell_dsc?
|
|
@@ -80,7 +86,7 @@ def windows_powershell_dsc?
|
|
|
80
86
|
begin
|
|
81
87
|
wmi = WmiLite::Wmi.new("root/microsoft/windows/desiredstateconfiguration")
|
|
82
88
|
lcm = wmi.query("SELECT * FROM meta_class WHERE __this ISA 'MSFT_DSCLocalConfigurationManager'")
|
|
83
|
-
supports_dsc = !!
|
|
89
|
+
supports_dsc = !!lcm
|
|
84
90
|
rescue WmiLite::WmiException
|
|
85
91
|
end
|
|
86
92
|
supports_dsc
|
|
@@ -95,7 +101,7 @@ end
|
|
|
95
101
|
|
|
96
102
|
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
|
|
97
103
|
def windows64?
|
|
98
|
-
windows? && (
|
|
104
|
+
windows? && (ENV["PROCESSOR_ARCHITECTURE"] == "AMD64" || ENV["PROCESSOR_ARCHITEW6432"] == "AMD64")
|
|
99
105
|
end
|
|
100
106
|
|
|
101
107
|
# detects if the hardware is 32-bit
|
|
@@ -175,6 +181,10 @@ def wpar?
|
|
|
175
181
|
!((ohai[:virtualization] || {})[:wpar_no].nil?)
|
|
176
182
|
end
|
|
177
183
|
|
|
184
|
+
def s390x?
|
|
185
|
+
RUBY_PLATFORM.include?("s390x")
|
|
186
|
+
end
|
|
187
|
+
|
|
178
188
|
def supports_cloexec?
|
|
179
189
|
Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC)
|
|
180
190
|
end
|
|
@@ -224,7 +234,17 @@ def aes_256_gcm?
|
|
|
224
234
|
end
|
|
225
235
|
|
|
226
236
|
def fips_mode_build?
|
|
227
|
-
|
|
237
|
+
return false if ENV.fetch("BUILDKITE_PIPELINE_SLUG", "") =~ /verify$/
|
|
238
|
+
|
|
239
|
+
if ENV.include?("BUILDKITE_LABEL") # try keying directly off Buildkite environments
|
|
240
|
+
# regex version of chef/chef-foundation:.expeditor/release.omnibus.yml:fips-platforms
|
|
241
|
+
[/el-.*-x86_64/, /el-.*-ppc64/, /el-.*aarch/, /ubuntu-/, /windows-/, /amazon-2/].any? do |os_arch|
|
|
242
|
+
ENV["BUILDKITE_LABEL"].match?(os_arch)
|
|
243
|
+
end
|
|
244
|
+
else
|
|
245
|
+
# if you're testing your local build
|
|
246
|
+
OpenSSL::OPENSSL_FIPS
|
|
247
|
+
end
|
|
228
248
|
end
|
|
229
249
|
|
|
230
250
|
def fips?
|
|
@@ -233,6 +253,7 @@ end
|
|
|
233
253
|
|
|
234
254
|
class HttpHelper
|
|
235
255
|
extend Ohai::Mixin::HttpHelper
|
|
256
|
+
|
|
236
257
|
def self.logger
|
|
237
258
|
Chef::Log
|
|
238
259
|
end
|
|
@@ -48,4 +48,4 @@ rescue LoadError
|
|
|
48
48
|
$stderr.puts "Failed to load ruby_installer. Assuming Ruby Installer is not being used."
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
add_libarchive_dll_directory if RUBY_PLATFORM.match?(/mswin|
|
|
51
|
+
add_libarchive_dll_directory if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
|
|
@@ -245,14 +245,14 @@ shared_examples_for "a file resource" do
|
|
|
245
245
|
|
|
246
246
|
include_context "deploying with move"
|
|
247
247
|
|
|
248
|
-
describe "when deploying via tmpdir" do
|
|
248
|
+
describe "when deploying via tmpdir", :not_supported_on_windows_11 do
|
|
249
249
|
|
|
250
250
|
include_context "deploying via tmpdir"
|
|
251
251
|
|
|
252
252
|
it_behaves_like "a configured file resource"
|
|
253
253
|
end
|
|
254
254
|
|
|
255
|
-
describe "when deploying via destdir" do
|
|
255
|
+
describe "when deploying via destdir", :not_supported_on_windows_11 do
|
|
256
256
|
|
|
257
257
|
include_context "deploying via destdir"
|
|
258
258
|
|
|
@@ -912,7 +912,7 @@ shared_examples_for "a configured file resource" do
|
|
|
912
912
|
dummy_desc
|
|
913
913
|
end
|
|
914
914
|
|
|
915
|
-
it_behaves_like "a securable resource without existing target"
|
|
915
|
+
it_behaves_like "a securable resource without existing target", :not_supported_on_windows_11
|
|
916
916
|
|
|
917
917
|
context "when the target file has the wrong content" do
|
|
918
918
|
before(:each) do
|
|
@@ -163,7 +163,7 @@ shared_context Chef::Resource::WindowsScript do
|
|
|
163
163
|
|
|
164
164
|
describe "when the run action is invoked on Windows" do
|
|
165
165
|
it "executes the script code" do
|
|
166
|
-
resource.code("
|
|
166
|
+
resource.code("chcp > \"#{script_output_path}\"")
|
|
167
167
|
resource.returns(0)
|
|
168
168
|
resource.run_action(:run)
|
|
169
169
|
end
|
|
@@ -199,7 +199,7 @@ shared_context Chef::Resource::WindowsScript do
|
|
|
199
199
|
end
|
|
200
200
|
|
|
201
201
|
it "executes the script code" do
|
|
202
|
-
resource.code("
|
|
202
|
+
resource.code("chcp > \"#{script_output_path}\"")
|
|
203
203
|
resource.returns(0)
|
|
204
204
|
resource.run_action(:run)
|
|
205
205
|
end
|
data/spec/tiny_server.rb
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
require "webrick"
|
|
20
20
|
require "webrick/https"
|
|
21
21
|
require "rack"
|
|
22
|
+
require "rackup"
|
|
22
23
|
require "singleton"
|
|
23
24
|
require "open-uri"
|
|
24
25
|
require "chef/config"
|
|
@@ -91,7 +92,7 @@ module TinyServer
|
|
|
91
92
|
|
|
92
93
|
def create_server(**extra_options)
|
|
93
94
|
server = WEBrick::HTTPServer.new(**options, **extra_options)
|
|
94
|
-
server.mount("/",
|
|
95
|
+
server.mount("/", Rackup::Handler::WEBrick, API.instance)
|
|
95
96
|
server
|
|
96
97
|
end
|
|
97
98
|
end
|
|
@@ -172,7 +173,9 @@ module TinyServer
|
|
|
172
173
|
|
|
173
174
|
def initialize(response_code = 200, data = nil, headers = nil, &block)
|
|
174
175
|
@response_code, @data = response_code, data
|
|
175
|
-
|
|
176
|
+
# .merge creates a new hash, headers is sometimes passed as nil, @response_headers gets mutated somewhere
|
|
177
|
+
# in processing
|
|
178
|
+
@response_headers = HEADERS.merge(headers || {})
|
|
176
179
|
@block = block_given? ? block : nil
|
|
177
180
|
end
|
|
178
181
|
|
|
@@ -564,16 +564,6 @@ describe Chef::Application::Client, "run_application", :unix_only do
|
|
|
564
564
|
expect(IO.select([@pipe[0]], nil, nil, 0)).not_to be_nil
|
|
565
565
|
expect(@pipe[0].gets).to eq("finished\n")
|
|
566
566
|
end
|
|
567
|
-
|
|
568
|
-
it "should exit hard when sent before converge" do
|
|
569
|
-
pid = fork do
|
|
570
|
-
sleep 3
|
|
571
|
-
@app.run_application
|
|
572
|
-
end
|
|
573
|
-
Process.kill("TERM", pid)
|
|
574
|
-
_pid, result = Process.waitpid2(pid)
|
|
575
|
-
expect(result.exitstatus).to eq(3)
|
|
576
|
-
end
|
|
577
567
|
end
|
|
578
568
|
end
|
|
579
569
|
|
data/spec/unit/client_spec.rb
CHANGED
|
@@ -23,6 +23,11 @@ require "chef/run_context"
|
|
|
23
23
|
require "chef/server_api"
|
|
24
24
|
require "rbconfig"
|
|
25
25
|
|
|
26
|
+
begin
|
|
27
|
+
require "chef-powershell"
|
|
28
|
+
rescue LoadError
|
|
29
|
+
end
|
|
30
|
+
|
|
26
31
|
class FooError < RuntimeError
|
|
27
32
|
end
|
|
28
33
|
|
|
@@ -113,8 +118,9 @@ shared_context "a client run" do
|
|
|
113
118
|
# --Client.register
|
|
114
119
|
# Make sure Client#register thinks the client key doesn't
|
|
115
120
|
# exist, so it tries to register and create one.
|
|
116
|
-
allow(
|
|
117
|
-
|
|
121
|
+
allow(Chef::HTTP::Authenticator).to receive(:detect_certificate_key).with(fqdn).and_return(false)
|
|
122
|
+
allow(File).to receive(:exist?).and_call_original
|
|
123
|
+
expect(File).to receive(:exist?)
|
|
118
124
|
.with(Chef::Config[:client_key])
|
|
119
125
|
.exactly(:once)
|
|
120
126
|
.and_return(api_client_exists?)
|
|
@@ -201,7 +207,6 @@ shared_context "a client run" do
|
|
|
201
207
|
|
|
202
208
|
# Post conditions: check that node has been filled in correctly
|
|
203
209
|
expect(client).to receive(:run_started)
|
|
204
|
-
|
|
205
210
|
stub_for_run
|
|
206
211
|
end
|
|
207
212
|
end
|
|
@@ -262,7 +267,7 @@ end
|
|
|
262
267
|
|
|
263
268
|
# requires platform and platform_version be defined
|
|
264
269
|
shared_examples "a completed run" do
|
|
265
|
-
include_context "run completed"
|
|
270
|
+
include_context "run completed" # should receive run_completed_successfully
|
|
266
271
|
|
|
267
272
|
it "runs ohai, sets up authentication, loads node state, synchronizes policy, converges" do
|
|
268
273
|
# This is what we're testing.
|
|
@@ -282,6 +287,77 @@ shared_examples "a failed run" do
|
|
|
282
287
|
end
|
|
283
288
|
end
|
|
284
289
|
|
|
290
|
+
describe Chef::Client, :windows_only do
|
|
291
|
+
let(:hostname) { "test" }
|
|
292
|
+
let(:my_client) { Chef::Client.new }
|
|
293
|
+
let(:cert_name) { "chef-#{hostname}" }
|
|
294
|
+
let(:node_name) { "#{hostname}" }
|
|
295
|
+
let(:end_date) do
|
|
296
|
+
d = Time.now
|
|
297
|
+
if d.month == 10 || d.month == 11 || d.month == 12
|
|
298
|
+
end_date = Time.new(d.year + 1, d.month - 9, d.day, d.hour, d.min, d.sec).utc.iso8601
|
|
299
|
+
else
|
|
300
|
+
end_date = Time.new(d.year, d.month + 3, d.day, d.hour, d.min, d.sec).utc.iso8601
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
# include_context "client"
|
|
304
|
+
before(:each) do
|
|
305
|
+
Chef::Config[:migrate_key_to_keystore] = true
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
after(:each) do
|
|
309
|
+
delete_certificate(cert_name)
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
context "when the client intially boots the first time" do
|
|
313
|
+
it "verfies that a certificate was correctly created and exists in the LocalMachine Cert Store" do
|
|
314
|
+
Chef::Config[:node_name] = "test"
|
|
315
|
+
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
|
316
|
+
my_client.import_pfx_to_store(new_pfx)
|
|
317
|
+
expect(my_client.check_certstore_for_key(cert_name)).not_to be false
|
|
318
|
+
delete_certificate(cert_name)
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
it "correctly returns a new Publc Key" do
|
|
322
|
+
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
|
323
|
+
cert_object = new_pfx.certificate.public_key.to_pem
|
|
324
|
+
expect(cert_object.to_s).to match(/PUBLIC KEY/)
|
|
325
|
+
delete_certificate(cert_name)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
context "when the client intially boots the first time and auth_key_registry_type is set to 'user' " do
|
|
331
|
+
it "verfies that a certificate was correctly created and exists in the CurrentUser Cert Store" do
|
|
332
|
+
Chef::Config[:node_name] = "test"
|
|
333
|
+
Chef::Config[:auth_key_registry_type] = "user"
|
|
334
|
+
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
|
335
|
+
my_client.import_pfx_to_store(new_pfx)
|
|
336
|
+
expect(my_client.check_certstore_for_key(cert_name)).not_to be false
|
|
337
|
+
delete_certificate(cert_name)
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
it "correctly returns a new Publc Key" do
|
|
341
|
+
Chef::Config[:auth_key_registry_type] = "user"
|
|
342
|
+
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
|
343
|
+
cert_object = new_pfx.certificate.public_key.to_pem
|
|
344
|
+
expect(cert_object.to_s).to match(/PUBLIC KEY/)
|
|
345
|
+
delete_certificate(cert_name)
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def delete_certificate(cert_name)
|
|
351
|
+
Chef::Config[:auth_key_registry_type] == "user" ? store = "CurrentUser" : store = "LocalMachine"
|
|
352
|
+
require "chef/mixin/powershell_exec"
|
|
353
|
+
extend Chef::Mixin::PowershellExec
|
|
354
|
+
powershell_code = <<~CODE
|
|
355
|
+
Get-ChildItem -path cert:\\#{store}\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{cert_name}" } | Remove-item
|
|
356
|
+
CODE
|
|
357
|
+
powershell_exec!(powershell_code)
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
|
|
285
361
|
describe Chef::Client do
|
|
286
362
|
include_context "client"
|
|
287
363
|
|
|
@@ -49,6 +49,14 @@ describe Chef::Compliance::Runner do
|
|
|
49
49
|
expect(runner).not_to be_enabled
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
it "is false if the node attributes have audit profiles and the audit cookbook is present, and the complince mode attribute is false" do
|
|
53
|
+
stub_const("::Reporter::ChefAutomate", true)
|
|
54
|
+
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
|
|
55
|
+
node.normal["audit"]["compliance_phase"] = false
|
|
56
|
+
|
|
57
|
+
expect(runner).not_to be_enabled
|
|
58
|
+
end
|
|
59
|
+
|
|
52
60
|
it "is true if the node attributes have audit profiles and the audit cookbook is present, and the complince mode attribute is true" do
|
|
53
61
|
stub_const("::Reporter::ChefAutomate", true)
|
|
54
62
|
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
|
|
@@ -159,12 +159,15 @@ describe Chef::Cookbook::SyntaxCheck do
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
describe "and a file has a syntax error" do
|
|
162
|
+
|
|
162
163
|
before do
|
|
163
164
|
cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "borken")
|
|
164
165
|
syntax_check.cookbook_path.replace(cookbook_path)
|
|
165
166
|
end
|
|
166
167
|
|
|
167
168
|
it "it indicates that a ruby file has a syntax error" do
|
|
169
|
+
expect(Chef::Log).to receive(:fatal).with("Cookbook file borken/recipes/default.rb has a ruby syntax error.")
|
|
170
|
+
allow(Chef::Log).to receive(:fatal)
|
|
168
171
|
expect(syntax_check.validate_ruby_files).to be_falsey
|
|
169
172
|
end
|
|
170
173
|
|
|
@@ -627,7 +627,7 @@ describe Chef::DataCollector do
|
|
|
627
627
|
events.resource_action_start(new_resource, :create)
|
|
628
628
|
events.resource_current_state_loaded(new_resource, :create, current_resource)
|
|
629
629
|
|
|
630
|
-
events.resource_action_start(implementation_resource
|
|
630
|
+
events.resource_action_start(implementation_resource, :create)
|
|
631
631
|
events.resource_current_state_loaded(implementation_resource, :create, implementation_resource)
|
|
632
632
|
events.resource_updated(implementation_resource, :create)
|
|
633
633
|
events.resource_after_state_loaded(implementation_resource, :create, implementation_resource)
|
|
@@ -876,7 +876,6 @@ describe Chef::DataCollector do
|
|
|
876
876
|
send_run_failed_or_completed_event
|
|
877
877
|
end
|
|
878
878
|
end
|
|
879
|
-
|
|
880
879
|
end
|
|
881
880
|
end
|
|
882
881
|
|
|
@@ -968,5 +967,110 @@ describe Chef::DataCollector do
|
|
|
968
967
|
data_collector.send(:send_to_data_collector, message)
|
|
969
968
|
end
|
|
970
969
|
end
|
|
970
|
+
|
|
971
|
+
context "when processing Windows registry keys" do
|
|
972
|
+
let(:total_resource_count) { 1 }
|
|
973
|
+
let(:updated_resource_count) { 1 }
|
|
974
|
+
let(:status) { "success" }
|
|
975
|
+
|
|
976
|
+
before do
|
|
977
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
|
978
|
+
run_status.stop_clock
|
|
979
|
+
end
|
|
980
|
+
|
|
981
|
+
it "removes registry key values not present in after state" do
|
|
982
|
+
resource = {
|
|
983
|
+
"type" => :registry_key,
|
|
984
|
+
"before" => {
|
|
985
|
+
values: [
|
|
986
|
+
{ name: "key1", value: "val1" },
|
|
987
|
+
{ name: "key2", value: "val2" },
|
|
988
|
+
{ name: "key3", value: "val3" },
|
|
989
|
+
],
|
|
990
|
+
},
|
|
991
|
+
"after" => {
|
|
992
|
+
values: [
|
|
993
|
+
{ name: "key1", value: "new_val1" },
|
|
994
|
+
{ name: "key3", value: "new_val3" },
|
|
995
|
+
],
|
|
996
|
+
},
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
message = {
|
|
1000
|
+
"resources" => [resource],
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
# Verify that key2 was removed from before values
|
|
1004
|
+
expected_before_values = [
|
|
1005
|
+
{ name: "key1", value: "val1" },
|
|
1006
|
+
{ name: "key3", value: "val3" },
|
|
1007
|
+
]
|
|
1008
|
+
|
|
1009
|
+
expect(http_client).to receive(:post).with(
|
|
1010
|
+
nil,
|
|
1011
|
+
hash_including("message_type" => "run_start"),
|
|
1012
|
+
{ "Content-Type" => "application/json" }
|
|
1013
|
+
)
|
|
1014
|
+
|
|
1015
|
+
expect(http_client).to receive(:post).with(
|
|
1016
|
+
nil,
|
|
1017
|
+
hash_including(
|
|
1018
|
+
"resources" => array_including(
|
|
1019
|
+
hash_including(
|
|
1020
|
+
"before" => hash_including(
|
|
1021
|
+
values: array_including(expected_before_values)
|
|
1022
|
+
)
|
|
1023
|
+
)
|
|
1024
|
+
)
|
|
1025
|
+
),
|
|
1026
|
+
{ "Content-Type" => "application/json" }
|
|
1027
|
+
)
|
|
1028
|
+
allow(Chef::DataCollector::RunEndMessage).to receive(:construct_message).and_return(message)
|
|
1029
|
+
data_collector.send(:send_run_completion, message)
|
|
1030
|
+
end
|
|
1031
|
+
|
|
1032
|
+
it "handles missing values gracefully" do
|
|
1033
|
+
resource = {
|
|
1034
|
+
"type" => :registry_key,
|
|
1035
|
+
"before" => {},
|
|
1036
|
+
"after" => { values: [] },
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
message = {
|
|
1040
|
+
"resources" => [resource],
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
expect(http_client).to receive(:post).with(
|
|
1044
|
+
nil,
|
|
1045
|
+
hash_including("message_type" => "run_start"),
|
|
1046
|
+
{ "Content-Type" => "application/json" }
|
|
1047
|
+
)
|
|
1048
|
+
|
|
1049
|
+
expect(http_client).to receive(:post).with(nil, message, { "Content-Type" => "application/json" })
|
|
1050
|
+
|
|
1051
|
+
allow(Chef::DataCollector::RunEndMessage).to receive(:construct_message).and_return(message)
|
|
1052
|
+
expect { data_collector.send(:send_run_completion, "success") }.not_to raise_error
|
|
1053
|
+
end
|
|
1054
|
+
|
|
1055
|
+
it "ignores non-registry resources" do
|
|
1056
|
+
resource = {
|
|
1057
|
+
"type" => :file,
|
|
1058
|
+
"before" => { content: "old" },
|
|
1059
|
+
"after" => { content: "new" },
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
message = {
|
|
1063
|
+
"resources" => [resource],
|
|
1064
|
+
}
|
|
1065
|
+
expect(http_client).to receive(:post).with(nil,
|
|
1066
|
+
hash_including("message_type" => "run_start"),
|
|
1067
|
+
{ "Content-Type" => "application/json" })
|
|
1068
|
+
|
|
1069
|
+
expect(http_client).to receive(:post).with(nil, message, { "Content-Type" => "application/json" })
|
|
1070
|
+
|
|
1071
|
+
allow(Chef::DataCollector::RunEndMessage).to receive(:construct_message).and_return(message)
|
|
1072
|
+
expect { data_collector.send(:send_run_completion, "success") }.not_to raise_error
|
|
1073
|
+
end
|
|
1074
|
+
end
|
|
971
1075
|
end
|
|
972
1076
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) Progress Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require "spec_helper"
|
|
19
|
+
|
|
20
|
+
describe Chef::DelayedEvaluator do
|
|
21
|
+
let(:magic) { "This is magic!" }
|
|
22
|
+
let(:de) { Chef::DelayedEvaluator.new { magic } }
|
|
23
|
+
|
|
24
|
+
describe "#inspect" do
|
|
25
|
+
it "inspects the result rather than the Proc" do
|
|
26
|
+
expect(de.inspect).to eq("lazy { (evaluates to) #{magic.inspect} }")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#call" do
|
|
31
|
+
it "evaluates correctly" do
|
|
32
|
+
expect(de.call).to eq(magic)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -94,7 +94,71 @@ describe Chef::FileCache do
|
|
|
94
94
|
it "searches for cached files by globbing" do
|
|
95
95
|
expect(Chef::FileCache.find("snappy/**/*")).to eq(%w{snappy/patter})
|
|
96
96
|
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe "#find handles regex-unsafe unix paths" do
|
|
100
|
+
before(:each) do
|
|
101
|
+
# Dir.mktmpdir doesn't allow regex unsafe characters (the nerve!), so we'll have to fake file lookups
|
|
102
|
+
@file_cache_path = "/tmp/[foo* ^bar]"
|
|
103
|
+
escaped_file_cache_path = '/tmp/\[foo\* ^bar\]'
|
|
104
|
+
Chef::Config[:file_cache_path] = @file_cache_path
|
|
105
|
+
allow(Chef::Util::PathHelper).to receive(:escape_glob_dir).and_return(escaped_file_cache_path)
|
|
106
|
+
allow(Dir).to receive(:[]).with(File.join(escaped_file_cache_path, "snappy/**/*")).and_return([
|
|
107
|
+
File.join(@file_cache_path, "snappy"),
|
|
108
|
+
File.join(@file_cache_path, "snappy", "patter"),
|
|
109
|
+
])
|
|
110
|
+
allow(Dir).to receive(:[]).with(escaped_file_cache_path).and_return([
|
|
111
|
+
@file_cache_path,
|
|
112
|
+
])
|
|
113
|
+
[
|
|
114
|
+
File.join(@file_cache_path, "snappy", "patter"),
|
|
115
|
+
File.join(@file_cache_path, "whiz", "bang"),
|
|
116
|
+
].each do |f|
|
|
117
|
+
allow(File).to receive(:file?).with(f).and_return(true)
|
|
118
|
+
end
|
|
119
|
+
[
|
|
120
|
+
File.join(@file_cache_path, "snappy"),
|
|
121
|
+
File.join(@file_cache_path, "whiz"),
|
|
122
|
+
].each do |f|
|
|
123
|
+
allow(File).to receive(:file?).with(f).and_return(false)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "searches for cached files by globbing" do
|
|
128
|
+
expect(Chef::FileCache.find("snappy/**/*")).to eq(%w{snappy/patter})
|
|
129
|
+
end
|
|
130
|
+
end
|
|
97
131
|
|
|
132
|
+
describe "#find handles Windows paths" do
|
|
133
|
+
before(:each) do
|
|
134
|
+
allow(ChefUtils).to receive(:windows?).and_return(true)
|
|
135
|
+
@file_cache_path = 'C:\tmp\fakecache'
|
|
136
|
+
escaped_file_cache_path = "C:\\tmp\\fakecache"
|
|
137
|
+
Chef::Config[:file_cache_path] = @file_cache_path
|
|
138
|
+
allow(Chef::Util::PathHelper).to receive(:escape_glob_dir).and_return(escaped_file_cache_path)
|
|
139
|
+
allow(Dir).to receive(:[]).with(File.join(escaped_file_cache_path, "snappy/**/*")).and_return([
|
|
140
|
+
File.join(@file_cache_path, "snappy"),
|
|
141
|
+
File.join(@file_cache_path, "snappy", "patter"),
|
|
142
|
+
])
|
|
143
|
+
allow(Dir).to receive(:[]).with(escaped_file_cache_path).and_return([
|
|
144
|
+
@file_cache_path,
|
|
145
|
+
])
|
|
146
|
+
[
|
|
147
|
+
File.join(@file_cache_path, "snappy", "patter"),
|
|
148
|
+
File.join(@file_cache_path, "whiz", "bang"),
|
|
149
|
+
].each do |f|
|
|
150
|
+
allow(File).to receive(:file?).with(f).and_return(true)
|
|
151
|
+
end
|
|
152
|
+
[
|
|
153
|
+
File.join(@file_cache_path, "snappy"),
|
|
154
|
+
File.join(@file_cache_path, "whiz"),
|
|
155
|
+
].each do |f|
|
|
156
|
+
allow(File).to receive(:file?).with(f).and_return(false)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
it "searches for cached files by globbing" do
|
|
160
|
+
expect(Chef::FileCache.find("snappy/**/*")).to eq(%w{snappy/patter})
|
|
161
|
+
end
|
|
98
162
|
end
|
|
99
163
|
|
|
100
164
|
describe "when checking for the existence of a file" do
|