chef 17.10.163 → 18.0.169
Sign up to get free protection for your applications and to get access to all the features.
- 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 +17 -15
- 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/checksum.rb +0 -6
- 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/cron.rb +1 -5
- data/lib/chef/provider/file.rb +2 -2
- 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/windows/msi.rb +2 -2
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/windows.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 +0 -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 +0 -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 +0 -1
- data/lib/chef/resource/gem_package.rb +0 -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 +1 -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 +0 -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 +0 -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 +0 -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 +0 -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 +0 -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 +0 -1
- data/lib/chef/resource/snap_package.rb +0 -1
- data/lib/chef/resource/solaris_package.rb +0 -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 +0 -1
- 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 +0 -1
- data/lib/chef/resource/yum_repository.rb +0 -1
- data/lib/chef/resource/zypper_package.rb +0 -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/checksum_spec.rb +0 -28
- 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 +0 -34
- 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 +106 -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
@@ -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
|
@@ -769,40 +769,6 @@ describe Chef::Provider::Cron do
|
|
769
769
|
end
|
770
770
|
end
|
771
771
|
|
772
|
-
context "when integers are provided to the resource to express time values" do
|
773
|
-
it "should not report any difference" do
|
774
|
-
@new_resource.minute(1)
|
775
|
-
@new_resource.hour(1)
|
776
|
-
@new_resource.day(1)
|
777
|
-
@new_resource.month(1)
|
778
|
-
@new_resource.weekday(1)
|
779
|
-
allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
|
780
|
-
# Chef Name: cronhole some stuff
|
781
|
-
1 1 1 1 1 /bin/true
|
782
|
-
CRONTAB
|
783
|
-
|
784
|
-
@provider.run_action(:create)
|
785
|
-
expect(@new_resource).not_to be_updated_by_last_action
|
786
|
-
end
|
787
|
-
end
|
788
|
-
|
789
|
-
context "when strings are provided to the resource to express time values" do
|
790
|
-
it "should not report any difference" do
|
791
|
-
@new_resource.minute("1")
|
792
|
-
@new_resource.hour("1")
|
793
|
-
@new_resource.day("1")
|
794
|
-
@new_resource.month("1")
|
795
|
-
@new_resource.weekday("1")
|
796
|
-
allow(@provider).to receive(:read_crontab).and_return(<<~CRONTAB)
|
797
|
-
# Chef Name: cronhole some stuff
|
798
|
-
1 1 1 1 1 /bin/true
|
799
|
-
CRONTAB
|
800
|
-
|
801
|
-
@provider.run_action(:create)
|
802
|
-
expect(@new_resource).not_to be_updated_by_last_action
|
803
|
-
end
|
804
|
-
end
|
805
|
-
|
806
772
|
context "when environment variable is used" do
|
807
773
|
before :each do
|
808
774
|
@provider.cron_exists = true
|
@@ -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
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
require "spec_helper"
|
22
22
|
|
23
|
-
describe Chef::Provider::User::Linux do
|
23
|
+
describe Chef::Provider::User::Linux, linux_only: true do
|
24
24
|
|
25
25
|
subject(:provider) do
|
26
26
|
p = described_class.new(@new_resource, @run_context)
|
@@ -71,6 +71,56 @@ describe Chef::Provider::User::Linux do
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
describe "expire_date behavior" do
|
75
|
+
before(:each) do
|
76
|
+
@new_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
|
77
|
+
@current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "defaults expire_date to nil" do
|
81
|
+
expect( @new_resource.expire_date ).to be nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "by default expire_date is nil and we use ''" do
|
85
|
+
expect( provider.universal_options ).to eql([])
|
86
|
+
end
|
87
|
+
|
88
|
+
it "setting expire_date to nil includes ''" do
|
89
|
+
@new_resource.expire_date nil
|
90
|
+
expect( provider.universal_options ).to eql([])
|
91
|
+
end
|
92
|
+
|
93
|
+
it "setting expire_date to 1982-04-16 includes -e" do
|
94
|
+
@new_resource.expire_date "1982-04-16"
|
95
|
+
expect( provider.universal_options ).to eql(["-e", "1982-04-16"])
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "inactive behavior" do
|
100
|
+
before(:each) do
|
101
|
+
@new_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
|
102
|
+
@current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "defaults inactive to nil" do
|
106
|
+
expect( @new_resource.inactive ).to be nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "by default inactive is nil and we use ''" do
|
110
|
+
expect( provider.universal_options ).to eql([])
|
111
|
+
end
|
112
|
+
|
113
|
+
it "setting inactive to nil includes ''" do
|
114
|
+
@new_resource.inactive nil
|
115
|
+
expect( provider.universal_options ).to eql([])
|
116
|
+
end
|
117
|
+
|
118
|
+
it "setting inactive to 90 includes -f" do
|
119
|
+
@new_resource.inactive 90
|
120
|
+
expect( provider.universal_options ).to eql(["-f", 90])
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
74
124
|
describe "compare_user_linux" do
|
75
125
|
before(:each) do
|
76
126
|
@new_resource = Chef::Resource::User::LinuxUser.new("notarealuser")
|
@@ -86,7 +136,6 @@ describe Chef::Provider::User::Linux do
|
|
86
136
|
"home" => ["/home/notarealuser", "/Users/notarealuser"],
|
87
137
|
"shell" => ["/usr/bin/zsh", "/bin/bash"],
|
88
138
|
"password" => %w{abcd 12345},
|
89
|
-
"sensitive" => [true],
|
90
139
|
}
|
91
140
|
end
|
92
141
|
|
@@ -98,15 +147,6 @@ describe Chef::Provider::User::Linux do
|
|
98
147
|
end
|
99
148
|
end
|
100
149
|
|
101
|
-
it "should show a blank for password if sensitive set to true" do
|
102
|
-
@new_resource.password mapping["password"][0]
|
103
|
-
@current_resource.password mapping["password"][1]
|
104
|
-
@new_resource.sensitive true
|
105
|
-
@current_resource.sensitive true
|
106
|
-
provider.compare_user
|
107
|
-
expect(provider.change_desc).to eql(["change password from ******** to ********"])
|
108
|
-
end
|
109
|
-
|
110
150
|
%w{uid gid}.each do |property|
|
111
151
|
it "should return false if string #{property} matches fixnum" do
|
112
152
|
@new_resource.send(property, "100")
|
@@ -178,12 +178,30 @@ describe Chef::Provider::User do
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
181
|
+
context "when ruby-shadow is supported on the platform" do
|
182
|
+
before do
|
183
|
+
allow(@provider).to receive(:supports_ruby_shadow?).and_return true
|
184
|
+
end
|
185
|
+
it "should fail assertions when ruby-shadow cannot be loaded" do
|
186
|
+
expect(@provider).to receive(:require).with("shadow") { raise LoadError }
|
187
|
+
@provider.load_current_resource
|
188
|
+
@provider.action = :create
|
189
|
+
@provider.define_resource_requirements
|
190
|
+
expect { @provider.process_resource_requirements }.to raise_error Chef::Exceptions::MissingLibrary
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context "when ruby-shadow is not supported on the platform" do
|
195
|
+
before do
|
196
|
+
allow(@provider).to receive(:supports_ruby_shadow?).and_return false
|
197
|
+
end
|
198
|
+
it "should not fail any assertions when ruby-shadow cannot be loaded" do
|
199
|
+
expect(@provider).to receive(:require).with("shadow") { raise LoadError }
|
200
|
+
@provider.load_current_resource
|
201
|
+
@provider.action = :create
|
202
|
+
@provider.define_resource_requirements
|
203
|
+
@provider.process_resource_requirements
|
204
|
+
end
|
187
205
|
end
|
188
206
|
|
189
207
|
end
|
@@ -29,7 +29,7 @@ rescue LoadError
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe Chef::Resource::ArchiveFile, :not_supported_on_aix do
|
32
|
+
describe Chef::Resource::ArchiveFile, :not_supported_on_aix, :not_supported_on_windows do
|
33
33
|
let(:node) { Chef::Node.new }
|
34
34
|
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
35
35
|
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientCron do
|
|
43
43
|
expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
|
44
44
|
end
|
45
45
|
|
46
|
+
it "set splay to 0" do
|
47
|
+
resource.splay "0"
|
48
|
+
expect(resource.splay).to eql(0)
|
49
|
+
end
|
50
|
+
|
46
51
|
it "builds a default value for chef_binary_path dist values" do
|
47
52
|
expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client")
|
48
53
|
end
|
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientLaunchd do
|
|
43
43
|
expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
|
44
44
|
end
|
45
45
|
|
46
|
+
it "set splay to 0" do
|
47
|
+
resource.splay "0"
|
48
|
+
expect(resource.splay).to eql(0)
|
49
|
+
end
|
50
|
+
|
46
51
|
it "builds a default value for chef_binary_path dist values" do
|
47
52
|
expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client")
|
48
53
|
end
|
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientScheduledTask do
|
|
43
43
|
expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
|
44
44
|
end
|
45
45
|
|
46
|
+
it "set splay to 0" do
|
47
|
+
resource.splay "0"
|
48
|
+
expect(resource.splay).to eql(0)
|
49
|
+
end
|
50
|
+
|
46
51
|
it "coerces frequency_modifier to an Integer" do
|
47
52
|
resource.frequency_modifier "10"
|
48
53
|
expect(resource.frequency_modifier).to eql(10)
|
@@ -102,7 +102,7 @@ describe Chef::Resource::ChefClientSystemdTimer do
|
|
102
102
|
|
103
103
|
it "sets CPUQuota if cpu_quota property is set" do
|
104
104
|
resource.cpu_quota 50
|
105
|
-
expect(provider.service_content["Service"]["CPUQuota"]).to eq(
|
105
|
+
expect(provider.service_content["Service"]["CPUQuota"]).to eq(50)
|
106
106
|
end
|
107
107
|
end
|
108
|
-
end
|
108
|
+
end
|