chef 10.34.6-x86-mingw32 → 11.6.2-x86-mingw32
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 +5 -13
- data/CONTRIBUTING.md +155 -0
- data/README.md +89 -0
- data/Rakefile +18 -1
- data/bin/chef-apply +25 -0
- data/bin/chef-service-manager +37 -0
- data/bin/chef-shell +34 -0
- data/bin/shef +6 -5
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +4 -4
- data/distro/common/html/{shef.1.html → chef-shell.1.html} +49 -46
- data/distro/common/html/chef-solo.8.html +4 -4
- data/distro/common/html/chef-solr.8.html +5 -5
- data/distro/common/html/knife-bootstrap.1.html +4 -4
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +4 -4
- data/distro/common/html/knife-cookbook-site.1.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +4 -4
- data/distro/common/html/knife-data-bag.1.html +4 -4
- data/distro/common/html/knife-environment.1.html +4 -4
- data/distro/common/html/knife-exec.1.html +9 -9
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +4 -4
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +4 -4
- data/distro/common/html/knife-ssh.1.html +4 -4
- data/distro/common/html/knife-status.1.html +4 -4
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +8 -13
- data/distro/common/man/man1/{shef.1 → chef-shell.1} +21 -57
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +0 -99
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +0 -168
- data/distro/common/man/man1/knife-exec.1 +4 -7
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +3 -6
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/distro/common/markdown/man1/{shef.mkd → chef-shell.mkd} +49 -43
- data/distro/common/markdown/man1/knife-exec.mkd +11 -6
- data/distro/common/markdown/man1/knife.mkd +4 -9
- data/distro/debian/etc/default/chef-client +0 -1
- data/distro/debian/etc/init.d/chef-client +6 -4
- data/distro/windows/service_manager.rb +2 -146
- data/lib/chef.rb +3 -6
- data/lib/chef/api_client.rb +20 -130
- data/lib/chef/api_client/registration.rb +126 -0
- data/lib/chef/application.rb +68 -18
- data/lib/chef/application/apply.rb +162 -0
- data/lib/chef/application/client.rb +37 -22
- data/lib/chef/application/knife.rb +2 -4
- data/lib/chef/application/solo.rb +27 -13
- data/lib/chef/application/windows_service.rb +114 -54
- data/lib/chef/application/windows_service_manager.rb +179 -0
- data/lib/chef/applications.rb +1 -0
- data/lib/chef/chef_fs.rb +9 -0
- data/lib/chef/chef_fs/chef_fs_data_store.rb +371 -0
- data/lib/chef/chef_fs/command_line.rb +284 -0
- data/lib/chef/chef_fs/config.rb +205 -0
- data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +26 -0
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +38 -0
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +29 -0
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +38 -0
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +56 -0
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +128 -0
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +40 -0
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +51 -0
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +36 -0
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +40 -0
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +27 -0
- data/lib/chef/chef_fs/file_pattern.rb +312 -0
- data/lib/chef/chef_fs/file_system.rb +426 -0
- data/lib/chef/chef_fs/file_system/acl_dir.rb +64 -0
- data/lib/chef/chef_fs/file_system/acl_entry.rb +58 -0
- data/lib/chef/chef_fs/file_system/acls_dir.rb +68 -0
- data/lib/chef/chef_fs/file_system/already_exists_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +47 -0
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +180 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +85 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +71 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +55 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_data_bags_dir.rb +36 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +60 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +121 -0
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +110 -0
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +223 -0
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +85 -0
- data/lib/chef/chef_fs/file_system/cookbook_frozen_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +54 -0
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +41 -0
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +149 -0
- data/lib/chef/chef_fs/file_system/data_bag_dir.rb +69 -0
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +72 -0
- data/lib/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +36 -0
- data/lib/chef/chef_fs/file_system/environments_dir.rb +60 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +90 -0
- data/lib/chef/chef_fs/file_system/file_system_error.rb +33 -0
- data/lib/chef/chef_fs/file_system/file_system_root_dir.rb +31 -0
- data/lib/chef/chef_fs/file_system/memory_dir.rb +52 -0
- data/lib/chef/chef_fs/file_system/memory_file.rb +17 -0
- data/lib/chef/chef_fs/file_system/memory_root.rb +21 -0
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +48 -0
- data/lib/chef/chef_fs/file_system/must_delete_recursively_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +55 -0
- data/lib/chef/chef_fs/file_system/nonexistent_fs_object.rb +36 -0
- data/lib/chef/chef_fs/file_system/not_found_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/operation_failed_error.rb +34 -0
- data/lib/chef/chef_fs/file_system/operation_not_allowed_error.rb +48 -0
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +113 -0
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +177 -0
- data/lib/chef/chef_fs/knife.rb +116 -0
- data/lib/chef/chef_fs/parallelizer.rb +129 -0
- data/lib/chef/chef_fs/path_utils.rb +90 -0
- data/lib/chef/chef_fs/raw_request.rb +79 -0
- data/lib/chef/client.rb +111 -34
- data/lib/chef/config.rb +111 -102
- data/lib/chef/cookbook/chefignore.rb +2 -1
- data/lib/chef/cookbook/metadata.rb +0 -2
- data/lib/chef/cookbook/syntax_check.rb +76 -14
- data/lib/chef/cookbook_loader.rb +39 -26
- data/lib/chef/cookbook_uploader.rb +16 -9
- data/lib/chef/cookbook_version.rb +2 -410
- data/lib/chef/daemon.rb +24 -19
- data/lib/chef/data_bag.rb +20 -104
- data/lib/chef/data_bag_item.rb +2 -65
- data/lib/chef/deprecation/mixin/template.rb +49 -0
- data/lib/chef/deprecation/provider/cookbook_file.rb +55 -0
- data/lib/chef/deprecation/provider/file.rb +197 -0
- data/lib/chef/deprecation/provider/remote_file.rb +86 -0
- data/lib/chef/deprecation/provider/template.rb +63 -0
- data/lib/chef/deprecation/warnings.rb +38 -0
- data/lib/chef/digester.rb +73 -0
- data/lib/chef/dsl.rb +6 -0
- data/lib/chef/dsl/data_query.rb +71 -0
- data/lib/chef/dsl/include_attribute.rb +63 -0
- data/lib/chef/dsl/include_recipe.rb +45 -0
- data/lib/chef/dsl/platform_introspection.rb +218 -0
- data/lib/chef/dsl/recipe.rb +87 -0
- data/lib/chef/dsl/registry_helper.rb +59 -0
- data/lib/chef/encrypted_data_bag_item.rb +171 -24
- data/lib/chef/environment.rb +39 -179
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/exceptions.rb +107 -8
- data/lib/chef/file_access_control/unix.rb +64 -7
- data/lib/chef/file_access_control/windows.rb +22 -11
- data/lib/chef/file_content_management/content_base.rb +56 -0
- data/lib/chef/file_content_management/deploy.rb +38 -0
- data/lib/chef/file_content_management/deploy/cp.rb +48 -0
- data/lib/chef/file_content_management/deploy/mv_unix.rb +77 -0
- data/lib/chef/file_content_management/deploy/mv_windows.rb +95 -0
- data/lib/chef/file_content_management/tempfile.rb +61 -0
- data/lib/chef/formatters/base.rb +4 -1
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/formatters/error_descriptor.rb +5 -4
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +23 -3
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +8 -0
- data/lib/chef/json_compat.rb +15 -14
- data/lib/chef/knife.rb +99 -41
- data/lib/chef/knife/bootstrap.rb +46 -2
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +1 -1
- data/lib/chef/knife/bootstrap/centos5-gems.erb +1 -1
- data/lib/chef/knife/bootstrap/chef-full.erb +1 -1
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +1 -1
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +1 -1
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +1 -1
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +1 -1
- data/lib/chef/knife/client_show.rb +2 -5
- data/lib/chef/knife/configure.rb +19 -17
- data/lib/chef/knife/cookbook_create.rb +6 -5
- data/lib/chef/knife/cookbook_download.rb +13 -5
- data/lib/chef/knife/cookbook_metadata.rb +1 -0
- data/lib/chef/knife/cookbook_site_share.rb +1 -0
- data/lib/chef/knife/cookbook_test.rb +4 -2
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +11 -5
- data/lib/chef/knife/core/generic_presenter.rb +42 -13
- data/lib/chef/knife/core/node_editor.rb +36 -16
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +43 -12
- data/lib/chef/knife/core/text_formatter.rb +23 -37
- data/lib/chef/knife/core/ui.rb +34 -13
- data/lib/chef/knife/delete.rb +106 -0
- data/lib/chef/knife/deps.rb +139 -0
- data/lib/chef/knife/diff.rb +63 -0
- data/lib/chef/knife/download.rb +63 -0
- data/lib/chef/knife/edit.rb +76 -0
- data/lib/chef/knife/environment_show.rb +2 -0
- data/lib/chef/knife/exec.rb +5 -5
- data/lib/chef/knife/help_topics.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +91 -7
- data/lib/chef/knife/list.rb +153 -0
- data/lib/chef/knife/node_run_list_set.rb +66 -0
- data/lib/chef/knife/node_show.rb +1 -7
- data/lib/chef/knife/raw.rb +64 -0
- data/lib/chef/knife/role_show.rb +2 -4
- data/lib/chef/knife/search.rb +45 -28
- data/lib/chef/knife/show.rb +55 -0
- data/lib/chef/knife/ssh.rb +14 -2
- data/lib/chef/knife/upload.rb +69 -0
- data/lib/chef/knife/user_create.rb +93 -0
- data/lib/chef/knife/user_delete.rb +46 -0
- data/lib/chef/knife/user_edit.rb +53 -0
- data/lib/chef/{provider/whyrun_safe_ruby_block.rb → knife/user_list.rb} +21 -9
- data/lib/chef/knife/user_reregister.rb +59 -0
- data/lib/chef/knife/user_show.rb +49 -0
- data/lib/chef/knife/xargs.rb +265 -0
- data/lib/chef/log.rb +2 -2
- data/lib/chef/mixin/checksum.rb +3 -3
- data/lib/chef/mixin/deep_merge.rb +78 -194
- data/lib/chef/mixin/deprecation.rb +35 -0
- data/lib/chef/mixin/file_class.rb +0 -9
- data/lib/chef/mixin/language.rb +22 -223
- data/lib/chef/mixin/language_include_attribute.rb +10 -36
- data/lib/chef/mixin/language_include_recipe.rb +7 -33
- data/lib/chef/mixin/params_validate.rb +0 -3
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +10 -61
- data/lib/chef/mixin/securable.rb +32 -7
- data/lib/chef/mixin/template.rb +156 -26
- data/lib/chef/mixin/windows_architecture_helper.rb +91 -0
- data/lib/chef/mixins.rb +1 -5
- data/{spec/unit/monkey_patches/uri_spec.rb → lib/chef/monkey_patches/file.rb} +6 -14
- data/lib/chef/monkey_patches/net-ssh-multi.rb +140 -0
- data/lib/chef/monkey_patches/net_http.rb +0 -34
- data/lib/chef/monkey_patches/securerandom.rb +44 -0
- data/lib/chef/monologger.rb +93 -0
- data/lib/chef/node.rb +139 -308
- data/lib/chef/node/attribute.rb +367 -473
- data/lib/chef/node/attribute_collections.rb +206 -0
- data/lib/chef/node/immutable_collections.rb +186 -0
- data/lib/chef/platform.rb +4 -496
- data/lib/chef/platform/provider_mapping.rb +529 -0
- data/lib/chef/{mixin/check_helper.rb → platform/query_helpers.rb} +20 -9
- data/lib/chef/provider.rb +14 -58
- data/lib/chef/provider/batch.rb +35 -0
- data/lib/chef/provider/breakpoint.rb +6 -6
- data/lib/chef/provider/cookbook_file.rb +11 -80
- data/lib/chef/provider/cookbook_file/content.rb +49 -0
- data/lib/chef/provider/deploy.rb +26 -21
- data/lib/chef/provider/deploy/revision.rb +27 -0
- data/lib/chef/provider/directory.rb +12 -18
- data/lib/chef/provider/execute.rb +22 -5
- data/lib/chef/provider/file.rb +297 -248
- data/lib/chef/provider/file/content.rb +39 -0
- data/lib/chef/provider/git.rb +76 -43
- data/lib/chef/provider/group.rb +31 -51
- data/lib/chef/provider/group/dscl.rb +13 -53
- data/lib/chef/provider/group/gpasswd.rb +19 -14
- data/lib/chef/provider/group/groupadd.rb +1 -41
- data/lib/chef/provider/group/groupmod.rb +36 -46
- data/lib/chef/provider/group/pw.rb +16 -59
- data/lib/chef/provider/group/suse.rb +13 -16
- data/lib/chef/provider/group/usermod.rb +18 -40
- data/lib/chef/provider/group/windows.rb +6 -13
- data/lib/chef/provider/http_request.rb +25 -42
- data/lib/chef/provider/ifconfig.rb +25 -35
- data/lib/chef/provider/ifconfig/debian.rb +71 -0
- data/lib/chef/provider/ifconfig/redhat.rb +47 -0
- data/lib/chef/provider/link.rb +12 -3
- data/lib/chef/provider/lwrp_base.rb +150 -0
- data/lib/chef/provider/mount.rb +1 -1
- data/lib/chef/provider/mount/mount.rb +8 -3
- data/lib/chef/provider/mount/windows.rb +4 -1
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +4 -1
- data/lib/chef/provider/package/smartos.rb +47 -36
- data/lib/chef/provider/package/zypper.rb +45 -55
- data/lib/chef/provider/powershell_script.rb +77 -0
- data/lib/chef/provider/registry_key.rb +156 -0
- data/lib/chef/provider/remote_directory.rb +6 -5
- data/lib/chef/provider/remote_file.rb +13 -100
- data/lib/chef/provider/remote_file/cache_control_data.rb +165 -0
- data/lib/chef/provider/remote_file/content.rb +75 -0
- data/lib/chef/provider/remote_file/fetcher.rb +43 -0
- data/lib/chef/provider/remote_file/ftp.rb +183 -0
- data/lib/chef/provider/remote_file/http.rb +124 -0
- data/lib/chef/provider/remote_file/local_file.rb +47 -0
- data/lib/chef/provider/route.rb +6 -2
- data/lib/chef/provider/ruby_block.rb +5 -2
- data/lib/chef/provider/script.rb +14 -2
- data/lib/chef/provider/service.rb +15 -0
- data/lib/chef/provider/service/init.rb +9 -7
- data/lib/chef/provider/service/macosx.rb +29 -81
- data/lib/chef/provider/service/simple.rb +1 -1
- data/lib/chef/provider/service/solaris.rb +6 -5
- data/lib/chef/provider/template.rb +16 -81
- data/lib/chef/provider/template/content.rb +61 -0
- data/lib/chef/provider/template_finder.rb +61 -0
- data/lib/chef/provider/user.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +175 -568
- data/lib/chef/provider/user/useradd.rb +50 -54
- data/lib/chef/provider/windows_script.rb +73 -0
- data/lib/chef/providers.rb +18 -1
- data/lib/chef/recipe.rb +14 -8
- data/lib/chef/resource.rb +52 -146
- data/lib/chef/resource/{whyrun_safe_ruby_block.rb → batch.rb} +10 -10
- data/lib/chef/resource/conditional.rb +4 -0
- data/lib/chef/resource/conditional_action_not_nothing.rb +48 -0
- data/lib/chef/resource/file.rb +31 -3
- data/lib/chef/resource/group.rb +1 -11
- data/lib/chef/resource/http_request.rb +2 -1
- data/lib/chef/resource/link.rb +17 -0
- data/lib/chef/resource/lwrp_base.rb +132 -0
- data/lib/chef/resource/mount.rb +39 -13
- data/lib/chef/resource/powershell_script.rb +31 -0
- data/lib/chef/resource/registry_key.rb +86 -0
- data/lib/chef/resource/remote_directory.rb +6 -5
- data/lib/chef/resource/remote_file.rb +62 -25
- data/lib/chef/resource/route.rb +1 -1
- data/lib/chef/resource/ruby_block.rb +2 -2
- data/lib/chef/resource/service.rb +14 -0
- data/lib/chef/resource/template.rb +145 -0
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource/windows_script.rb +62 -0
- data/lib/chef/resource_collection.rb +69 -31
- data/lib/chef/resource_reporter.rb +81 -52
- data/lib/chef/resources.rb +4 -1
- data/lib/chef/rest.rb +55 -127
- data/lib/chef/rest/auth_credentials.rb +4 -20
- data/lib/chef/rest/rest_request.rb +7 -8
- data/lib/chef/role.rb +1 -97
- data/lib/chef/run_context.rb +108 -130
- data/lib/chef/run_context/cookbook_compiler.rb +280 -0
- data/lib/chef/run_list.rb +0 -2
- data/lib/chef/run_list/run_list_expansion.rb +1 -16
- data/lib/chef/run_lock.rb +96 -0
- data/lib/chef/runner.rb +28 -6
- data/lib/chef/sandbox.rb +15 -148
- data/lib/chef/scan_access_control.rb +8 -5
- data/lib/chef/search/query.rb +2 -2
- data/lib/chef/shef/ext.rb +3 -575
- data/lib/chef/{shef.rb → shell.rb} +35 -40
- data/lib/chef/shell/ext.rb +593 -0
- data/lib/chef/{shef → shell}/model_wrapper.rb +3 -3
- data/lib/chef/{shef/shef_rest.rb → shell/shell_rest.rb} +4 -4
- data/lib/chef/{shef/shef_session.rb → shell/shell_session.rb} +15 -13
- data/lib/chef/shell_out.rb +7 -0
- data/lib/chef/user.rb +182 -0
- data/lib/chef/util/backup.rb +84 -0
- data/lib/chef/util/diff.rb +145 -0
- data/lib/chef/util/file_edit.rb +1 -1
- data/lib/chef/util/selinux.rb +100 -0
- data/lib/chef/util/windows/net_group.rb +1 -5
- data/lib/chef/util/windows/net_user.rb +14 -1
- data/lib/chef/util/windows/volume.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +42 -0
- data/lib/chef/version_class.rb +1 -1
- data/lib/chef/version_constraint.rb +6 -5
- data/lib/chef/{index_queue.rb → version_constraint/platform.rb} +11 -14
- data/lib/chef/win32/api/file.rb +8 -2
- data/lib/chef/win32/api/security.rb +45 -1
- data/lib/chef/win32/registry.rb +382 -0
- data/lib/chef/win32/security.rb +19 -0
- data/lib/chef/win32/version.rb +25 -8
- data/spec/data/apt/chef-integration-test-1.0/debian/changelog +5 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/control +13 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/files +1 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test-1.0/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/changelog +11 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/compat +1 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/control +13 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/copyright +34 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/files +1 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/rules +13 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/source/format +1 -0
- data/spec/data/apt/chef-integration-test_1.0-1_amd64.changes +22 -0
- data/spec/data/apt/chef-integration-test_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test_1.0.orig.tar.gz +0 -0
- data/spec/data/apt/chef-integration-test_1.1-1_amd64.changes +22 -0
- data/spec/data/apt/chef-integration-test_1.1-1_amd64.deb +0 -0
- data/spec/data/apt/chef-integration-test_1.1.orig.tar.gz +0 -0
- data/spec/data/apt/var/www/apt/conf/distributions +7 -0
- data/spec/data/apt/var/www/apt/conf/incoming +4 -0
- data/spec/data/apt/var/www/apt/conf/pulls +3 -0
- data/spec/data/apt/var/www/apt/db/checksums.db +0 -0
- data/spec/data/apt/var/www/apt/db/contents.cache.db +0 -0
- data/spec/data/apt/var/www/apt/db/packages.db +0 -0
- data/spec/data/apt/var/www/apt/db/references.db +0 -0
- data/spec/data/apt/var/www/apt/db/release.caches.db +0 -0
- data/spec/data/apt/var/www/apt/db/version +4 -0
- data/spec/data/apt/var/www/apt/dists/sid/Release +19 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages +16 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Packages.gz +0 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-amd64/Release +5 -0
- data/spec/data/apt/var/www/apt/dists/sid/main/binary-i386/Packages +0 -0
- data/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.0-1_amd64.deb +0 -0
- data/spec/data/apt/var/www/apt/pool/main/c/chef-integration-test/chef-integration-test_1.1-1_amd64.deb +0 -0
- data/spec/data/bootstrap/encrypted_data_bag_secret +1 -0
- data/spec/data/bootstrap/secret.erb +9 -0
- data/spec/data/cookbooks/ignorken/recipes/default.rb +1 -0
- data/spec/data/cookbooks/ignorken/recipes/ignoreme.rb +2 -0
- data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
- data/spec/data/cookbooks/openldap/templates/default/all_windows_line_endings.erb +4 -0
- data/spec/data/cookbooks/openldap/templates/default/helper_test.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/helpers_via_partial_test.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/no_windows_line_endings.erb +4 -0
- data/spec/data/cookbooks/openldap/templates/default/some_windows_line_endings.erb +4 -0
- data/spec/data/cookbooks/preseed/files/default/preseed-file.seed +1 -0
- data/spec/data/cookbooks/preseed/templates/default/preseed-template.seed +1 -0
- data/spec/data/file-providers-method-snapshot-chef-11-4.json +127 -0
- data/spec/data/git_bundles/example-repo.gitbundle +0 -0
- data/spec/data/knife_subcommand/test_yourself.rb +8 -0
- data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
- data/spec/data/nodes/default.rb +3 -3
- data/spec/data/nodes/test.example.com.rb +3 -3
- data/spec/data/nodes/test.rb +3 -3
- data/spec/data/null_config.rb +1 -0
- data/spec/data/partial_one.erb +1 -0
- data/spec/data/remote_file/nyan_cat.png.gz +0 -0
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
- data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
- data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
- data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
- data/spec/data/shef-config.rb +10 -0
- data/spec/functional/dsl/registry_helper_spec.rb +63 -0
- data/spec/functional/file_content_management/deploy_strategies_spec.rb +238 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +1 -1
- data/spec/functional/knife/exec_spec.rb +3 -3
- data/spec/functional/knife/smoke_test.rb +34 -0
- data/spec/functional/knife/ssh_spec.rb +5 -1
- data/spec/functional/provider/remote_file/cache_control_data_spec.rb +101 -0
- data/spec/functional/resource/batch_spec.rb +64 -0
- data/spec/functional/resource/cookbook_file_spec.rb +15 -9
- data/spec/functional/resource/deploy_revision_spec.rb +180 -0
- data/spec/functional/resource/directory_spec.rb +5 -1
- data/spec/functional/resource/file_spec.rb +71 -21
- data/spec/functional/resource/git_spec.rb +259 -0
- data/spec/functional/resource/link_spec.rb +424 -388
- data/spec/functional/resource/package_spec.rb +297 -0
- data/spec/functional/resource/powershell_spec.rb +188 -0
- data/spec/functional/resource/registry_spec.rb +576 -0
- data/spec/functional/resource/remote_directory_spec.rb +143 -37
- data/spec/functional/resource/remote_file_spec.rb +99 -13
- data/spec/functional/resource/template_spec.rb +180 -3
- data/spec/functional/resource/user_spec.rb +547 -0
- data/spec/functional/run_lock_spec.rb +243 -0
- data/spec/functional/shell_spec.rb +102 -0
- data/spec/functional/win32/registry_helper_spec.rb +632 -0
- data/spec/functional/win32/security_spec.rb +37 -0
- data/spec/functional/win32/service_manager_spec.rb +269 -0
- data/spec/functional/win32/versions_spec.rb +78 -0
- data/spec/integration/knife/chef_repo_path_spec.rb +805 -0
- data/spec/integration/knife/chef_repository_file_system_spec.rb +276 -0
- data/spec/integration/knife/chefignore_spec.rb +271 -0
- data/spec/integration/knife/delete_spec.rb +944 -0
- data/spec/integration/knife/deps_spec.rb +648 -0
- data/spec/integration/knife/diff_spec.rb +536 -0
- data/spec/integration/knife/download_spec.rb +962 -0
- data/spec/integration/knife/list_spec.rb +633 -0
- data/spec/integration/knife/raw_spec.rb +166 -0
- data/spec/integration/knife/redirection_spec.rb +57 -0
- data/spec/integration/knife/show_spec.rb +158 -0
- data/spec/integration/knife/upload_spec.rb +1060 -0
- data/spec/integration/solo/solo_spec.rb +41 -0
- data/spec/spec_helper.rb +49 -13
- data/spec/stress/win32/security_spec.rb +1 -1
- data/spec/support/chef_helpers.rb +33 -3
- data/spec/support/lib/chef/resource/cat.rb +3 -5
- data/spec/support/lib/chef/resource/one_two_three_four.rb +8 -10
- data/spec/support/lib/chef/resource/zen_master.rb +8 -10
- data/spec/support/platform_helpers.rb +46 -13
- data/spec/support/platforms/win32/spec_service.rb +59 -0
- data/spec/support/shared/functional/diff_disabled.rb +10 -0
- data/spec/support/shared/functional/directory_resource.rb +129 -38
- data/spec/support/shared/functional/file_resource.rb +837 -71
- data/spec/support/shared/functional/securable_resource.rb +189 -58
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +385 -0
- data/spec/support/shared/integration/integration_helper.rb +166 -0
- data/spec/support/shared/integration/knife_support.rb +171 -0
- data/spec/support/shared/unit/execute_resource.rb +125 -0
- data/spec/support/shared/unit/file_system_support.rb +70 -0
- data/spec/support/shared/unit/platform_introspector.rb +162 -0
- data/spec/support/shared/unit/provider/file.rb +609 -0
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +407 -0
- data/spec/support/shared/unit/script_resource.rb +52 -0
- data/spec/support/shared/unit/windows_script_resource.rb +48 -0
- data/spec/tiny_server.rb +13 -11
- data/spec/unit/api_client/registration_spec.rb +172 -0
- data/spec/unit/api_client_spec.rb +78 -156
- data/spec/unit/application/apply.rb +84 -0
- data/spec/unit/application/client_spec.rb +16 -14
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application/solo_spec.rb +1 -1
- data/spec/unit/application_spec.rb +113 -3
- data/spec/unit/checksum/storage/filesystem_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +328 -0
- data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
- data/spec/unit/chef_fs/file_system_spec.rb +135 -0
- data/spec/unit/client_spec.rb +195 -23
- data/spec/unit/config_spec.rb +102 -51
- data/spec/unit/cookbook/syntax_check_spec.rb +75 -111
- data/spec/unit/cookbook_loader_spec.rb +154 -91
- data/spec/unit/cookbook_manifest_spec.rb +81 -81
- data/spec/unit/cookbook_spec.rb +3 -20
- data/spec/unit/cookbook_version_spec.rb +23 -122
- data/spec/unit/daemon_spec.rb +24 -19
- data/spec/unit/data_bag_spec.rb +13 -4
- data/spec/unit/deprecation_spec.rb +86 -0
- data/spec/unit/digester_spec.rb +50 -0
- data/spec/unit/dsl/data_query_spec.rb +66 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
- data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +197 -157
- data/spec/unit/environment_spec.rb +94 -126
- data/spec/unit/exceptions_spec.rb +8 -4
- data/spec/unit/file_access_control_spec.rb +21 -1
- data/spec/unit/file_content_management/deploy/cp_spec.rb +46 -0
- data/spec/unit/file_content_management/deploy/mv_unix_spec.rb +103 -0
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +179 -0
- data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +38 -2
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +6 -5
- data/spec/unit/json_compat_spec.rb +8 -0
- data/spec/unit/knife/bootstrap_spec.rb +130 -29
- data/spec/unit/knife/configure_spec.rb +64 -45
- data/spec/unit/knife/cookbook_download_spec.rb +24 -3
- data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
- data/spec/unit/knife/cookbook_test_spec.rb +1 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +39 -0
- data/spec/unit/knife/core/bootstrap_context_spec.rb +79 -62
- data/spec/unit/knife/core/subcommand_loader_spec.rb +20 -0
- data/spec/unit/knife/core/ui_spec.rb +196 -124
- data/spec/unit/knife/data_bag_create_spec.rb +9 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +1 -4
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -6
- data/spec/unit/knife/data_bag_show_spec.rb +11 -4
- data/spec/unit/knife/index_rebuild_spec.rb +96 -33
- data/spec/unit/knife/knife_help.rb +7 -7
- data/spec/unit/knife/node_edit_spec.rb +6 -33
- data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
- data/spec/unit/knife/node_run_list_set_spec.rb +140 -0
- data/spec/unit/knife/ssh_spec.rb +12 -15
- data/spec/unit/knife/status_spec.rb +2 -2
- data/spec/unit/knife/user_create_spec.rb +86 -0
- data/spec/unit/knife/user_delete_spec.rb +39 -0
- data/spec/unit/knife/user_edit_spec.rb +42 -0
- data/spec/unit/knife/user_list_spec.rb +32 -0
- data/spec/unit/knife/user_reregister_spec.rb +53 -0
- data/spec/unit/knife/user_show_spec.rb +41 -0
- data/spec/unit/knife_spec.rb +74 -0
- data/spec/unit/lwrp_spec.rb +102 -60
- data/spec/unit/mixin/checksum_spec.rb +2 -2
- data/spec/unit/mixin/deep_merge_spec.rb +130 -791
- data/spec/unit/mixin/deprecation_spec.rb +23 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +7 -1
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/securable_spec.rb +5 -3
- data/spec/unit/mixin/template_spec.rb +145 -14
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +83 -0
- data/spec/unit/node/attribute_spec.rb +273 -173
- data/spec/unit/node/immutable_collections_spec.rb +139 -0
- data/spec/unit/node_spec.rb +418 -370
- data/spec/unit/platform_spec.rb +21 -8
- data/spec/unit/provider/breakpoint_spec.rb +8 -8
- data/spec/unit/provider/cookbook_file/content_spec.rb +40 -0
- data/spec/unit/provider/cookbook_file_spec.rb +26 -187
- data/spec/unit/provider/cron/solaris_spec.rb +1 -1
- data/spec/unit/provider/deploy/revision_spec.rb +19 -11
- data/spec/unit/provider/deploy_spec.rb +2 -2
- data/spec/unit/provider/directory_spec.rb +99 -67
- data/spec/unit/provider/env_spec.rb +2 -2
- data/spec/unit/provider/execute_spec.rb +27 -1
- data/spec/unit/provider/file/content_spec.rb +101 -0
- data/spec/unit/provider/file_spec.rb +25 -475
- data/spec/unit/provider/git_spec.rb +224 -28
- data/spec/unit/provider/group/dscl_spec.rb +0 -36
- data/spec/unit/provider/group/gpasswd_spec.rb +9 -16
- data/spec/unit/provider/group/groupadd_spec.rb +4 -3
- data/spec/unit/provider/group/groupmod_spec.rb +1 -0
- data/spec/unit/provider/group/pw_spec.rb +15 -12
- data/spec/unit/provider/group/usermod_spec.rb +9 -22
- data/spec/unit/provider/group/windows_spec.rb +8 -0
- data/spec/unit/provider/group_spec.rb +6 -28
- data/spec/unit/provider/http_request_spec.rb +28 -69
- data/spec/unit/provider/ifconfig/debian_spec.rb +89 -0
- data/spec/unit/provider/ifconfig/redhat_spec.rb +71 -0
- data/spec/unit/provider/ifconfig_spec.rb +0 -33
- data/spec/unit/provider/mount/mount_spec.rb +33 -2
- data/spec/unit/provider/mount/windows_spec.rb +4 -1
- data/spec/unit/provider/mount_spec.rb +16 -6
- data/spec/unit/provider/ohai_spec.rb +4 -4
- data/spec/unit/provider/package/apt_spec.rb +0 -1
- data/spec/unit/provider/package/ips_spec.rb +0 -1
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +3 -2
- data/spec/unit/provider/package/zypper_spec.rb +84 -22
- data/spec/unit/provider/package_spec.rb +7 -9
- data/spec/unit/provider/powershell_spec.rb +38 -0
- data/spec/unit/provider/registry_key_spec.rb +269 -0
- data/spec/unit/provider/remote_directory_spec.rb +7 -7
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +211 -0
- data/spec/unit/provider/remote_file/content_spec.rb +230 -0
- data/spec/unit/provider/remote_file/fetcher_spec.rb +75 -0
- data/spec/unit/provider/remote_file/ftp_spec.rb +224 -0
- data/spec/unit/provider/remote_file/http_spec.rb +319 -0
- data/spec/unit/provider/remote_file/local_file_spec.rb +60 -0
- data/spec/unit/provider/remote_file_spec.rb +33 -259
- data/spec/unit/provider/route_spec.rb +29 -12
- data/spec/unit/provider/ruby_block_spec.rb +8 -0
- data/spec/unit/provider/service/arch_service_spec.rb +5 -5
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +5 -5
- data/spec/unit/provider/service/init_service_spec.rb +27 -4
- data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
- data/spec/unit/provider/service/invokercd_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +176 -207
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/simple_service_spec.rb +3 -3
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +21 -18
- data/spec/unit/provider/service/systemd_service_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -11
- data/spec/unit/provider/service_spec.rb +3 -3
- data/spec/unit/provider/subversion_spec.rb +1 -1
- data/spec/unit/provider/template/content_spec.rb +78 -0
- data/spec/unit/provider/template_spec.rb +52 -160
- data/spec/unit/provider/user/dscl_spec.rb +285 -681
- data/spec/unit/provider/user/solaris_spec.rb +39 -373
- data/spec/unit/provider/user/useradd_spec.rb +12 -379
- data/spec/unit/provider/user_spec.rb +1 -1
- data/spec/unit/recipe_spec.rb +10 -8
- data/spec/unit/registry_helper_spec.rb +376 -0
- data/spec/unit/resource/batch_spec.rb +48 -0
- data/spec/unit/resource/conditional_action_not_nothing_spec.rb +45 -0
- data/spec/unit/resource/execute_spec.rb +3 -101
- data/spec/unit/resource/file_spec.rb +0 -5
- data/spec/unit/resource/group_spec.rb +9 -0
- data/spec/unit/resource/ifconfig_spec.rb +60 -1
- data/spec/unit/resource/link_spec.rb +1 -0
- data/spec/unit/resource/mount_spec.rb +37 -11
- data/spec/unit/resource/powershell_spec.rb +48 -0
- data/spec/unit/resource/registry_key_spec.rb +171 -0
- data/spec/unit/resource/remote_file_spec.rb +63 -25
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +7 -3
- data/spec/unit/resource/script_spec.rb +13 -36
- data/spec/unit/resource/service_spec.rb +11 -0
- data/spec/unit/resource/template_spec.rb +111 -8
- data/spec/unit/resource/user_spec.rb +7 -0
- data/spec/unit/resource_collection_spec.rb +61 -32
- data/spec/unit/resource_reporter_spec.rb +115 -102
- data/spec/unit/resource_spec.rb +197 -5
- data/spec/unit/rest/auth_credentials_spec.rb +4 -21
- data/spec/unit/rest_spec.rb +134 -284
- data/spec/unit/run_context/cookbook_compiler_spec.rb +190 -0
- data/spec/unit/run_context_spec.rb +18 -4
- data/spec/unit/run_list_spec.rb +0 -209
- data/spec/unit/run_lock_spec.rb +37 -0
- data/spec/unit/runner_spec.rb +102 -3
- data/spec/unit/scan_access_control_spec.rb +8 -6
- data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
- data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
- data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +16 -58
- data/spec/unit/shell_out_spec.rb +18 -0
- data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
- data/spec/unit/user_spec.rb +255 -0
- data/spec/unit/util/backup_spec.rb +149 -0
- data/spec/unit/util/diff_spec.rb +596 -0
- data/spec/unit/util/selinux_spec.rb +172 -0
- data/spec/unit/version/platform_spec.rb +61 -0
- data/spec/unit/version_constraint/platform_spec.rb +46 -0
- data/spec/unit/version_constraint_spec.rb +5 -0
- metadata +493 -264
- data/README.rdoc +0 -177
- data/distro/common/html/knife-recipe.1.html +0 -92
- data/lib/chef/certificate.rb +0 -161
- data/lib/chef/checksum.rb +0 -167
- data/lib/chef/checksum_cache.rb +0 -190
- data/lib/chef/cookbook_version_selector.rb +0 -168
- data/lib/chef/couchdb.rb +0 -246
- data/lib/chef/index_queue/amqp_client.rb +0 -116
- data/lib/chef/index_queue/consumer.rb +0 -76
- data/lib/chef/index_queue/indexable.rb +0 -109
- data/lib/chef/knife/bootstrap/ubuntu12.10-gems.erb +0 -60
- data/lib/chef/monkey_patches/dir.rb +0 -36
- data/lib/chef/monkey_patches/moneta.rb +0 -50
- data/lib/chef/monkey_patches/uri.rb +0 -70
- data/lib/chef/openid_registration.rb +0 -187
- data/lib/chef/solr_query.rb +0 -187
- data/lib/chef/solr_query/lucene.treetop +0 -150
- data/lib/chef/solr_query/lucene_nodes.rb +0 -285
- data/lib/chef/solr_query/query_transform.rb +0 -65
- data/lib/chef/solr_query/solr_http_request.rb +0 -132
- data/lib/chef/webui_user.rb +0 -231
- data/spec/data/mac_users/10.7-8.plist.xml +0 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
- data/spec/data/mac_users/10.7.plist.xml +0 -559
- data/spec/data/mac_users/10.7.shadow.xml +0 -11
- data/spec/data/mac_users/10.8.plist.xml +0 -559
- data/spec/data/mac_users/10.8.shadow.xml +0 -21
- data/spec/data/mac_users/10.9.plist.xml +0 -560
- data/spec/data/mac_users/10.9.shadow.xml +0 -21
- data/spec/functional/resource/base.rb +0 -40
- data/spec/functional/resource/group_spec.rb +0 -343
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/unit/certificate_spec.rb +0 -76
- data/spec/unit/checksum_cache_spec.rb +0 -209
- data/spec/unit/checksum_spec.rb +0 -94
- data/spec/unit/couchdb_spec.rb +0 -274
- data/spec/unit/index_queue_spec.rb +0 -391
- data/spec/unit/mixin/language_spec.rb +0 -305
- data/spec/unit/openid_registration_spec.rb +0 -153
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +0 -47
- data/spec/unit/solr_query/query_transform_spec.rb +0 -454
- data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
- data/spec/unit/solr_query_spec.rb +0 -203
- data/spec/unit/webui_user_spec.rb +0 -238
@@ -0,0 +1,139 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 Opscode, 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
|
+
require "chef/node/immutable_collections"
|
21
|
+
|
22
|
+
describe Chef::Node::ImmutableMash do
|
23
|
+
before do
|
24
|
+
@data_in = {:top => {:second_level => "some value"},
|
25
|
+
"top_level_2" => %w[array of values],
|
26
|
+
:top_level_3 => [{:hash_array => 1, :hash_array_b => 2}],
|
27
|
+
:top_level_4 => {:level2 => {:key => "value"}}
|
28
|
+
}
|
29
|
+
@immutable_mash = Chef::Node::ImmutableMash.new(@data_in)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "element references like regular hash" do
|
33
|
+
@immutable_mash[:top][:second_level].should == "some value"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "elelment references like a regular Mash" do
|
37
|
+
@immutable_mash[:top_level_2].should == %w[array of values]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "converts Hash-like inputs into ImmutableMash's" do
|
41
|
+
@immutable_mash[:top].should be_a(Chef::Node::ImmutableMash)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "converts array inputs into ImmutableArray's" do
|
45
|
+
@immutable_mash[:top_level_2].should be_a(Chef::Node::ImmutableArray)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "converts arrays of hashes to ImmutableArray's of ImmutableMashes" do
|
49
|
+
@immutable_mash[:top_level_3].first.should be_a(Chef::Node::ImmutableMash)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "converts nested hashes to ImmutableMashes" do
|
53
|
+
@immutable_mash[:top_level_4].should be_a(Chef::Node::ImmutableMash)
|
54
|
+
@immutable_mash[:top_level_4][:level2].should be_a(Chef::Node::ImmutableMash)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
[
|
59
|
+
:[]=,
|
60
|
+
:clear,
|
61
|
+
:default=,
|
62
|
+
:default_proc=,
|
63
|
+
:delete,
|
64
|
+
:delete_if,
|
65
|
+
:keep_if,
|
66
|
+
:merge!,
|
67
|
+
:update,
|
68
|
+
:reject!,
|
69
|
+
:replace,
|
70
|
+
:select!,
|
71
|
+
:shift
|
72
|
+
].each do |mutator|
|
73
|
+
it "doesn't allow mutation via `#{mutator}'" do
|
74
|
+
lambda { @immutable_mash.send(mutator) }.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "returns a mutable version of itself when duped" do
|
79
|
+
mutable = @immutable_mash.dup
|
80
|
+
mutable[:new_key] = :value
|
81
|
+
mutable[:new_key].should == :value
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
describe Chef::Node::ImmutableArray do
|
87
|
+
|
88
|
+
before do
|
89
|
+
@immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz])
|
90
|
+
end
|
91
|
+
|
92
|
+
##
|
93
|
+
# Note: other behaviors, such as immutibilizing input data, are tested along
|
94
|
+
# with ImmutableMash, above
|
95
|
+
###
|
96
|
+
|
97
|
+
[
|
98
|
+
:<<,
|
99
|
+
:[]=,
|
100
|
+
:clear,
|
101
|
+
:collect!,
|
102
|
+
:compact!,
|
103
|
+
:default=,
|
104
|
+
:default_proc=,
|
105
|
+
:delete,
|
106
|
+
:delete_at,
|
107
|
+
:delete_if,
|
108
|
+
:fill,
|
109
|
+
:flatten!,
|
110
|
+
:insert,
|
111
|
+
:keep_if,
|
112
|
+
:map!,
|
113
|
+
:merge!,
|
114
|
+
:pop,
|
115
|
+
:push,
|
116
|
+
:update,
|
117
|
+
:reject!,
|
118
|
+
:reverse!,
|
119
|
+
:replace,
|
120
|
+
:select!,
|
121
|
+
:shift,
|
122
|
+
:slice!,
|
123
|
+
:sort!,
|
124
|
+
:sort_by!,
|
125
|
+
:uniq!,
|
126
|
+
:unshift
|
127
|
+
].each do |mutator|
|
128
|
+
it "does not allow mutation via `#{mutator}" do
|
129
|
+
lambda { @immutable_array.send(mutator)}.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
it "returns a mutable version of itself when duped" do
|
134
|
+
mutable = @immutable_array.dup
|
135
|
+
mutable[0] = :value
|
136
|
+
mutable[0].should == :value
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
data/spec/unit/node_spec.rb
CHANGED
@@ -20,10 +20,11 @@ require 'spec_helper'
|
|
20
20
|
require 'ostruct'
|
21
21
|
|
22
22
|
describe Chef::Node do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
|
24
|
+
let(:node) { Chef::Node.new() }
|
25
|
+
let(:platform_introspector) { node }
|
26
|
+
|
27
|
+
it_behaves_like "a platform introspector"
|
27
28
|
|
28
29
|
it "creates a node and assigns it a name" do
|
29
30
|
node = Chef::Node.build('solo-node')
|
@@ -34,41 +35,45 @@ describe Chef::Node do
|
|
34
35
|
lambda{Chef::Node.build('solo node')}.should raise_error(Chef::Exceptions::ValidationFailed)
|
35
36
|
end
|
36
37
|
|
38
|
+
it "should be sortable" do
|
39
|
+
n1 = Chef::Node.build('alpha')
|
40
|
+
n2 = Chef::Node.build('beta')
|
41
|
+
n3 = Chef::Node.build('omega')
|
42
|
+
[n3, n1, n2].sort.should == [n1, n2, n3]
|
43
|
+
end
|
44
|
+
|
37
45
|
describe "when the node does not exist on the server" do
|
38
46
|
before do
|
39
47
|
response = OpenStruct.new(:code => '404')
|
40
48
|
exception = Net::HTTPServerException.new("404 not found", response)
|
41
49
|
Chef::Node.stub!(:load).and_raise(exception)
|
42
|
-
|
50
|
+
node.name("created-node")
|
43
51
|
end
|
44
52
|
|
45
53
|
it "creates a new node for find_or_create" do
|
46
|
-
Chef::Node.stub!(:new).and_return(
|
47
|
-
|
54
|
+
Chef::Node.stub!(:new).and_return(node)
|
55
|
+
node.should_receive(:create).and_return(node)
|
48
56
|
node = Chef::Node.find_or_create("created-node")
|
49
57
|
node.name.should == 'created-node'
|
50
|
-
node.should equal(
|
58
|
+
node.should equal(node)
|
51
59
|
end
|
52
60
|
end
|
53
61
|
|
54
62
|
describe "when the node exists on the server" do
|
55
63
|
before do
|
56
|
-
|
57
|
-
Chef::Node.stub!(:load).and_return(
|
64
|
+
node.name('existing-node')
|
65
|
+
Chef::Node.stub!(:load).and_return(node)
|
58
66
|
end
|
59
67
|
|
60
68
|
it "loads the node via the REST API for find_or_create" do
|
61
|
-
Chef::Node.find_or_create('existing-node').should equal(
|
69
|
+
Chef::Node.find_or_create('existing-node').should equal(node)
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
65
73
|
describe "run_state" do
|
66
|
-
it "
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
it "should have a seen_recipes hash" do
|
71
|
-
@node.run_state[:seen_recipes].should be_a_kind_of(Hash)
|
74
|
+
it "is an empty hash" do
|
75
|
+
node.run_state.should respond_to(:keys)
|
76
|
+
node.run_state.should be_empty
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
@@ -81,180 +86,225 @@ describe Chef::Node do
|
|
81
86
|
|
82
87
|
describe "name" do
|
83
88
|
it "should allow you to set a name with name(something)" do
|
84
|
-
lambda {
|
89
|
+
lambda { node.name("latte") }.should_not raise_error
|
85
90
|
end
|
86
91
|
|
87
92
|
it "should return the name with name()" do
|
88
|
-
|
89
|
-
|
93
|
+
node.name("latte")
|
94
|
+
node.name.should eql("latte")
|
90
95
|
end
|
91
96
|
|
92
97
|
it "should always have a string for name" do
|
93
|
-
lambda {
|
98
|
+
lambda { node.name(Hash.new) }.should raise_error(ArgumentError)
|
94
99
|
end
|
95
100
|
|
96
101
|
it "cannot be blank" do
|
97
|
-
lambda {
|
102
|
+
lambda { node.name("")}.should raise_error(Chef::Exceptions::ValidationFailed)
|
98
103
|
end
|
99
104
|
|
100
105
|
it "should not accept name doesn't match /^[\-[:alnum:]_:.]+$/" do
|
101
|
-
lambda {
|
106
|
+
lambda { node.name("space in it")}.should raise_error(Chef::Exceptions::ValidationFailed)
|
102
107
|
end
|
103
108
|
end
|
104
109
|
|
105
110
|
describe "chef_environment" do
|
106
111
|
it "should set an environment with chef_environment(something)" do
|
107
|
-
lambda {
|
112
|
+
lambda { node.chef_environment("latte") }.should_not raise_error
|
108
113
|
end
|
109
114
|
|
110
115
|
it "should return the chef_environment with chef_environment()" do
|
111
|
-
|
112
|
-
|
116
|
+
node.chef_environment("latte")
|
117
|
+
node.chef_environment.should == "latte"
|
113
118
|
end
|
114
119
|
|
115
120
|
it "should disallow non-strings" do
|
116
|
-
lambda {
|
117
|
-
lambda {
|
121
|
+
lambda { node.chef_environment(Hash.new) }.should raise_error(ArgumentError)
|
122
|
+
lambda { node.chef_environment(42) }.should raise_error(ArgumentError)
|
118
123
|
end
|
119
124
|
|
120
125
|
it "cannot be blank" do
|
121
|
-
lambda {
|
126
|
+
lambda { node.chef_environment("")}.should raise_error(Chef::Exceptions::ValidationFailed)
|
122
127
|
end
|
123
128
|
end
|
124
129
|
|
125
130
|
describe "attributes" do
|
126
|
-
it "should be loaded from the node's cookbooks" do
|
127
|
-
@cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
|
128
|
-
@node.cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
|
129
|
-
@node.load_attributes
|
130
|
-
@node.ldap_server.should eql("ops1prod")
|
131
|
-
@node.ldap_basedn.should eql("dc=hjksolutions,dc=com")
|
132
|
-
@node.ldap_replication_password.should eql("forsure")
|
133
|
-
@node.smokey.should eql("robinson")
|
134
|
-
end
|
135
|
-
|
136
131
|
it "should have attributes" do
|
137
|
-
|
132
|
+
node.attribute.should be_a_kind_of(Hash)
|
138
133
|
end
|
139
134
|
|
140
135
|
it "should allow attributes to be accessed by name or symbol directly on node[]" do
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
node.default["locust"] = "something"
|
137
|
+
node[:locust].should eql("something")
|
138
|
+
node["locust"].should eql("something")
|
144
139
|
end
|
145
140
|
|
146
141
|
it "should return nil if it cannot find an attribute with node[]" do
|
147
|
-
|
142
|
+
node["secret"].should eql(nil)
|
148
143
|
end
|
149
144
|
|
150
|
-
it "
|
151
|
-
|
152
|
-
@node["secret"].should eql("shush")
|
145
|
+
it "does not allow you to set an attribute via node[]=" do
|
146
|
+
lambda { node["secret"] = "shush" }.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
|
153
147
|
end
|
154
148
|
|
155
149
|
it "should allow you to query whether an attribute exists with attribute?" do
|
156
|
-
|
157
|
-
|
158
|
-
|
150
|
+
node.default["locust"] = "something"
|
151
|
+
node.attribute?("locust").should eql(true)
|
152
|
+
node.attribute?("no dice").should eql(false)
|
159
153
|
end
|
160
154
|
|
161
155
|
it "should let you go deep with attribute?" do
|
162
|
-
|
163
|
-
|
164
|
-
|
156
|
+
node.set["battles"]["people"]["wonkey"] = true
|
157
|
+
node["battles"]["people"].attribute?("wonkey").should == true
|
158
|
+
node["battles"]["people"].attribute?("snozzberry").should == false
|
165
159
|
end
|
166
160
|
|
167
|
-
it "
|
168
|
-
|
169
|
-
@node.attribute[:sunshine].should eql("is bright")
|
161
|
+
it "does not allow you to set an attribute via method_missing" do
|
162
|
+
lambda { node.sunshine = "is bright"}.should raise_error(Chef::Exceptions::ImmutableAttributeModification)
|
170
163
|
end
|
171
164
|
|
172
165
|
it "should allow you get get an attribute via method_missing" do
|
173
|
-
|
174
|
-
|
166
|
+
node.default.sunshine = "is bright"
|
167
|
+
node.sunshine.should eql("is bright")
|
175
168
|
end
|
176
169
|
|
177
170
|
describe "normal attributes" do
|
178
171
|
it "should allow you to set an attribute with set, without pre-declaring a hash" do
|
179
|
-
|
180
|
-
|
172
|
+
node.set[:snoopy][:is_a_puppy] = true
|
173
|
+
node[:snoopy][:is_a_puppy].should == true
|
181
174
|
end
|
182
175
|
|
183
176
|
it "should allow you to set an attribute with set_unless" do
|
184
|
-
|
185
|
-
|
177
|
+
node.set_unless[:snoopy][:is_a_puppy] = false
|
178
|
+
node[:snoopy][:is_a_puppy].should == false
|
186
179
|
end
|
187
180
|
|
188
181
|
it "should not allow you to set an attribute with set_unless if it already exists" do
|
189
|
-
|
190
|
-
|
191
|
-
|
182
|
+
node.set[:snoopy][:is_a_puppy] = true
|
183
|
+
node.set_unless[:snoopy][:is_a_puppy] = false
|
184
|
+
node[:snoopy][:is_a_puppy].should == true
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should allow you to set a value after a set_unless" do
|
188
|
+
# this tests for set_unless_present state bleeding between statements CHEF-3806
|
189
|
+
node.set_unless[:snoopy][:is_a_puppy] = false
|
190
|
+
node.set[:snoopy][:is_a_puppy] = true
|
191
|
+
node[:snoopy][:is_a_puppy].should == true
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should let you set a value after a 'dangling' set_unless" do
|
195
|
+
# this tests for set_unless_present state bleeding between statements CHEF-3806
|
196
|
+
node.set[:snoopy][:is_a_puppy] = "what"
|
197
|
+
node.set_unless[:snoopy][:is_a_puppy]
|
198
|
+
node.set[:snoopy][:is_a_puppy] = true
|
199
|
+
node[:snoopy][:is_a_puppy].should == true
|
192
200
|
end
|
193
201
|
|
194
202
|
it "auto-vivifies attributes created via method syntax" do
|
195
|
-
|
196
|
-
|
203
|
+
node.set.fuu.bahrr.baz = "qux"
|
204
|
+
node.fuu.bahrr.baz.should == "qux"
|
197
205
|
end
|
198
206
|
|
199
207
|
end
|
200
208
|
|
201
209
|
describe "default attributes" do
|
202
210
|
it "should be set with default, without pre-declaring a hash" do
|
203
|
-
|
204
|
-
|
211
|
+
node.default[:snoopy][:is_a_puppy] = true
|
212
|
+
node[:snoopy][:is_a_puppy].should == true
|
205
213
|
end
|
206
214
|
|
207
215
|
it "should allow you to set with default_unless without pre-declaring a hash" do
|
208
|
-
|
209
|
-
|
216
|
+
node.default_unless[:snoopy][:is_a_puppy] = false
|
217
|
+
node[:snoopy][:is_a_puppy].should == false
|
210
218
|
end
|
211
219
|
|
212
220
|
it "should not allow you to set an attribute with default_unless if it already exists" do
|
213
|
-
|
214
|
-
|
215
|
-
|
221
|
+
node.default[:snoopy][:is_a_puppy] = true
|
222
|
+
node.default_unless[:snoopy][:is_a_puppy] = false
|
223
|
+
node[:snoopy][:is_a_puppy].should == true
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should allow you to set a value after a default_unless" do
|
227
|
+
# this tests for set_unless_present state bleeding between statements CHEF-3806
|
228
|
+
node.default_unless[:snoopy][:is_a_puppy] = false
|
229
|
+
node.default[:snoopy][:is_a_puppy] = true
|
230
|
+
node[:snoopy][:is_a_puppy].should == true
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should allow you to set a value after a 'dangling' default_unless" do
|
234
|
+
# this tests for set_unless_present state bleeding between statements CHEF-3806
|
235
|
+
node.default[:snoopy][:is_a_puppy] = "what"
|
236
|
+
node.default_unless[:snoopy][:is_a_puppy]
|
237
|
+
node.default[:snoopy][:is_a_puppy] = true
|
238
|
+
node[:snoopy][:is_a_puppy].should == true
|
216
239
|
end
|
217
240
|
|
218
241
|
it "auto-vivifies attributes created via method syntax" do
|
219
|
-
|
220
|
-
|
242
|
+
node.default.fuu.bahrr.baz = "qux"
|
243
|
+
node.fuu.bahrr.baz.should == "qux"
|
244
|
+
end
|
245
|
+
|
246
|
+
it "accesses force defaults via default!" do
|
247
|
+
node.default![:foo] = "wet bar"
|
248
|
+
node.default[:foo] = "bar"
|
249
|
+
node[:foo].should == "wet bar"
|
221
250
|
end
|
222
251
|
|
223
252
|
end
|
224
253
|
|
225
254
|
describe "override attributes" do
|
226
255
|
it "should be set with override, without pre-declaring a hash" do
|
227
|
-
|
228
|
-
|
256
|
+
node.override[:snoopy][:is_a_puppy] = true
|
257
|
+
node[:snoopy][:is_a_puppy].should == true
|
229
258
|
end
|
230
259
|
|
231
260
|
it "should allow you to set with override_unless without pre-declaring a hash" do
|
232
|
-
|
233
|
-
|
261
|
+
node.override_unless[:snoopy][:is_a_puppy] = false
|
262
|
+
node[:snoopy][:is_a_puppy].should == false
|
234
263
|
end
|
235
264
|
|
236
265
|
it "should not allow you to set an attribute with override_unless if it already exists" do
|
237
|
-
|
238
|
-
|
239
|
-
|
266
|
+
node.override[:snoopy][:is_a_puppy] = true
|
267
|
+
node.override_unless[:snoopy][:is_a_puppy] = false
|
268
|
+
node[:snoopy][:is_a_puppy].should == true
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should allow you to set a value after an override_unless" do
|
272
|
+
# this tests for set_unless_present state bleeding between statements CHEF-3806
|
273
|
+
node.override_unless[:snoopy][:is_a_puppy] = false
|
274
|
+
node.override[:snoopy][:is_a_puppy] = true
|
275
|
+
node[:snoopy][:is_a_puppy].should == true
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should allow you to set a value after a 'dangling' override_unless" do
|
279
|
+
# this tests for set_unless_present state bleeding between statements CHEF-3806
|
280
|
+
node.override_unless[:snoopy][:is_a_puppy] = "what"
|
281
|
+
node.override_unless[:snoopy][:is_a_puppy]
|
282
|
+
node.override[:snoopy][:is_a_puppy] = true
|
283
|
+
node[:snoopy][:is_a_puppy].should == true
|
240
284
|
end
|
241
285
|
|
242
286
|
it "auto-vivifies attributes created via method syntax" do
|
243
|
-
|
244
|
-
|
287
|
+
node.override.fuu.bahrr.baz = "qux"
|
288
|
+
node.fuu.bahrr.baz.should == "qux"
|
289
|
+
end
|
290
|
+
|
291
|
+
it "sets force_overrides via override!" do
|
292
|
+
node.override![:foo] = "wet bar"
|
293
|
+
node.override[:foo] = "bar"
|
294
|
+
node[:foo].should == "wet bar"
|
245
295
|
end
|
246
296
|
|
247
297
|
end
|
248
298
|
|
249
299
|
it "should raise an ArgumentError if you ask for an attribute that doesn't exist via method_missing" do
|
250
|
-
lambda {
|
300
|
+
lambda { node.sunshine }.should raise_error(NoMethodError)
|
251
301
|
end
|
252
302
|
|
253
303
|
it "should allow you to iterate over attributes with each_attribute" do
|
254
|
-
|
255
|
-
|
304
|
+
node.default.sunshine = "is bright"
|
305
|
+
node.default.canada = "is a nice place"
|
256
306
|
seen_attributes = Hash.new
|
257
|
-
|
307
|
+
node.each_attribute do |a,v|
|
258
308
|
seen_attributes[a] = v
|
259
309
|
end
|
260
310
|
seen_attributes.should have_key("sunshine")
|
@@ -272,62 +322,62 @@ describe Chef::Node do
|
|
272
322
|
|
273
323
|
it "consumes the run list portion of a collection of attributes and returns the remainder" do
|
274
324
|
attrs = {"run_list" => [ "role[base]", "recipe[chef::server]" ], "foo" => "bar"}
|
275
|
-
|
276
|
-
|
325
|
+
node.consume_run_list(attrs).should == {"foo" => "bar"}
|
326
|
+
node.run_list.should == [ "role[base]", "recipe[chef::server]" ]
|
277
327
|
end
|
278
328
|
|
279
329
|
it "should overwrites the run list with the run list it consumes" do
|
280
|
-
|
281
|
-
|
282
|
-
|
330
|
+
node.consume_run_list "recipes" => [ "one", "two" ]
|
331
|
+
node.consume_run_list "recipes" => [ "three" ]
|
332
|
+
node.run_list.should == [ "three" ]
|
283
333
|
end
|
284
334
|
|
285
335
|
it "should not add duplicate recipes from the json attributes" do
|
286
|
-
|
287
|
-
|
288
|
-
|
336
|
+
node.run_list << "one"
|
337
|
+
node.consume_run_list "recipes" => [ "one", "two", "three" ]
|
338
|
+
node.run_list.should == [ "one", "two", "three" ]
|
289
339
|
end
|
290
340
|
|
291
341
|
it "doesn't change the run list if no run_list is specified in the json" do
|
292
|
-
|
293
|
-
|
294
|
-
|
342
|
+
node.run_list << "role[database]"
|
343
|
+
node.consume_run_list "foo" => "bar"
|
344
|
+
node.run_list.should == ["role[database]"]
|
295
345
|
end
|
296
346
|
|
297
347
|
it "raises an exception if you provide both recipe and run_list attributes, since this is ambiguous" do
|
298
|
-
lambda {
|
348
|
+
lambda { node.consume_run_list "recipes" => "stuff", "run_list" => "other_stuff" }.should raise_error(Chef::Exceptions::AmbiguousRunlistSpecification)
|
299
349
|
end
|
300
350
|
|
301
351
|
it "should add json attributes to the node" do
|
302
|
-
|
303
|
-
|
304
|
-
|
352
|
+
node.consume_external_attrs(@ohai_data, {"one" => "two", "three" => "four"})
|
353
|
+
node.one.should eql("two")
|
354
|
+
node.three.should eql("four")
|
305
355
|
end
|
306
356
|
|
307
357
|
it "should set the tags attribute to an empty array if it is not already defined" do
|
308
|
-
|
309
|
-
|
358
|
+
node.consume_external_attrs(@ohai_data, {})
|
359
|
+
node.tags.should eql([])
|
310
360
|
end
|
311
361
|
|
312
362
|
it "should not set the tags attribute to an empty array if it is already defined" do
|
313
|
-
|
314
|
-
|
315
|
-
|
363
|
+
node.normal[:tags] = [ "radiohead" ]
|
364
|
+
node.consume_external_attrs(@ohai_data, {})
|
365
|
+
node.tags.should eql([ "radiohead" ])
|
316
366
|
end
|
317
367
|
|
318
368
|
it "deep merges attributes instead of overwriting them" do
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
369
|
+
node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
|
370
|
+
node.one.to_hash.should == {"two" => {"three" => "four"}}
|
371
|
+
node.consume_external_attrs(@ohai_data, "one" => {"abc" => "123"})
|
372
|
+
node.consume_external_attrs(@ohai_data, "one" => {"two" => {"foo" => "bar"}})
|
373
|
+
node.one.to_hash.should == {"two" => {"three" => "four", "foo" => "bar"}, "abc" => "123"}
|
324
374
|
end
|
325
375
|
|
326
376
|
it "gives attributes from JSON priority when deep merging" do
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
377
|
+
node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "four"}})
|
378
|
+
node.one.to_hash.should == {"two" => {"three" => "four"}}
|
379
|
+
node.consume_external_attrs(@ohai_data, "one" => {"two" => {"three" => "forty-two"}})
|
380
|
+
node.one.to_hash.should == {"two" => {"three" => "forty-two"}}
|
331
381
|
end
|
332
382
|
|
333
383
|
end
|
@@ -338,161 +388,249 @@ describe Chef::Node do
|
|
338
388
|
end
|
339
389
|
|
340
390
|
it "sets its platform according to platform detection" do
|
341
|
-
|
342
|
-
|
343
|
-
|
391
|
+
node.consume_external_attrs(@ohai_data, {})
|
392
|
+
node.automatic_attrs[:platform].should == 'foobuntu'
|
393
|
+
node.automatic_attrs[:platform_version].should == '23.42'
|
344
394
|
end
|
345
395
|
|
346
396
|
it "consumes the run list from provided json attributes" do
|
347
|
-
|
348
|
-
|
397
|
+
node.consume_external_attrs(@ohai_data, {"run_list" => ['recipe[unicorn]']})
|
398
|
+
node.run_list.should == ['recipe[unicorn]']
|
349
399
|
end
|
350
400
|
|
351
401
|
it "saves non-runlist json attrs for later" do
|
352
402
|
expansion = Chef::RunList::RunListExpansion.new('_default', [])
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
403
|
+
node.run_list.stub!(:expand).and_return(expansion)
|
404
|
+
node.consume_external_attrs(@ohai_data, {"foo" => "bar"})
|
405
|
+
node.expand!
|
406
|
+
node.normal_attrs.should == {"foo" => "bar", "tags" => []}
|
357
407
|
end
|
358
408
|
|
359
409
|
end
|
360
410
|
|
361
411
|
describe "when expanding its run list and merging attributes" do
|
362
412
|
before do
|
363
|
-
@
|
364
|
-
|
413
|
+
@environment = Chef::Environment.new.tap do |e|
|
414
|
+
e.name('rspec_env')
|
415
|
+
e.default_attributes("env default key" => "env default value")
|
416
|
+
e.override_attributes("env override key" => "env override value")
|
417
|
+
end
|
418
|
+
Chef::Environment.should_receive(:load).with("rspec_env").and_return(@environment)
|
419
|
+
@expansion = Chef::RunList::RunListExpansion.new("rspec_env", [])
|
420
|
+
node.chef_environment("rspec_env")
|
421
|
+
node.run_list.stub!(:expand).and_return(@expansion)
|
365
422
|
end
|
366
423
|
|
367
424
|
it "sets the 'recipes' automatic attribute to the recipes in the expanded run_list" do
|
368
425
|
@expansion.recipes << 'recipe[chef::client]' << 'recipe[nginx::default]'
|
369
|
-
|
370
|
-
|
426
|
+
node.expand!
|
427
|
+
node.automatic_attrs[:recipes].should == ['recipe[chef::client]', 'recipe[nginx::default]']
|
371
428
|
end
|
372
429
|
|
373
430
|
it "sets the 'roles' automatic attribute to the expanded role list" do
|
374
431
|
@expansion.instance_variable_set(:@applied_roles, {'arf' => nil, 'countersnark' => nil})
|
375
|
-
|
376
|
-
|
432
|
+
node.expand!
|
433
|
+
node.automatic_attrs[:roles].sort.should == ['arf', 'countersnark']
|
434
|
+
end
|
435
|
+
|
436
|
+
it "applies default attributes from the environment as environment defaults" do
|
437
|
+
node.expand!
|
438
|
+
node.attributes.env_default["env default key"].should == "env default value"
|
439
|
+
end
|
440
|
+
|
441
|
+
it "applies override attributes from the environment as env overrides" do
|
442
|
+
node.expand!
|
443
|
+
node.attributes.env_override["env override key"].should == "env override value"
|
444
|
+
end
|
445
|
+
|
446
|
+
it "applies default attributes from roles as role defaults" do
|
447
|
+
@expansion.default_attrs["role default key"] = "role default value"
|
448
|
+
node.expand!
|
449
|
+
node.attributes.role_default["role default key"].should == "role default value"
|
377
450
|
end
|
378
451
|
|
452
|
+
it "applies override attributes from roles as role overrides" do
|
453
|
+
@expansion.override_attrs["role override key"] = "role override value"
|
454
|
+
node.expand!
|
455
|
+
node.attributes.role_override["role override key"].should == "role override value"
|
456
|
+
end
|
379
457
|
end
|
380
458
|
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
459
|
+
describe "when querying for recipes in the run list" do
|
460
|
+
context "when a recipe is in the top level run list" do
|
461
|
+
before do
|
462
|
+
node.run_list << "recipe[nginx::module]"
|
463
|
+
end
|
464
|
+
|
465
|
+
it "finds the recipe" do
|
466
|
+
node.recipe?("nginx::module").should be_true
|
467
|
+
end
|
468
|
+
|
469
|
+
it "does not find a recipe not in the run list" do
|
470
|
+
node.recipe?("nginx::other_module").should be_false
|
471
|
+
end
|
472
|
+
end
|
473
|
+
context "when a recipe is in the expanded run list only" do
|
474
|
+
before do
|
475
|
+
node.run_list << "role[base]"
|
476
|
+
node.automatic_attrs[:recipes] = [ "nginx::module" ]
|
477
|
+
end
|
478
|
+
|
479
|
+
it "finds a recipe in the expanded run list" do
|
480
|
+
node.recipe?("nginx::module").should be_true
|
481
|
+
end
|
482
|
+
|
483
|
+
it "does not find a recipe that's not in the run list" do
|
484
|
+
node.recipe?("nginx::other_module").should be_false
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
describe "when clearing computed state at the beginning of a run" do
|
490
|
+
before do
|
491
|
+
node.default[:foo] = "default"
|
492
|
+
node.normal[:foo] = "normal"
|
493
|
+
node.override[:foo] = "override"
|
494
|
+
node.reset_defaults_and_overrides
|
495
|
+
end
|
496
|
+
|
497
|
+
it "removes default attributes" do
|
498
|
+
node.default.should be_empty
|
499
|
+
end
|
500
|
+
|
501
|
+
it "removes override attributes" do
|
502
|
+
node.override.should be_empty
|
503
|
+
end
|
504
|
+
|
505
|
+
it "leaves normal level attributes untouched" do
|
506
|
+
node[:foo].should == "normal"
|
507
|
+
end
|
508
|
+
|
509
|
+
end
|
510
|
+
|
511
|
+
describe "when merging environment attributes" do
|
512
|
+
before do
|
513
|
+
node.chef_environment = "rspec"
|
514
|
+
@expansion = Chef::RunList::RunListExpansion.new("rspec", [])
|
515
|
+
@expansion.default_attrs.replace({:default => "from role", :d_role => "role only"})
|
516
|
+
@expansion.override_attrs.replace({:override => "from role", :o_role => "role only"})
|
517
|
+
|
518
|
+
|
519
|
+
@environment = Chef::Environment.new
|
520
|
+
@environment.default_attributes = {:default => "from env", :d_env => "env only" }
|
521
|
+
@environment.override_attributes = {:override => "from env", :o_env => "env only"}
|
522
|
+
Chef::Environment.stub!(:load).and_return(@environment)
|
523
|
+
node.apply_expansion_attributes(@expansion)
|
524
|
+
end
|
525
|
+
|
526
|
+
it "does not nuke role-only default attrs" do
|
527
|
+
node[:d_role].should == "role only"
|
528
|
+
end
|
529
|
+
|
530
|
+
it "does not nuke role-only override attrs" do
|
531
|
+
node[:o_role].should == "role only"
|
532
|
+
end
|
533
|
+
|
534
|
+
it "does not nuke env-only default attrs" do
|
535
|
+
node[:o_env].should == "env only"
|
536
|
+
end
|
537
|
+
|
538
|
+
it "does not nuke role-only override attrs" do
|
539
|
+
node[:o_env].should == "env only"
|
540
|
+
end
|
541
|
+
|
542
|
+
it "gives role defaults precedence over env defaults" do
|
543
|
+
node[:default].should == "from role"
|
544
|
+
end
|
545
|
+
|
546
|
+
it "gives env overrides precedence over role overrides" do
|
547
|
+
node[:override].should == "from env"
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
describe "when evaluating attributes files" do
|
552
|
+
before do
|
553
|
+
@cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
|
554
|
+
@cookbook_loader = Chef::CookbookLoader.new(@cookbook_repo)
|
555
|
+
@cookbook_loader.load_cookbooks
|
556
|
+
|
557
|
+
@cookbook_collection = Chef::CookbookCollection.new(@cookbook_loader.cookbooks_by_name)
|
558
|
+
|
559
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
560
|
+
@run_context = Chef::RunContext.new(node, @cookbook_collection, @events)
|
561
|
+
|
562
|
+
node.include_attribute("openldap::default")
|
563
|
+
node.include_attribute("openldap::smokey")
|
564
|
+
end
|
565
|
+
|
566
|
+
it "sets attributes from the files" do
|
567
|
+
node.ldap_server.should eql("ops1prod")
|
568
|
+
node.ldap_basedn.should eql("dc=hjksolutions,dc=com")
|
569
|
+
node.ldap_replication_password.should eql("forsure")
|
570
|
+
node.smokey.should eql("robinson")
|
571
|
+
end
|
572
|
+
|
573
|
+
it "gives a sensible error when attempting to load a missing attributes file" do
|
574
|
+
lambda { node.include_attribute("nope-this::doesnt-exist") }.should raise_error(Chef::Exceptions::CookbookNotFound)
|
575
|
+
end
|
576
|
+
end
|
408
577
|
|
409
578
|
describe "roles" do
|
410
579
|
it "should allow you to query whether or not it has a recipe applied with role?" do
|
411
|
-
|
412
|
-
|
413
|
-
|
580
|
+
node.run_list << "role[sunrise]"
|
581
|
+
node.role?("sunrise").should eql(true)
|
582
|
+
node.role?("not at home").should eql(false)
|
414
583
|
end
|
415
584
|
|
416
585
|
it "should allow you to set roles with arguments" do
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
586
|
+
node.run_list << "role[one]"
|
587
|
+
node.run_list << "role[two]"
|
588
|
+
node.role?("one").should eql(true)
|
589
|
+
node.role?("two").should eql(true)
|
421
590
|
end
|
422
591
|
end
|
423
592
|
|
424
593
|
describe "run_list" do
|
425
594
|
it "should have a Chef::RunList of recipes and roles that should be applied" do
|
426
|
-
|
595
|
+
node.run_list.should be_a_kind_of(Chef::RunList)
|
427
596
|
end
|
428
597
|
|
429
598
|
it "should allow you to query the run list with arguments" do
|
430
|
-
|
431
|
-
|
599
|
+
node.run_list "recipe[baz]"
|
600
|
+
node.run_list?("recipe[baz]").should eql(true)
|
432
601
|
end
|
433
602
|
|
434
603
|
it "should allow you to set the run list with arguments" do
|
435
|
-
|
436
|
-
|
437
|
-
|
604
|
+
node.run_list "recipe[baz]", "role[foo]"
|
605
|
+
node.run_list?("recipe[baz]").should eql(true)
|
606
|
+
node.run_list?("role[foo]").should eql(true)
|
438
607
|
end
|
439
608
|
end
|
440
609
|
|
441
610
|
describe "from file" do
|
442
611
|
it "should load a node from a ruby file" do
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
612
|
+
node.from_file(File.expand_path(File.join(CHEF_SPEC_DATA, "nodes", "test.rb")))
|
613
|
+
node.name.should eql("test.example.com-short")
|
614
|
+
node.sunshine.should eql("in")
|
615
|
+
node.something.should eql("else")
|
616
|
+
node.run_list.should == ["operations-master", "operations-monitoring"]
|
448
617
|
end
|
449
618
|
|
450
619
|
it "should raise an exception if the file cannot be found or read" do
|
451
|
-
lambda {
|
452
|
-
end
|
453
|
-
end
|
454
|
-
|
455
|
-
describe "find_file" do
|
456
|
-
it "should load a node from a file by fqdn" do
|
457
|
-
@node.find_file("test.example.com")
|
458
|
-
@node.name.should == "test.example.com"
|
459
|
-
@node.chef_environment.should == "dev"
|
460
|
-
end
|
461
|
-
|
462
|
-
it "should load a node from a file by hostname" do
|
463
|
-
File.stub!(:exists?).and_return(true)
|
464
|
-
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.example.com.rb")).and_return(false)
|
465
|
-
@node.find_file("test.example.com")
|
466
|
-
@node.name.should == "test.example.com-short"
|
467
|
-
end
|
468
|
-
|
469
|
-
it "should load a node from the default file" do
|
470
|
-
File.stub!(:exists?).and_return(true)
|
471
|
-
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.example.com.rb")).and_return(false)
|
472
|
-
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.rb")).and_return(false)
|
473
|
-
@node.find_file("test.example.com")
|
474
|
-
@node.name.should == "test.example.com-default"
|
475
|
-
end
|
476
|
-
|
477
|
-
it "should raise an ArgumentError if it cannot find any node file at all" do
|
478
|
-
File.stub!(:exists?).and_return(true)
|
479
|
-
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.example.com.rb")).and_return(false)
|
480
|
-
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "test.rb")).and_return(false)
|
481
|
-
File.should_receive(:exists?).with(File.join(Chef::Config[:node_path], "default.rb")).and_return(false)
|
482
|
-
lambda { @node.find_file("test.example.com") }.should raise_error(ArgumentError)
|
620
|
+
lambda { node.from_file("/tmp/monkeydiving") }.should raise_error(IOError)
|
483
621
|
end
|
484
622
|
end
|
485
623
|
|
486
624
|
describe "update_from!" do
|
487
625
|
before(:each) do
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
626
|
+
node.name("orig")
|
627
|
+
node.chef_environment("dev")
|
628
|
+
node.default_attrs = { "one" => { "two" => "three", "four" => "five", "eight" => "nine" } }
|
629
|
+
node.override_attrs = { "one" => { "two" => "three", "four" => "six" } }
|
630
|
+
node.normal_attrs = { "one" => { "two" => "seven" } }
|
631
|
+
node.run_list << "role[marxist]"
|
632
|
+
node.run_list << "role[leninist]"
|
633
|
+
node.run_list << "recipe[stalinist]"
|
496
634
|
|
497
635
|
@example = Chef::Node.new()
|
498
636
|
@example.name("newname")
|
@@ -506,31 +644,31 @@ describe Chef::Node do
|
|
506
644
|
end
|
507
645
|
|
508
646
|
it "allows update of everything except name" do
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
647
|
+
node.update_from!(@example)
|
648
|
+
node.name.should == "orig"
|
649
|
+
node.chef_environment.should == @example.chef_environment
|
650
|
+
node.default_attrs.should == @example.default_attrs
|
651
|
+
node.override_attrs.should == @example.override_attrs
|
652
|
+
node.normal_attrs.should == @example.normal_attrs
|
653
|
+
node.run_list.should == @example.run_list
|
516
654
|
end
|
517
655
|
|
518
656
|
it "should not update the name of the node" do
|
519
|
-
|
520
|
-
|
657
|
+
node.should_not_receive(:name).with(@example.name)
|
658
|
+
node.update_from!(@example)
|
521
659
|
end
|
522
660
|
end
|
523
661
|
|
524
662
|
describe "to_hash" do
|
525
663
|
it "should serialize itself as a hash" do
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
h =
|
664
|
+
node.chef_environment("dev")
|
665
|
+
node.default_attrs = { "one" => { "two" => "three", "four" => "five", "eight" => "nine" } }
|
666
|
+
node.override_attrs = { "one" => { "two" => "three", "four" => "six" } }
|
667
|
+
node.normal_attrs = { "one" => { "two" => "seven" } }
|
668
|
+
node.run_list << "role[marxist]"
|
669
|
+
node.run_list << "role[leninist]"
|
670
|
+
node.run_list << "recipe[stalinist]"
|
671
|
+
h = node.to_hash
|
534
672
|
h["one"]["two"].should == "three"
|
535
673
|
h["one"]["four"].should == "six"
|
536
674
|
h["one"]["eight"].should == "nine"
|
@@ -543,10 +681,10 @@ describe Chef::Node do
|
|
543
681
|
end
|
544
682
|
end
|
545
683
|
|
546
|
-
describe "json" do
|
684
|
+
describe "converting to or from json" do
|
547
685
|
it "should serialize itself as json", :json => true do
|
548
|
-
|
549
|
-
json = Chef::JSONCompat.to_json(
|
686
|
+
node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
|
687
|
+
json = Chef::JSONCompat.to_json(node)
|
550
688
|
json.should =~ /json_class/
|
551
689
|
json.should =~ /name/
|
552
690
|
json.should =~ /chef_environment/
|
@@ -556,33 +694,50 @@ describe Chef::Node do
|
|
556
694
|
json.should =~ /run_list/
|
557
695
|
end
|
558
696
|
|
559
|
-
it 'should
|
697
|
+
it 'should serialize valid json with a run list', :json => true do
|
560
698
|
#This test came about because activesupport mucks with Chef json serialization
|
561
699
|
#Test should pass with and without Activesupport
|
562
|
-
|
563
|
-
|
564
|
-
json = Chef::JSONCompat.to_json(
|
700
|
+
node.run_list << {"type" => "role", "name" => 'Cthulu'}
|
701
|
+
node.run_list << {"type" => "role", "name" => 'Hastur'}
|
702
|
+
json = Chef::JSONCompat.to_json(node)
|
565
703
|
json.should =~ /\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/
|
566
704
|
end
|
567
705
|
|
706
|
+
it "merges the override components into a combined override object" do
|
707
|
+
node.attributes.role_override["role override"] = "role override"
|
708
|
+
node.attributes.env_override["env override"] = "env override"
|
709
|
+
node_for_json = node.for_json
|
710
|
+
node_for_json["override"]["role override"].should == "role override"
|
711
|
+
node_for_json["override"]["env override"].should == "env override"
|
712
|
+
end
|
713
|
+
|
714
|
+
it "merges the default components into a combined default object" do
|
715
|
+
node.attributes.role_default["role default"] = "role default"
|
716
|
+
node.attributes.env_default["env default"] = "env default"
|
717
|
+
node_for_json = node.for_json
|
718
|
+
node_for_json["default"]["role default"].should == "role default"
|
719
|
+
node_for_json["default"]["env default"].should == "env default"
|
720
|
+
end
|
721
|
+
|
722
|
+
|
568
723
|
it "should deserialize itself from json", :json => true do
|
569
|
-
|
570
|
-
json = Chef::JSONCompat.to_json(
|
724
|
+
node.from_file(File.expand_path("nodes/test.example.com.rb", CHEF_SPEC_DATA))
|
725
|
+
json = Chef::JSONCompat.to_json(node)
|
571
726
|
serialized_node = Chef::JSONCompat.from_json(json)
|
572
727
|
serialized_node.should be_a_kind_of(Chef::Node)
|
573
|
-
serialized_node.name.should eql(
|
574
|
-
serialized_node.chef_environment.should eql(
|
575
|
-
|
728
|
+
serialized_node.name.should eql(node.name)
|
729
|
+
serialized_node.chef_environment.should eql(node.chef_environment)
|
730
|
+
node.each_attribute do |k,v|
|
576
731
|
serialized_node[k].should eql(v)
|
577
732
|
end
|
578
|
-
serialized_node.run_list.should ==
|
733
|
+
serialized_node.run_list.should == node.run_list
|
579
734
|
end
|
580
735
|
end
|
581
736
|
|
582
737
|
describe "to_s" do
|
583
738
|
it "should turn into a string like node[name]" do
|
584
|
-
|
585
|
-
|
739
|
+
node.name("airplane")
|
740
|
+
node.to_s.should eql("node[airplane]")
|
586
741
|
end
|
587
742
|
end
|
588
743
|
|
@@ -621,31 +776,31 @@ describe Chef::Node do
|
|
621
776
|
describe "destroy" do
|
622
777
|
it "should destroy a node" do
|
623
778
|
@rest.should_receive(:delete_rest).with("nodes/monkey").and_return("foo")
|
624
|
-
|
625
|
-
|
779
|
+
node.name("monkey")
|
780
|
+
node.destroy
|
626
781
|
end
|
627
782
|
end
|
628
783
|
|
629
784
|
describe "save" do
|
630
785
|
it "should update a node if it already exists" do
|
631
|
-
|
632
|
-
@rest.should_receive(:put_rest).with("nodes/monkey",
|
633
|
-
|
786
|
+
node.name("monkey")
|
787
|
+
@rest.should_receive(:put_rest).with("nodes/monkey", node).and_return("foo")
|
788
|
+
node.save
|
634
789
|
end
|
635
790
|
|
636
791
|
it "should not try and create if it can update" do
|
637
|
-
|
638
|
-
@rest.should_receive(:put_rest).with("nodes/monkey",
|
792
|
+
node.name("monkey")
|
793
|
+
@rest.should_receive(:put_rest).with("nodes/monkey", node).and_return("foo")
|
639
794
|
@rest.should_not_receive(:post_rest)
|
640
|
-
|
795
|
+
node.save
|
641
796
|
end
|
642
797
|
|
643
798
|
it "should create if it cannot update" do
|
644
|
-
|
799
|
+
node.name("monkey")
|
645
800
|
exception = mock("404 error", :code => "404")
|
646
801
|
@rest.should_receive(:put_rest).and_raise(Net::HTTPServerException.new("foo", exception))
|
647
|
-
@rest.should_receive(:post_rest).with("nodes",
|
648
|
-
|
802
|
+
@rest.should_receive(:post_rest).with("nodes", node)
|
803
|
+
node.save
|
649
804
|
end
|
650
805
|
|
651
806
|
describe "when whyrun mode is enabled" do
|
@@ -656,120 +811,13 @@ describe Chef::Node do
|
|
656
811
|
Chef::Config[:why_run] = false
|
657
812
|
end
|
658
813
|
it "should not save" do
|
659
|
-
|
814
|
+
node.name("monkey")
|
660
815
|
@rest.should_not_receive(:put_rest)
|
661
816
|
@rest.should_not_receive(:post_rest)
|
662
|
-
|
817
|
+
node.save
|
663
818
|
end
|
664
819
|
end
|
665
820
|
end
|
666
821
|
end
|
667
822
|
|
668
|
-
describe "acting as a CouchDB-backed model" do
|
669
|
-
before(:each) do
|
670
|
-
@couchdb = Chef::CouchDB.new
|
671
|
-
@mock_couch = mock('couch mock')
|
672
|
-
end
|
673
|
-
|
674
|
-
describe "list" do
|
675
|
-
before(:each) do
|
676
|
-
@mock_couch.stub!(:list).and_return(
|
677
|
-
{ "rows" => [ { "value" => "a", "key" => "avenue" } ] }
|
678
|
-
)
|
679
|
-
Chef::CouchDB.stub!(:new).and_return(@mock_couch)
|
680
|
-
end
|
681
|
-
|
682
|
-
it "should retrieve a list of nodes from CouchDB" do
|
683
|
-
Chef::Node.cdb_list.should eql(["avenue"])
|
684
|
-
end
|
685
|
-
|
686
|
-
it "should return just the ids if inflate is false" do
|
687
|
-
Chef::Node.cdb_list(false).should eql(["avenue"])
|
688
|
-
end
|
689
|
-
|
690
|
-
it "should return the full objects if inflate is true" do
|
691
|
-
Chef::Node.cdb_list(true).should eql(["a"])
|
692
|
-
end
|
693
|
-
end
|
694
|
-
|
695
|
-
describe "when loading a given node" do
|
696
|
-
it "should load a node from couchdb by name" do
|
697
|
-
@couchdb.should_receive(:load).with("node", "coffee").and_return(true)
|
698
|
-
Chef::CouchDB.stub!(:new).and_return(@couchdb)
|
699
|
-
Chef::Node.cdb_load("coffee")
|
700
|
-
end
|
701
|
-
end
|
702
|
-
|
703
|
-
describe "when destroying a Node" do
|
704
|
-
it "should delete this node from couchdb" do
|
705
|
-
@couchdb.should_receive(:delete).with("node", "bob", 1).and_return(true)
|
706
|
-
Chef::CouchDB.stub!(:new).and_return(@couchdb)
|
707
|
-
node = Chef::Node.new
|
708
|
-
node.name "bob"
|
709
|
-
node.couchdb_rev = 1
|
710
|
-
node.cdb_destroy
|
711
|
-
end
|
712
|
-
end
|
713
|
-
|
714
|
-
describe "when saving a Node" do
|
715
|
-
before(:each) do
|
716
|
-
@couchdb.stub!(:store).and_return({ "rev" => 33 })
|
717
|
-
Chef::CouchDB.stub!(:new).and_return(@couchdb)
|
718
|
-
@node = Chef::Node.new
|
719
|
-
@node.name "bob"
|
720
|
-
@node.couchdb_rev = 1
|
721
|
-
end
|
722
|
-
|
723
|
-
it "should save the node to couchdb" do
|
724
|
-
@couchdb.should_receive(:store).with("node", "bob", @node).and_return({ "rev" => 33 })
|
725
|
-
@node.cdb_save
|
726
|
-
end
|
727
|
-
|
728
|
-
it "should store the new couchdb_rev" do
|
729
|
-
@node.cdb_save
|
730
|
-
@node.couchdb_rev.should eql(33)
|
731
|
-
end
|
732
|
-
end
|
733
|
-
|
734
|
-
describe "create_design_document" do
|
735
|
-
it "should create our design document" do
|
736
|
-
@couchdb.should_receive(:create_design_document).with("nodes", Chef::Node::DESIGN_DOCUMENT)
|
737
|
-
Chef::CouchDB.stub!(:new).and_return(@couchdb)
|
738
|
-
Chef::Node.create_design_document
|
739
|
-
end
|
740
|
-
end
|
741
|
-
|
742
|
-
end
|
743
|
-
|
744
|
-
describe "regression test for CHEF-4631" do
|
745
|
-
before(:each) do
|
746
|
-
@node.stub!(:chef_environment).and_return("_default")
|
747
|
-
end
|
748
|
-
|
749
|
-
it "array values in the role default attributes should be concatanated to the nodes default attributes" do
|
750
|
-
@node.default_attrs = {"foo" => {"bar" => ["1", "2"]}}
|
751
|
-
expansion = mock("Expansion", :default_attrs => { "foo" => {"bar" => ["3", "2"]}}, :override_attrs => { })
|
752
|
-
@node.apply_expansion_attributes(expansion)
|
753
|
-
@node["foo"]["bar"].should == ["1", "2", "3", "2"]
|
754
|
-
@node["foo"].to_hash["bar"].should == ["1", "2", "3", "2"]
|
755
|
-
end
|
756
|
-
|
757
|
-
it "array values in the role override attributes should override the nodes default attributes" do
|
758
|
-
@node.default_attrs = {"foo" => {"bar" => ["1", "2"]}}
|
759
|
-
expansion = mock("Expansion", :default_attrs => { "foo" => {"bar" => ["3", "2"]}}, :override_attrs => { "foo" => {"bar" => ["5"] } })
|
760
|
-
@node.apply_expansion_attributes(expansion)
|
761
|
-
@node["foo"]["bar"].should == ["5"]
|
762
|
-
@node["foo"].to_hash["bar"].should == ["5"]
|
763
|
-
end
|
764
|
-
|
765
|
-
it "array values in the role override attributes should merge with the nodes override attributes" do
|
766
|
-
@node.default_attrs = {"foo" => {"bar" => ["1", "2"]}}
|
767
|
-
@node.override_attrs = {"foo" => {"bar" => ["5", "0"]}}
|
768
|
-
expansion = mock("Expansion", :default_attrs => { "foo" => {"bar" => ["3", "2"]}}, :override_attrs => { "foo" => {"bar" => ["5"] } })
|
769
|
-
@node.apply_expansion_attributes(expansion)
|
770
|
-
@node["foo"]["bar"].should == ["5", "0", "5"]
|
771
|
-
@node["foo"].to_hash["bar"].should == ["5", "0", "5"]
|
772
|
-
end
|
773
|
-
end
|
774
|
-
|
775
823
|
end
|