chef 17.10.163 → 18.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +25 -21
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
- data/chef.gemspec +33 -27
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/base.rb +20 -2
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/chef_fs/path_utils.rb +7 -9
- data/lib/chef/client.rb +186 -2
- data/lib/chef/compliance/default_attributes.rb +2 -2
- data/lib/chef/compliance/input.rb +1 -1
- data/lib/chef/compliance/profile.rb +1 -1
- data/lib/chef/compliance/profile_collection.rb +0 -1
- data/lib/chef/compliance/runner.rb +6 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +4 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
- data/lib/chef/cookbook/synchronizer.rb +21 -3
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/cookbook_manifest.rb +2 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_collector.rb +14 -0
- data/lib/chef/delayed_evaluator.rb +4 -0
- data/lib/chef/dsl/reader_helpers.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +77 -0
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +0 -1
- data/lib/chef/exceptions.rb +9 -1
- data/lib/chef/file_access_control/windows.rb +4 -1
- data/lib/chef/file_cache.rb +17 -2
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
- data/lib/chef/http/authenticator.rb +253 -3
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
- data/lib/chef/mixin/openssl_helper.rb +1 -16
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute.rb +3 -11
- data/lib/chef/node/attribute_collections.rb +10 -1
- data/lib/chef/node/immutable_collections.rb +17 -6
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/state_tracking.rb +7 -4
- data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
- data/lib/chef/node.rb +23 -1
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/policy_builder/policyfile.rb +8 -0
- data/lib/chef/property.rb +13 -6
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/launchd.rb +2 -1
- data/lib/chef/provider/mount/linux.rb +6 -1
- data/lib/chef/provider/mount/mount.rb +13 -5
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/chocolatey.rb +260 -22
- data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
- data/lib/chef/provider/package/homebrew.rb +6 -9
- data/lib/chef/provider/package/powershell.rb +1 -0
- data/lib/chef/provider/package/rubygems.rb +5 -1
- data/lib/chef/provider/package/snap.rb +3 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/yum/yum_helper.py +3 -3
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -3
- data/lib/chef/provider/powershell_script.rb +96 -6
- data/lib/chef/provider/registry_key.rb +2 -0
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +23 -8
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/service.rb +14 -0
- data/lib/chef/provider/user/aix.rb +5 -0
- data/lib/chef/provider/user/linux.rb +29 -0
- data/lib/chef/provider/user/mac.rb +1 -1
- data/lib/chef/provider/user/windows.rb +5 -0
- data/lib/chef/provider/user.rb +45 -9
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +4 -12
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +21 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +138 -18
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +13 -1
- data/lib/chef/resource/batch.rb +0 -1
- data/lib/chef/resource/bff_package.rb +0 -1
- data/lib/chef/resource/breakpoint.rb +0 -1
- data/lib/chef/resource/build_essential.rb +0 -1
- data/lib/chef/resource/cab_package.rb +0 -1
- data/lib/chef/resource/chef_client_config.rb +12 -14
- data/lib/chef/resource/chef_client_cron.rb +1 -2
- data/lib/chef/resource/chef_client_launchd.rb +2 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -2
- data/lib/chef/resource/chef_handler.rb +0 -1
- data/lib/chef/resource/chef_sleep.rb +1 -3
- data/lib/chef/resource/chef_vault_secret.rb +0 -1
- data/lib/chef/resource/chocolatey_config.rb +0 -1
- data/lib/chef/resource/chocolatey_feature.rb +0 -1
- data/lib/chef/resource/chocolatey_installer.rb +207 -0
- data/lib/chef/resource/chocolatey_package.rb +8 -1
- data/lib/chef/resource/chocolatey_source.rb +0 -1
- data/lib/chef/resource/cookbook_file.rb +0 -1
- data/lib/chef/resource/cron/_cron_shared.rb +0 -1
- data/lib/chef/resource/cron/cron.rb +0 -1
- data/lib/chef/resource/cron/cron_d.rb +15 -1
- data/lib/chef/resource/cron_access.rb +0 -1
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/directory.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +2 -1
- data/lib/chef/resource/dnf_package.rb +0 -1
- data/lib/chef/resource/dpkg_package.rb +0 -1
- data/lib/chef/resource/dsc_resource.rb +0 -1
- data/lib/chef/resource/dsc_script.rb +1 -2
- data/lib/chef/resource/execute.rb +8 -7
- data/lib/chef/resource/file.rb +0 -1
- data/lib/chef/resource/freebsd_package.rb +2 -1
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +25 -2
- data/lib/chef/resource/habitat/habitat_package.rb +0 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/habitat_config.rb +0 -1
- data/lib/chef/resource/habitat_install.rb +2 -2
- data/lib/chef/resource/habitat_service.rb +0 -1
- data/lib/chef/resource/habitat_user_toml.rb +0 -1
- data/lib/chef/resource/homebrew_cask.rb +21 -33
- data/lib/chef/resource/homebrew_package.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +32 -18
- data/lib/chef/resource/homebrew_update.rb +4 -6
- data/lib/chef/resource/hostname.rb +0 -1
- data/lib/chef/resource/http_request.rb +0 -1
- data/lib/chef/resource/ifconfig.rb +0 -1
- data/lib/chef/resource/inspec_input.rb +0 -1
- data/lib/chef/resource/inspec_waiver.rb +0 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
- data/lib/chef/resource/ips_package.rb +0 -1
- data/lib/chef/resource/kernel_module.rb +0 -1
- data/lib/chef/resource/ksh.rb +0 -1
- data/lib/chef/resource/launchd.rb +9 -3
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +0 -1
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_pkg.rb +111 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -4
- data/lib/chef/resource/macosx_service.rb +0 -1
- data/lib/chef/resource/macports_package.rb +2 -1
- data/lib/chef/resource/mdadm.rb +0 -1
- data/lib/chef/resource/mount.rb +0 -1
- data/lib/chef/resource/msu_package.rb +0 -1
- data/lib/chef/resource/notify_group.rb +0 -2
- data/lib/chef/resource/ohai.rb +0 -1
- data/lib/chef/resource/ohai_hint.rb +0 -1
- data/lib/chef/resource/openbsd_package.rb +2 -1
- data/lib/chef/resource/openssl_dhparam.rb +0 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
- data/lib/chef/resource/openssl_x509_crl.rb +0 -2
- data/lib/chef/resource/openssl_x509_request.rb +0 -2
- data/lib/chef/resource/osx_profile.rb +0 -1
- data/lib/chef/resource/package.rb +0 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +0 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +7 -3
- data/lib/chef/resource/portage_package.rb +2 -1
- data/lib/chef/resource/powershell_package.rb +4 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +5 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +6 -1
- data/lib/chef/resource/remote_directory.rb +0 -1
- data/lib/chef/resource/remote_file.rb +0 -1
- data/lib/chef/resource/rhsm_errata.rb +0 -1
- data/lib/chef/resource/rhsm_errata_level.rb +0 -1
- data/lib/chef/resource/rhsm_register.rb +2 -4
- data/lib/chef/resource/rhsm_repo.rb +0 -1
- data/lib/chef/resource/rhsm_subscription.rb +0 -1
- data/lib/chef/resource/route.rb +0 -1
- data/lib/chef/resource/rpm_package.rb +2 -1
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/ruby_block.rb +0 -1
- data/lib/chef/resource/scm/_scm.rb +0 -2
- data/lib/chef/resource/scm/git.rb +0 -2
- data/lib/chef/resource/scm/subversion.rb +0 -2
- data/lib/chef/resource/script.rb +0 -1
- data/lib/chef/resource/selinux/common_helpers.rb +47 -0
- data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
- data/lib/chef/resource/selinux/selinux_default.erb +15 -0
- data/lib/chef/resource/selinux_boolean.rb +101 -0
- data/lib/chef/resource/selinux_fcontext.rb +160 -0
- data/lib/chef/resource/selinux_install.rb +107 -0
- data/lib/chef/resource/selinux_login.rb +129 -0
- data/lib/chef/resource/selinux_module.rb +143 -0
- data/lib/chef/resource/selinux_permissive.rb +64 -0
- data/lib/chef/resource/selinux_port.rb +118 -0
- data/lib/chef/resource/selinux_state.rb +166 -0
- data/lib/chef/resource/selinux_user.rb +137 -0
- data/lib/chef/resource/service.rb +4 -2
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +25 -1
- data/lib/chef/resource/solaris_package.rb +2 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
- data/lib/chef/resource/sudo.rb +37 -3
- data/lib/chef/resource/support/client.erb +2 -2
- data/lib/chef/resource/support/ulimit.erb +40 -0
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +0 -1
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +0 -1
- data/lib/chef/resource/user/aix_user.rb +0 -1
- data/lib/chef/resource/user/linux_user.rb +0 -1
- data/lib/chef/resource/user/mac_user.rb +0 -1
- data/lib/chef/resource/user/pw_user.rb +0 -1
- data/lib/chef/resource/user/solaris_user.rb +0 -1
- data/lib/chef/resource/user/windows_user.rb +0 -1
- data/lib/chef/resource/user.rb +10 -1
- data/lib/chef/resource/user_ulimit.rb +38 -1
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
- data/lib/chef/resource/windows_ad_join.rb +0 -2
- data/lib/chef/resource/windows_audit_policy.rb +0 -2
- data/lib/chef/resource/windows_auto_run.rb +0 -1
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +0 -1
- data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
- data/lib/chef/resource/windows_dfs_folder.rb +0 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
- data/lib/chef/resource/windows_dfs_server.rb +0 -1
- data/lib/chef/resource/windows_dns_record.rb +0 -1
- data/lib/chef/resource/windows_dns_zone.rb +0 -1
- data/lib/chef/resource/windows_env.rb +0 -1
- data/lib/chef/resource/windows_feature.rb +0 -1
- data/lib/chef/resource/windows_feature_dism.rb +0 -1
- data/lib/chef/resource/windows_feature_powershell.rb +0 -1
- data/lib/chef/resource/windows_firewall_profile.rb +0 -2
- data/lib/chef/resource/windows_firewall_rule.rb +0 -1
- data/lib/chef/resource/windows_font.rb +2 -3
- data/lib/chef/resource/windows_package.rb +3 -4
- data/lib/chef/resource/windows_pagefile.rb +0 -2
- data/lib/chef/resource/windows_path.rb +0 -1
- data/lib/chef/resource/windows_printer.rb +0 -1
- data/lib/chef/resource/windows_printer_port.rb +0 -1
- data/lib/chef/resource/windows_script.rb +0 -2
- data/lib/chef/resource/windows_security_policy.rb +2 -3
- data/lib/chef/resource/windows_service.rb +0 -1
- data/lib/chef/resource/windows_share.rb +0 -1
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +0 -1
- data/lib/chef/resource/windows_uac.rb +0 -1
- data/lib/chef/resource/windows_update_settings.rb +0 -1
- data/lib/chef/resource/windows_user_privilege.rb +14 -11
- data/lib/chef/resource/windows_workgroup.rb +0 -1
- data/lib/chef/resource/yum_package.rb +2 -1
- data/lib/chef/resource/yum_repository.rb +4 -1
- data/lib/chef/resource/zypper_package.rb +2 -1
- data/lib/chef/resource/zypper_repository.rb +0 -1
- data/lib/chef/resource.rb +23 -5
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/resource_reporter.rb +4 -0
- data/lib/chef/resources.rb +11 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
- data/lib/chef/util/powershell/ps_credential.rb +10 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +12 -4
- data/lib/chef/win32/security.rb +16 -1
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +26 -42
- data/spec/functional/resource/link_spec.rb +8 -8
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/registry_spec.rb +233 -609
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -1
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +1 -1
- data/spec/functional/resource/zypper_package_spec.rb +12 -0
- data/spec/functional/shell_spec.rb +1 -2
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +0 -3
- data/spec/integration/client/client_spec.rb +88 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +5 -5
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/client/open_ssl_spec.rb +3 -3
- data/spec/integration/compliance/compliance_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +1 -1
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/integration/recipes/use_partial_spec.rb +2 -1
- data/spec/integration/solo/solo_spec.rb +2 -2
- data/spec/spec_helper.rb +7 -4
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/platform_helpers.rb +28 -7
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/tiny_server.rb +5 -2
- data/spec/unit/application/client_spec.rb +0 -10
- data/spec/unit/chef_fs/file_system_spec.rb +2 -0
- data/spec/unit/client_spec.rb +80 -4
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/data_collector_spec.rb +106 -2
- data/spec/unit/delayed_evaluator_spec.rb +35 -0
- data/spec/unit/file_cache_spec.rb +64 -0
- data/spec/unit/http/authenticator_spec.rb +121 -0
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/apt_repository_spec.rb +48 -12
- data/spec/unit/provider/cron_spec.rb +2 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +15 -4
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/apt_spec.rb +18 -13
- data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/powershell_script_spec.rb +100 -4
- data/spec/unit/provider/registry_key_spec.rb +17 -17
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -1
- data/spec/unit/provider/user/windows_spec.rb +1 -0
- data/spec/unit/provider/user_spec.rb +24 -6
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- data/spec/unit/resource/archive_file_spec.rb +1 -1
- data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
- data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_pkg_spec.rb +38 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/rest_resource_spec.rb +381 -0
- data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
- data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
- data/spec/unit/resource/selinux_install_spec.rb +60 -0
- data/spec/unit/resource/selinux_login_spec.rb +73 -0
- data/spec/unit/resource/selinux_module_spec.rb +55 -0
- data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
- data/spec/unit/resource/selinux_port_spec.rb +42 -0
- data/spec/unit/resource/selinux_state_spec.rb +46 -0
- data/spec/unit/resource/selinux_user_spec.rb +92 -0
- data/spec/unit/resource/sysctl_spec.rb +2 -2
- data/spec/unit/resource/user/linux_user_spec.rb +42 -0
- data/spec/unit/resource/yum_repository_spec.rb +4 -0
- data/spec/unit/resource_inspector_spec.rb +36 -0
- data/spec/unit/resource_reporter_spec.rb +57 -3
- data/spec/unit/resource_spec.rb +94 -2
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
- data/tasks/rspec.rb +1 -1
- metadata +126 -44
- data/lib/chef/powershell.rb +0 -81
- data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
- /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxBoolean do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxBoolean.new("fakey_fakerton", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:set) }
|
|
26
|
+
let(:selinux_state) { double("shellout!", stdout: "permissive") }
|
|
27
|
+
|
|
28
|
+
it "sets boolean proprty as name_property" do
|
|
29
|
+
expect(resource.boolean).to eql("fakey_fakerton")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "sets the default action as :set" do
|
|
33
|
+
expect(resource.action).to eql([:set])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "supports :set action" do
|
|
37
|
+
expect { resource.action :set }.not_to raise_error
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "coercing value property" do
|
|
41
|
+
it "should set value properly to 'on' when valid parameter is sent and is literal positive" do
|
|
42
|
+
resource.value = 1
|
|
43
|
+
expect(resource.value).to eql("on")
|
|
44
|
+
|
|
45
|
+
resource.value = "true"
|
|
46
|
+
expect(resource.value).to eql("on")
|
|
47
|
+
|
|
48
|
+
resource.value = true
|
|
49
|
+
expect(resource.value).to eql("on")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should set value properly to 'off' when valid parameter is sent and is literal negative" do
|
|
53
|
+
resource.value = 0
|
|
54
|
+
expect(resource.value).to eql("off")
|
|
55
|
+
|
|
56
|
+
resource.value = "false"
|
|
57
|
+
expect(resource.value).to eql("off")
|
|
58
|
+
|
|
59
|
+
resource.value = false
|
|
60
|
+
expect(resource.value).to eql("off")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "should raise an exception if invalid parameter is sent" do
|
|
64
|
+
expect do
|
|
65
|
+
resource.value = "ON"
|
|
66
|
+
end.to raise_error(ArgumentError)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "#Chef::SELinux::CommonHelpers" do
|
|
71
|
+
context "#selinux_permissive?" do
|
|
72
|
+
it "should return true if selinux_state is :permissive" do
|
|
73
|
+
allow(provider).to receive(:shell_out!).and_return(selinux_state)
|
|
74
|
+
expect(provider.selinux_permissive?).to eql(true)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context "#selinux_disabled?" do
|
|
79
|
+
it "should return false if selinux_state is :permissive" do
|
|
80
|
+
allow(provider).to receive(:shell_out!).and_return(selinux_state)
|
|
81
|
+
expect(provider.selinux_disabled?).to eql(false)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
context "#selinux_enforcing?" do
|
|
86
|
+
it "should return false if selinux_state is :permissive" do
|
|
87
|
+
allow(provider).to receive(:shell_out!).and_return(selinux_state)
|
|
88
|
+
expect(provider.selinux_enforcing?).to eql(false)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxFcontext do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxFcontext.new("fakey_fakerton", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:manage) }
|
|
26
|
+
let(:restoreconf) { double("shellout", stdout: "restorecon reset /var/www/html/index.html context unconfined_u:object_r:user_home_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0") }
|
|
27
|
+
|
|
28
|
+
it "sets file_spec proprty as name_property" do
|
|
29
|
+
expect(resource.file_spec).to eql("fakey_fakerton")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "sets the default action as :manage" do
|
|
33
|
+
expect(resource.action).to eql([:manage])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "supports :manage, :addormodify, :add, :modify, :delete actions" do
|
|
37
|
+
expect { resource.action :manage }.not_to raise_error
|
|
38
|
+
expect { resource.action :addormodify }.not_to raise_error
|
|
39
|
+
expect { resource.action :add }.not_to raise_error
|
|
40
|
+
expect { resource.action :modify }.not_to raise_error
|
|
41
|
+
expect { resource.action :delete }.not_to raise_error
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "checks 'a', 'f', 'd', 'c', 'b', 's', 'l', 'p' as valid file_type property values" do
|
|
45
|
+
expect { resource.file_type "a" }.not_to raise_error
|
|
46
|
+
expect { resource.file_type "f" }.not_to raise_error
|
|
47
|
+
expect { resource.file_type "d" }.not_to raise_error
|
|
48
|
+
expect { resource.file_type "c" }.not_to raise_error
|
|
49
|
+
expect { resource.file_type "b" }.not_to raise_error
|
|
50
|
+
expect { resource.file_type "s" }.not_to raise_error
|
|
51
|
+
expect { resource.file_type "l" }.not_to raise_error
|
|
52
|
+
expect { resource.file_type "p" }.not_to raise_error
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "sets default value for file_type property to 'a'" do
|
|
56
|
+
expect(resource.file_type).to eql("a")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#relabel_files" do
|
|
60
|
+
it "returns verbose output with details of the file for which SELinux config is restored" do
|
|
61
|
+
allow(provider).to receive(:shell_out!).and_return(restoreconf)
|
|
62
|
+
expect(provider.relabel_files).to eql(restoreconf)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxInstall do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxInstall.new("fakey_fakerton", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:install) }
|
|
26
|
+
|
|
27
|
+
it "sets the default action as :install" do
|
|
28
|
+
expect(resource.action).to eql([:install])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "supports :install, :upgrade, :remove actions" do
|
|
32
|
+
expect { resource.action :install }.not_to raise_error
|
|
33
|
+
expect { resource.action :upgrade }.not_to raise_error
|
|
34
|
+
expect { resource.action :remove }.not_to raise_error
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "sets default packages on 'rhel', 'fedora', 'amazon' platforms" do
|
|
38
|
+
node.automatic_attrs[:platform_family] = "rhel"
|
|
39
|
+
expect(resource.packages).to eql(%w{make policycoreutils selinux-policy selinux-policy-targeted selinux-policy-devel libselinux-utils setools-console})
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "sets default packages on debian irrespective of platform_version" do
|
|
43
|
+
node.automatic_attrs[:platform_family] = "debian"
|
|
44
|
+
expect(resource.packages).to eql(%w{make policycoreutils selinux-basics selinux-policy-default selinux-policy-dev auditd setools})
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "sets default packages on ubuntu 18.04 platforms" do
|
|
48
|
+
node.automatic_attrs[:platform_family] = "debian"
|
|
49
|
+
node.automatic_attrs[:platform] = "ubuntu"
|
|
50
|
+
node.automatic_attrs[:platform_version] = 18.04
|
|
51
|
+
expect(resource.packages).to eql(%w{make policycoreutils selinux selinux-basics selinux-policy-default selinux-policy-dev auditd setools})
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "sets default packages on ubuntu platforms and versions other than 18.04" do
|
|
55
|
+
node.automatic_attrs[:platform_family] = "debian"
|
|
56
|
+
node.automatic_attrs[:platform] = "ubuntu"
|
|
57
|
+
node.automatic_attrs[:platform_version] = 20.04
|
|
58
|
+
expect(resource.packages).to eql(%w{make policycoreutils selinux-basics selinux-policy-default selinux-policy-dev auditd setools})
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxLogin do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxLogin.new("fakey_fakerton", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:manage) }
|
|
26
|
+
|
|
27
|
+
it "sets login property as name_property" do
|
|
28
|
+
expect(resource.login).to eql("fakey_fakerton")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "sets the default action as :manage" do
|
|
32
|
+
expect(resource.action).to eql([:manage])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "supports :manage, :add, :modify, :delete actions" do
|
|
36
|
+
expect { resource.action :manage }.not_to raise_error
|
|
37
|
+
expect { resource.action :add }.not_to raise_error
|
|
38
|
+
expect { resource.action :modify }.not_to raise_error
|
|
39
|
+
expect { resource.action :delete }.not_to raise_error
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "#semanage_login_args" do
|
|
43
|
+
let(:provider) { resource.provider_for_action(:modify) }
|
|
44
|
+
|
|
45
|
+
context "when no parameters are provided" do
|
|
46
|
+
it "returns an empty string" do
|
|
47
|
+
expect(provider.semanage_login_args).to eq("")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "when all parameters are provided" do
|
|
52
|
+
it "returns all params" do
|
|
53
|
+
resource.user "user_u"
|
|
54
|
+
resource.range "s0"
|
|
55
|
+
expect(provider.semanage_login_args).to eq(" -s user_u -r s0")
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context "when no user is provided" do
|
|
60
|
+
it "returns range param" do
|
|
61
|
+
resource.range "s0"
|
|
62
|
+
expect(provider.semanage_login_args).to eq(" -r s0")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "when no range is provided" do
|
|
67
|
+
it "returns user param" do
|
|
68
|
+
resource.user "user_u"
|
|
69
|
+
expect(provider.semanage_login_args).to eq(" -s user_u")
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#
|
|
2
|
+
#
|
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
|
4
|
+
# License:: Apache License, Version 2.0
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
require "spec_helper"
|
|
20
|
+
|
|
21
|
+
describe Chef::Resource::SelinuxModule do
|
|
22
|
+
let(:node) { Chef::Node.new }
|
|
23
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
24
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
25
|
+
let(:resource) { Chef::Resource::SelinuxModule.new("fakey_fakerton", run_context) }
|
|
26
|
+
let(:provider) { resource.provider_for_action(:create) }
|
|
27
|
+
|
|
28
|
+
it "sets module_name property as name_property" do
|
|
29
|
+
expect(resource.module_name).to eql("fakey_fakerton")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "sets default value for base_dir property" do
|
|
33
|
+
expect(resource.base_dir).to eql("/etc/selinux/local")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "sets the default action as :create" do
|
|
37
|
+
expect(resource.action).to eql([:create])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "supports :create, :delete, :install, :remove actions" do
|
|
41
|
+
expect { resource.action :create }.not_to raise_error
|
|
42
|
+
expect { resource.action :delete }.not_to raise_error
|
|
43
|
+
expect { resource.action :install }.not_to raise_error
|
|
44
|
+
expect { resource.action :remove }.not_to raise_error
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "#selinux_module_filepath" do
|
|
48
|
+
it "returns selinux module file path based upon base_dir property and module_name property" do
|
|
49
|
+
resource.base_dir = "/opt/selinux"
|
|
50
|
+
resource.module_name = "my_module"
|
|
51
|
+
file_type = "te"
|
|
52
|
+
expect(provider.selinux_module_filepath(file_type)).to eql("/opt/selinux/my_module.te")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxPermissive do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxPermissive.new("fakey_fakerton", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:add) }
|
|
26
|
+
|
|
27
|
+
it "sets context property as name_property" do
|
|
28
|
+
expect(resource.context).to eql("fakey_fakerton")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "sets the default action as :add" do
|
|
32
|
+
expect(resource.action).to eql([:add])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "supports :add, :delete actions" do
|
|
36
|
+
expect { resource.action :add }.not_to raise_error
|
|
37
|
+
expect { resource.action :delete }.not_to raise_error
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxPort do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxPort.new("5678", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:manage) }
|
|
26
|
+
|
|
27
|
+
it "sets port property as name_property" do
|
|
28
|
+
expect(resource.port).to eql("5678")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "sets the default action as :manage" do
|
|
32
|
+
expect(resource.action).to eql([:manage])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "supports :manage, :addormodify, :add, :modify, :delete actions" do
|
|
36
|
+
expect { resource.action :manage }.not_to raise_error
|
|
37
|
+
expect { resource.action :addormodify }.not_to raise_error
|
|
38
|
+
expect { resource.action :add }.not_to raise_error
|
|
39
|
+
expect { resource.action :modify }.not_to raise_error
|
|
40
|
+
expect { resource.action :delete }.not_to raise_error
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxState do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxState.new("5678", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:enforcing) }
|
|
26
|
+
|
|
27
|
+
it "sets the default action as :enforcing" do
|
|
28
|
+
expect(resource.action).to eql([:enforcing])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "sets default value for policy property for 'rhel', 'fedora', 'amazon' platforms" do
|
|
32
|
+
node.automatic_attrs[:platform_family] = "rhel"
|
|
33
|
+
expect(resource.policy).to eql("targeted")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "supports :enforcing, :permissive, :disabled actions" do
|
|
37
|
+
expect { resource.action :enforcing }.not_to raise_error
|
|
38
|
+
expect { resource.action :permissive }.not_to raise_error
|
|
39
|
+
expect { resource.action :disabled }.not_to raise_error
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "sets default value for policy property for debian platforms" do
|
|
43
|
+
node.automatic_attrs[:platform_family] = "debian"
|
|
44
|
+
expect(resource.policy).to eql("default")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
|
|
20
|
+
describe Chef::Resource::SelinuxUser do
|
|
21
|
+
let(:node) { Chef::Node.new }
|
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
|
24
|
+
let(:resource) { Chef::Resource::SelinuxUser.new("fakey_fakerton", run_context) }
|
|
25
|
+
let(:provider) { resource.provider_for_action(:manage) }
|
|
26
|
+
let(:semanage_list) { double("shellout", stdout: "") }
|
|
27
|
+
|
|
28
|
+
it "sets user property as name_property" do
|
|
29
|
+
expect(resource.user).to eql("fakey_fakerton")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "sets the default action as :manage" do
|
|
33
|
+
expect(resource.action).to eql([:manage])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "supports :manage, :add, :modify, :delete actions" do
|
|
37
|
+
expect { resource.action :manage }.not_to raise_error
|
|
38
|
+
expect { resource.action :add }.not_to raise_error
|
|
39
|
+
expect { resource.action :modify }.not_to raise_error
|
|
40
|
+
expect { resource.action :delete }.not_to raise_error
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "sorts roles property values" do
|
|
44
|
+
expect { resource.roles %w{c a b} }.not_to raise_error
|
|
45
|
+
expect(resource.roles).to eq(%w{a b c})
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe "#semanage_user_args" do
|
|
49
|
+
let(:provider) { resource.provider_for_action(:modify) }
|
|
50
|
+
|
|
51
|
+
context "when no parameters are provided" do
|
|
52
|
+
it "returns an empty string" do
|
|
53
|
+
expect(provider.semanage_user_args).to eq("")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context "when all parameters are provided" do
|
|
58
|
+
it "returns all params" do
|
|
59
|
+
resource.level "s0"
|
|
60
|
+
resource.range "s0"
|
|
61
|
+
resource.roles %w{sysadm_r staff_r}
|
|
62
|
+
expect(provider.semanage_user_args).to eq(" -L s0 -r s0 -R 'staff_r sysadm_r'")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context "when no roles are provided" do
|
|
67
|
+
it "returns level and range params" do
|
|
68
|
+
resource.level "s0"
|
|
69
|
+
resource.range "s0"
|
|
70
|
+
resource.roles []
|
|
71
|
+
|
|
72
|
+
expect(provider.semanage_user_args).to eq(" -L s0 -r s0")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "when no range is provided" do
|
|
77
|
+
it "returns level and roles params" do
|
|
78
|
+
resource.level "s0"
|
|
79
|
+
resource.roles %w{sysadm_r staff_r}
|
|
80
|
+
expect(provider.semanage_user_args).to eq(" -L s0 -R 'staff_r sysadm_r'")
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context "when no level is provided" do
|
|
85
|
+
it "returns range and roles params" do
|
|
86
|
+
resource.range "s0"
|
|
87
|
+
resource.roles %w{sysadm_r staff_r}
|
|
88
|
+
expect(provider.semanage_user_args).to eq(" -r s0 -R 'staff_r sysadm_r'")
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -62,14 +62,14 @@ describe Chef::Resource::Sysctl do
|
|
|
62
62
|
context "when comment is a String" do
|
|
63
63
|
it "Returns content for use with a file resource" do
|
|
64
64
|
resource.comment("This sets foo / bar on our system")
|
|
65
|
-
expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\nfoo = bar")
|
|
65
|
+
expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\nfoo = bar\n")
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
context "when comment is an Array" do
|
|
70
70
|
it "Returns content for use with a file resource" do
|
|
71
71
|
resource.comment(["This sets foo / bar on our system", "We need for baz"])
|
|
72
|
-
expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\n# We need for baz\nfoo = bar")
|
|
72
|
+
expect(provider.contruct_sysctl_content).to eql("# This sets foo / bar on our system\n# We need for baz\nfoo = bar\n")
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Chef::Resource::User, "initialize" do
|
|
4
|
+
let(:resource) { Chef::Resource::User::LinuxUser.new("notarealuser") }
|
|
5
|
+
|
|
6
|
+
describe "inactive attribute" do
|
|
7
|
+
it "allows a string" do
|
|
8
|
+
resource.inactive "100"
|
|
9
|
+
expect(resource.inactive).to eql("100")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "allows an integer" do
|
|
13
|
+
resource.inactive 100
|
|
14
|
+
expect(resource.inactive).to eql(100)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "does not allow a hash" do
|
|
18
|
+
expect { resource.inactive({ woot: "i found it" }) }.to raise_error(ArgumentError)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe "expire_date attribute" do
|
|
23
|
+
it "allows a string" do
|
|
24
|
+
resource.expire_date "100"
|
|
25
|
+
expect(resource.expire_date).to eql("100")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "does not allow an integer" do
|
|
29
|
+
expect { resource.expire_date(90) }.to raise_error(ArgumentError)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "does not allow a hash" do
|
|
33
|
+
expect { resource.expire_date({ woot: "i found it" }) }.to raise_error(ArgumentError)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
%w{inactive expire_date}.each do |prop|
|
|
38
|
+
it "sets #{prop} to nil" do
|
|
39
|
+
expect(resource.send(prop)).to eql(nil)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -68,6 +68,10 @@ describe Chef::Resource::YumRepository do
|
|
|
68
68
|
expect(resource.make_cache).to eql(true)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
it "makecache_fast property defaults to false" do
|
|
72
|
+
expect(resource.makecache_fast).to eql(false)
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
it "mode property defaults to '0644'" do
|
|
72
76
|
expect(resource.mode).to eql("0644")
|
|
73
77
|
end
|