chef 12.0.0.alpha.2-x86-mingw32 → 12.0.0.rc.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +9 -0
- data/README.md +1 -1
- data/Rakefile +12 -0
- data/bin/chef-service-manager +1 -1
- data/bin/chef-windows-service +35 -0
- data/distro/common/html/_sources/ctl_chef_server.txt +307 -10
- data/distro/common/html/ctl_chef_client.html +3 -7
- data/distro/common/html/ctl_chef_server.html +609 -41
- data/distro/common/html/ctl_chef_shell.html +2 -2
- data/distro/common/html/ctl_chef_solo.html +1 -1
- data/distro/common/html/index.html +13 -13
- data/distro/common/html/knife.html +10 -10
- data/distro/common/html/knife_bootstrap.html +8 -8
- data/distro/common/html/knife_client.html +12 -12
- data/distro/common/html/knife_common_options.html +7 -7
- data/distro/common/html/knife_configure.html +3 -3
- data/distro/common/html/knife_cookbook.html +19 -19
- data/distro/common/html/knife_cookbook_site.html +28 -28
- data/distro/common/html/knife_data_bag.html +28 -13
- data/distro/common/html/knife_delete.html +2 -2
- data/distro/common/html/knife_deps.html +3 -3
- data/distro/common/html/knife_diff.html +4 -4
- data/distro/common/html/knife_download.html +3 -3
- data/distro/common/html/knife_edit.html +2 -2
- data/distro/common/html/knife_environment.html +14 -14
- data/distro/common/html/knife_exec.html +11 -11
- data/distro/common/html/knife_index_rebuild.html +2 -2
- data/distro/common/html/knife_list.html +3 -3
- data/distro/common/html/knife_node.html +23 -23
- data/distro/common/html/knife_raw.html +4 -4
- data/distro/common/html/knife_recipe_list.html +3 -3
- data/distro/common/html/knife_role.html +11 -11
- data/distro/common/html/knife_search.html +4 -4
- data/distro/common/html/knife_serve.html +3 -3
- data/distro/common/html/knife_show.html +3 -3
- data/distro/common/html/knife_ssh.html +7 -7
- data/distro/common/html/knife_ssl_check.html +7 -7
- data/distro/common/html/knife_ssl_fetch.html +9 -9
- data/distro/common/html/knife_status.html +3 -3
- data/distro/common/html/knife_tag.html +9 -9
- data/distro/common/html/knife_upload.html +3 -3
- data/distro/common/html/knife_user.html +9 -9
- data/distro/common/html/knife_using.html +11 -11
- data/distro/common/html/knife_xargs.html +14 -5
- data/distro/common/html/search.html +2 -2
- data/distro/common/html/searchindex.js +1 -1
- data/distro/common/man/man1/chef-shell.1 +2 -2
- data/distro/common/man/man1/knife-bootstrap.1 +7 -7
- data/distro/common/man/man1/knife-client.1 +10 -10
- data/distro/common/man/man1/knife-configure.1 +5 -5
- data/distro/common/man/man1/knife-cookbook-site.1 +24 -24
- data/distro/common/man/man1/knife-cookbook.1 +12 -12
- data/distro/common/man/man1/knife-data-bag.1 +34 -10
- data/distro/common/man/man1/knife-delete.1 +5 -5
- data/distro/common/man/man1/knife-deps.1 +5 -5
- data/distro/common/man/man1/knife-diff.1 +7 -7
- data/distro/common/man/man1/knife-download.1 +5 -5
- data/distro/common/man/man1/knife-edit.1 +5 -5
- data/distro/common/man/man1/knife-environment.1 +11 -11
- data/distro/common/man/man1/knife-exec.1 +11 -11
- data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
- data/distro/common/man/man1/knife-list.1 +5 -5
- data/distro/common/man/man1/knife-node.1 +16 -16
- data/distro/common/man/man1/knife-raw.1 +6 -6
- data/distro/common/man/man1/knife-recipe-list.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +7 -7
- data/distro/common/man/man1/knife-search.1 +6 -6
- data/distro/common/man/man1/knife-serve.1 +6 -6
- data/distro/common/man/man1/knife-show.1 +5 -5
- data/distro/common/man/man1/knife-ssh.1 +9 -9
- data/distro/common/man/man1/knife-ssl-check.1 +7 -7
- data/distro/common/man/man1/knife-ssl-fetch.1 +9 -9
- data/distro/common/man/man1/knife-status.1 +5 -5
- data/distro/common/man/man1/knife-tag.1 +8 -8
- data/distro/common/man/man1/knife-upload.1 +5 -5
- data/distro/common/man/man1/knife-user.1 +8 -8
- data/distro/common/man/man1/knife-xargs.1 +36 -10
- data/distro/common/man/man1/knife.1 +14 -14
- data/distro/common/man/man8/chef-client.8 +3 -10
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/ext/win32-eventlog/Rakefile +50 -0
- data/ext/win32-eventlog/chef-log.man +26 -0
- data/lib/chef/application.rb +313 -241
- data/lib/chef/application/apply.rb +10 -8
- data/lib/chef/application/client.rb +58 -33
- data/lib/chef/application/solo.rb +33 -12
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_invites_entry.rb +2 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -1
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +2 -1
- data/lib/chef/client.rb +18 -48
- data/lib/chef/config.rb +43 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +14 -7
- data/lib/chef/cookbook/metadata.rb +81 -38
- data/lib/chef/cookbook/syntax_check.rb +18 -52
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_version.rb +58 -39
- data/lib/chef/data_bag.rb +2 -2
- data/lib/chef/deprecation/provider/file.rb +2 -1
- data/lib/chef/dsl/data_query.rb +2 -29
- data/lib/chef/dsl/recipe.rb +8 -22
- data/lib/chef/encrypted_data_bag_item/assertions.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/check_encrypted.rb +56 -0
- data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +1 -1
- data/lib/chef/event_loggers/base.rb +62 -0
- data/lib/chef/event_loggers/windows_eventlog.rb +104 -0
- data/lib/chef/exceptions.rb +18 -1
- data/lib/chef/file_cache.rb +3 -2
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +15 -6
- data/lib/chef/http.rb +20 -13
- data/lib/chef/http/ssl_policies.rb +2 -1
- data/lib/chef/json_compat.rb +9 -3
- data/lib/chef/knife.rb +2 -1
- data/lib/chef/knife/bootstrap.rb +12 -18
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +43 -8
- data/lib/chef/knife/core/bootstrap_context.rb +6 -11
- data/lib/chef/knife/core/object_loader.rb +5 -5
- data/lib/chef/knife/core/status_presenter.rb +156 -0
- data/lib/chef/knife/core/subcommand_loader.rb +6 -5
- data/lib/chef/knife/core/ui.rb +4 -4
- data/lib/chef/knife/data_bag_create.rb +7 -32
- data/lib/chef/knife/data_bag_edit.rb +24 -43
- data/lib/chef/knife/data_bag_from_file.rb +6 -31
- data/lib/chef/knife/data_bag_secret_options.rb +142 -0
- data/lib/chef/knife/data_bag_show.rb +19 -33
- data/lib/chef/knife/node_from_file.rb +9 -8
- data/lib/chef/knife/ssh.rb +0 -7
- data/lib/chef/knife/ssl_check.rb +70 -6
- data/lib/chef/knife/status.rb +11 -58
- data/lib/chef/mixin/command/unix.rb +2 -2
- data/lib/chef/mixin/convert_to_class_name.rb +54 -0
- data/lib/chef/mixin/descendants_tracker.rb +82 -0
- data/lib/chef/mixin/homebrew_user.rb +68 -0
- data/lib/chef/mixin/shell_out.rb +0 -4
- data/lib/chef/mixin/windows_architecture_helper.rb +16 -0
- data/lib/chef/mixin/windows_env_helper.rb +56 -0
- data/lib/chef/node.rb +2 -2
- data/lib/chef/node_map.rb +146 -0
- data/lib/chef/platform/provider_mapping.rb +11 -39
- data/lib/chef/platform/provider_priority_map.rb +80 -0
- data/lib/chef/platform/query_helpers.rb +5 -1
- data/lib/chef/platform/service_helpers.rb +113 -0
- data/lib/chef/provider.rb +24 -0
- data/lib/chef/provider/breakpoint.rb +2 -0
- data/lib/chef/provider/cookbook_file.rb +2 -0
- data/lib/chef/provider/cron.rb +1 -1
- data/lib/chef/provider/cron/unix.rb +13 -9
- data/lib/chef/provider/deploy.rb +3 -2
- data/lib/chef/provider/deploy/revision.rb +4 -2
- data/lib/chef/provider/deploy/timestamped.rb +2 -0
- data/lib/chef/provider/directory.rb +2 -0
- data/lib/chef/provider/dsc_script.rb +179 -0
- data/lib/chef/provider/env.rb +25 -10
- data/lib/chef/provider/env/windows.rb +9 -16
- data/lib/chef/provider/erl_call.rb +2 -0
- data/lib/chef/provider/execute.rb +5 -2
- data/lib/chef/provider/file.rb +2 -0
- data/lib/chef/provider/git.rb +51 -23
- data/lib/chef/provider/group/dscl.rb +2 -2
- data/lib/chef/provider/group/pw.rb +9 -13
- data/lib/chef/provider/http_request.rb +2 -0
- data/lib/chef/provider/link.rb +3 -0
- data/lib/chef/provider/log.rb +2 -0
- data/lib/chef/provider/lwrp_base.rb +11 -9
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/package/aix.rb +2 -0
- data/lib/chef/provider/package/apt.rb +2 -0
- data/lib/chef/provider/package/dpkg.rb +2 -0
- data/lib/chef/provider/package/easy_install.rb +2 -0
- data/lib/chef/provider/package/freebsd/pkg.rb +2 -1
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/freebsd/port.rb +1 -9
- data/lib/chef/provider/package/homebrew.rb +127 -0
- data/lib/chef/provider/package/ips.rb +2 -0
- data/lib/chef/provider/package/macports.rb +3 -0
- data/lib/chef/provider/package/pacman.rb +5 -4
- data/lib/chef/provider/package/paludis.rb +4 -2
- data/lib/chef/provider/package/portage.rb +4 -1
- data/lib/chef/provider/package/rpm.rb +2 -0
- data/lib/chef/provider/package/rubygems.rb +4 -0
- data/lib/chef/provider/package/smartos.rb +2 -0
- data/lib/chef/provider/package/solaris.rb +2 -0
- data/lib/chef/provider/package/windows.rb +5 -2
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/powershell_script.rb +3 -1
- data/lib/chef/provider/remote_directory.rb +25 -10
- data/lib/chef/provider/route.rb +2 -0
- data/lib/chef/provider/ruby_block.rb +2 -0
- data/lib/chef/provider/script.rb +6 -0
- data/lib/chef/provider/service/aix.rb +128 -0
- data/lib/chef/provider/service/aixinit.rb +117 -0
- data/lib/chef/provider/service/arch.rb +6 -0
- data/lib/chef/provider/service/debian.rb +35 -29
- data/lib/chef/provider/service/freebsd.rb +7 -1
- data/lib/chef/provider/service/gentoo.rb +5 -1
- data/lib/chef/provider/service/init.rb +2 -0
- data/lib/chef/provider/service/insserv.rb +15 -8
- data/lib/chef/provider/service/invokercd.rb +6 -0
- data/lib/chef/provider/service/macosx.rb +4 -1
- data/lib/chef/provider/service/redhat.rb +9 -3
- data/lib/chef/provider/service/simple.rb +2 -0
- data/lib/chef/provider/service/solaris.rb +2 -0
- data/lib/chef/provider/service/systemd.rb +7 -0
- data/lib/chef/provider/service/upstart.rb +7 -0
- data/lib/chef/provider/service/windows.rb +5 -0
- data/lib/chef/provider/subversion.rb +2 -0
- data/lib/chef/provider/template.rb +1 -0
- data/lib/chef/provider/user/dscl.rb +3 -2
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +2 -0
- data/lib/chef/provider_resolver.rb +103 -0
- data/lib/chef/providers.rb +6 -2
- data/lib/chef/recipe.rb +2 -0
- data/lib/chef/resource.rb +69 -78
- data/lib/chef/resource/apt_package.rb +3 -1
- data/lib/chef/resource/bash.rb +1 -0
- data/lib/chef/resource/bff_package.rb +0 -1
- data/lib/chef/resource/breakpoint.rb +1 -1
- data/lib/chef/resource/chef_gem.rb +1 -2
- data/lib/chef/resource/conditional.rb +26 -6
- data/lib/chef/resource/cookbook_file.rb +2 -3
- data/lib/chef/resource/csh.rb +1 -0
- data/lib/chef/resource/deploy.rb +0 -1
- data/lib/chef/resource/deploy_revision.rb +6 -1
- data/lib/chef/resource/directory.rb +1 -2
- data/lib/chef/resource/dpkg_package.rb +2 -1
- data/lib/chef/resource/dsc_script.rb +125 -0
- data/lib/chef/resource/easy_install_package.rb +2 -1
- data/lib/chef/resource/erl_call.rb +1 -0
- data/lib/chef/resource/execute.rb +26 -9
- data/lib/chef/resource/file.rb +1 -3
- data/lib/chef/resource/freebsd_package.rb +10 -23
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/git.rb +2 -1
- data/lib/chef/resource/homebrew_package.rb +46 -0
- data/lib/chef/resource/http_request.rb +1 -0
- data/lib/chef/resource/ips_package.rb +3 -1
- data/lib/chef/resource/link.rb +1 -2
- data/lib/chef/resource/log.rb +4 -0
- data/lib/chef/resource/lwrp_base.rb +24 -15
- data/lib/chef/resource/macports_package.rb +3 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +3 -1
- data/lib/chef/resource/perl.rb +1 -0
- data/lib/chef/resource/powershell_script.rb +0 -2
- data/lib/chef/resource/python.rb +1 -1
- data/lib/chef/resource/remote_directory.rb +1 -2
- data/lib/chef/resource/remote_file.rb +1 -1
- data/lib/chef/resource/rpm_package.rb +2 -1
- data/lib/chef/resource/ruby.rb +1 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +2 -25
- data/lib/chef/resource/service.rb +0 -4
- data/lib/chef/resource/smartos_package.rb +3 -4
- data/lib/chef/resource/solaris_package.rb +7 -1
- data/lib/chef/resource/subversion.rb +0 -1
- data/lib/chef/resource/template.rb +2 -3
- data/lib/chef/resource/timestamped_deploy.rb +1 -2
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
- data/lib/chef/resource/windows_package.rb +3 -4
- data/lib/chef/resource/windows_script.rb +3 -0
- data/lib/chef/resource/windows_service.rb +2 -2
- data/lib/chef/resource/yum_package.rb +3 -1
- data/lib/chef/resource_collection.rb +50 -227
- data/lib/chef/resource_collection/resource_collection_serialization.rb +59 -0
- data/lib/chef/resource_collection/resource_list.rb +89 -0
- data/lib/chef/resource_collection/resource_set.rb +170 -0
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/role.rb +1 -1
- data/lib/chef/run_context.rb +5 -1
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/backup.rb +3 -2
- data/lib/chef/util/dsc/configuration_generator.rb +115 -0
- data/lib/chef/util/dsc/lcm_output_parser.rb +133 -0
- data/lib/chef/util/dsc/local_configuration_manager.rb +141 -0
- data/lib/chef/util/dsc/resource_info.rb +26 -0
- data/lib/chef/util/path_helper.rb +12 -0
- data/lib/chef/util/powershell/cmdlet.rb +136 -0
- data/lib/chef/util/powershell/cmdlet_result.rb +46 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/system.rb +9 -0
- data/lib/chef/win32/version.rb +2 -0
- data/spec/.DS_Store +0 -0
- data/spec/data/.DS_Store +0 -0
- data/spec/data/bootstrap/test-hints.erb +1 -1
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/data/cb_version_cookbooks/cookbook2/files/test.txt +0 -0
- data/spec/data/cb_version_cookbooks/cookbook2/templates/test.erb +0 -0
- data/spec/data/cookbooks/ignorken/files/default/not_me.rb +2 -0
- data/spec/data/cookbooks/ignorken/templates/ubuntu-12.10/not_me.rb +2 -0
- data/spec/data/cookbooks/openldap/libraries/openldap.rb +4 -0
- data/spec/data/cookbooks/openldap/libraries/openldap/version.rb +3 -0
- data/spec/data/lwrp/.DS_Store +0 -0
- data/spec/data/lwrp/providers/.DS_Store +0 -0
- data/spec/data/lwrp/providers/buck_passer.rb +9 -2
- data/spec/data/lwrp/resources/.DS_Store +0 -0
- data/spec/data/lwrp/resources/foo.rb +3 -2
- data/spec/data/lwrp_override/.DS_Store +0 -0
- data/spec/data/lwrp_override/providers/.DS_Store +0 -0
- data/spec/data/lwrp_override/providers/buck_passer.rb +5 -10
- data/spec/data/lwrp_override/resources/.DS_Store +0 -0
- data/spec/data/lwrp_override/resources/foo.rb +4 -3
- data/spec/functional/assets/chefinittest +34 -0
- data/spec/functional/assets/testchefsubsys +11 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +19 -16
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +82 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
- data/spec/functional/knife/exec_spec.rb +1 -1
- data/spec/functional/resource/aix_service_spec.rb +136 -0
- data/spec/functional/resource/aixinit_service_spec.rb +211 -0
- data/spec/functional/resource/base.rb +1 -0
- data/spec/functional/resource/batch_spec.rb +4 -11
- data/spec/functional/resource/cron_spec.rb +7 -1
- data/spec/functional/resource/dsc_script_spec.rb +382 -0
- data/spec/functional/resource/env_spec.rb +54 -0
- data/spec/functional/resource/execute_spec.rb +113 -0
- data/spec/functional/resource/file_spec.rb +2 -0
- data/spec/functional/resource/group_spec.rb +7 -4
- data/spec/functional/resource/powershell_spec.rb +198 -185
- data/spec/functional/resource/rpm_spec.rb +5 -4
- data/spec/functional/resource/user/dscl_spec.rb +2 -1
- data/spec/functional/util/path_helper_spec.rb +37 -0
- data/spec/functional/util/powershell/cmdlet_spec.rb +114 -0
- data/spec/integration/client/client_spec.rb +1 -1
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +1 -1
- data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
- data/spec/integration/knife/chefignore_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +1 -1
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +2 -2
- data/spec/integration/knife/delete_spec.rb +1 -1
- data/spec/integration/knife/deps_spec.rb +1 -1
- data/spec/integration/knife/diff_spec.rb +1 -1
- data/spec/integration/knife/download_spec.rb +1 -1
- data/spec/integration/knife/list_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +1 -1
- data/spec/integration/knife/redirection_spec.rb +1 -1
- data/spec/integration/knife/serve_spec.rb +1 -1
- data/spec/integration/knife/show_spec.rb +1 -1
- data/spec/integration/knife/upload_spec.rb +4 -3
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/spec_helper.rb +15 -0
- data/spec/support/chef_helpers.rb +1 -0
- data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
- data/spec/support/lib/chef/resource/zen_follower.rb +1 -7
- data/spec/support/platform_helpers.rb +28 -0
- data/spec/support/shared/functional/file_resource.rb +6 -0
- data/spec/support/shared/functional/windows_script.rb +118 -0
- data/spec/support/shared/integration/integration_helper.rb +5 -2
- data/spec/support/shared/matchers/exit_with_code.rb +28 -0
- data/spec/support/shared/matchers/match_environment_variable.rb +17 -0
- data/spec/support/shared/shared_examples.rb +14 -0
- data/spec/support/shared/unit/execute_resource.rb +0 -7
- data/spec/support/shared/unit/resource/static_provider_resolution.rb +71 -0
- data/spec/support/shared/unit/script_resource.rb +1 -1
- data/spec/support/shared/unit/windows_script_resource.rb +35 -2
- data/spec/tiny_server.rb +1 -2
- data/spec/unit/api_client_spec.rb +5 -1
- data/spec/unit/application/{apply.rb → apply_spec.rb} +13 -5
- data/spec/unit/application/client_spec.rb +106 -13
- data/spec/unit/application/solo_spec.rb +25 -1
- data/spec/unit/client_spec.rb +1 -26
- data/spec/unit/config_fetcher_spec.rb +2 -1
- data/spec/unit/config_spec.rb +91 -2
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +8 -0
- data/spec/unit/cookbook/metadata_spec.rb +43 -6
- data/spec/unit/cookbook/syntax_check_spec.rb +8 -2
- data/spec/unit/cookbook_loader_spec.rb +4 -2
- data/spec/unit/cookbook_version_spec.rb +83 -2
- data/spec/unit/data_bag_item_spec.rb +5 -1
- data/spec/unit/data_bag_spec.rb +6 -1
- data/spec/unit/dsl/data_query_spec.rb +8 -110
- data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +95 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +16 -23
- data/spec/unit/environment_spec.rb +6 -2
- data/spec/unit/exceptions_spec.rb +6 -0
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +16 -15
- data/spec/unit/json_compat_spec.rb +12 -2
- data/spec/unit/knife/bootstrap_spec.rb +16 -63
- data/spec/unit/knife/cookbook_site_share_spec.rb +59 -6
- data/spec/unit/knife/core/bootstrap_context_spec.rb +8 -37
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +28 -0
- data/spec/unit/knife/data_bag_create_spec.rb +63 -71
- data/spec/unit/knife/data_bag_edit_spec.rb +83 -49
- data/spec/unit/knife/data_bag_from_file_spec.rb +104 -126
- data/spec/unit/knife/data_bag_secret_options_spec.rb +165 -0
- data/spec/unit/knife/data_bag_show_spec.rb +74 -72
- data/spec/unit/knife/environment_from_file_spec.rb +3 -2
- data/spec/unit/knife/ssl_check_spec.rb +46 -1
- data/spec/unit/knife/status_spec.rb +1 -2
- data/spec/unit/knife_spec.rb +18 -1
- data/spec/unit/lwrp_spec.rb +29 -8
- data/spec/unit/mixin/homebrew_user_spec.rb +100 -0
- data/spec/unit/node_map_spec.rb +155 -0
- data/spec/unit/node_spec.rb +11 -0
- data/spec/unit/platform/query_helpers_spec.rb +23 -0
- data/spec/unit/platform_spec.rb +23 -0
- data/spec/unit/provider/breakpoint_spec.rb +9 -9
- data/spec/unit/provider/cookbook_file/content_spec.rb +3 -3
- data/spec/unit/provider/cookbook_file_spec.rb +1 -1
- data/spec/unit/provider/cron/unix_spec.rb +78 -60
- data/spec/unit/provider/cron_spec.rb +175 -175
- data/spec/unit/provider/deploy/revision_spec.rb +22 -21
- data/spec/unit/provider/deploy/timestamped_spec.rb +3 -3
- data/spec/unit/provider/deploy_spec.rb +231 -230
- data/spec/unit/provider/directory_spec.rb +55 -55
- data/spec/unit/provider/dsc_script_spec.rb +174 -0
- data/spec/unit/provider/env/windows_spec.rb +70 -34
- data/spec/unit/provider/env_spec.rb +95 -49
- data/spec/unit/provider/erl_call_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +43 -27
- data/spec/unit/provider/file/content_spec.rb +9 -9
- data/spec/unit/provider/file_spec.rb +1 -1
- data/spec/unit/provider/git_spec.rb +221 -159
- data/spec/unit/provider/group/dscl_spec.rb +64 -63
- data/spec/unit/provider/group/gpasswd_spec.rb +14 -14
- data/spec/unit/provider/group/groupadd_spec.rb +33 -33
- data/spec/unit/provider/group/groupmod_spec.rb +23 -23
- data/spec/unit/provider/group/pw_spec.rb +21 -21
- data/spec/unit/provider/group/usermod_spec.rb +20 -20
- data/spec/unit/provider/group/windows_spec.rb +15 -15
- data/spec/unit/provider/group_spec.rb +76 -76
- data/spec/unit/provider/http_request_spec.rb +30 -30
- data/spec/unit/provider/ifconfig/aix_spec.rb +20 -20
- data/spec/unit/provider/ifconfig/debian_spec.rb +25 -9
- data/spec/unit/provider/ifconfig/redhat_spec.rb +13 -13
- data/spec/unit/provider/ifconfig_spec.rb +43 -43
- data/spec/unit/provider/link_spec.rb +60 -60
- data/spec/unit/provider/log_spec.rb +0 -4
- data/spec/unit/provider/mdadm_spec.rb +23 -23
- data/spec/unit/provider/mount/aix_spec.rb +17 -17
- data/spec/unit/provider/mount/mount_spec.rb +115 -119
- data/spec/unit/provider/mount/solaris_spec.rb +72 -72
- data/spec/unit/provider/mount/windows_spec.rb +24 -24
- data/spec/unit/provider/ohai_spec.rb +11 -11
- data/spec/unit/provider/package/aix_spec.rb +34 -34
- data/spec/unit/provider/package/apt_spec.rb +36 -36
- data/spec/unit/provider/package/dpkg_spec.rb +27 -27
- data/spec/unit/provider/package/easy_install_spec.rb +16 -16
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +53 -53
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +24 -24
- data/spec/unit/provider/package/freebsd/port_spec.rb +45 -35
- data/spec/unit/provider/package/homebrew_spec.rb +266 -0
- data/spec/unit/provider/package/ips_spec.rb +34 -34
- data/spec/unit/provider/package/macports_spec.rb +49 -49
- data/spec/unit/provider/package/pacman_spec.rb +35 -39
- data/spec/unit/provider/package/paludis_spec.rb +20 -20
- data/spec/unit/provider/package/portage_spec.rb +38 -38
- data/spec/unit/provider/package/rpm_spec.rb +29 -29
- data/spec/unit/provider/package/rubygems_spec.rb +284 -270
- data/spec/unit/provider/package/smartos_spec.rb +15 -15
- data/spec/unit/provider/package/solaris_spec.rb +35 -35
- data/spec/unit/provider/package/windows/msi_spec.rb +3 -3
- data/spec/unit/provider/package/windows_spec.rb +6 -6
- data/spec/unit/provider/package/yum_spec.rb +416 -416
- data/spec/unit/provider/package/zypper_spec.rb +47 -47
- data/spec/unit/provider/package_spec.rb +107 -107
- data/spec/unit/provider/powershell_spec.rb +1 -1
- data/spec/unit/provider/registry_key_spec.rb +61 -61
- data/spec/unit/provider/remote_directory_spec.rb +36 -36
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +24 -24
- data/spec/unit/provider/remote_file/content_spec.rb +45 -45
- data/spec/unit/provider/remote_file/fetcher_spec.rb +9 -9
- data/spec/unit/provider/remote_file/ftp_spec.rb +32 -32
- data/spec/unit/provider/remote_file/http_spec.rb +44 -44
- data/spec/unit/provider/remote_file/local_file_spec.rb +9 -9
- data/spec/unit/provider/remote_file_spec.rb +3 -3
- data/spec/unit/provider/route_spec.rb +63 -63
- data/spec/unit/provider/ruby_block_spec.rb +4 -4
- data/spec/unit/provider/script_spec.rb +12 -12
- data/spec/unit/provider/service/aix_service_spec.rb +181 -0
- data/spec/unit/provider/service/aixinit_service_spec.rb +269 -0
- data/spec/unit/provider/service/arch_service_spec.rb +48 -48
- data/spec/unit/provider/service/debian_service_spec.rb +40 -40
- data/spec/unit/provider/service/gentoo_service_spec.rb +28 -28
- data/spec/unit/provider/service/init_service_spec.rb +39 -39
- data/spec/unit/provider/service/insserv_service_spec.rb +8 -8
- data/spec/unit/provider/service/invokercd_service_spec.rb +35 -35
- data/spec/unit/provider/service/macosx_spec.rb +49 -49
- data/spec/unit/provider/service/redhat_spec.rb +27 -27
- data/spec/unit/provider/service/simple_service_spec.rb +28 -28
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +43 -46
- data/spec/unit/provider/service/systemd_service_spec.rb +63 -63
- data/spec/unit/provider/service/upstart_service_spec.rb +78 -78
- data/spec/unit/provider/service/windows_spec.rb +92 -92
- data/spec/unit/provider/service_spec.rb +40 -40
- data/spec/unit/provider/subversion_spec.rb +80 -80
- data/spec/unit/provider/template/content_spec.rb +9 -9
- data/spec/unit/provider/template_spec.rb +6 -6
- data/spec/unit/provider/user/dscl_spec.rb +170 -167
- data/spec/unit/provider/user/pw_spec.rb +48 -48
- data/spec/unit/provider/user/solaris_spec.rb +8 -8
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_spec.rb +26 -26
- data/spec/unit/provider/user_spec.rb +72 -72
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +4 -4
- data/spec/unit/provider_resolver_spec.rb +387 -0
- data/spec/unit/recipe_spec.rb +33 -12
- data/spec/unit/resource/apt_package_spec.rb +10 -13
- data/spec/unit/resource/bash_spec.rb +4 -4
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/breakpoint_spec.rb +11 -7
- data/spec/unit/resource/chef_gem_spec.rb +8 -15
- data/spec/unit/resource/conditional_action_not_nothing_spec.rb +2 -2
- data/spec/unit/resource/conditional_spec.rb +35 -16
- data/spec/unit/resource/cookbook_file_spec.rb +13 -13
- data/spec/unit/resource/cron_spec.rb +37 -37
- data/spec/unit/resource/csh_spec.rb +4 -4
- data/spec/unit/resource/deploy_revision_spec.rb +13 -18
- data/spec/unit/resource/deploy_spec.rb +60 -55
- data/spec/unit/resource/directory_spec.rb +18 -18
- data/spec/unit/resource/dpkg_package_spec.rb +8 -14
- data/spec/unit/resource/dsc_script_spec.rb +98 -0
- data/spec/unit/resource/easy_install_package_spec.rb +9 -18
- data/spec/unit/resource/env_spec.rb +12 -12
- data/spec/unit/resource/erl_call_spec.rb +11 -11
- data/spec/unit/resource/execute_spec.rb +5 -0
- data/spec/unit/resource/file_spec.rb +29 -29
- data/spec/unit/resource/freebsd_package_spec.rb +11 -12
- data/spec/unit/resource/gem_package_spec.rb +8 -15
- data/spec/unit/resource/git_spec.rb +12 -8
- data/spec/unit/resource/group_spec.rb +27 -27
- data/spec/unit/resource/homebrew_package_spec.rb +50 -0
- data/spec/unit/resource/http_request_spec.rb +6 -6
- data/spec/unit/resource/ifconfig_spec.rb +8 -8
- data/spec/unit/resource/ips_package_spec.rb +10 -13
- data/spec/unit/resource/link_spec.rb +25 -25
- data/spec/unit/resource/log_spec.rb +9 -9
- data/spec/unit/resource/macports_package_spec.rb +8 -13
- data/spec/unit/resource/mdadm_spec.rb +18 -18
- data/spec/unit/resource/mount_spec.rb +45 -45
- data/spec/unit/resource/ohai_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +12 -12
- data/spec/unit/resource/pacman_package_spec.rb +8 -14
- data/spec/unit/resource/perl_spec.rb +4 -4
- data/spec/unit/resource/portage_package_spec.rb +3 -3
- data/spec/unit/resource/powershell_spec.rb +7 -7
- data/spec/unit/resource/python_spec.rb +4 -4
- data/spec/unit/resource/registry_key_spec.rb +32 -32
- data/spec/unit/resource/remote_directory_spec.rb +17 -17
- data/spec/unit/resource/remote_file_spec.rb +41 -41
- data/spec/unit/resource/route_spec.rb +19 -19
- data/spec/unit/resource/rpm_package_spec.rb +9 -13
- data/spec/unit/resource/ruby_block_spec.rb +8 -8
- data/spec/unit/resource/ruby_spec.rb +4 -4
- data/spec/unit/resource/scm_spec.rb +40 -40
- data/spec/unit/resource/script_spec.rb +2 -2
- data/spec/unit/resource/service_spec.rb +37 -47
- data/spec/unit/resource/smartos_package_spec.rb +10 -15
- data/spec/unit/resource/solaris_package_spec.rb +13 -28
- data/spec/unit/resource/subversion_spec.rb +16 -12
- data/spec/unit/resource/template_spec.rb +35 -35
- data/spec/unit/resource/timestamped_deploy_spec.rb +30 -4
- data/spec/unit/resource/user_spec.rb +23 -23
- data/spec/unit/resource/windows_package_spec.rb +17 -10
- data/spec/unit/resource/windows_service_spec.rb +9 -6
- data/spec/unit/resource/yum_package_spec.rb +16 -21
- data/spec/unit/resource_collection/resource_list_spec.rb +137 -0
- data/spec/unit/resource_collection/resource_set_spec.rb +199 -0
- data/spec/unit/resource_collection_spec.rb +73 -92
- data/spec/unit/resource_definition_spec.rb +38 -40
- data/spec/unit/resource_reporter_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +68 -33
- data/spec/unit/rest_spec.rb +83 -76
- data/spec/unit/role_spec.rb +5 -0
- data/spec/unit/run_list_spec.rb +5 -1
- data/spec/unit/runner_spec.rb +245 -238
- data/spec/unit/shell/shell_ext_spec.rb +1 -1
- data/spec/unit/user_spec.rb +5 -1
- data/spec/unit/util/dsc/configuration_generator_spec.rb +171 -0
- data/spec/unit/util/dsc/lcm_output_parser_spec.rb +169 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +139 -0
- data/spec/unit/util/path_helper_spec.rb +23 -1
- data/spec/unit/util/powershell/cmdlet_spec.rb +106 -0
- data/spec/unit/workstation_config_loader_spec.rb +1 -1
- metadata +303 -196
- checksums.yaml +0 -7
- data/distro/README +0 -2
- data/distro/arch/etc/conf.d/chef-client.conf +0 -5
- data/distro/arch/etc/conf.d/chef-expander.conf +0 -8
- data/distro/arch/etc/conf.d/chef-server-webui.conf +0 -10
- data/distro/arch/etc/conf.d/chef-server.conf +0 -10
- data/distro/arch/etc/conf.d/chef-solr.conf +0 -8
- data/distro/arch/etc/rc.d/chef-client +0 -90
- data/distro/arch/etc/rc.d/chef-expander +0 -78
- data/distro/arch/etc/rc.d/chef-server +0 -78
- data/distro/arch/etc/rc.d/chef-server-webui +0 -78
- data/distro/arch/etc/rc.d/chef-solr +0 -78
- data/distro/debian/etc/default/chef-client +0 -4
- data/distro/debian/etc/default/chef-expander +0 -8
- data/distro/debian/etc/default/chef-server +0 -9
- data/distro/debian/etc/default/chef-server-webui +0 -9
- data/distro/debian/etc/default/chef-solr +0 -8
- data/distro/debian/etc/init.d/chef-client +0 -212
- data/distro/debian/etc/init.d/chef-expander +0 -176
- data/distro/debian/etc/init.d/chef-server +0 -122
- data/distro/debian/etc/init.d/chef-server-webui +0 -123
- data/distro/debian/etc/init.d/chef-solr +0 -176
- data/distro/debian/etc/init/chef-client.conf +0 -17
- data/distro/debian/etc/init/chef-expander.conf +0 -17
- data/distro/debian/etc/init/chef-server-webui.conf +0 -17
- data/distro/debian/etc/init/chef-server.conf +0 -17
- data/distro/debian/etc/init/chef-solr.conf +0 -17
- data/distro/redhat/etc/init.d/chef-client +0 -121
- data/distro/redhat/etc/init.d/chef-expander +0 -104
- data/distro/redhat/etc/init.d/chef-server +0 -112
- data/distro/redhat/etc/init.d/chef-server-webui +0 -112
- data/distro/redhat/etc/init.d/chef-solr +0 -104
- data/distro/redhat/etc/logrotate.d/chef-client +0 -8
- data/distro/redhat/etc/logrotate.d/chef-expander +0 -8
- data/distro/redhat/etc/logrotate.d/chef-server +0 -8
- data/distro/redhat/etc/logrotate.d/chef-server-webui +0 -8
- data/distro/redhat/etc/logrotate.d/chef-solr +0 -8
- data/distro/redhat/etc/sysconfig/chef-client +0 -15
- data/distro/redhat/etc/sysconfig/chef-expander +0 -7
- data/distro/redhat/etc/sysconfig/chef-server +0 -14
- data/distro/redhat/etc/sysconfig/chef-server-webui +0 -14
- data/distro/redhat/etc/sysconfig/chef-solr +0 -8
- data/distro/windows/service_manager.rb +0 -20
- data/lib/chef/resource_platform_map.rb +0 -151
- data/spec/support/shared/matchers.rb +0 -17
- data/spec/unit/resource_platform_map_spec.rb +0 -164
@@ -28,12 +28,12 @@ describe Chef::Provider::CookbookFile::Content do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "prefers the explicit cookbook name on the resource to the implicit one" do
|
31
|
-
new_resource.
|
32
|
-
content.send(:resource_cookbook).
|
31
|
+
allow(new_resource).to receive(:cookbook).and_return('nginx')
|
32
|
+
expect(content.send(:resource_cookbook)).to eq('nginx')
|
33
33
|
end
|
34
34
|
|
35
35
|
it "falls back to the implicit cookbook name on the resource" do
|
36
|
-
content.send(:resource_cookbook).
|
36
|
+
expect(content.send(:resource_cookbook)).to eq('apache2')
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
@@ -21,26 +21,34 @@
|
|
21
21
|
require 'spec_helper'
|
22
22
|
|
23
23
|
describe Chef::Provider::Cron::Unix do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
|
25
|
+
subject(:provider) { Chef::Provider::Cron::Unix.new(new_resource, run_context) }
|
26
|
+
|
27
|
+
let(:username) { "root" }
|
28
|
+
|
29
|
+
let(:node) { Chef::Node.new }
|
30
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
31
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
32
|
+
let(:new_resource) do
|
33
|
+
Chef::Resource::Cron.new("cronhole some stuff").tap do |resource|
|
34
|
+
resource.user username
|
35
|
+
resource.minute "30"
|
36
|
+
resource.command "/bin/true"
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
let(:status) { double('Process::Status', :exitstatus => exitstatus) }
|
41
|
+
let(:exitstatus) { 0 }
|
42
|
+
let(:shell_out) { double('Mixlib::ShellOut', :status => status, :stdout => stdout, :stderr => stderr) }
|
43
|
+
|
44
|
+
it "is a Chef::Provider:Cron" do
|
45
|
+
expect(provider).to be_a(Chef::Provider::Cron)
|
38
46
|
end
|
39
47
|
|
40
48
|
describe "read_crontab" do
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
let(:stderr) { "" }
|
50
|
+
let(:stdout) do
|
51
|
+
String.new(<<-CRONTAB)
|
44
52
|
0 2 * * * /some/other/command
|
45
53
|
|
46
54
|
# Chef Name: something else
|
@@ -48,74 +56,84 @@ describe Chef::Provider::Cron::Unix do
|
|
48
56
|
|
49
57
|
# Another comment
|
50
58
|
CRONTAB
|
51
|
-
|
59
|
+
end
|
60
|
+
|
61
|
+
before do
|
62
|
+
allow(Chef::Log).to receive(:debug)
|
63
|
+
allow(shell_out).to receive(:format_for_exception).and_return("formatted command output")
|
64
|
+
allow(provider).to receive(:shell_out).with('/usr/bin/crontab -l', :user => username).and_return(shell_out)
|
52
65
|
end
|
53
66
|
|
54
67
|
it "should call crontab -l with the user" do
|
55
|
-
|
56
|
-
|
68
|
+
provider.send(:read_crontab)
|
69
|
+
expect(provider).to have_received(:shell_out).with('/usr/bin/crontab -l', :user => username)
|
57
70
|
end
|
58
71
|
|
59
72
|
it "should return the contents of the crontab" do
|
60
|
-
crontab =
|
61
|
-
crontab.
|
62
|
-
|
73
|
+
crontab = provider.send(:read_crontab)
|
74
|
+
expect(crontab).to eq(stdout)
|
75
|
+
end
|
63
76
|
|
64
|
-
|
65
|
-
|
77
|
+
context "when the user has no crontab" do
|
78
|
+
let(:exitstatus) { 1 }
|
66
79
|
|
67
|
-
|
68
|
-
|
69
|
-
|
80
|
+
it "should return nil if the user has no crontab" do
|
81
|
+
expect(provider.send(:read_crontab)).to be_nil
|
82
|
+
end
|
70
83
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
84
|
+
it "logs the crontab output to debug" do
|
85
|
+
provider.send(:read_crontab)
|
86
|
+
expect(Chef::Log).to have_received(:debug).with("formatted command output")
|
87
|
+
end
|
75
88
|
end
|
76
89
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
90
|
+
context "when any other error occurs" do
|
91
|
+
let (:exitstatus) { 2 }
|
92
|
+
|
93
|
+
it "should raise an exception if another error occurs" do
|
94
|
+
expect {
|
95
|
+
provider.send(:read_crontab)
|
96
|
+
}.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, exit: 2")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "logs the crontab output to debug" do
|
100
|
+
provider.send(:read_crontab) rescue nil
|
101
|
+
expect(Chef::Log).to have_received(:debug).with("formatted command output")
|
102
|
+
end
|
83
103
|
end
|
84
104
|
end
|
85
105
|
|
86
106
|
describe "write_crontab" do
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
107
|
+
let(:stdout) { "" }
|
108
|
+
let(:stderr) { "" }
|
109
|
+
let(:tempfile) { double("foo", :path => "/tmp/foo", :close => true) }
|
110
|
+
|
111
|
+
before do
|
112
|
+
expect(Tempfile).to receive(:new).and_return(tempfile)
|
113
|
+
expect(tempfile).to receive(:flush)
|
114
|
+
expect(tempfile).to receive(:chmod).with(420)
|
115
|
+
expect(tempfile).to receive(:close!)
|
116
|
+
allow(tempfile).to receive(:<<)
|
117
|
+
allow(provider).to receive(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username).and_return(shell_out)
|
95
118
|
end
|
96
119
|
|
97
120
|
it "should call crontab for the user" do
|
98
|
-
|
99
|
-
|
100
|
-
@provider.send(:write_crontab, "Foo")
|
121
|
+
provider.send(:write_crontab, "Foo")
|
122
|
+
expect(provider).to have_received(:shell_out).with("/usr/bin/crontab #{tempfile.path}", :user => username)
|
101
123
|
end
|
102
124
|
|
103
125
|
it "should call crontab with a file containing the crontab" do
|
104
|
-
|
105
|
-
|
106
|
-
$1.should == "/tmp/foo"
|
107
|
-
@status
|
108
|
-
end
|
109
|
-
@tempfile.should_receive(:<<).with("Foo\n# wibble\n wah!!")
|
110
|
-
@provider.send(:write_crontab, "Foo\n# wibble\n wah!!")
|
126
|
+
provider.send(:write_crontab, "Foo\n# wibble\n wah!!")
|
127
|
+
expect(tempfile).to have_received(:<<).with("Foo\n# wibble\n wah!!")
|
111
128
|
end
|
112
129
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
130
|
+
context "when writing the crontab fails" do
|
131
|
+
let(:exitstatus) { 1 }
|
132
|
+
it "should raise an exception if the command returns non-zero" do
|
133
|
+
expect {
|
134
|
+
provider.send(:write_crontab, "Foo")
|
135
|
+
}.to raise_error(Chef::Exceptions::Cron, /Error updating state of #{new_resource.name}, exit: 1/)
|
136
|
+
end
|
119
137
|
end
|
120
138
|
end
|
121
139
|
end
|
@@ -35,7 +35,7 @@ describe Chef::Provider::Cron do
|
|
35
35
|
|
36
36
|
context "with a matching entry in the user's crontab" do
|
37
37
|
before :each do
|
38
|
-
@provider.
|
38
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
39
39
|
0 2 * * * /some/other/command
|
40
40
|
|
41
41
|
# Chef Name: cronhole some stuff
|
@@ -49,18 +49,18 @@ CRONTAB
|
|
49
49
|
|
50
50
|
it "should set cron_exists" do
|
51
51
|
@provider.load_current_resource
|
52
|
-
@provider.cron_exists.
|
53
|
-
@provider.cron_empty.
|
52
|
+
expect(@provider.cron_exists).to eq(true)
|
53
|
+
expect(@provider.cron_empty).to eq(false)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should pull the details out of the cron line" do
|
57
57
|
cron = @provider.load_current_resource
|
58
|
-
cron.time.
|
59
|
-
cron.command.
|
58
|
+
expect(cron.time).to eq(:reboot)
|
59
|
+
expect(cron.command).to eq('/bin/true param1 param2')
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should pull env vars out" do
|
63
|
-
@provider.
|
63
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
64
64
|
0 2 * * * /some/other/command
|
65
65
|
|
66
66
|
# Chef Name: cronhole some stuff
|
@@ -75,16 +75,16 @@ HOME=/home/foo
|
|
75
75
|
# Another comment
|
76
76
|
CRONTAB
|
77
77
|
cron = @provider.load_current_resource
|
78
|
-
cron.mailto.
|
79
|
-
cron.shell.
|
80
|
-
cron.path.
|
81
|
-
cron.home.
|
82
|
-
cron.time.
|
83
|
-
cron.command.
|
78
|
+
expect(cron.mailto).to eq('foo@example.com')
|
79
|
+
expect(cron.shell).to eq('/bin/foosh')
|
80
|
+
expect(cron.path).to eq('/bin:/foo')
|
81
|
+
expect(cron.home).to eq('/home/foo')
|
82
|
+
expect(cron.time).to eq(:reboot)
|
83
|
+
expect(cron.command).to eq('/bin/true param1 param2')
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should parse and load generic and standard environment variables from cron entry" do
|
87
|
-
@provider.
|
87
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
88
88
|
# Chef Name: cronhole some stuff
|
89
89
|
MAILTO=warn@example.com
|
90
90
|
TEST=lol
|
@@ -93,12 +93,12 @@ FLAG=1
|
|
93
93
|
CRONTAB
|
94
94
|
cron = @provider.load_current_resource
|
95
95
|
|
96
|
-
cron.mailto.
|
97
|
-
cron.environment.
|
96
|
+
expect(cron.mailto).to eq("warn@example.com")
|
97
|
+
expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"})
|
98
98
|
end
|
99
99
|
|
100
100
|
it "should not break with variables that match the cron resource internals" do
|
101
|
-
@provider.
|
101
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
102
102
|
# Chef Name: cronhole some stuff
|
103
103
|
MINUTE=40
|
104
104
|
REBOOT=midnight
|
@@ -108,19 +108,19 @@ ENVIRONMENT=production
|
|
108
108
|
CRONTAB
|
109
109
|
cron = @provider.load_current_resource
|
110
110
|
|
111
|
-
cron.time.
|
112
|
-
cron.environment.
|
111
|
+
expect(cron.time).to eq(:reboot)
|
112
|
+
expect(cron.environment).to eq({"MINUTE" => "40", "REBOOT" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
|
113
113
|
end
|
114
114
|
|
115
115
|
it "should report the match" do
|
116
|
-
Chef::Log.
|
116
|
+
expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
|
117
117
|
@provider.load_current_resource
|
118
118
|
end
|
119
119
|
|
120
120
|
describe "action_create" do
|
121
121
|
before :each do
|
122
|
-
@provider.
|
123
|
-
@provider.
|
122
|
+
allow(@provider).to receive(:write_crontab)
|
123
|
+
allow(@provider).to receive(:read_crontab).and_return(nil)
|
124
124
|
end
|
125
125
|
|
126
126
|
context "when there is no existing crontab" do
|
@@ -130,7 +130,7 @@ CRONTAB
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should create a crontab with the entry" do
|
133
|
-
@provider.
|
133
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
134
134
|
# Chef Name: cronhole some stuff
|
135
135
|
@reboot /bin/true
|
136
136
|
ENDCRON
|
@@ -156,24 +156,24 @@ CRONTAB
|
|
156
156
|
describe "when examining the current system state" do
|
157
157
|
context "with no crontab for the user" do
|
158
158
|
before :each do
|
159
|
-
@provider.
|
159
|
+
allow(@provider).to receive(:read_crontab).and_return(nil)
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should set cron_empty" do
|
163
163
|
@provider.load_current_resource
|
164
|
-
@provider.cron_empty.
|
165
|
-
@provider.cron_exists.
|
164
|
+
expect(@provider.cron_empty).to eq(true)
|
165
|
+
expect(@provider.cron_exists).to eq(false)
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should report an empty crontab" do
|
169
|
-
Chef::Log.
|
169
|
+
expect(Chef::Log).to receive(:debug).with("Cron empty for '#{@new_resource.user}'")
|
170
170
|
@provider.load_current_resource
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
174
|
context "with no matching entry in the user's crontab" do
|
175
175
|
before :each do
|
176
|
-
@provider.
|
176
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
177
177
|
0 2 * * * /some/other/command
|
178
178
|
|
179
179
|
# Chef Name: something else
|
@@ -185,29 +185,29 @@ CRONTAB
|
|
185
185
|
|
186
186
|
it "should not set cron_exists or cron_empty" do
|
187
187
|
@provider.load_current_resource
|
188
|
-
@provider.cron_exists.
|
189
|
-
@provider.cron_empty.
|
188
|
+
expect(@provider.cron_exists).to eq(false)
|
189
|
+
expect(@provider.cron_empty).to eq(false)
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should report no entry found" do
|
193
|
-
Chef::Log.
|
193
|
+
expect(Chef::Log).to receive(:debug).with("Cron '#{@new_resource.name}' not found")
|
194
194
|
@provider.load_current_resource
|
195
195
|
end
|
196
196
|
|
197
197
|
it "should not fail if there's an existing cron with a numerical argument" do
|
198
|
-
@provider.
|
198
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
199
199
|
# Chef Name: foo[bar] (baz)
|
200
200
|
21 */4 * * * some_prog 1234567
|
201
201
|
CRONTAB
|
202
|
-
|
202
|
+
expect {
|
203
203
|
@provider.load_current_resource
|
204
|
-
}.
|
204
|
+
}.not_to raise_error
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
208
|
context "with a matching entry in the user's crontab" do
|
209
209
|
before :each do
|
210
|
-
@provider.
|
210
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
211
211
|
0 2 * * * /some/other/command
|
212
212
|
|
213
213
|
# Chef Name: cronhole some stuff
|
@@ -221,23 +221,23 @@ CRONTAB
|
|
221
221
|
|
222
222
|
it "should set cron_exists" do
|
223
223
|
@provider.load_current_resource
|
224
|
-
@provider.cron_exists.
|
225
|
-
@provider.cron_empty.
|
224
|
+
expect(@provider.cron_exists).to eq(true)
|
225
|
+
expect(@provider.cron_empty).to eq(false)
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should pull the details out of the cron line" do
|
229
229
|
cron = @provider.load_current_resource
|
230
|
-
cron.minute.
|
231
|
-
cron.hour.
|
232
|
-
cron.day.
|
233
|
-
cron.month.
|
234
|
-
cron.weekday.
|
235
|
-
cron.time.
|
236
|
-
cron.command.
|
230
|
+
expect(cron.minute).to eq('*')
|
231
|
+
expect(cron.hour).to eq('5')
|
232
|
+
expect(cron.day).to eq('*')
|
233
|
+
expect(cron.month).to eq('1')
|
234
|
+
expect(cron.weekday).to eq('*')
|
235
|
+
expect(cron.time).to eq(nil)
|
236
|
+
expect(cron.command).to eq('/bin/true param1 param2')
|
237
237
|
end
|
238
238
|
|
239
239
|
it "should pull env vars out" do
|
240
|
-
@provider.
|
240
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
241
241
|
0 2 * * * /some/other/command
|
242
242
|
|
243
243
|
# Chef Name: cronhole some stuff
|
@@ -252,21 +252,21 @@ HOME=/home/foo
|
|
252
252
|
# Another comment
|
253
253
|
CRONTAB
|
254
254
|
cron = @provider.load_current_resource
|
255
|
-
cron.mailto.
|
256
|
-
cron.shell.
|
257
|
-
cron.path.
|
258
|
-
cron.home.
|
259
|
-
cron.minute.
|
260
|
-
cron.hour.
|
261
|
-
cron.day.
|
262
|
-
cron.month.
|
263
|
-
cron.weekday.
|
264
|
-
cron.time.
|
265
|
-
cron.command.
|
255
|
+
expect(cron.mailto).to eq('foo@example.com')
|
256
|
+
expect(cron.shell).to eq('/bin/foosh')
|
257
|
+
expect(cron.path).to eq('/bin:/foo')
|
258
|
+
expect(cron.home).to eq('/home/foo')
|
259
|
+
expect(cron.minute).to eq('*')
|
260
|
+
expect(cron.hour).to eq('5')
|
261
|
+
expect(cron.day).to eq('*')
|
262
|
+
expect(cron.month).to eq('1')
|
263
|
+
expect(cron.weekday).to eq('*')
|
264
|
+
expect(cron.time).to eq(nil)
|
265
|
+
expect(cron.command).to eq('/bin/true param1 param2')
|
266
266
|
end
|
267
267
|
|
268
268
|
it "should parse and load generic and standard environment variables from cron entry" do
|
269
|
-
@provider.
|
269
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
270
270
|
# Chef Name: cronhole some stuff
|
271
271
|
MAILTO=warn@example.com
|
272
272
|
TEST=lol
|
@@ -275,12 +275,12 @@ FLAG=1
|
|
275
275
|
CRONTAB
|
276
276
|
cron = @provider.load_current_resource
|
277
277
|
|
278
|
-
cron.mailto.
|
279
|
-
cron.environment.
|
278
|
+
expect(cron.mailto).to eq("warn@example.com")
|
279
|
+
expect(cron.environment).to eq({"TEST" => "lol", "FLAG" => "1"})
|
280
280
|
end
|
281
281
|
|
282
282
|
it "should not break with variabels that match the cron resource internals" do
|
283
|
-
@provider.
|
283
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
284
284
|
# Chef Name: cronhole some stuff
|
285
285
|
MINUTE=40
|
286
286
|
HOUR=midnight
|
@@ -290,20 +290,20 @@ ENVIRONMENT=production
|
|
290
290
|
CRONTAB
|
291
291
|
cron = @provider.load_current_resource
|
292
292
|
|
293
|
-
cron.minute.
|
294
|
-
cron.hour.
|
295
|
-
cron.environment.
|
293
|
+
expect(cron.minute).to eq('*')
|
294
|
+
expect(cron.hour).to eq('5')
|
295
|
+
expect(cron.environment).to eq({"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"})
|
296
296
|
end
|
297
297
|
|
298
298
|
it "should report the match" do
|
299
|
-
Chef::Log.
|
299
|
+
expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
|
300
300
|
@provider.load_current_resource
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
304
304
|
context "with a matching entry in the user's crontab using month names and weekday names (#CHEF-3178)" do
|
305
305
|
before :each do
|
306
|
-
@provider.
|
306
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
307
307
|
0 2 * * * /some/other/command
|
308
308
|
|
309
309
|
# Chef Name: cronhole some stuff
|
@@ -317,64 +317,64 @@ CRONTAB
|
|
317
317
|
|
318
318
|
it "should set cron_exists" do
|
319
319
|
@provider.load_current_resource
|
320
|
-
@provider.cron_exists.
|
321
|
-
@provider.cron_empty.
|
320
|
+
expect(@provider.cron_exists).to eq(true)
|
321
|
+
expect(@provider.cron_empty).to eq(false)
|
322
322
|
end
|
323
323
|
|
324
324
|
it "should pull the details out of the cron line" do
|
325
325
|
cron = @provider.load_current_resource
|
326
|
-
cron.minute.
|
327
|
-
cron.hour.
|
328
|
-
cron.day.
|
329
|
-
cron.month.
|
330
|
-
cron.weekday.
|
331
|
-
cron.command.
|
326
|
+
expect(cron.minute).to eq('*')
|
327
|
+
expect(cron.hour).to eq('5')
|
328
|
+
expect(cron.day).to eq('*')
|
329
|
+
expect(cron.month).to eq('Jan')
|
330
|
+
expect(cron.weekday).to eq('Mon')
|
331
|
+
expect(cron.command).to eq('/bin/true param1 param2')
|
332
332
|
end
|
333
333
|
|
334
334
|
it "should report the match" do
|
335
|
-
Chef::Log.
|
335
|
+
expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
|
336
336
|
@provider.load_current_resource
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
340
340
|
context "with a matching entry without a crontab line" do
|
341
341
|
it "should set cron_exists and leave current_resource values at defaults" do
|
342
|
-
@provider.
|
342
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
343
343
|
0 2 * * * /some/other/command
|
344
344
|
|
345
345
|
# Chef Name: cronhole some stuff
|
346
346
|
CRONTAB
|
347
347
|
cron = @provider.load_current_resource
|
348
|
-
@provider.cron_exists.
|
349
|
-
cron.minute.
|
350
|
-
cron.hour.
|
351
|
-
cron.day.
|
352
|
-
cron.month.
|
353
|
-
cron.weekday.
|
354
|
-
cron.time.
|
355
|
-
cron.command.
|
348
|
+
expect(@provider.cron_exists).to eq(true)
|
349
|
+
expect(cron.minute).to eq('*')
|
350
|
+
expect(cron.hour).to eq('*')
|
351
|
+
expect(cron.day).to eq('*')
|
352
|
+
expect(cron.month).to eq('*')
|
353
|
+
expect(cron.weekday).to eq('*')
|
354
|
+
expect(cron.time).to eq(nil)
|
355
|
+
expect(cron.command).to eq(nil)
|
356
356
|
end
|
357
357
|
|
358
358
|
it "should not pick up a commented out crontab line" do
|
359
|
-
@provider.
|
359
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
360
360
|
0 2 * * * /some/other/command
|
361
361
|
|
362
362
|
# Chef Name: cronhole some stuff
|
363
363
|
#* 5 * 1 * /bin/true param1 param2
|
364
364
|
CRONTAB
|
365
365
|
cron = @provider.load_current_resource
|
366
|
-
@provider.cron_exists.
|
367
|
-
cron.minute.
|
368
|
-
cron.hour.
|
369
|
-
cron.day.
|
370
|
-
cron.month.
|
371
|
-
cron.weekday.
|
372
|
-
cron.time.
|
373
|
-
cron.command.
|
366
|
+
expect(@provider.cron_exists).to eq(true)
|
367
|
+
expect(cron.minute).to eq('*')
|
368
|
+
expect(cron.hour).to eq('*')
|
369
|
+
expect(cron.day).to eq('*')
|
370
|
+
expect(cron.month).to eq('*')
|
371
|
+
expect(cron.weekday).to eq('*')
|
372
|
+
expect(cron.time).to eq(nil)
|
373
|
+
expect(cron.command).to eq(nil)
|
374
374
|
end
|
375
375
|
|
376
376
|
it "should not pick up a later crontab entry" do
|
377
|
-
@provider.
|
377
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
378
378
|
0 2 * * * /some/other/command
|
379
379
|
|
380
380
|
# Chef Name: cronhole some stuff
|
@@ -385,14 +385,14 @@ CRONTAB
|
|
385
385
|
# Another comment
|
386
386
|
CRONTAB
|
387
387
|
cron = @provider.load_current_resource
|
388
|
-
@provider.cron_exists.
|
389
|
-
cron.minute.
|
390
|
-
cron.hour.
|
391
|
-
cron.day.
|
392
|
-
cron.month.
|
393
|
-
cron.weekday.
|
394
|
-
cron.time.
|
395
|
-
cron.command.
|
388
|
+
expect(@provider.cron_exists).to eq(true)
|
389
|
+
expect(cron.minute).to eq('*')
|
390
|
+
expect(cron.hour).to eq('*')
|
391
|
+
expect(cron.day).to eq('*')
|
392
|
+
expect(cron.month).to eq('*')
|
393
|
+
expect(cron.weekday).to eq('*')
|
394
|
+
expect(cron.time).to eq(nil)
|
395
|
+
expect(cron.command).to eq(nil)
|
396
396
|
end
|
397
397
|
end
|
398
398
|
end
|
@@ -409,35 +409,35 @@ CRONTAB
|
|
409
409
|
[:minute, :hour, :day, :month, :weekday, :command, :mailto, :path, :shell, :home].each do |attribute|
|
410
410
|
it "should return true if #{attribute} doesn't match" do
|
411
411
|
@new_resource.send(attribute, "something_else")
|
412
|
-
@provider.cron_different
|
412
|
+
expect(@provider.cron_different?).to eql(true)
|
413
413
|
end
|
414
414
|
end
|
415
415
|
|
416
416
|
it "should return true if special time string doesn't match" do
|
417
417
|
@new_resource.send(:time, :reboot)
|
418
|
-
@provider.cron_different
|
418
|
+
expect(@provider.cron_different?).to eql(true)
|
419
419
|
end
|
420
420
|
|
421
421
|
it "should return true if environment doesn't match" do
|
422
422
|
@new_resource.environment "FOO" => "something_else"
|
423
|
-
@provider.cron_different
|
423
|
+
expect(@provider.cron_different?).to eql(true)
|
424
424
|
end
|
425
425
|
|
426
426
|
it "should return true if mailto doesn't match" do
|
427
427
|
@current_resource.mailto "foo@bar.com"
|
428
428
|
@new_resource.mailto(nil)
|
429
|
-
@provider.cron_different
|
429
|
+
expect(@provider.cron_different?).to eql(true)
|
430
430
|
end
|
431
431
|
|
432
432
|
it "should return false if the objects are identical" do
|
433
|
-
@provider.cron_different
|
433
|
+
expect(@provider.cron_different?).to eq(false)
|
434
434
|
end
|
435
435
|
end
|
436
436
|
|
437
437
|
describe "action_create" do
|
438
438
|
before :each do
|
439
|
-
@provider.
|
440
|
-
@provider.
|
439
|
+
allow(@provider).to receive(:write_crontab)
|
440
|
+
allow(@provider).to receive(:read_crontab).and_return(nil)
|
441
441
|
end
|
442
442
|
|
443
443
|
context "when there is no existing crontab" do
|
@@ -447,7 +447,7 @@ CRONTAB
|
|
447
447
|
end
|
448
448
|
|
449
449
|
it "should create a crontab with the entry" do
|
450
|
-
@provider.
|
450
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
451
451
|
# Chef Name: cronhole some stuff
|
452
452
|
30 * * * * /bin/true
|
453
453
|
ENDCRON
|
@@ -460,7 +460,7 @@ CRONTAB
|
|
460
460
|
@new_resource.shell '/bin/foosh'
|
461
461
|
@new_resource.home '/home/foo'
|
462
462
|
@new_resource.environment "TEST" => "LOL"
|
463
|
-
@provider.
|
463
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
464
464
|
# Chef Name: cronhole some stuff
|
465
465
|
MAILTO=foo@example.com
|
466
466
|
PATH=/usr/bin:/my/custom/path
|
@@ -474,11 +474,11 @@ TEST=LOL
|
|
474
474
|
|
475
475
|
it "should mark the resource as updated" do
|
476
476
|
@provider.run_action(:create)
|
477
|
-
@new_resource.
|
477
|
+
expect(@new_resource).to be_updated_by_last_action
|
478
478
|
end
|
479
479
|
|
480
480
|
it "should log the action" do
|
481
|
-
Chef::Log.
|
481
|
+
expect(Chef::Log).to receive(:info).with("cron[cronhole some stuff] added crontab entry")
|
482
482
|
@provider.run_action(:create)
|
483
483
|
end
|
484
484
|
end
|
@@ -486,7 +486,7 @@ TEST=LOL
|
|
486
486
|
context "when there is a crontab with no matching section" do
|
487
487
|
before :each do
|
488
488
|
@provider.cron_exists = false
|
489
|
-
@provider.
|
489
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
490
490
|
0 2 * * * /some/other/command
|
491
491
|
|
492
492
|
# Chef Name: something else
|
@@ -497,7 +497,7 @@ TEST=LOL
|
|
497
497
|
end
|
498
498
|
|
499
499
|
it "should add the entry to the crontab" do
|
500
|
-
@provider.
|
500
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
501
501
|
0 2 * * * /some/other/command
|
502
502
|
|
503
503
|
# Chef Name: something else
|
@@ -516,7 +516,7 @@ TEST=LOL
|
|
516
516
|
@new_resource.shell '/bin/foosh'
|
517
517
|
@new_resource.home '/home/foo'
|
518
518
|
@new_resource.environment "TEST" => "LOL"
|
519
|
-
@provider.
|
519
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
520
520
|
0 2 * * * /some/other/command
|
521
521
|
|
522
522
|
# Chef Name: something else
|
@@ -536,11 +536,11 @@ TEST=LOL
|
|
536
536
|
|
537
537
|
it "should mark the resource as updated" do
|
538
538
|
@provider.run_action(:create)
|
539
|
-
@new_resource.
|
539
|
+
expect(@new_resource).to be_updated_by_last_action
|
540
540
|
end
|
541
541
|
|
542
542
|
it "should log the action" do
|
543
|
-
Chef::Log.
|
543
|
+
expect(Chef::Log).to receive(:info).with("cron[cronhole some stuff] added crontab entry")
|
544
544
|
@provider.run_action(:create)
|
545
545
|
end
|
546
546
|
end
|
@@ -548,8 +548,8 @@ TEST=LOL
|
|
548
548
|
context "when there is a crontab with a matching but different section" do
|
549
549
|
before :each do
|
550
550
|
@provider.cron_exists = true
|
551
|
-
@provider.
|
552
|
-
@provider.
|
551
|
+
allow(@provider).to receive(:cron_different?).and_return(true)
|
552
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
553
553
|
0 2 * * * /some/other/command
|
554
554
|
|
555
555
|
# Chef Name: cronhole some stuff
|
@@ -562,7 +562,7 @@ TEST=LOL
|
|
562
562
|
end
|
563
563
|
|
564
564
|
it "should update the crontab entry" do
|
565
|
-
@provider.
|
565
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
566
566
|
0 2 * * * /some/other/command
|
567
567
|
|
568
568
|
# Chef Name: cronhole some stuff
|
@@ -581,7 +581,7 @@ TEST=LOL
|
|
581
581
|
@new_resource.shell '/bin/foosh'
|
582
582
|
@new_resource.home '/home/foo'
|
583
583
|
@new_resource.environment "TEST" => "LOL"
|
584
|
-
@provider.
|
584
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
585
585
|
0 2 * * * /some/other/command
|
586
586
|
|
587
587
|
# Chef Name: cronhole some stuff
|
@@ -601,11 +601,11 @@ TEST=LOL
|
|
601
601
|
|
602
602
|
it "should mark the resource as updated" do
|
603
603
|
@provider.run_action(:create)
|
604
|
-
@new_resource.
|
604
|
+
expect(@new_resource).to be_updated_by_last_action
|
605
605
|
end
|
606
606
|
|
607
607
|
it "should log the action" do
|
608
|
-
Chef::Log.
|
608
|
+
expect(Chef::Log).to receive(:info).with("cron[cronhole some stuff] updated crontab entry")
|
609
609
|
@provider.run_action(:create)
|
610
610
|
end
|
611
611
|
end
|
@@ -613,16 +613,16 @@ TEST=LOL
|
|
613
613
|
context "when there is a crontab with a matching section with no crontab line in it" do
|
614
614
|
before :each do
|
615
615
|
@provider.cron_exists = true
|
616
|
-
@provider.
|
616
|
+
allow(@provider).to receive(:cron_different?).and_return(true)
|
617
617
|
end
|
618
618
|
|
619
619
|
it "should add the crontab to the entry" do
|
620
|
-
@provider.
|
620
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
621
621
|
0 2 * * * /some/other/command
|
622
622
|
|
623
623
|
# Chef Name: cronhole some stuff
|
624
624
|
CRONTAB
|
625
|
-
@provider.
|
625
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
626
626
|
0 2 * * * /some/other/command
|
627
627
|
|
628
628
|
# Chef Name: cronhole some stuff
|
@@ -632,7 +632,7 @@ TEST=LOL
|
|
632
632
|
end
|
633
633
|
|
634
634
|
it "should not blat any following entries" do
|
635
|
-
@provider.
|
635
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
636
636
|
0 2 * * * /some/other/command
|
637
637
|
|
638
638
|
# Chef Name: cronhole some stuff
|
@@ -642,7 +642,7 @@ TEST=LOL
|
|
642
642
|
|
643
643
|
# Another comment
|
644
644
|
CRONTAB
|
645
|
-
@provider.
|
645
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
646
646
|
0 2 * * * /some/other/command
|
647
647
|
|
648
648
|
# Chef Name: cronhole some stuff
|
@@ -657,7 +657,7 @@ TEST=LOL
|
|
657
657
|
end
|
658
658
|
|
659
659
|
it "should handle env vars with no crontab" do
|
660
|
-
@provider.
|
660
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
661
661
|
0 2 * * * /some/other/command
|
662
662
|
|
663
663
|
# Chef Name: cronhole some stuff
|
@@ -675,7 +675,7 @@ HOME=/home/foo
|
|
675
675
|
@new_resource.path '/usr/bin:/my/custom/path'
|
676
676
|
@new_resource.shell '/bin/foosh'
|
677
677
|
@new_resource.home '/home/foo'
|
678
|
-
@provider.
|
678
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
679
679
|
0 2 * * * /some/other/command
|
680
680
|
|
681
681
|
# Chef Name: cronhole some stuff
|
@@ -697,8 +697,8 @@ HOME=/home/foo
|
|
697
697
|
context "when there is a crontab with a matching and identical section" do
|
698
698
|
before :each do
|
699
699
|
@provider.cron_exists = true
|
700
|
-
@provider.
|
701
|
-
@provider.
|
700
|
+
allow(@provider).to receive(:cron_different?).and_return(false)
|
701
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
702
702
|
0 2 * * * /some/other/command
|
703
703
|
|
704
704
|
# Chef Name: cronhole some stuff
|
@@ -709,18 +709,18 @@ CRONTAB
|
|
709
709
|
end
|
710
710
|
|
711
711
|
it "should not update the crontab" do
|
712
|
-
@provider.
|
712
|
+
expect(@provider).not_to receive(:write_crontab)
|
713
713
|
@provider.run_action(:create)
|
714
714
|
end
|
715
715
|
|
716
716
|
it "should not mark the resource as updated" do
|
717
717
|
@provider.run_action(:create)
|
718
|
-
@new_resource.
|
718
|
+
expect(@new_resource).not_to be_updated_by_last_action
|
719
719
|
end
|
720
720
|
|
721
721
|
it "should log nothing changed" do
|
722
|
-
Chef::Log.
|
723
|
-
Chef::Log.
|
722
|
+
expect(Chef::Log).to receive(:debug).with("Found cron '#{@new_resource.name}'")
|
723
|
+
expect(Chef::Log).to receive(:debug).with("Skipping existing cron entry '#{@new_resource.name}'")
|
724
724
|
@provider.run_action(:create)
|
725
725
|
end
|
726
726
|
end
|
@@ -728,8 +728,8 @@ CRONTAB
|
|
728
728
|
|
729
729
|
describe "action_delete" do
|
730
730
|
before :each do
|
731
|
-
@provider.
|
732
|
-
@provider.
|
731
|
+
allow(@provider).to receive(:write_crontab)
|
732
|
+
allow(@provider).to receive(:read_crontab).and_return(nil)
|
733
733
|
end
|
734
734
|
|
735
735
|
context "when the user's crontab has no matching section" do
|
@@ -738,21 +738,21 @@ CRONTAB
|
|
738
738
|
end
|
739
739
|
|
740
740
|
it "should do nothing" do
|
741
|
-
@provider.
|
742
|
-
Chef::Log.
|
741
|
+
expect(@provider).not_to receive(:write_crontab)
|
742
|
+
expect(Chef::Log).not_to receive(:info)
|
743
743
|
@provider.run_action(:delete)
|
744
744
|
end
|
745
745
|
|
746
746
|
it "should not mark the resource as updated" do
|
747
747
|
@provider.run_action(:delete)
|
748
|
-
@new_resource.
|
748
|
+
expect(@new_resource).not_to be_updated_by_last_action
|
749
749
|
end
|
750
750
|
end
|
751
751
|
|
752
752
|
context "when the user has a crontab with a matching section" do
|
753
753
|
before :each do
|
754
754
|
@provider.cron_exists = true
|
755
|
-
@provider.
|
755
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
756
756
|
0 2 * * * /some/other/command
|
757
757
|
|
758
758
|
# Chef Name: cronhole some stuff
|
@@ -765,7 +765,7 @@ CRONTAB
|
|
765
765
|
end
|
766
766
|
|
767
767
|
it "should remove the entry" do
|
768
|
-
@provider.
|
768
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
769
769
|
0 2 * * * /some/other/command
|
770
770
|
|
771
771
|
# Chef Name: something else
|
@@ -777,7 +777,7 @@ CRONTAB
|
|
777
777
|
end
|
778
778
|
|
779
779
|
it "should remove any env vars with the entry" do
|
780
|
-
@provider.
|
780
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
781
781
|
0 2 * * * /some/other/command
|
782
782
|
|
783
783
|
# Chef Name: cronhole some stuff
|
@@ -789,7 +789,7 @@ FOO=test
|
|
789
789
|
|
790
790
|
# Another comment
|
791
791
|
CRONTAB
|
792
|
-
@provider.
|
792
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
793
793
|
0 2 * * * /some/other/command
|
794
794
|
|
795
795
|
# Chef Name: something else
|
@@ -802,11 +802,11 @@ FOO=test
|
|
802
802
|
|
803
803
|
it "should mark the resource as updated" do
|
804
804
|
@provider.run_action(:delete)
|
805
|
-
@new_resource.
|
805
|
+
expect(@new_resource).to be_updated_by_last_action
|
806
806
|
end
|
807
807
|
|
808
808
|
it "should log the action" do
|
809
|
-
Chef::Log.
|
809
|
+
expect(Chef::Log).to receive(:info).with("#{@new_resource} deleted crontab entry")
|
810
810
|
@provider.run_action(:delete)
|
811
811
|
end
|
812
812
|
end
|
@@ -817,12 +817,12 @@ FOO=test
|
|
817
817
|
end
|
818
818
|
|
819
819
|
it "should remove the section" do
|
820
|
-
@provider.
|
820
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
821
821
|
0 2 * * * /some/other/command
|
822
822
|
|
823
823
|
# Chef Name: cronhole some stuff
|
824
824
|
CRONTAB
|
825
|
-
@provider.
|
825
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
826
826
|
0 2 * * * /some/other/command
|
827
827
|
|
828
828
|
ENDCRON
|
@@ -830,7 +830,7 @@ FOO=test
|
|
830
830
|
end
|
831
831
|
|
832
832
|
it "should not blat following sections" do
|
833
|
-
@provider.
|
833
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
834
834
|
0 2 * * * /some/other/command
|
835
835
|
|
836
836
|
# Chef Name: cronhole some stuff
|
@@ -840,7 +840,7 @@ FOO=test
|
|
840
840
|
|
841
841
|
# Another comment
|
842
842
|
CRONTAB
|
843
|
-
@provider.
|
843
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
844
844
|
0 2 * * * /some/other/command
|
845
845
|
|
846
846
|
#30 * * 3 * /bin/true
|
@@ -853,7 +853,7 @@ FOO=test
|
|
853
853
|
end
|
854
854
|
|
855
855
|
it "should remove any envvars with the section" do
|
856
|
-
@provider.
|
856
|
+
allow(@provider).to receive(:read_crontab).and_return(<<-CRONTAB)
|
857
857
|
0 2 * * * /some/other/command
|
858
858
|
|
859
859
|
# Chef Name: cronhole some stuff
|
@@ -864,7 +864,7 @@ MAILTO=foo@example.com
|
|
864
864
|
|
865
865
|
# Another comment
|
866
866
|
CRONTAB
|
867
|
-
@provider.
|
867
|
+
expect(@provider).to receive(:write_crontab).with(<<-ENDCRON)
|
868
868
|
0 2 * * * /some/other/command
|
869
869
|
|
870
870
|
#30 * * 3 * /bin/true
|
@@ -889,17 +889,17 @@ MAILTO=foo@example.com
|
|
889
889
|
|
890
890
|
# Another comment
|
891
891
|
CRONTAB
|
892
|
-
@provider.
|
892
|
+
allow(@provider).to receive(:popen4).and_yield(1234, StringIO.new, @stdout, StringIO.new).and_return(@status)
|
893
893
|
end
|
894
894
|
|
895
895
|
it "should call crontab -l with the user" do
|
896
|
-
@provider.
|
896
|
+
expect(@provider).to receive(:popen4).with("crontab -l -u #{@new_resource.user}").and_return(@status)
|
897
897
|
@provider.send(:read_crontab)
|
898
898
|
end
|
899
899
|
|
900
900
|
it "should return the contents of the crontab" do
|
901
901
|
crontab = @provider.send(:read_crontab)
|
902
|
-
crontab.
|
902
|
+
expect(crontab).to eq <<-CRONTAB
|
903
903
|
0 2 * * * /some/other/command
|
904
904
|
|
905
905
|
# Chef Name: something else
|
@@ -911,16 +911,16 @@ MAILTO=foo@example.com
|
|
911
911
|
|
912
912
|
it "should return nil if the user has no crontab" do
|
913
913
|
status = double("Status", :exitstatus => 1)
|
914
|
-
@provider.
|
915
|
-
@provider.send(:read_crontab).
|
914
|
+
allow(@provider).to receive(:popen4).and_return(status)
|
915
|
+
expect(@provider.send(:read_crontab)).to eq(nil)
|
916
916
|
end
|
917
917
|
|
918
918
|
it "should raise an exception if another error occurs" do
|
919
919
|
status = double("Status", :exitstatus => 2)
|
920
|
-
@provider.
|
921
|
-
|
920
|
+
allow(@provider).to receive(:popen4).and_return(status)
|
921
|
+
expect do
|
922
922
|
@provider.send(:read_crontab)
|
923
|
-
end.
|
923
|
+
end.to raise_error(Chef::Exceptions::Cron, "Error determining state of #{@new_resource.name}, exit: 2")
|
924
924
|
end
|
925
925
|
end
|
926
926
|
|
@@ -928,24 +928,24 @@ MAILTO=foo@example.com
|
|
928
928
|
before :each do
|
929
929
|
@status = double("Status", :exitstatus => 0)
|
930
930
|
@stdin = StringIO.new
|
931
|
-
@provider.
|
931
|
+
allow(@provider).to receive(:popen4).and_yield(1234, @stdin, StringIO.new, StringIO.new).and_return(@status)
|
932
932
|
end
|
933
933
|
|
934
934
|
it "should call crontab for the user" do
|
935
|
-
@provider.
|
935
|
+
expect(@provider).to receive(:popen4).with("crontab -u #{@new_resource.user} -", :waitlast => true).and_return(@status)
|
936
936
|
@provider.send(:write_crontab, "Foo")
|
937
937
|
end
|
938
938
|
|
939
939
|
it "should write the given string to the crontab command" do
|
940
940
|
@provider.send(:write_crontab, "Foo\n# wibble\n wah!!")
|
941
|
-
@stdin.string.
|
941
|
+
expect(@stdin.string).to eq("Foo\n# wibble\n wah!!")
|
942
942
|
end
|
943
943
|
|
944
944
|
it "should raise an exception if the command returns non-zero" do
|
945
|
-
@status.
|
946
|
-
|
945
|
+
allow(@status).to receive(:exitstatus).and_return(1)
|
946
|
+
expect do
|
947
947
|
@provider.send(:write_crontab, "Foo")
|
948
|
-
end.
|
948
|
+
end.to raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
|
949
949
|
end
|
950
950
|
|
951
951
|
it "should raise an exception if the command die's and parent tries to write" do
|
@@ -954,14 +954,14 @@ MAILTO=foo@example.com
|
|
954
954
|
raise Errno::EPIPE, "Test"
|
955
955
|
end
|
956
956
|
end
|
957
|
-
@status.
|
958
|
-
@provider.
|
957
|
+
allow(@status).to receive(:exitstatus).and_return(1)
|
958
|
+
allow(@provider).to receive(:popen4).and_yield(1234, WriteErrPipe.new, StringIO.new, StringIO.new).and_return(@status)
|
959
959
|
|
960
|
-
Chef::Log.
|
960
|
+
expect(Chef::Log).to receive(:debug).with("Broken pipe - Test")
|
961
961
|
|
962
|
-
|
962
|
+
expect do
|
963
963
|
@provider.send(:write_crontab, "Foo")
|
964
|
-
end.
|
964
|
+
end.to raise_error(Chef::Exceptions::Cron, "Error updating state of #{@new_resource.name}, exit: 1")
|
965
965
|
end
|
966
966
|
|
967
967
|
end
|
@@ -970,7 +970,7 @@ MAILTO=foo@example.com
|
|
970
970
|
context "when weekday is symbol" do
|
971
971
|
it "should return weekday in crontab format" do
|
972
972
|
@new_resource.weekday :wednesday
|
973
|
-
@provider.send(:weekday_in_crontab).
|
973
|
+
expect(@provider.send(:weekday_in_crontab)).to eq("3")
|
974
974
|
end
|
975
975
|
|
976
976
|
it "should raise an error with an unknown weekday" do
|
@@ -981,7 +981,7 @@ MAILTO=foo@example.com
|
|
981
981
|
context "when weekday is a number in a string" do
|
982
982
|
it "should return the string" do
|
983
983
|
@new_resource.weekday "3"
|
984
|
-
@provider.send(:weekday_in_crontab).
|
984
|
+
expect(@provider.send(:weekday_in_crontab)).to eq("3")
|
985
985
|
end
|
986
986
|
|
987
987
|
it "should raise an error with an out of range number" do
|
@@ -992,14 +992,14 @@ MAILTO=foo@example.com
|
|
992
992
|
context "when weekday is string with the name of the week" do
|
993
993
|
it "should return the string" do
|
994
994
|
@new_resource.weekday "mon"
|
995
|
-
@provider.send(:weekday_in_crontab).
|
995
|
+
expect(@provider.send(:weekday_in_crontab)).to eq("mon")
|
996
996
|
end
|
997
997
|
end
|
998
998
|
|
999
999
|
context "when weekday is an integer" do
|
1000
1000
|
it "should return the integer" do
|
1001
1001
|
@new_resource.weekday 1
|
1002
|
-
@provider.send(:weekday_in_crontab).
|
1002
|
+
expect(@provider.send(:weekday_in_crontab)).to eq("1")
|
1003
1003
|
end
|
1004
1004
|
|
1005
1005
|
it "should raise an error with an out of range integer" do
|