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
@@ -25,50 +25,39 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
25
25
|
|
26
26
|
def group_should_exist(group)
|
27
27
|
case ohai[:os]
|
28
|
-
when "
|
29
|
-
expect(shell_out("pw groupshow -n #{group}").exitstatus).to eq(0)
|
30
|
-
when "windows"
|
31
|
-
expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.not_to raise_error
|
32
|
-
else
|
28
|
+
when "linux"
|
33
29
|
expect { Etc.getgrnam(group) }.not_to raise_error
|
34
30
|
expect(group).to eq(Etc.getgrnam(group).name)
|
31
|
+
when "windows"
|
32
|
+
expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.not_to raise_error
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
36
|
def user_exist_in_group?(user)
|
39
37
|
case ohai[:platform_family]
|
40
|
-
when "
|
41
|
-
|
42
|
-
|
43
|
-
true
|
44
|
-
else
|
45
|
-
false
|
46
|
-
end
|
38
|
+
when "windows"
|
39
|
+
user_sid = sid_string_from_user(user)
|
40
|
+
user_sid.nil? ? false : Chef::Util::Windows::NetGroup.new(group_name).local_get_members.include?(user_sid)
|
47
41
|
when "mac_os_x"
|
48
42
|
membership_info = shell_out("dscl . -read /Groups/#{group_name}").stdout
|
49
43
|
members = membership_info.split(" ")
|
50
44
|
members.shift # Get rid of GroupMembership: string
|
51
45
|
members.include?(user)
|
52
|
-
when "windows"
|
53
|
-
user_sid = sid_string_from_user(user)
|
54
|
-
user_sid.nil? ? false : Chef::Util::Windows::NetGroup.new(group_name).local_get_members.include?(user_sid)
|
55
46
|
else
|
56
|
-
#
|
57
|
-
# Adding a
|
58
|
-
#
|
59
|
-
sleep
|
47
|
+
# NOTE: For some reason our temporary AIX 7.x systems do not correctly report group membership immediately after changes have been made.
|
48
|
+
# Adding a delay for this platform is enough to get correct results.
|
49
|
+
# reference: https://github.com/chef/release-engineering/issues/1617
|
50
|
+
sleep 3 if aix?
|
60
51
|
Etc.getgrnam(group_name).mem.include?(user)
|
61
52
|
end
|
62
53
|
end
|
63
54
|
|
64
55
|
def group_should_not_exist(group)
|
65
56
|
case ohai[:os]
|
66
|
-
when "
|
67
|
-
expect(
|
57
|
+
when "linux"
|
58
|
+
expect { Etc.getgrnam(group) }.to raise_error(ArgumentError, "can't find group for #{group}")
|
68
59
|
when "windows"
|
69
60
|
expect { Chef::Util::Windows::NetGroup.new(group).local_get_members }.to raise_error(ArgumentError, /The group name could not be found./)
|
70
|
-
else
|
71
|
-
expect { Etc.getgrnam(group) }.to raise_error(ArgumentError, "can't find group for #{group}")
|
72
61
|
end
|
73
62
|
end
|
74
63
|
|
@@ -144,6 +133,10 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
144
133
|
temp_resource.append(true)
|
145
134
|
temp_resource.run_action(:modify)
|
146
135
|
members.each do |member|
|
136
|
+
# NOTE For some reason our temporary AIX 7.x systems do not correctly report group membership immediately after changes have been made.
|
137
|
+
# Adding a delay for this platform is enough to get correct results.
|
138
|
+
# reference: https://github.com/chef/release-engineering/issues/1617
|
139
|
+
sleep 3 if aix?
|
147
140
|
expect(user_exist_in_group?(member)).to eq(true)
|
148
141
|
end
|
149
142
|
end
|
@@ -169,7 +162,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
169
162
|
end
|
170
163
|
|
171
164
|
# dscl doesn't perform any error checking and will let you add users that don't exist.
|
172
|
-
describe "when no users exist", :not_supported_on_macos
|
165
|
+
describe "when no users exist", :not_supported_on_macos do
|
173
166
|
describe "when append is not set" do
|
174
167
|
# excluded_members can only be used when append is set. It is ignored otherwise.
|
175
168
|
let(:excluded_members) { [] }
|
@@ -210,14 +203,13 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
210
203
|
end
|
211
204
|
end
|
212
205
|
|
213
|
-
describe "when append is not set"
|
206
|
+
describe "when append is not set" do
|
214
207
|
it "should set the group to to contain given members" do
|
215
208
|
group_resource.run_action(tested_action)
|
216
209
|
|
217
210
|
included_members.each do |member|
|
218
211
|
expect(user_exist_in_group?(member)).to eq(true)
|
219
212
|
end
|
220
|
-
|
221
213
|
(spec_members - included_members).each do |member|
|
222
214
|
expect(user_exist_in_group?(member)).to eq(false)
|
223
215
|
end
|
@@ -235,16 +227,14 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
235
227
|
included_members.each do |member|
|
236
228
|
expect(user_exist_in_group?(member)).to eq(true)
|
237
229
|
end
|
238
|
-
|
239
|
-
(
|
240
|
-
expect(user_exist_in_group?(member)).to eq(false)
|
241
|
-
end
|
230
|
+
(spec_members - included_members).each do |member|
|
231
|
+
expect(user_exist_in_group?(member)).to eq(false)
|
242
232
|
end
|
243
233
|
end
|
244
234
|
end
|
245
235
|
end
|
246
236
|
|
247
|
-
describe "when append is set"
|
237
|
+
describe "when append is set" do
|
248
238
|
before(:each) do
|
249
239
|
group_resource.append(true)
|
250
240
|
end
|
@@ -255,7 +245,6 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
255
245
|
included_members.each do |member|
|
256
246
|
expect(user_exist_in_group?(member)).to eq(true)
|
257
247
|
end
|
258
|
-
|
259
248
|
excluded_members.each do |member|
|
260
249
|
expect(user_exist_in_group?(member)).to eq(false)
|
261
250
|
end
|
@@ -272,7 +261,6 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
272
261
|
included_members.each do |member|
|
273
262
|
expect(user_exist_in_group?(member)).to eq(true)
|
274
263
|
end
|
275
|
-
|
276
264
|
excluded_members.each do |member|
|
277
265
|
expect(user_exist_in_group?(member)).to eq(false)
|
278
266
|
end
|
@@ -352,7 +340,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
352
340
|
expect(group_resource.append).to eq(false)
|
353
341
|
end
|
354
342
|
|
355
|
-
describe "group create action"
|
343
|
+
describe "group create action" do
|
356
344
|
after(:each) do
|
357
345
|
group_resource.run_action(:remove)
|
358
346
|
group_should_not_exist(group_name)
|
@@ -409,7 +397,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
409
397
|
end
|
410
398
|
|
411
399
|
describe "group remove action" do
|
412
|
-
describe "when there is a group"
|
400
|
+
describe "when there is a group" do
|
413
401
|
before do
|
414
402
|
group_resource.run_action(:create)
|
415
403
|
group_should_exist(group_name)
|
@@ -441,7 +429,7 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
441
429
|
end
|
442
430
|
end
|
443
431
|
|
444
|
-
describe "when there is a group", :
|
432
|
+
describe "when there is a group", :not_supported_on_freebsd_gte_12_3 do
|
445
433
|
it_behaves_like "correct group management"
|
446
434
|
end
|
447
435
|
|
@@ -474,16 +462,12 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
|
|
474
462
|
end
|
475
463
|
|
476
464
|
it "does not raise an error on manage" do
|
477
|
-
|
478
|
-
allow(shell_out).to receive("pw user show").and_return(double("User"))
|
479
|
-
else
|
480
|
-
allow(Etc).to receive(:getpwnam).and_return(double("User"))
|
481
|
-
end
|
465
|
+
allow(Etc).to receive(:getpwnam).and_return(double("User"))
|
482
466
|
expect { group_resource.run_action(:manage) }.not_to raise_error
|
483
467
|
end
|
484
468
|
end
|
485
469
|
|
486
|
-
describe "when there is a group", :
|
470
|
+
describe "when there is a group", :not_supported_on_freebsd_gte_12_3 do
|
487
471
|
it_behaves_like "correct group management"
|
488
472
|
end
|
489
473
|
|
@@ -345,17 +345,17 @@ describe Chef::Resource::Link do
|
|
345
345
|
let(:test_user) { "test-link-user" }
|
346
346
|
before do
|
347
347
|
user(test_user).run_action(:create)
|
348
|
-
#
|
349
|
-
# Adding a
|
350
|
-
#
|
351
|
-
sleep
|
348
|
+
# NOTE: For some reason our temporary AIX 7.x systems do not correctly report user existence immediately after changes have been made.
|
349
|
+
# Adding a delay for this platform is enough to get correct results.
|
350
|
+
# reference: https://github.com/chef/release-engineering/issues/1617
|
351
|
+
sleep 3 if aix?
|
352
352
|
end
|
353
353
|
after do
|
354
354
|
user(test_user).run_action(:remove)
|
355
|
-
# TODO For some reason our temporary AIX 7.
|
356
|
-
# Adding a
|
357
|
-
#
|
358
|
-
sleep
|
355
|
+
# TODO For some reason our temporary AIX 7.x systems do not correctly report user existence immediately after changes have been made.
|
356
|
+
# Adding a delay for this platform is enough to get correct results.
|
357
|
+
# reference: https://github.com/chef/release-engineering/issues/1617
|
358
|
+
sleep 3 if aix?
|
359
359
|
end
|
360
360
|
before(:each) do
|
361
361
|
resource.owner(test_user)
|
@@ -38,12 +38,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
|
|
38
38
|
expect(resource.domain).to eq("NSGlobalDomain")
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
42
|
-
expect(resource.host).to
|
41
|
+
it "nil for the host property" do
|
42
|
+
expect(resource.host).to be_nil
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
expect(resource.user).to
|
45
|
+
it "nil for the user property" do
|
46
|
+
expect(resource.user).to be_nil
|
47
47
|
end
|
48
48
|
|
49
49
|
it ":write for resource action" do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "plist"
|
3
|
+
|
4
|
+
describe Chef::Resource::PlistResource, :macos_only, requires_root: true do
|
5
|
+
include RecipeDSLHelper
|
6
|
+
|
7
|
+
let(:global_prefs) do
|
8
|
+
File.join(Dir.mktmpdir, ".GlobalPreferences.plist")
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
FileUtils.rm_f global_prefs
|
13
|
+
end
|
14
|
+
|
15
|
+
context "make Monday the first DOW" do
|
16
|
+
it "creates a new plist with a hash value" do
|
17
|
+
plist global_prefs do
|
18
|
+
entry "AppleFirstWeekday"
|
19
|
+
value(gregorian: 4)
|
20
|
+
end
|
21
|
+
expect(File.exist?(global_prefs))
|
22
|
+
expect(shell_out!("/usr/libexec/PlistBuddy -c 'Print :\"AppleFirstWeekday\":gregorian' \"#{global_prefs}\"").stdout.to_i).to eq(4)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) Chef 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
|
+
require "chef/mixin/shell_out"
|
20
|
+
|
21
|
+
metadata = {
|
22
|
+
requires_root: true,
|
23
|
+
linux_only: true,
|
24
|
+
}
|
25
|
+
|
26
|
+
describe "Chef::Resource::User with Chef::Provider::User::LinuxUser provider", metadata do
|
27
|
+
include Chef::Mixin::ShellOut
|
28
|
+
|
29
|
+
def clean_user
|
30
|
+
shell_out!("/usr/sbin/userdel #{username}")
|
31
|
+
rescue Mixlib::ShellOut::ShellCommandFailed
|
32
|
+
# Raised when the user is already cleaned
|
33
|
+
end
|
34
|
+
|
35
|
+
def ensure_file_cache_path_exists
|
36
|
+
path = Chef::Config["file_cache_path"]
|
37
|
+
FileUtils.mkdir_p(path) unless File.directory?(path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def user_should_exist
|
41
|
+
expect(shell_out("grep -q #{username} /etc/passwd").error?).to be(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_password(pass, user)
|
45
|
+
expect(shell_out("grep ^#{user}: /etc/shadow | cut -d: -f2 | grep ^#{pass}$").exitstatus).to eq(0)
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:node) do
|
49
|
+
n = Chef::Node.new
|
50
|
+
n.consume_external_attrs(OHAI_SYSTEM.data.dup, {})
|
51
|
+
n
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:events) do
|
55
|
+
Chef::EventDispatch::Dispatcher.new
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:run_context) do
|
59
|
+
Chef::RunContext.new(node, {}, events)
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:username) do
|
63
|
+
"greatchef"
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:uid) { nil }
|
67
|
+
let(:gid) do
|
68
|
+
# SLES 15 doesn't have the "20" group and
|
69
|
+
# so lets just pick the last group... no,
|
70
|
+
# Etc.group.map(&:gid).last does not work
|
71
|
+
Etc.enum_for(:group).map(&:gid).last
|
72
|
+
end
|
73
|
+
let(:home) { nil }
|
74
|
+
let(:manage_home) { false }
|
75
|
+
let(:password) { "XXXYYYZZZ" }
|
76
|
+
let(:comment) { "Great Chef" }
|
77
|
+
let(:shell) { "/bin/bash" }
|
78
|
+
let(:salt) { nil }
|
79
|
+
|
80
|
+
let(:user_resource) do
|
81
|
+
r = Chef::Resource::User::LinuxUser.new("TEST USER RESOURCE", run_context)
|
82
|
+
r.username(username)
|
83
|
+
r.uid(uid)
|
84
|
+
r.gid(gid)
|
85
|
+
|
86
|
+
r.home(home)
|
87
|
+
r.shell(shell)
|
88
|
+
r.comment(comment)
|
89
|
+
r.manage_home(manage_home)
|
90
|
+
r.password(password)
|
91
|
+
r.salt(salt)
|
92
|
+
r
|
93
|
+
end
|
94
|
+
|
95
|
+
before do
|
96
|
+
clean_user
|
97
|
+
ensure_file_cache_path_exists
|
98
|
+
end
|
99
|
+
|
100
|
+
after(:each) do
|
101
|
+
clean_user
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "action :create" do
|
105
|
+
it "should create the user" do
|
106
|
+
user_resource.run_action(:create)
|
107
|
+
user_should_exist
|
108
|
+
check_password(password, username)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "when user exists" do
|
113
|
+
before do
|
114
|
+
existing_resource = user_resource.dup
|
115
|
+
existing_resource.run_action(:create)
|
116
|
+
user_should_exist
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "when password is updated" do
|
120
|
+
it "should update the password of the user" do
|
121
|
+
user_resource.password("mykitchen")
|
122
|
+
user_resource.run_action(:create)
|
123
|
+
check_password("mykitchen", username)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -56,34 +56,10 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
|
|
56
56
|
let(:store) { "Chef-Functional-Test" }
|
57
57
|
let(:store_name) { "MY" }
|
58
58
|
let(:store_location) { "LocalMachine" }
|
59
|
-
let(:
|
60
|
-
<<~CERT
|
61
|
-
-----BEGIN CERTIFICATE-----
|
62
|
-
MIIDQTCCAimgAwIBAgIQX3zqNCJbsKlEvzCz3Z9aNDANBgkqhkiG9w0BAQsFADAh
|
63
|
-
MR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVzdHMuY29tMCAXDTIwMDMwNTEwMjcw
|
64
|
-
NVoYDzIxMjAwMzA1MTAzNzA2WjAhMR8wHQYDVQQDDBZ3d3cuZHVtbXljaGVmdGVz
|
65
|
-
dHMuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtuYKDb6woWIH
|
66
|
-
HPPOrcVpgJFVxbkjgk+tsYwbIiqR9jtRaKE6nM/awOgn9/dFF4k8KB8Em0sUx7Vq
|
67
|
-
J3YhK2N2cAacgP2Frqqf5znpNBBOg968RoZzGx0EiXFvLsqC4y8ggApWTbMXPRk4
|
68
|
-
1a7GlpUpSqI3y5cLeEbzwGQKu8I1I+v7P2fTlnJPHarM7sBbL8bieukkFHYu78iV
|
69
|
-
u1wpKOCCfs5DTmJu8WN+z1Mar9vyrWMBlt2wBBgNHPz5mcXUzJHTzaI/D9RGgBgF
|
70
|
-
V0IkNqISx/IzR62jjj2g6MgTH4G/0mM6O5sxduM4yGmWZNZpVzh0yMLgH619MZlj
|
71
|
-
SMQIN3U/SQIDAQABo3MwcTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB
|
72
|
-
BQUHAwIGCCsGAQUFBwMBMCEGA1UdEQQaMBiCFnd3dy5kdW1teWNoZWZ0ZXN0cy5j
|
73
|
-
b20wHQYDVR0OBBYEFHwS3gs03m6RcpR+66u4OqGiZdYnMA0GCSqGSIb3DQEBCwUA
|
74
|
-
A4IBAQCFHqMjHUfBZahIsKHQIcFCbC1NFh1ZHlJKZzrRBRwRzX19OttHGMyLpDd6
|
75
|
-
tM9Ac6LLR8S4QIWg+HF3IrkN+vfTRDZAccj+tIwBRstmdsEz/rAJ79Vb/00mXZQx
|
76
|
-
0FPiBDR3hE7On2oo24DU8kJP3v6TrunwtIomVGqrrkwZzvxqyW+WJMB2shGNFw5J
|
77
|
-
mKYBiiXsHl4Bi7V4zhXssrLp877sqpNLeXloXBmAlT39SwQTP9ImZaV5R6udqlvo
|
78
|
-
Gfgm5PH/WeK6MV3n5ik0v1rS0LwR2o82WlIB6a4iSEbzY3qSLsWOwt8o5QjAVzCR
|
79
|
-
tNdbdS3U8nrG73iA2clmF57ARQWC
|
80
|
-
-----END CERTIFICATE-----
|
81
|
-
CERT
|
82
|
-
end
|
59
|
+
let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
|
83
60
|
let(:cert_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.cer") }
|
84
61
|
let(:pfx_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.pfx") }
|
85
62
|
let(:key_output_path) { ::File.join(Chef::Config[:file_cache_path], "output.key") }
|
86
|
-
let(:download_cert_url) { "https://testingchef.blob.core.windows.net/files/test.cer" }
|
87
63
|
let(:cer_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.cer") }
|
88
64
|
let(:base64_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "base64_test.cer") }
|
89
65
|
let(:pem_path) { File.join(CHEF_SPEC_DATA, "windows_certificates", "test.pem") }
|
@@ -152,7 +128,6 @@ tNdbdS3U8nrG73iA2clmF57ARQWC
|
|
152
128
|
end
|
153
129
|
|
154
130
|
it "can add a certificate from a valid url" do
|
155
|
-
stub_request(:get, download_cert_url).to_return(body: test_cert_body)
|
156
131
|
resource.source = download_cert_url
|
157
132
|
resource.run_action(:create)
|
158
133
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
|
-
describe Chef::Resource::WindowsFont, :windows_only
|
21
|
+
describe Chef::Resource::WindowsFont, :windows_only do
|
22
22
|
let(:resource_name) { "Playmaker.ttf" }
|
23
23
|
let(:resource_source) { "https://www.wfonts.com/download/data/2020/05/06/playmaker/Playmaker.ttf" }
|
24
24
|
|
@@ -37,13 +37,16 @@ describe Chef::Resource::WindowsFont, :windows_only, :broken do # these tests ha
|
|
37
37
|
resource
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
expect(subject).to be_updated_by_last_action
|
43
|
-
end
|
40
|
+
## these were commented out because testing hangs in the verify pipeline with them enabled. WEIRD
|
41
|
+
## that needs to be addressed
|
44
42
|
|
45
|
-
it "
|
46
|
-
|
47
|
-
|
48
|
-
end
|
43
|
+
# it "installs font on first install" do
|
44
|
+
# subject.run_action(:install)
|
45
|
+
# expect(subject).to be_updated_by_last_action
|
46
|
+
# end
|
47
|
+
|
48
|
+
# it "does not install font when already installed" do
|
49
|
+
# subject.run_action(:install)
|
50
|
+
# expect(subject).not_to be_updated_by_last_action
|
51
|
+
# end
|
49
52
|
end
|
@@ -20,7 +20,7 @@ require "chef/mixin/shell_out"
|
|
20
20
|
|
21
21
|
# run this test only for following platforms.
|
22
22
|
exclude_test = !(%w{rhel fedora amazon}.include?(OHAI_SYSTEM[:platform_family]) && !File.exist?("/usr/bin/dnf"))
|
23
|
-
describe Chef::Resource::YumPackage, :requires_root, external: exclude_test
|
23
|
+
describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
|
24
24
|
include RecipeDSLHelper
|
25
25
|
include Chef::Mixin::ShellOut
|
26
26
|
|
@@ -57,12 +57,6 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not
|
|
57
57
|
baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
|
58
58
|
enable=1
|
59
59
|
gpgcheck=0
|
60
|
-
[chef-yum-empty]
|
61
|
-
name=Chef DNF spec empty repo
|
62
|
-
baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo-empty
|
63
|
-
enable=1
|
64
|
-
gpgcheck=0
|
65
|
-
|
66
60
|
EOF
|
67
61
|
end
|
68
62
|
# ensure we don't have any stray chef_rpms installed
|
@@ -1101,16 +1095,6 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test, not
|
|
1101
1095
|
end.should_not_be_updated
|
1102
1096
|
end
|
1103
1097
|
|
1104
|
-
it "should work to disable a repo" do
|
1105
|
-
flush_cache
|
1106
|
-
expect {
|
1107
|
-
yum_package "chef_rpm" do
|
1108
|
-
options "--disablerepo=chef-yum-localtesting --enablerepo=chef-yum-empty"
|
1109
|
-
action :install
|
1110
|
-
end
|
1111
|
-
}.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
|
1112
|
-
end
|
1113
|
-
|
1114
1098
|
it "when an idempotent install action is run, does not leave repos disabled" do
|
1115
1099
|
flush_cache
|
1116
1100
|
# this is a bit tricky -- we need this action to be idempotent, so that it doesn't recycle any
|
@@ -74,6 +74,18 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
|
|
74
74
|
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
75
75
|
end
|
76
76
|
|
77
|
+
it "install package with source argument" do
|
78
|
+
zypper_package.source = "#{CHEF_SPEC_ASSETS}/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
|
79
|
+
zypper_package.run_action(:install)
|
80
|
+
expect(zypper_package.updated_by_last_action?).to be true
|
81
|
+
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^chef_rpm-1.10-1.#{pkg_arch}$")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "raises an error when passed a source that does not exist" do
|
85
|
+
zypper_package.source = "#{CHEF_SPEC_ASSETS}/false/zypprepo/chef_rpm-1.10-1.#{pkg_arch}.rpm"
|
86
|
+
expect { zypper_package.run_action(:install) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
|
87
|
+
end
|
88
|
+
|
77
89
|
it "does not install if the package is installed" do
|
78
90
|
preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
|
79
91
|
zypper_package.run_action(:install)
|
@@ -177,15 +189,6 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
|
|
177
189
|
expect(zypper_package.updated_by_last_action?).to be true
|
178
190
|
expect(shell_out("rpm -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n' chef_rpm").stdout.chomp).to match("^package chef_rpm is not installed$")
|
179
191
|
end
|
180
|
-
|
181
|
-
context "Package doesn't exist" do
|
182
|
-
let(:package_name) { "nonexistent_repo" }
|
183
|
-
it "does nothing if the package is not installed" do
|
184
|
-
zypper_package.run_action(:remove)
|
185
|
-
expect(zypper_package.updated_by_last_action?).to be false
|
186
|
-
end
|
187
|
-
|
188
|
-
end
|
189
192
|
end
|
190
193
|
|
191
194
|
context "with no available version" do
|
@@ -256,7 +259,6 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do
|
|
256
259
|
expect(shell_out("zypper locks | grep chef_rpm_provides").stdout.chomp).not_to match("chef_rpm_provides")
|
257
260
|
end
|
258
261
|
end
|
259
|
-
|
260
262
|
def remove_package
|
261
263
|
pkg_to_remove = Chef::Resource::ZypperPackage.new(package_name, run_context)
|
262
264
|
pkg_to_remove.run_action(:remove)
|
@@ -78,7 +78,6 @@ describe Shell do
|
|
78
78
|
def run_chef_shell_with(options)
|
79
79
|
# Windows ruby installs don't (always?) have PTY,
|
80
80
|
# so hide the require here
|
81
|
-
|
82
81
|
require "pty"
|
83
82
|
|
84
83
|
# FIXME this is temporary... Solaris envs have TERM set to unknown
|
@@ -87,7 +86,7 @@ describe Shell do
|
|
87
86
|
ENV["TERM"] = "vt100" if ["", "unknown"].include?(ENV["TERM"].to_s)
|
88
87
|
|
89
88
|
config = File.expand_path("shef-config.rb", CHEF_SPEC_DATA)
|
90
|
-
reader, writer, pid = PTY.spawn("bundle exec
|
89
|
+
reader, writer, pid = PTY.spawn("bundle exec #{ChefUtils::Dist::Infra::SHELL} --no-multiline --no-singleline --no-colorize -c #{config} #{options}")
|
91
90
|
read_until(reader, "chef (#{Chef::VERSION})>")
|
92
91
|
yield reader, writer if block_given?
|
93
92
|
writer.puts('"done"')
|
@@ -25,7 +25,7 @@ describe "Chef Versions", :executables do
|
|
25
25
|
include Chef::Mixin::ShellOut
|
26
26
|
let(:chef_dir) { File.join(__dir__, "..", "..") }
|
27
27
|
|
28
|
-
binaries = [ ChefUtils::Dist::Infra::CLIENT,
|
28
|
+
binaries = [ ChefUtils::Dist::Infra::CLIENT, ChefUtils::Dist::Infra::SHELL, "chef-apply", ChefUtils::Dist::Solo::EXEC ]
|
29
29
|
|
30
30
|
binaries.each do |binary|
|
31
31
|
it "#{binary} version should be sane" do
|
@@ -395,9 +395,6 @@ describe "Chef::Win32::Registry", :windows_only do
|
|
395
395
|
expect { @registry.get_subkeys("JKLM\\Software\\Root") }.to raise_error(Chef::Exceptions::Win32RegHiveMissing)
|
396
396
|
end
|
397
397
|
it "returns the array of subkeys for a given key" do
|
398
|
-
::Win32::Registry.define_method :export_string do |str, enc = (Encoding.default_internal || "utf-8")|
|
399
|
-
str.encode(enc)
|
400
|
-
end
|
401
398
|
subkeys = @registry.get_subkeys("HKCU\\Software\\Root")
|
402
399
|
reg_subkeys = []
|
403
400
|
::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root", Win32::Registry::KEY_ALL_ACCESS) do |reg|
|