chef 17.10.163 → 18.0.185
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 +19 -20
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +8 -7
- data/chef.gemspec +16 -14
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/client.rb +182 -0
- 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/waiver.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- 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/exceptions.rb +8 -0
- data/lib/chef/http/authenticator.rb +170 -3
- data/lib/chef/http/ssl_policies.rb +4 -4
- data/lib/chef/mixin/homebrew_user.rb +5 -15
- data/lib/chef/mixin/openssl_helper.rb +13 -17
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/property.rb +5 -3
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/mount/linux.rb +5 -0
- data/lib/chef/provider/mount/mount.rb +8 -0
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +1 -14
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/snap.rb +1 -1
- 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 +14 -2
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -8
- data/lib/chef/provider/service/windows.rb +1 -1
- 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.rb +46 -14
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +1 -1
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +2 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +0 -1
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +0 -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 +14 -18
- 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 +1 -2
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +0 -1
- 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_package.rb +0 -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 +0 -1
- data/lib/chef/resource/execute.rb +0 -1
- 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 +0 -1
- 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 +8 -8
- data/lib/chef/resource/homebrew_package.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +5 -6
- data/lib/chef/resource/homebrew_update.rb +0 -2
- 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 +0 -1
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +2 -6
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_userdefaults.rb +5 -10
- 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 +0 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +0 -1
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +0 -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 +0 -3
- 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_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/service.rb +0 -1
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +2 -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 +0 -1
- data/lib/chef/resource/support/client.erb +5 -6
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +1 -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 +0 -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_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 +0 -1
- 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 +0 -1
- 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 +0 -1
- data/lib/chef/resource/zypper_package.rb +2 -1
- data/lib/chef/resource/zypper_repository.rb +0 -1
- data/lib/chef/resource.rb +12 -5
- data/lib/chef/resources.rb +7 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +7 -3
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/example.crt +20 -29
- data/spec/data/trusted_certs/example_no_cn.crt +34 -30
- data/spec/data/trusted_certs/opscode.pem +54 -33
- data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
- data/spec/functional/resource/dsc_script_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/macos_userdefaults_spec.rb +4 -4
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -26
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +1 -17
- data/spec/functional/resource/zypper_package_spec.rb +12 -10
- 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 +82 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/ipv6_spec.rb +1 -1
- 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 +1 -5
- data/spec/support/platform_helpers.rb +0 -4
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/unit/application/client_spec.rb +0 -10
- data/spec/unit/client_spec.rb +70 -2
- data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/http/authenticator_spec.rb +68 -0
- data/spec/unit/mixin/homebrew_user_spec.rb +7 -30
- data/spec/unit/mixin/openssl_helper_spec.rb +1 -1
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/provider/cron_spec.rb +2 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/mount/linux_spec.rb +10 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +3 -20
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -11
- data/spec/unit/provider/user_spec.rb +24 -6
- 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 +2 -2
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
- 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_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/sysctl_spec.rb +2 -2
- data/spec/unit/resource/user/linux_user_spec.rb +42 -0
- data/spec/unit/resource_spec.rb +8 -2
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/tasks/rspec.rb +1 -1
- metadata +100 -55
- data/spec/functional/assets/yumrepo-empty/repodata/01a3b-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/401dc-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/5dc1e-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/6bf96-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/7c365-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/dabe2-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +0 -55
- data/spec/integration/client/fips_spec.rb +0 -29
- data/spec/integration/client/open_ssl_spec.rb +0 -20
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
- /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
|
@@ -19,6 +19,70 @@
|
|
|
19
19
|
require "spec_helper"
|
|
20
20
|
require "chef/http/authenticator"
|
|
21
21
|
|
|
22
|
+
describe Chef::HTTP::Authenticator, :windows_only do
|
|
23
|
+
let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
|
|
24
|
+
let(:method) { "GET" }
|
|
25
|
+
let(:url) { URI("https://chef.example.com/organizations/test") }
|
|
26
|
+
let(:headers) { {} }
|
|
27
|
+
let(:data) { "" }
|
|
28
|
+
let(:node_name) { "test" }
|
|
29
|
+
let(:passwrd) { "some_insecure_password" }
|
|
30
|
+
|
|
31
|
+
before do
|
|
32
|
+
Chef::Config[:node_name] = node_name
|
|
33
|
+
cert_name = "chef-#{node_name}"
|
|
34
|
+
d = Time.now
|
|
35
|
+
end_date = Time.new + (3600 * 24 * 90)
|
|
36
|
+
end_date = end_date.utc.iso8601
|
|
37
|
+
|
|
38
|
+
my_client = Chef::Client.new
|
|
39
|
+
pfx = my_client.generate_pfx_package(cert_name, end_date)
|
|
40
|
+
my_client.import_pfx_to_store(pfx)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
after(:each) do
|
|
44
|
+
require "chef/mixin/powershell_exec"
|
|
45
|
+
extend Chef::Mixin::PowershellExec
|
|
46
|
+
cert_name = "chef-#{node_name}"
|
|
47
|
+
delete_certificate(cert_name)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context "when retrieving a certificate from the certificate store" do
|
|
51
|
+
it "retrieves a certificate password from the registry when the hive does not already exist" do
|
|
52
|
+
delete_registry_hive
|
|
53
|
+
expect { class_instance.get_cert_password }.not_to raise_error
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "should return a password of at least 14 characters in length" do
|
|
57
|
+
password = class_instance.get_cert_password
|
|
58
|
+
expect(password.length).to eql(14)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "correctly retrieves a valid certificate in pem format from the certstore" do
|
|
62
|
+
require "openssl"
|
|
63
|
+
certificate = class_instance.retrieve_certificate_key(node_name)
|
|
64
|
+
cert_object = OpenSSL::PKey::RSA.new(certificate)
|
|
65
|
+
expect(cert_object.to_s).to match(/BEGIN RSA PRIVATE KEY/)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def delete_certificate(cert_name)
|
|
70
|
+
powershell_code = <<~CODE
|
|
71
|
+
Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{cert_name}" } | Remove-item
|
|
72
|
+
CODE
|
|
73
|
+
powershell_exec!(powershell_code)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def delete_registry_hive
|
|
77
|
+
@win32registry = Chef::Win32::Registry.new
|
|
78
|
+
path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
|
|
79
|
+
present = @win32registry.get_values(path)
|
|
80
|
+
unless present.nil? || present.empty?
|
|
81
|
+
@win32registry.delete_key(path, true)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
22
86
|
describe Chef::HTTP::Authenticator do
|
|
23
87
|
let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
|
|
24
88
|
let(:method) { "GET" }
|
|
@@ -26,6 +90,10 @@ describe Chef::HTTP::Authenticator do
|
|
|
26
90
|
let(:headers) { {} }
|
|
27
91
|
let(:data) { "" }
|
|
28
92
|
|
|
93
|
+
before do
|
|
94
|
+
::Chef::Config[:node_name] = "foo"
|
|
95
|
+
end
|
|
96
|
+
|
|
29
97
|
context "when handle_request is called" do
|
|
30
98
|
shared_examples_for "merging the server API version into the headers" do
|
|
31
99
|
before do
|
|
@@ -47,8 +47,6 @@ describe Chef::Mixin::HomebrewUser do
|
|
|
47
47
|
let(:user) { nil }
|
|
48
48
|
let(:brew_owner) { 2001 }
|
|
49
49
|
let(:default_brew_path) { "/usr/local/bin/brew" }
|
|
50
|
-
let(:default_brew_path_arm) { "/opt/homebrew/bin/brew" }
|
|
51
|
-
let(:default_brew_path_linux) { "/home/linuxbrew/.linuxbrew/bin/brew" }
|
|
52
50
|
let(:stat_double) do
|
|
53
51
|
d = double
|
|
54
52
|
expect(d).to receive(:uid).and_return(brew_owner)
|
|
@@ -61,38 +59,16 @@ describe Chef::Mixin::HomebrewUser do
|
|
|
61
59
|
expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(name: "name"))
|
|
62
60
|
end
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "returns the owner of the brew executable when it is at a default location for x86_64 machines" do
|
|
70
|
-
false_unless_specific_value(File, :exist?, default_brew_path)
|
|
71
|
-
false_unless_specific_value(File, :executable?, default_brew_path)
|
|
72
|
-
allow(File).to receive(:stat).with(default_brew_path).and_return(stat_double)
|
|
73
|
-
expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it "returns the owner of the brew executable when it is at a default location for arm machines" do
|
|
77
|
-
false_unless_specific_value(File, :exist?, default_brew_path_arm)
|
|
78
|
-
false_unless_specific_value(File, :executable?, default_brew_path_arm)
|
|
79
|
-
allow(File).to receive(:stat).with(default_brew_path_arm).and_return(stat_double)
|
|
80
|
-
expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "returns the owner of the brew executable when it is at a default location for linux machines" do
|
|
84
|
-
false_unless_specific_value(File, :exist?, default_brew_path_linux)
|
|
85
|
-
false_unless_specific_value(File, :executable?, default_brew_path_linux)
|
|
86
|
-
allow(File).to receive(:stat).with(default_brew_path_linux).and_return(stat_double)
|
|
62
|
+
it "returns the owner of the brew executable when it is at a default location" do
|
|
63
|
+
expect(File).to receive(:exist?).with(default_brew_path).and_return(true)
|
|
64
|
+
expect(File).to receive(:stat).with(default_brew_path).and_return(stat_double)
|
|
87
65
|
expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
|
|
88
66
|
end
|
|
89
67
|
|
|
90
68
|
it "returns the owner of the brew executable when it is not at a default location" do
|
|
91
|
-
|
|
92
|
-
false_unless_specific_value(File, :exist?, "/foo")
|
|
93
|
-
false_unless_specific_value(File, :executable?, "/foo")
|
|
69
|
+
expect(File).to receive(:exist?).with(default_brew_path).and_return(false)
|
|
94
70
|
allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("/foo")
|
|
95
|
-
|
|
71
|
+
expect(File).to receive(:stat).with("/foo").and_return(stat_double)
|
|
96
72
|
expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner)
|
|
97
73
|
end
|
|
98
74
|
|
|
@@ -102,7 +78,8 @@ describe Chef::Mixin::HomebrewUser do
|
|
|
102
78
|
describe "when the homebrew user is not provided" do
|
|
103
79
|
|
|
104
80
|
it "raises an error if no executable is found" do
|
|
105
|
-
expect(File).to receive(:exist?).
|
|
81
|
+
expect(File).to receive(:exist?).with(default_brew_path).and_return(false)
|
|
82
|
+
allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("")
|
|
106
83
|
expect { homebrew_user.find_homebrew_uid(user) }.to raise_error(Chef::Exceptions::CannotDetermineHomebrewOwner)
|
|
107
84
|
end
|
|
108
85
|
|
|
@@ -92,7 +92,7 @@ describe Chef::Mixin::OpenSSLHelper do
|
|
|
92
92
|
|
|
93
93
|
context "When the dhparam.pem file does exist, and does contain a vaild dhparam key" do
|
|
94
94
|
it "returns true" do
|
|
95
|
-
@dhparam_file.puts(::OpenSSL::PKey::DH.new(
|
|
95
|
+
@dhparam_file.puts(::OpenSSL::PKey::DH.new(256).to_pem) # this is 256 to speed up specs
|
|
96
96
|
@dhparam_file.close
|
|
97
97
|
expect(instance.dhparam_pem_valid?(@dhparam_file.path)).to be_truthy
|
|
98
98
|
end
|
|
@@ -26,7 +26,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
|
|
|
26
26
|
describe "#powershell_exec" do
|
|
27
27
|
context "not specifying an interpreter" do
|
|
28
28
|
it "runs a basic command and returns a Chef::PowerShell object" do
|
|
29
|
-
expect(object.powershell_exec("$PSVersionTable")).to be_kind_of(
|
|
29
|
+
expect(object.powershell_exec("$PSVersionTable")).to be_kind_of(ChefPowerShell::PowerShell)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "uses less than version 6" do
|
|
@@ -37,7 +37,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
|
|
|
37
37
|
|
|
38
38
|
context "using pwsh interpreter" do
|
|
39
39
|
it "runs a basic command and returns a Chef::PowerShell object" do
|
|
40
|
-
expect(object.powershell_exec("$PSVersionTable", :pwsh)).to be_kind_of(
|
|
40
|
+
expect(object.powershell_exec("$PSVersionTable", :pwsh)).to be_kind_of(ChefPowerShell::Pwsh)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "uses greater than version 6" do
|
|
@@ -48,7 +48,7 @@ describe Chef::Mixin::PowershellExec, :windows_only do
|
|
|
48
48
|
|
|
49
49
|
context "using powershell interpreter" do
|
|
50
50
|
it "runs a basic command and returns a Chef::PowerShell object" do
|
|
51
|
-
expect(object.powershell_exec("$PSVersionTable", :powershell)).to be_kind_of(
|
|
51
|
+
expect(object.powershell_exec("$PSVersionTable", :powershell)).to be_kind_of(ChefPowerShell::PowerShell)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "uses less than version 6" do
|
|
@@ -76,11 +76,11 @@ describe Chef::Mixin::PowershellExec, :windows_only do
|
|
|
76
76
|
|
|
77
77
|
describe "#powershell_exec!" do
|
|
78
78
|
it "runs a basic command and returns a Chef::PowerShell object" do
|
|
79
|
-
expect(object.powershell_exec!("$PSVersionTable")).to be_kind_of(
|
|
79
|
+
expect(object.powershell_exec!("$PSVersionTable")).to be_kind_of(ChefPowerShell::PowerShell)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it "raises an error if the command fails" do
|
|
83
|
-
expect { object.powershell_exec!("this-should-error") }.to raise_error(
|
|
83
|
+
expect { object.powershell_exec!("this-should-error") }.to raise_error(ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
it "raises an error if the interpreter is invalid" do
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
require "spec_helper"
|
|
20
20
|
|
|
21
|
-
describe "Chef::Platform#supports_dsc_invoke_resource?" do
|
|
21
|
+
describe "Chef::Platform#supports_dsc_invoke_resource?", :windows_only do
|
|
22
22
|
it "returns false if powershell is not present" do
|
|
23
23
|
node = Chef::Node.new
|
|
24
24
|
expect(Chef::Platform.supports_dsc_invoke_resource?(node)).to be_falsey
|
|
@@ -39,25 +39,10 @@ describe "Chef::Platform#supports_dsc_invoke_resource?" do
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
describe "Chef::Platform#dsc_refresh_mode_disabled?" do
|
|
42
|
+
describe "Chef::Platform#dsc_refresh_mode_disabled?", :windows_only do
|
|
43
43
|
let(:node) { instance_double("Chef::Node") }
|
|
44
|
-
let(:powershell) { instance_double("Chef::PowerShell") }
|
|
45
44
|
|
|
46
45
|
it "returns true when RefreshMode is Disabled" do
|
|
47
|
-
expect(Chef::PowerShell).to receive(:new)
|
|
48
|
-
.with("Get-DscLocalConfigurationManager")
|
|
49
|
-
.and_return(powershell)
|
|
50
|
-
expect(powershell).to receive(:error!)
|
|
51
|
-
expect(powershell).to receive(:result).and_return({ "RefreshMode" => "Disabled" })
|
|
52
|
-
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be true
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "returns false when RefreshMode is not Disabled" do
|
|
56
|
-
expect(Chef::PowerShell).to receive(:new)
|
|
57
|
-
.with("Get-DscLocalConfigurationManager")
|
|
58
|
-
.and_return(powershell)
|
|
59
|
-
expect(powershell).to receive(:error!)
|
|
60
|
-
expect(powershell).to receive(:result).and_return({ "RefreshMode" => "LaLaLa" })
|
|
61
46
|
expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be false
|
|
62
47
|
end
|
|
63
48
|
end
|
|
@@ -779,6 +779,7 @@ describe Chef::Provider::Cron do
|
|
|
779
779
|
allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
|
|
780
780
|
# Chef Name: cronhole some stuff
|
|
781
781
|
1 1 1 1 1 /bin/true
|
|
782
|
+
|
|
782
783
|
CRONTAB
|
|
783
784
|
|
|
784
785
|
@provider.run_action(:create)
|
|
@@ -796,6 +797,7 @@ describe Chef::Provider::Cron do
|
|
|
796
797
|
allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
|
|
797
798
|
# Chef Name: cronhole some stuff
|
|
798
799
|
1 1 1 1 1 /bin/true
|
|
800
|
+
|
|
799
801
|
CRONTAB
|
|
800
802
|
|
|
801
803
|
@provider.run_action(:create)
|
|
@@ -19,87 +19,75 @@
|
|
|
19
19
|
require "spec_helper"
|
|
20
20
|
|
|
21
21
|
describe Chef::Provider::HttpRequest do
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@new_resource.message "is cool"
|
|
31
|
-
|
|
32
|
-
@provider = Chef::Provider::HttpRequest.new(@new_resource, @run_context)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe "load_current_resource" do
|
|
36
|
-
|
|
37
|
-
it "should set up a Chef::ServerAPI client, with no authentication" do
|
|
38
|
-
expect(Chef::HTTP::Simple).to receive(:new).with(@new_resource.url)
|
|
39
|
-
@provider.load_current_resource
|
|
22
|
+
let(:node) { Chef::Node.new }
|
|
23
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
24
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
25
|
+
let(:new_resource) do
|
|
26
|
+
Chef::Resource::HttpRequest.new("adam").tap do |new_resource|
|
|
27
|
+
new_resource.name "adam"
|
|
28
|
+
new_resource.url "http://www.opscode.com/"
|
|
29
|
+
new_resource.message "is cool"
|
|
40
30
|
end
|
|
41
31
|
end
|
|
42
32
|
|
|
33
|
+
let(:provider) { Chef::Provider::HttpRequest.new(new_resource, run_context) }
|
|
34
|
+
|
|
43
35
|
describe "when making REST calls" do
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# that would overwrite our supplied mock Chef::Rest # object
|
|
47
|
-
allow(@provider).to receive(:load_current_resource).and_return(true)
|
|
48
|
-
@http = double("Chef::ServerAPI")
|
|
49
|
-
@provider.http = @http
|
|
36
|
+
let(:http) do
|
|
37
|
+
provider.http = double("Chef::ServerAPI")
|
|
50
38
|
end
|
|
51
39
|
|
|
52
40
|
describe "action_get" do
|
|
53
41
|
|
|
54
42
|
it "should inflate a message block at runtime" do
|
|
55
|
-
|
|
56
|
-
expect(
|
|
57
|
-
|
|
58
|
-
expect(
|
|
43
|
+
new_resource.message { "return" }
|
|
44
|
+
expect(http).to receive(:get).with("http://www.opscode.com/", {})
|
|
45
|
+
provider.run_action(:get)
|
|
46
|
+
expect(new_resource).to be_updated
|
|
59
47
|
end
|
|
60
48
|
|
|
61
49
|
it "should run a GET request" do
|
|
62
|
-
expect(
|
|
63
|
-
|
|
64
|
-
expect(
|
|
50
|
+
expect(http).to receive(:get).with("http://www.opscode.com/", {})
|
|
51
|
+
provider.run_action(:get)
|
|
52
|
+
expect(new_resource).to be_updated
|
|
65
53
|
end
|
|
66
54
|
end
|
|
67
55
|
|
|
68
56
|
describe "action_put" do
|
|
69
57
|
it "should run a PUT request with the message as the payload" do
|
|
70
|
-
expect(
|
|
71
|
-
|
|
72
|
-
expect(
|
|
58
|
+
expect(http).to receive(:put).with("http://www.opscode.com/", new_resource.message, {})
|
|
59
|
+
provider.run_action(:put)
|
|
60
|
+
expect(new_resource).to be_updated
|
|
73
61
|
end
|
|
74
62
|
|
|
75
63
|
it "should inflate a message block at runtime" do
|
|
76
|
-
|
|
77
|
-
expect(
|
|
78
|
-
|
|
79
|
-
expect(
|
|
64
|
+
new_resource.message(lambda { "return" })
|
|
65
|
+
expect(http).to receive(:put).with("http://www.opscode.com/", "return", {})
|
|
66
|
+
provider.run_action(:put)
|
|
67
|
+
expect(new_resource).to be_updated
|
|
80
68
|
end
|
|
81
69
|
end
|
|
82
70
|
|
|
83
71
|
describe "action_post" do
|
|
84
72
|
it "should run a PUT request with the message as the payload" do
|
|
85
|
-
expect(
|
|
86
|
-
|
|
87
|
-
expect(
|
|
73
|
+
expect(http).to receive(:post).with("http://www.opscode.com/", new_resource.message, {})
|
|
74
|
+
provider.run_action(:post)
|
|
75
|
+
expect(new_resource).to be_updated
|
|
88
76
|
end
|
|
89
77
|
|
|
90
78
|
it "should inflate a message block at runtime" do
|
|
91
|
-
|
|
92
|
-
expect(
|
|
93
|
-
|
|
94
|
-
expect(
|
|
79
|
+
new_resource.message { "return" }
|
|
80
|
+
expect(http).to receive(:post).with("http://www.opscode.com/", "return", {})
|
|
81
|
+
provider.run_action(:post)
|
|
82
|
+
expect(new_resource).to be_updated
|
|
95
83
|
end
|
|
96
84
|
end
|
|
97
85
|
|
|
98
86
|
describe "action_delete" do
|
|
99
87
|
it "should run a DELETE request" do
|
|
100
|
-
expect(
|
|
101
|
-
|
|
102
|
-
expect(
|
|
88
|
+
expect(http).to receive(:delete).with("http://www.opscode.com/", {})
|
|
89
|
+
provider.run_action(:delete)
|
|
90
|
+
expect(new_resource).to be_updated
|
|
103
91
|
end
|
|
104
92
|
end
|
|
105
93
|
|
|
@@ -107,52 +95,52 @@ describe Chef::Provider::HttpRequest do
|
|
|
107
95
|
# and false for a "304 Not Modified" response
|
|
108
96
|
describe "action_head" do
|
|
109
97
|
before do
|
|
110
|
-
|
|
98
|
+
provider.http = http
|
|
111
99
|
end
|
|
112
100
|
|
|
113
101
|
it "should inflate a message block at runtime" do
|
|
114
|
-
|
|
115
|
-
expect(
|
|
116
|
-
|
|
117
|
-
expect(
|
|
102
|
+
new_resource.message { "return" }
|
|
103
|
+
expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
|
|
104
|
+
provider.run_action(:head)
|
|
105
|
+
expect(new_resource).to be_updated
|
|
118
106
|
end
|
|
119
107
|
|
|
120
108
|
it "should run a HEAD request" do
|
|
121
|
-
expect(
|
|
122
|
-
|
|
123
|
-
expect(
|
|
109
|
+
expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
|
|
110
|
+
provider.run_action(:head)
|
|
111
|
+
expect(new_resource).to be_updated
|
|
124
112
|
end
|
|
125
113
|
|
|
126
114
|
it "should update a HEAD request with empty string response body (CHEF-4762)" do
|
|
127
|
-
expect(
|
|
128
|
-
|
|
129
|
-
expect(
|
|
115
|
+
expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return("")
|
|
116
|
+
provider.run_action(:head)
|
|
117
|
+
expect(new_resource).to be_updated
|
|
130
118
|
end
|
|
131
119
|
|
|
132
120
|
it "should update a HEAD request with nil response body (CHEF-4762)" do
|
|
133
|
-
expect(
|
|
134
|
-
|
|
135
|
-
expect(
|
|
121
|
+
expect(http).to receive(:head).with("http://www.opscode.com/", {}).and_return(nil)
|
|
122
|
+
provider.run_action(:head)
|
|
123
|
+
expect(new_resource).to be_updated
|
|
136
124
|
end
|
|
137
125
|
|
|
138
126
|
it "should not update a HEAD request if a not modified response (CHEF-4762)" do
|
|
139
127
|
if_modified_since = File.mtime(__FILE__).httpdate
|
|
140
|
-
|
|
141
|
-
expect(
|
|
142
|
-
|
|
143
|
-
expect(
|
|
128
|
+
new_resource.headers "If-Modified-Since" => if_modified_since
|
|
129
|
+
expect(http).to receive(:head).with("http://www.opscode.com/", { "If-Modified-Since" => if_modified_since }).and_return(false)
|
|
130
|
+
provider.run_action(:head)
|
|
131
|
+
expect(new_resource).not_to be_updated
|
|
144
132
|
end
|
|
145
133
|
|
|
146
134
|
it "should run a HEAD request with If-Modified-Since header" do
|
|
147
|
-
|
|
148
|
-
expect(
|
|
149
|
-
|
|
135
|
+
new_resource.headers "If-Modified-Since" => File.mtime(__FILE__).httpdate
|
|
136
|
+
expect(http).to receive(:head).with("http://www.opscode.com/", new_resource.headers)
|
|
137
|
+
provider.run_action(:head)
|
|
150
138
|
end
|
|
151
139
|
|
|
152
140
|
it "doesn't call converge_by if HEAD does not return modified" do
|
|
153
|
-
expect(
|
|
154
|
-
expect(
|
|
155
|
-
|
|
141
|
+
expect(http).to receive(:head).and_return(false)
|
|
142
|
+
expect(provider).not_to receive(:converge_by)
|
|
143
|
+
provider.run_action(:head)
|
|
156
144
|
end
|
|
157
145
|
end
|
|
158
146
|
end
|
|
@@ -25,6 +25,7 @@ describe Chef::Provider::Mount::Linux do
|
|
|
25
25
|
allow(::File).to receive(:exists?).with("/dev/sdz1").and_return true
|
|
26
26
|
allow(::File).to receive(:exists?).with("/tmp/foo").and_return true
|
|
27
27
|
allow(::File).to receive(:exists?).with("//192.168.11.102/Share/backup").and_return true
|
|
28
|
+
allow(::File).to receive(:exists?).with("//192.168.11.102/Share/backup folder").and_return true
|
|
28
29
|
allow(::File).to receive(:realpath).with("/dev/sdz1").and_return "/dev/sdz1"
|
|
29
30
|
allow(::File).to receive(:realpath).with("/tmp/foo").and_return "/tmp/foo"
|
|
30
31
|
end
|
|
@@ -103,6 +104,15 @@ describe Chef::Provider::Mount::Linux do
|
|
|
103
104
|
provider.load_current_resource
|
|
104
105
|
expect(provider.current_resource.mounted).to be_truthy
|
|
105
106
|
end
|
|
107
|
+
|
|
108
|
+
it "should set mounted true if device name has a space and the mount point is found in the mounts list" do
|
|
109
|
+
new_resource.device "//192.168.11.102/Share/backup folder"
|
|
110
|
+
new_resource.fstype "cifs"
|
|
111
|
+
mount = "/tmp/foo //192.168.11.102/Share/backup\x20folder cifs rw\n"
|
|
112
|
+
allow(provider).to receive(:shell_out!).and_return(double(stdout: mount))
|
|
113
|
+
provider.load_current_resource
|
|
114
|
+
expect(provider.current_resource.mounted).to be_truthy
|
|
115
|
+
end
|
|
106
116
|
end
|
|
107
117
|
|
|
108
118
|
context "to check if loop resource is mounted" do
|
|
@@ -47,11 +47,6 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
|
|
|
47
47
|
allow(provider).to receive(:choco_exe).and_return(choco_exe)
|
|
48
48
|
local_list_obj = double(stdout: local_list_stdout)
|
|
49
49
|
allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-l", "-r", { returns: [0, 2], timeout: timeout }).and_return(local_list_obj)
|
|
50
|
-
allow(provider).to receive(:powershell_exec!).with("#{choco_exe} --version").and_return(double(result: "2.1.0"))
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
after(:each) do
|
|
54
|
-
provider.instance_variable_set(:@get_choco_version, nil)
|
|
55
50
|
end
|
|
56
51
|
|
|
57
52
|
def allow_remote_list(package_names, args = nil)
|
|
@@ -66,9 +61,9 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
|
|
|
66
61
|
remote_list_obj = double(stdout: remote_list_stdout)
|
|
67
62
|
package_names.each do |pkg|
|
|
68
63
|
if args
|
|
69
|
-
allow(provider).to receive(:shell_out_compacted!).with(choco_exe,
|
|
64
|
+
allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, *args, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
|
|
70
65
|
else
|
|
71
|
-
allow(provider).to receive(:shell_out_compacted!).with(choco_exe,
|
|
66
|
+
allow(provider).to receive(:shell_out_compacted!).with(choco_exe, "list", "-r", pkg, { returns: [0, 2], timeout: timeout }).and_return(remote_list_obj)
|
|
72
67
|
end
|
|
73
68
|
end
|
|
74
69
|
end
|
|
@@ -83,18 +78,6 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
|
|
|
83
78
|
end
|
|
84
79
|
end
|
|
85
80
|
|
|
86
|
-
describe "choco searches change with the version" do
|
|
87
|
-
it "Choco V1 uses List" do
|
|
88
|
-
allow(provider).to receive(:powershell_exec!).with("#{choco_exe} --version").and_return(double(result: "1.4.0"))
|
|
89
|
-
expect(provider.query_command).to eql("list")
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "Choco V2 uses Search" do
|
|
93
|
-
allow(provider).to receive(:powershell_exec!).with("#{choco_exe} --version").and_return(double(result: "2.1.0"))
|
|
94
|
-
expect(provider.query_command).to eql("search")
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
81
|
describe "#candidate_version" do
|
|
99
82
|
it "should set the candidate_version to the latest version when not pinning" do
|
|
100
83
|
allow_remote_list(["git"])
|
|
@@ -167,7 +150,7 @@ describe Chef::Provider::Package::Chocolatey, :windows_only do
|
|
|
167
150
|
new_resource.package_name("package-does-not-exist")
|
|
168
151
|
new_resource.returns([0])
|
|
169
152
|
allow(provider).to receive(:shell_out_compacted!)
|
|
170
|
-
.with(choco_exe,
|
|
153
|
+
.with(choco_exe, "list", "-r", new_resource.package_name.first, { returns: new_resource.returns, timeout: timeout })
|
|
171
154
|
.and_raise(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
|
|
172
155
|
expect { provider.send(:available_packages) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with [0], but received '2'")
|
|
173
156
|
end
|
|
@@ -139,7 +139,7 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
|
|
|
139
139
|
.to_return(status: 200, body: "", headers: {})
|
|
140
140
|
stub_request(:get, "https://rubygems2.org/info/sexp_processor")
|
|
141
141
|
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-info")))
|
|
142
|
-
stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.
|
|
142
|
+
stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.16.1.gemspec.rz")
|
|
143
143
|
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
|
|
144
144
|
|
|
145
145
|
dep = Gem::Dependency.new("sexp_processor", ">= 0")
|
|
@@ -32,6 +32,8 @@ describe Chef::Provider::Package::Zypper do
|
|
|
32
32
|
|
|
33
33
|
let(:status) { double(stdout: "\n", exitstatus: 0) }
|
|
34
34
|
|
|
35
|
+
let(:source) { "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm" }
|
|
36
|
+
|
|
35
37
|
before(:each) do
|
|
36
38
|
allow(Chef::Resource::Package).to receive(:new).and_return(current_resource)
|
|
37
39
|
allow(provider).to receive(:shell_out_compacted!).and_return(status)
|
|
@@ -163,6 +165,21 @@ describe Chef::Provider::Package::Zypper do
|
|
|
163
165
|
)
|
|
164
166
|
provider.install_package(["emacs"], ["1.0"])
|
|
165
167
|
end
|
|
168
|
+
|
|
169
|
+
it "should run zypper install with source option" do
|
|
170
|
+
new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
|
|
171
|
+
allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.rpm").and_return(true)
|
|
172
|
+
shell_out_expectation!(
|
|
173
|
+
"zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
|
|
174
|
+
)
|
|
175
|
+
provider.install_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
it "should raise an exception if a source is supplied but not found when :install" do
|
|
179
|
+
new_resource.source "/tmp/blah/wget_1.11.4-1ubuntu1_amd64.rpm"
|
|
180
|
+
allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
|
|
181
|
+
expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
|
|
182
|
+
end
|
|
166
183
|
end
|
|
167
184
|
|
|
168
185
|
describe "upgrade_package" do
|
|
@@ -200,6 +217,21 @@ describe Chef::Provider::Package::Zypper do
|
|
|
200
217
|
)
|
|
201
218
|
provider.upgrade_package(["emacs"], ["1.0"])
|
|
202
219
|
end
|
|
220
|
+
|
|
221
|
+
it "should run zypper upgrade with source option" do
|
|
222
|
+
new_resource.source "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
|
|
223
|
+
allow(::File).to receive(:exist?).with("/tmp/wget_1.11.4-1ubuntu1_amd64.rpm").and_return(true)
|
|
224
|
+
shell_out_expectation!(
|
|
225
|
+
"zypper", "--non-interactive", "install", "--auto-agree-with-licenses", "--oldpackage", "/tmp/wget_1.11.4-1ubuntu1_amd64.rpm"
|
|
226
|
+
)
|
|
227
|
+
provider.upgrade_package(["wget"], ["1.11.4-1ubuntu1_amd64"])
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "should raise an exception if a source is supplied but not found when :upgrade" do
|
|
231
|
+
new_resource.source "/tmp/blah/wget_1.11.4-1ubuntu1_amd64.rpm"
|
|
232
|
+
allow(::File).to receive(:exist?).with(new_resource.source).and_return(false)
|
|
233
|
+
expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package)
|
|
234
|
+
end
|
|
203
235
|
end
|
|
204
236
|
|
|
205
237
|
describe "remove_package" do
|