chef 11.6.2-x86-mingw32 → 11.8.0.rc.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +12 -12
- data/Rakefile +11 -14
- data/bin/chef-apply +2 -2
- data/bin/chef-client +2 -2
- data/bin/chef-service-manager +2 -2
- data/bin/chef-shell +3 -0
- data/bin/chef-solo +2 -2
- data/bin/knife +3 -3
- data/distro/arch/etc/rc.d/chef-client +2 -2
- data/distro/arch/etc/rc.d/chef-server +2 -2
- data/distro/arch/etc/rc.d/chef-server-webui +2 -2
- data/distro/arch/etc/rc.d/chef-solr +2 -2
- data/distro/common/html/chef-client.8.html +3 -3
- data/distro/common/html/chef-expander.8.html +3 -3
- data/distro/common/html/chef-expanderctl.8.html +3 -3
- data/distro/common/html/chef-server-webui.8.html +3 -3
- data/distro/common/html/chef-server.8.html +3 -3
- data/distro/common/html/chef-shell.1.html +3 -3
- data/distro/common/html/chef-solo.8.html +3 -3
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +3 -3
- data/distro/common/html/knife-client.1.html +3 -3
- data/distro/common/html/knife-configure.1.html +13 -13
- data/distro/common/html/knife-cookbook-site.1.html +3 -3
- data/distro/common/html/knife-cookbook.1.html +7 -7
- data/distro/common/html/knife-data-bag.1.html +3 -3
- data/distro/common/html/knife-environment.1.html +3 -3
- data/distro/common/html/knife-exec.1.html +3 -3
- data/distro/common/html/knife-index.1.html +3 -3
- data/distro/common/html/knife-node.1.html +3 -3
- data/distro/common/html/knife-role.1.html +3 -3
- data/distro/common/html/knife-search.1.html +3 -3
- data/distro/common/html/knife-ssh.1.html +3 -3
- data/distro/common/html/knife-status.1.html +3 -3
- data/distro/common/html/knife-tag.1.html +3 -3
- data/distro/common/html/knife.1.html +3 -3
- data/distro/common/man/man1/README.md +58 -0
- data/distro/common/man/man1/chef-shell.1 +114 -219
- data/distro/common/man/man1/knife-bootstrap.1 +176 -180
- data/distro/common/man/man1/knife-client.1 +368 -0
- data/distro/common/man/man1/knife-configure.1 +147 -85
- data/distro/common/man/man1/knife-cookbook-site.1 +465 -133
- data/distro/common/man/man1/knife-cookbook.1 +614 -304
- data/distro/common/man/man1/knife-data-bag.1 +476 -113
- data/distro/common/man/man1/knife-delete.1 +132 -0
- data/distro/common/man/man1/knife-deps.1 +219 -0
- data/distro/common/man/man1/knife-diff.1 +212 -0
- data/distro/common/man/man1/knife-download.1 +220 -0
- data/distro/common/man/man1/knife-edit.1 +126 -0
- data/distro/common/man/man1/knife-environment.1 +324 -0
- data/distro/common/man/man1/knife-exec.1 +317 -35
- data/distro/common/man/man1/knife-index-rebuild.1 +115 -0
- data/distro/common/man/man1/knife-list.1 +167 -0
- data/distro/common/man/man1/knife-node.1 +567 -123
- data/distro/common/man/man1/knife-raw.1 +170 -0
- data/distro/common/man/man1/knife-recipe-list.1 +133 -0
- data/distro/common/man/man1/knife-role.1 +367 -81
- data/distro/common/man/man1/knife-search.1 +267 -243
- data/distro/common/man/man1/knife-show.1 +138 -0
- data/distro/common/man/man1/knife-ssh.1 +241 -66
- data/distro/common/man/man1/knife-status.1 +202 -24
- data/distro/common/man/man1/knife-tag.1 +176 -39
- data/distro/common/man/man1/knife-upload.1 +239 -0
- data/distro/common/man/man1/knife-user.1 +317 -0
- data/distro/common/man/man1/knife-xargs.1 +166 -0
- data/distro/common/man/man1/knife.1 +227 -284
- data/distro/common/man/man8/chef-client.8 +247 -81
- data/distro/common/man/man8/chef-solo.8 +142 -110
- data/distro/common/markdown/man1/knife-bootstrap.mkd +1 -1
- data/distro/common/markdown/man1/knife-configure.mkd +11 -11
- data/distro/common/markdown/man1/knife-cookbook.mkd +4 -4
- data/distro/common/markdown/man8/chef-expander.mkd +1 -1
- data/distro/common/markdown/man8/chef-expanderctl.mkd +1 -1
- data/distro/debian/etc/init.d/chef-client +1 -1
- data/distro/debian/etc/init.d/chef-expander +1 -1
- data/distro/debian/etc/init.d/chef-server +1 -1
- data/distro/debian/etc/init.d/chef-server-webui +1 -1
- data/distro/debian/etc/init.d/chef-solr +1 -1
- data/distro/debian/etc/init/chef-client.conf +1 -1
- data/distro/debian/etc/init/chef-expander.conf +1 -1
- data/distro/debian/etc/init/chef-server-webui.conf +1 -1
- data/distro/debian/etc/init/chef-server.conf +1 -1
- data/distro/debian/etc/init/chef-solr.conf +1 -1
- data/distro/redhat/etc/init.d/chef-client +1 -1
- data/distro/redhat/etc/init.d/chef-server +2 -2
- data/distro/redhat/etc/init.d/chef-server-webui +2 -2
- data/distro/redhat/etc/init.d/chef-solr +2 -2
- data/lib/chef/api_client.rb +20 -5
- data/lib/chef/application.rb +53 -22
- data/lib/chef/application/agent.rb +2 -2
- data/lib/chef/application/client.rb +34 -24
- data/lib/chef/application/knife.rb +10 -0
- data/lib/chef/application/solo.rb +9 -27
- data/lib/chef/application/windows_service.rb +24 -10
- data/lib/chef/application/windows_service_manager.rb +8 -0
- data/lib/chef/checksum/storage.rb +2 -2
- data/lib/chef/checksum/storage/filesystem.rb +2 -2
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +2 -1
- data/lib/chef/chef_fs/config.rb +19 -64
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -2
- data/lib/chef/chef_fs/file_system.rb +2 -2
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_acls_dir.rb +37 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +16 -8
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +19 -4
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +27 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +31 -3
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +12 -5
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +12 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +3 -2
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +2 -5
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +21 -6
- data/lib/chef/chef_fs/file_system/data_bag_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -2
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +15 -5
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +2 -1
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/operation_failed_error.rb +8 -0
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -2
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -6
- data/lib/chef/chef_fs/knife.rb +39 -22
- data/lib/chef/chef_fs/path_utils.rb +5 -0
- data/lib/chef/client.rb +9 -3
- data/lib/chef/config.rb +306 -115
- data/lib/chef/config_fetcher.rb +79 -0
- data/lib/chef/cookbook/file_vendor.rb +5 -5
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook/syntax_check.rb +6 -16
- data/lib/chef/cookbook_site_streaming_uploader.rb +8 -4
- data/lib/chef/cookbook_uploader.rb +10 -8
- data/lib/chef/cookbook_version.rb +24 -8
- data/lib/chef/daemon.rb +14 -75
- data/lib/chef/data_bag.rb +2 -3
- data/lib/chef/dsl/include_recipe.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +1 -1
- data/lib/chef/event_dispatch/dispatcher.rb +1 -1
- data/lib/chef/file_access_control/windows.rb +1 -1
- data/lib/chef/formatters/doc.rb +5 -5
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +2 -2
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/handler/json_file.rb +2 -2
- data/lib/chef/http.rb +386 -0
- data/lib/chef/{rest → http}/auth_credentials.rb +1 -1
- data/lib/chef/http/authenticator.rb +89 -0
- data/lib/chef/http/basic_client.rb +114 -0
- data/lib/chef/{rest → http}/cookie_jar.rb +1 -1
- data/lib/chef/http/cookie_manager.rb +56 -0
- data/lib/chef/http/decompressor.rb +137 -0
- data/lib/chef/{rest/rest_request.rb → http/http_request.rb} +13 -74
- data/lib/chef/http/json_input.rb +53 -0
- data/lib/chef/http/json_output.rb +69 -0
- data/lib/chef/http/json_to_model_output.rb +34 -0
- data/lib/chef/http/simple.rb +16 -0
- data/lib/chef/http/ssl_policies.rb +129 -0
- data/lib/chef/knife.rb +45 -23
- data/lib/chef/knife/bootstrap.rb +10 -3
- data/lib/chef/knife/bootstrap/chef-full.erb +10 -1
- data/lib/chef/knife/client_create.rb +1 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_create.rb +7 -7
- data/lib/chef/knife/cookbook_download.rb +2 -2
- data/lib/chef/knife/cookbook_metadata_from_file.rb +2 -2
- data/lib/chef/knife/cookbook_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_install.rb +2 -2
- data/lib/chef/knife/cookbook_site_list.rb +2 -2
- data/lib/chef/knife/cookbook_site_search.rb +3 -3
- data/lib/chef/knife/cookbook_site_show.rb +5 -5
- data/lib/chef/knife/core/bootstrap_context.rb +7 -3
- data/lib/chef/knife/core/node_editor.rb +16 -36
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +5 -5
- data/lib/chef/knife/core/ui.rb +9 -13
- data/lib/chef/knife/data_bag_create.rb +7 -5
- data/lib/chef/knife/data_bag_delete.rb +3 -3
- data/lib/chef/knife/data_bag_edit.rb +9 -7
- data/lib/chef/knife/data_bag_from_file.rb +10 -8
- data/lib/chef/knife/data_bag_list.rb +2 -2
- data/lib/chef/knife/data_bag_show.rb +9 -7
- data/lib/chef/knife/delete.rb +2 -0
- data/lib/chef/knife/deps.rb +2 -0
- data/lib/chef/knife/diff.rb +6 -0
- data/lib/chef/knife/download.rb +6 -0
- data/lib/chef/knife/edit.rb +5 -8
- data/lib/chef/knife/environment_from_file.rb +2 -2
- data/lib/chef/knife/help_topics.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +2 -2
- data/lib/chef/knife/list.rb +2 -0
- data/lib/chef/knife/raw.rb +31 -5
- data/lib/chef/knife/show.rb +2 -0
- data/lib/chef/knife/ssh.rb +21 -7
- data/lib/chef/knife/status.rb +1 -1
- data/lib/chef/knife/upload.rb +2 -0
- data/lib/chef/knife/xargs.rb +2 -0
- data/lib/chef/mixin/checksum.rb +2 -2
- data/lib/chef/mixin/command.rb +46 -17
- data/lib/chef/mixin/convert_to_class_name.rb +8 -8
- data/lib/chef/mixin/create_path.rb +9 -9
- data/lib/chef/mixin/deep_merge.rb +2 -2
- data/lib/chef/mixin/from_file.rb +6 -6
- data/lib/chef/mixin/language_include_recipe.rb +2 -2
- data/lib/chef/mixin/params_validate.rb +21 -21
- data/lib/chef/mixin/shell_out.rb +9 -0
- data/lib/chef/mixin/template.rb +13 -16
- data/lib/chef/mixin/why_run.rb +16 -16
- data/lib/chef/mixin/windows_architecture_helper.rb +5 -5
- data/lib/chef/mixin/xml_escape.rb +10 -10
- data/lib/chef/monkey_patches/numeric.rb +1 -1
- data/lib/chef/monkey_patches/regexp.rb +4 -4
- data/lib/chef/monkey_patches/string.rb +3 -3
- data/lib/chef/monkey_patches/tempfile.rb +2 -2
- data/lib/chef/node.rb +8 -0
- data/lib/chef/node/attribute.rb +1 -1
- data/lib/chef/platform/provider_mapping.rb +26 -1
- data/lib/chef/provider/batch.rb +3 -3
- data/lib/chef/provider/cron.rb +27 -13
- data/lib/chef/provider/cron/aix.rb +48 -0
- data/lib/chef/provider/cron/solaris.rb +6 -40
- data/lib/chef/provider/cron/unix.rb +76 -0
- data/lib/chef/provider/deploy/timestamped.rb +4 -4
- data/lib/chef/provider/erl_call.rb +1 -1
- data/lib/chef/provider/execute.rb +2 -2
- data/lib/chef/provider/git.rb +1 -0
- data/lib/chef/provider/group.rb +21 -21
- data/lib/chef/provider/group/dscl.rb +9 -9
- data/lib/chef/provider/group/gpasswd.rb +5 -5
- data/lib/chef/provider/group/groupadd.rb +11 -10
- data/lib/chef/provider/group/pw.rb +11 -11
- data/lib/chef/provider/group/suse.rb +4 -4
- data/lib/chef/provider/group/usermod.rb +8 -8
- data/lib/chef/provider/group/windows.rb +9 -9
- data/lib/chef/provider/http_request.rb +8 -8
- data/lib/chef/provider/ifconfig.rb +57 -37
- data/lib/chef/provider/ifconfig/aix.rb +99 -0
- data/lib/chef/provider/log.rb +3 -3
- data/lib/chef/provider/mdadm.rb +5 -4
- data/lib/chef/provider/mount.rb +12 -12
- data/lib/chef/provider/mount/aix.rb +179 -0
- data/lib/chef/provider/mount/mount.rb +29 -15
- data/lib/chef/provider/package.rb +26 -16
- data/lib/chef/provider/package/aix.rb +146 -0
- data/lib/chef/provider/package/apt.rb +16 -31
- data/lib/chef/provider/package/dpkg.rb +9 -9
- data/lib/chef/provider/package/freebsd.rb +2 -2
- data/lib/chef/provider/package/ips.rb +3 -3
- data/lib/chef/provider/package/macports.rb +1 -1
- data/lib/chef/provider/package/pacman.rb +8 -8
- data/lib/chef/provider/package/rpm.rb +14 -14
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +3 -3
- data/lib/chef/provider/package/solaris.rb +16 -6
- data/lib/chef/provider/package/yum-dump.py +4 -4
- data/lib/chef/provider/package/yum.rb +3 -3
- data/lib/chef/provider/powershell_script.rb +7 -7
- data/lib/chef/provider/remote_file/ftp.rb +1 -0
- data/lib/chef/provider/remote_file/http.rb +6 -13
- data/lib/chef/provider/remote_file/local_file.rb +1 -0
- data/lib/chef/provider/resource_update.rb +9 -9
- data/lib/chef/provider/ruby_block.rb +3 -3
- data/lib/chef/provider/script.rb +1 -1
- data/lib/chef/provider/service.rb +2 -2
- data/lib/chef/provider/service/debian.rb +35 -15
- data/lib/chef/provider/service/freebsd.rb +9 -9
- data/lib/chef/provider/service/gentoo.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/invokercd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/simple.rb +6 -6
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +3 -3
- data/lib/chef/provider/service/upstart.rb +15 -15
- data/lib/chef/provider/subversion.rb +6 -5
- data/lib/chef/provider/user.rb +13 -9
- data/lib/chef/provider/user/dscl.rb +28 -28
- data/lib/chef/provider/user/pw.rb +11 -11
- data/lib/chef/provider/user/useradd.rb +1 -1
- data/lib/chef/provider/user/windows.rb +7 -7
- data/lib/chef/provider/windows_script.rb +7 -7
- data/lib/chef/providers.rb +4 -0
- data/lib/chef/recipe.rb +2 -19
- data/lib/chef/resource/apt_package.rb +3 -3
- data/lib/chef/resource/bash.rb +3 -3
- data/lib/chef/resource/batch.rb +4 -4
- data/lib/chef/resource/bff_package.rb +36 -0
- data/lib/chef/resource/breakpoint.rb +3 -3
- data/lib/chef/resource/cron.rb +5 -5
- data/lib/chef/resource/csh.rb +3 -3
- data/lib/chef/resource/deploy.rb +16 -3
- data/lib/chef/resource/deploy_revision.rb +6 -6
- data/lib/chef/resource/directory.rb +2 -2
- data/lib/chef/resource/dpkg_package.rb +4 -4
- data/lib/chef/resource/easy_install_package.rb +1 -1
- data/lib/chef/resource/erl_call.rb +1 -1
- data/lib/chef/resource/freebsd_package.rb +4 -4
- data/lib/chef/resource/group.rb +15 -6
- data/lib/chef/resource/http_request.rb +6 -6
- data/lib/chef/resource/ifconfig.rb +4 -4
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/log.rb +12 -11
- data/lib/chef/resource/macports_package.rb +2 -2
- data/lib/chef/resource/mount.rb +11 -12
- data/lib/chef/resource/ohai.rb +3 -3
- data/lib/chef/resource/pacman_package.rb +4 -4
- data/lib/chef/resource/perl.rb +3 -3
- data/lib/chef/resource/portage_package.rb +4 -4
- data/lib/chef/resource/powershell_script.rb +3 -3
- data/lib/chef/resource/python.rb +3 -3
- data/lib/chef/resource/route.rb +4 -4
- data/lib/chef/resource/rpm_package.rb +2 -2
- data/lib/chef/resource/ruby.rb +3 -3
- data/lib/chef/resource/ruby_block.rb +3 -3
- data/lib/chef/resource/scm.rb +10 -2
- data/lib/chef/resource/script.rb +5 -5
- data/lib/chef/resource/service.rb +5 -5
- data/lib/chef/resource/smartos_package.rb +8 -6
- data/lib/chef/resource/solaris_package.rb +8 -7
- data/lib/chef/resource/subversion.rb +3 -3
- data/lib/chef/resource/timestamped_deploy.rb +4 -4
- data/lib/chef/resource/user.rb +13 -13
- data/lib/chef/resource/windows_script.rb +6 -6
- data/lib/chef/resource/yum_package.rb +2 -2
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_collection/stepable_iterator.rb +22 -22
- data/lib/chef/resource_definition.rb +8 -8
- data/lib/chef/resource_definition_list.rb +2 -2
- data/lib/chef/resource_reporter.rb +8 -2
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/rest.rb +70 -334
- data/lib/chef/role.rb +17 -13
- data/lib/chef/run_context.rb +14 -0
- data/lib/chef/run_context/cookbook_compiler.rb +3 -3
- data/lib/chef/run_lock.rb +73 -20
- data/lib/chef/server_api.rb +41 -0
- data/lib/chef/shell.rb +3 -19
- data/lib/chef/shell/shell_session.rb +1 -1
- data/lib/chef/streaming_cookbook_uploader.rb +30 -26
- data/lib/chef/tasks/chef_repo.rake +17 -17
- data/lib/chef/util/backup.rb +2 -1
- data/lib/chef/util/diff.rb +76 -33
- data/lib/chef/util/windows.rb +2 -2
- data/lib/chef/util/windows/net_group.rb +2 -2
- data/lib/chef/util/windows/net_use.rb +2 -2
- data/lib/chef/util/windows/net_user.rb +3 -3
- data/lib/chef/util/windows/volume.rb +3 -3
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +1 -1
- data/lib/chef/win32/api/synchronization.rb +89 -0
- data/lib/chef/win32/handle.rb +1 -1
- data/lib/chef/win32/mutex.rb +94 -0
- data/lib/chef/win32/security/ace.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/lib/chef/win32/version.rb +5 -3
- data/spec/data/bootstrap/no_proxy.erb +2 -0
- data/spec/data/cookbooks/openldap/metadata.rb +8 -0
- data/spec/data/cookbooks/preseed/files/default/preseed-template.seed +4 -0
- data/spec/data/trusted_certs/example.crt +22 -0
- data/spec/data/trusted_certs/intermediate.pem +27 -0
- data/spec/data/trusted_certs/opscode.pem +38 -0
- data/spec/data/trusted_certs/root.pem +22 -0
- data/spec/functional/assets/PkgA.1.0.0.0.bff +0 -0
- data/spec/functional/assets/PkgA.2.0.0.0.bff +0 -0
- data/spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm +0 -0
- data/spec/functional/assets/dummy-2-0.aix6.1.noarch.rpm +0 -0
- data/spec/functional/assets/mytest-1.0-1.noarch.rpm +0 -0
- data/spec/functional/assets/mytest-2.0-1.noarch.rpm +0 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +4 -7
- data/spec/functional/knife/exec_spec.rb +0 -3
- data/spec/functional/knife/ssh_spec.rb +2 -6
- data/spec/functional/resource/base.rb +41 -0
- data/spec/functional/resource/batch_spec.rb +6 -33
- data/spec/functional/resource/bff_spec.rb +122 -0
- data/spec/functional/resource/cron_spec.rb +147 -0
- data/spec/functional/resource/group_spec.rb +204 -0
- data/spec/functional/resource/ifconfig_spec.rb +163 -0
- data/spec/functional/resource/link_spec.rb +4 -4
- data/spec/functional/resource/mount_spec.rb +207 -0
- data/spec/functional/resource/package_spec.rb +95 -17
- data/spec/functional/resource/powershell_spec.rb +21 -22
- data/spec/functional/resource/registry_spec.rb +5 -19
- data/spec/functional/resource/remote_file_spec.rb +14 -0
- data/spec/functional/resource/rpm_spec.rb +122 -0
- data/spec/functional/resource/template_spec.rb +11 -44
- data/spec/functional/resource/user_spec.rb +2 -1
- data/spec/functional/run_lock_spec.rb +48 -5
- data/spec/functional/shell_spec.rb +46 -26
- data/spec/functional/tiny_server_spec.rb +2 -2
- data/spec/functional/version_spec.rb +35 -0
- data/spec/functional/win32/versions_spec.rb +3 -3
- data/spec/integration/client/client_spec.rb +146 -0
- data/spec/integration/knife/chef_fs_data_store_spec.rb +353 -0
- data/spec/integration/knife/chef_repo_path_spec.rb +72 -19
- data/spec/integration/knife/common_options_spec.rb +103 -0
- data/spec/integration/knife/download_spec.rb +38 -2
- data/spec/integration/knife/raw_spec.rb +63 -0
- data/spec/integration/knife/upload_spec.rb +20 -4
- data/spec/integration/solo/solo_spec.rb +78 -25
- data/spec/spec_helper.rb +35 -1
- data/spec/support/lib/chef/provider/easy.rb +4 -4
- data/spec/support/lib/chef/provider/snakeoil.rb +4 -4
- data/spec/support/lib/chef/resource/cat.rb +5 -5
- data/spec/support/lib/chef/resource/with_state.rb +37 -0
- data/spec/support/lib/library_load_order.rb +22 -0
- data/spec/support/platform_helpers.rb +8 -0
- data/spec/support/shared/functional/file_resource.rb +4 -22
- data/spec/support/shared/functional/windows_script.rb +48 -0
- data/spec/support/shared/integration/integration_helper.rb +5 -22
- data/spec/support/shared/integration/knife_support.rb +3 -3
- data/spec/support/shared/unit/script_resource.rb +7 -7
- data/spec/support/shared/unit/windows_script_resource.rb +7 -7
- data/spec/tiny_server.rb +2 -2
- data/spec/unit/api_client/registration_spec.rb +1 -1
- data/spec/unit/api_client_spec.rb +25 -2
- data/spec/unit/application/apply.rb +1 -9
- data/spec/unit/application/client_spec.rb +19 -44
- data/spec/unit/application/solo_spec.rb +10 -50
- data/spec/unit/application_spec.rb +51 -80
- data/spec/unit/checksum/storage/filesystem_spec.rb +3 -2
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +47 -0
- data/spec/unit/chef_spec.rb +2 -2
- data/spec/unit/client_spec.rb +2 -18
- data/spec/unit/config_fetcher_spec.rb +98 -0
- data/spec/unit/config_spec.rb +107 -29
- data/spec/unit/cookbook/metadata_spec.rb +50 -50
- data/spec/unit/cookbook/synchronizer_spec.rb +3 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +1 -2
- data/spec/unit/cookbook_loader_spec.rb +28 -12
- data/spec/unit/cookbook_manifest_spec.rb +11 -11
- data/spec/unit/cookbook_site_streaming_uploader.rb +200 -0
- data/spec/unit/cookbook_version_spec.rb +16 -0
- data/spec/unit/daemon_spec.rb +0 -132
- data/spec/unit/data_bag_item_spec.rb +6 -6
- data/spec/unit/data_bag_spec.rb +6 -8
- data/spec/unit/digester_spec.rb +2 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +0 -15
- data/spec/unit/file_cache_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +4 -4
- data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb +2 -2
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +4 -4
- data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
- data/spec/unit/handler_spec.rb +5 -5
- data/spec/unit/http/ssl_policies_spec.rb +170 -0
- data/spec/unit/knife/bootstrap_spec.rb +31 -14
- data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
- data/spec/unit/knife/client_create_spec.rb +2 -2
- data/spec/unit/knife/client_delete_spec.rb +2 -2
- data/spec/unit/knife/client_edit_spec.rb +2 -2
- data/spec/unit/knife/client_list_spec.rb +2 -2
- data/spec/unit/knife/client_reregister_spec.rb +2 -2
- data/spec/unit/knife/client_show_spec.rb +2 -2
- data/spec/unit/knife/config_file_selection_spec.rb +53 -36
- data/spec/unit/knife/configure_spec.rb +0 -6
- data/spec/unit/knife/cookbook_create_spec.rb +1 -12
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +2 -2
- data/spec/unit/knife/cookbook_show_spec.rb +3 -3
- data/spec/unit/knife/cookbook_site_install_spec.rb +1 -1
- data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -2
- data/spec/unit/knife/core/ui_spec.rb +118 -0
- data/spec/unit/knife/data_bag_show_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/index_rebuild_spec.rb +1 -1
- data/spec/unit/knife/node_delete_spec.rb +3 -3
- data/spec/unit/knife/node_edit_spec.rb +35 -8
- data/spec/unit/knife/node_list_spec.rb +3 -3
- data/spec/unit/knife/node_run_list_add_spec.rb +3 -3
- data/spec/unit/knife/node_show_spec.rb +3 -3
- data/spec/unit/knife/role_create_spec.rb +3 -3
- data/spec/unit/knife/role_delete_spec.rb +3 -3
- data/spec/unit/knife/role_list_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +1 -8
- data/spec/unit/knife_spec.rb +0 -2
- data/spec/unit/log_spec.rb +2 -2
- data/spec/unit/mash_spec.rb +2 -2
- data/spec/unit/mixin/checksum_spec.rb +3 -3
- data/spec/unit/mixin/command_spec.rb +1 -1
- data/spec/unit/mixin/convert_to_class_name_spec.rb +7 -7
- data/spec/unit/mixin/deprecation_spec.rb +2 -2
- data/spec/unit/mixin/params_validate_spec.rb +72 -72
- data/spec/unit/mixin/securable_spec.rb +0 -14
- data/spec/unit/mixin/shell_out_spec.rb +1 -1
- data/spec/unit/mixin/template_spec.rb +34 -0
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +5 -5
- data/spec/unit/mixin/xml_escape_spec.rb +2 -2
- data/spec/unit/node/attribute_spec.rb +11 -11
- data/spec/unit/node/immutable_collections_spec.rb +2 -2
- data/spec/unit/node_spec.rb +5 -0
- data/spec/unit/platform_spec.rb +36 -35
- data/spec/unit/provider/cron/{solaris_spec.rb → unix_spec.rb} +6 -6
- data/spec/unit/provider/cron_spec.rb +21 -3
- data/spec/unit/provider/deploy/timestamped_spec.rb +5 -5
- data/spec/unit/provider/deploy_spec.rb +21 -7
- data/spec/unit/provider/env_spec.rb +2 -2
- data/spec/unit/provider/execute_spec.rb +2 -2
- data/spec/unit/provider/file/content_spec.rb +0 -8
- data/spec/unit/provider/git_spec.rb +29 -9
- data/spec/unit/provider/group/dscl_spec.rb +12 -12
- data/spec/unit/provider/group/gpasswd_spec.rb +2 -2
- data/spec/unit/provider/group/groupadd_spec.rb +14 -0
- data/spec/unit/provider/group/groupmod_spec.rb +13 -13
- data/spec/unit/provider/group/pw_spec.rb +16 -16
- data/spec/unit/provider/group/usermod_spec.rb +10 -9
- data/spec/unit/provider/group/windows_spec.rb +14 -0
- data/spec/unit/provider/group_spec.rb +29 -29
- data/spec/unit/provider/http_request_spec.rb +15 -15
- data/spec/unit/provider/ifconfig/aix_spec.rb +180 -0
- data/spec/unit/provider/ifconfig_spec.rb +9 -9
- data/spec/unit/provider/link_spec.rb +2 -2
- data/spec/unit/provider/log_spec.rb +8 -8
- data/spec/unit/provider/mdadm_spec.rb +14 -11
- data/spec/unit/provider/mount/aix_spec.rb +237 -0
- data/spec/unit/provider/mount/mount_spec.rb +2 -0
- data/spec/unit/provider/mount/windows_spec.rb +2 -2
- data/spec/unit/provider/mount_spec.rb +6 -6
- data/spec/unit/provider/package/aix_spec.rb +171 -0
- data/spec/unit/provider/package/apt_spec.rb +130 -171
- data/spec/unit/provider/package/dpkg_spec.rb +3 -3
- data/spec/unit/provider/package/freebsd_spec.rb +28 -0
- data/spec/unit/provider/package/ips_spec.rb +1 -1
- data/spec/unit/provider/package/rpm_spec.rb +15 -15
- data/spec/unit/provider/package/smartos_spec.rb +21 -3
- data/spec/unit/provider/package_spec.rb +4 -2
- data/spec/unit/provider/powershell_spec.rb +3 -3
- data/spec/unit/provider/remote_directory_spec.rb +2 -2
- data/spec/unit/provider/remote_file/ftp_spec.rb +0 -5
- data/spec/unit/provider/remote_file/http_spec.rb +12 -28
- data/spec/unit/provider/remote_file/local_file_spec.rb +2 -1
- data/spec/unit/provider/route_spec.rb +2 -2
- data/spec/unit/provider/ruby_block_spec.rb +2 -2
- data/spec/unit/provider/service/arch_service_spec.rb +17 -17
- data/spec/unit/provider/service/debian_service_spec.rb +242 -152
- data/spec/unit/provider/service/freebsd_service_spec.rb +9 -9
- data/spec/unit/provider/service/gentoo_service_spec.rb +9 -9
- data/spec/unit/provider/service/init_service_spec.rb +11 -11
- data/spec/unit/provider/service/insserv_service_spec.rb +5 -5
- data/spec/unit/provider/service/invokercd_service_spec.rb +10 -10
- data/spec/unit/provider/service/redhat_spec.rb +6 -6
- data/spec/unit/provider/service/simple_service_spec.rb +6 -6
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +3 -3
- data/spec/unit/provider/service/upstart_service_spec.rb +5 -5
- data/spec/unit/provider/service/windows_spec.rb +7 -7
- data/spec/unit/provider/subversion_spec.rb +1 -1
- data/spec/unit/provider/user/dscl_spec.rb +21 -21
- data/spec/unit/provider/user/pw_spec.rb +2 -2
- data/spec/unit/provider/user/windows_spec.rb +5 -5
- data/spec/unit/provider/user_spec.rb +39 -47
- data/spec/unit/resource/apt_package_spec.rb +6 -6
- data/spec/unit/resource/bash_spec.rb +5 -5
- data/spec/unit/resource/batch_spec.rb +7 -7
- data/spec/unit/resource/breakpoint_spec.rb +8 -8
- data/spec/unit/resource/chef_gem_spec.rb +6 -6
- data/spec/unit/resource/cookbook_file_spec.rb +11 -11
- data/spec/unit/resource/cron_spec.rb +15 -15
- data/spec/unit/resource/csh_spec.rb +5 -5
- data/spec/unit/resource/deploy_revision_spec.rb +6 -6
- data/spec/unit/resource/deploy_spec.rb +50 -36
- data/spec/unit/resource/directory_spec.rb +1 -1
- data/spec/unit/resource/dpkg_package_spec.rb +6 -6
- data/spec/unit/resource/env_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/freebsd_package_spec.rb +6 -6
- data/spec/unit/resource/gem_package_spec.rb +6 -6
- data/spec/unit/resource/git_spec.rb +8 -8
- data/spec/unit/resource/group_spec.rb +11 -11
- data/spec/unit/resource/http_request_spec.rb +7 -7
- data/spec/unit/resource/ifconfig_spec.rb +1 -1
- data/spec/unit/resource/ips_package_spec.rb +6 -6
- data/spec/unit/resource/link_spec.rb +1 -1
- data/spec/unit/resource/log_spec.rb +13 -10
- data/spec/unit/resource/macports_package_spec.rb +2 -2
- data/spec/unit/resource/mdadm_spec.rb +3 -3
- data/spec/unit/resource/mount_spec.rb +13 -13
- data/spec/unit/resource/ohai_spec.rb +1 -1
- data/spec/unit/resource/package_spec.rb +6 -6
- data/spec/unit/resource/pacman_package_spec.rb +6 -6
- data/spec/unit/resource/perl_spec.rb +5 -5
- data/spec/unit/resource/portage_package_spec.rb +6 -6
- data/spec/unit/resource/powershell_spec.rb +5 -5
- data/spec/unit/resource/python_spec.rb +5 -5
- data/spec/unit/resource/registry_key_spec.rb +2 -2
- data/spec/unit/resource/remote_directory_spec.rb +9 -9
- data/spec/unit/resource/remote_file_spec.rb +4 -4
- data/spec/unit/resource/route_spec.rb +13 -13
- data/spec/unit/resource/rpm_package_spec.rb +2 -2
- data/spec/unit/resource/ruby_block_spec.rb +4 -4
- data/spec/unit/resource/ruby_spec.rb +5 -5
- data/spec/unit/resource/scm_spec.rb +14 -1
- data/spec/unit/resource/script_spec.rb +5 -5
- data/spec/unit/resource/service_spec.rb +18 -18
- data/spec/unit/resource/smartos_package_spec.rb +6 -6
- data/spec/unit/resource/solaris_package_spec.rb +57 -0
- data/spec/unit/resource/subversion_spec.rb +6 -6
- data/spec/unit/resource/timestamped_deploy_spec.rb +4 -4
- data/spec/unit/resource/user_spec.rb +13 -13
- data/spec/unit/resource/yum_package_spec.rb +7 -7
- data/spec/unit/resource_collection/stepable_iterator_spec.rb +21 -21
- data/spec/unit/resource_definition_spec.rb +23 -23
- data/spec/unit/resource_reporter_spec.rb +27 -0
- data/spec/unit/rest/auth_credentials_spec.rb +0 -94
- data/spec/unit/rest_spec.rb +117 -99
- data/spec/unit/role_spec.rb +57 -4
- data/spec/unit/run_context/cookbook_compiler_spec.rb +4 -20
- data/spec/unit/run_context_spec.rb +44 -3
- data/spec/unit/run_list/run_list_item_spec.rb +1 -1
- data/spec/unit/run_lock_spec.rb +6 -3
- data/spec/unit/scan_access_control_spec.rb +2 -2
- data/spec/unit/search/query_spec.rb +3 -3
- data/spec/unit/util/backup_spec.rb +6 -13
- data/spec/unit/util/diff_spec.rb +36 -53
- data/spec/unit/version/platform_spec.rb +3 -3
- data/spec/unit/version_class_spec.rb +5 -5
- data/spec/unit/version_constraint/platform_spec.rb +2 -2
- data/spec/unit/windows_service_spec.rb +54 -0
- metadata +290 -108
- checksums.yaml +0 -7
- data/distro/common/man/man1/knife-index.1 +0 -29
- data/distro/common/man/man8/chef-expander.8 +0 -97
- data/distro/common/man/man8/chef-expanderctl.8 +0 -62
- data/distro/common/man/man8/chef-server-webui.8 +0 -155
- data/distro/common/man/man8/chef-server.8 +0 -147
- data/distro/common/man/man8/chef-solr.8 +0 -122
- data/lib/chef/chef_fs/raw_request.rb +0 -79
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -19,19 +19,19 @@
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
21
|
describe Chef::Resource::YumPackage, "initialize" do
|
22
|
-
|
22
|
+
|
23
23
|
before(:each) do
|
24
24
|
@resource = Chef::Resource::YumPackage.new("foo")
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
it "should return a Chef::Resource::YumPackage" do
|
28
28
|
@resource.should be_a_kind_of(Chef::Resource::YumPackage)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "should set the resource_name to :yum_package" do
|
32
32
|
@resource.resource_name.should eql(:yum_package)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should set the provider to Chef::Provider::Package::Yum" do
|
36
36
|
@resource.provider.should eql(Chef::Provider::Package::Yum)
|
37
37
|
end
|
@@ -56,7 +56,7 @@ describe Chef::Resource::YumPackage, "flush_cache" do
|
|
56
56
|
it "should default the flush timing to false" do
|
57
57
|
flush_hash = { :before => false, :after => false }
|
58
58
|
@resource.flush_cache.should == flush_hash
|
59
|
-
end
|
59
|
+
end
|
60
60
|
|
61
61
|
it "should allow you to set the flush timing with an array" do
|
62
62
|
flush_array = [ :before, :after ]
|
@@ -5,9 +5,9 @@
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
7
7
|
# You may obtain a copy of the License at
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# Unless required by applicable law or agreed to in writing, software
|
12
12
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -19,17 +19,17 @@ require 'spec_helper'
|
|
19
19
|
|
20
20
|
describe Chef::ResourceCollection::StepableIterator do
|
21
21
|
CRSI = Chef::ResourceCollection::StepableIterator
|
22
|
-
|
22
|
+
|
23
23
|
it "has an empty array for its collection by default" do
|
24
24
|
CRSI.new.collection.should == []
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
describe "doing basic iteration" do
|
28
28
|
before do
|
29
29
|
@simple_collection = [1,2,3,4]
|
30
30
|
@iterator = CRSI.for_collection(@simple_collection)
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "re-initializes the instance with a collection" do
|
34
34
|
@iterator.collection.should equal(@simple_collection)
|
35
35
|
@iterator.size.should == 4
|
@@ -51,7 +51,7 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
51
51
|
collected_by_index.should == @simple_collection
|
52
52
|
collected_by_index.should_not equal(@simple_collection)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it "iterates over the collection with index and element" do
|
56
56
|
collected = {}
|
57
57
|
@iterator.each_with_index do |element, index|
|
@@ -59,32 +59,32 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
59
59
|
end
|
60
60
|
collected.should == {0=>1, 1=>2, 2=>3, 3=>4}
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
describe "pausing and resuming iteration" do
|
66
|
-
|
66
|
+
|
67
67
|
before do
|
68
68
|
@collection = []
|
69
69
|
@snitch_var = nil
|
70
70
|
@collection << lambda { @snitch_var = 23 }
|
71
71
|
@collection << lambda { @iterator.pause }
|
72
72
|
@collection << lambda { @snitch_var = 42 }
|
73
|
-
|
73
|
+
|
74
74
|
@iterator = CRSI.for_collection(@collection)
|
75
75
|
@iterator.each { |proc| proc.call }
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
it "allows the iteration to be paused" do
|
79
79
|
@snitch_var.should == 23
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
it "allows the iteration to be resumed" do
|
83
83
|
@snitch_var.should == 23
|
84
84
|
@iterator.resume
|
85
85
|
@snitch_var.should == 42
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
it "allows iteration to be rewound" do
|
89
89
|
@iterator.skip_back(2)
|
90
90
|
@iterator.resume
|
@@ -92,13 +92,13 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
92
92
|
@iterator.resume
|
93
93
|
@snitch_var.should == 42
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
it "allows iteration to be fast forwarded" do
|
97
97
|
@iterator.skip_forward
|
98
98
|
@iterator.resume
|
99
99
|
@snitch_var.should == 23
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
it "allows iteration to be rewound" do
|
103
103
|
@snitch_var = nil
|
104
104
|
@iterator.rewind
|
@@ -106,7 +106,7 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
106
106
|
@iterator.resume
|
107
107
|
@snitch_var.should == 23
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
it "allows iteration to be stepped" do
|
111
111
|
@snitch_var = nil
|
112
112
|
@iterator.rewind
|
@@ -114,13 +114,13 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
114
114
|
@iterator.position.should == 1
|
115
115
|
@snitch_var.should == 23
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
it "doesn't step if there are no more steps" do
|
119
119
|
@iterator.step.should == 3
|
120
120
|
lambda {@iterator.step}.should_not raise_error
|
121
121
|
@iterator.step.should be_nil
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
it "allows the iteration to start by being stepped" do
|
125
125
|
@snitch_var = nil
|
126
126
|
@iterator = CRSI.for_collection(@collection)
|
@@ -129,7 +129,7 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
129
129
|
@iterator.position.should == 1
|
130
130
|
@snitch_var.should == 23
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
it "should work correctly when elements are added to the collection during iteration" do
|
134
134
|
@collection.insert(2, lambda { @snitch_var = 815})
|
135
135
|
@collection.insert(3, lambda { @iterator.pause })
|
@@ -138,7 +138,7 @@ describe Chef::ResourceCollection::StepableIterator do
|
|
138
138
|
@iterator.resume
|
139
139
|
@snitch_var.should == 42
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
end
|
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -22,16 +22,16 @@ describe Chef::ResourceDefinition do
|
|
22
22
|
before(:each) do
|
23
23
|
@def = Chef::ResourceDefinition.new()
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
describe "initialize" do
|
27
27
|
it "should be a Chef::ResourceDefinition" do
|
28
28
|
@def.should be_a_kind_of(Chef::ResourceDefinition)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
it "should not initialize a new node if one is not provided" do
|
32
32
|
@def.node.should eql(nil)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
it "should accept a node as an argument" do
|
36
36
|
node = Chef::Node.new
|
37
37
|
node.name("bobo")
|
@@ -39,7 +39,7 @@ describe Chef::ResourceDefinition do
|
|
39
39
|
@def.node.name.should == "bobo"
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
describe "node" do
|
44
44
|
it "should set the node with node=" do
|
45
45
|
node = Chef::Node.new
|
@@ -47,32 +47,32 @@ describe Chef::ResourceDefinition do
|
|
47
47
|
@def.node = node
|
48
48
|
@def.node.name.should == "bobo"
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
it "should return the node" do
|
52
52
|
@def.node = Chef::Node.new
|
53
53
|
@def.node.should be_a_kind_of(Chef::Node)
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should accept a new definition with a symbol for a name" do
|
58
|
-
lambda {
|
59
|
-
@def.define :smoke do
|
58
|
+
lambda {
|
59
|
+
@def.define :smoke do
|
60
60
|
end
|
61
61
|
}.should_not raise_error(ArgumentError)
|
62
|
-
lambda {
|
62
|
+
lambda {
|
63
63
|
@def.define "george washington" do
|
64
|
-
end
|
64
|
+
end
|
65
65
|
}.should raise_error(ArgumentError)
|
66
66
|
@def.name.should eql(:smoke)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
it "should accept a new definition with a hash" do
|
70
|
-
lambda {
|
70
|
+
lambda {
|
71
71
|
@def.define :smoke, :cigar => "cuban", :cigarette => "marlboro" do
|
72
72
|
end
|
73
73
|
}.should_not raise_error(ArgumentError)
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it "should expose the prototype hash params in the params hash" do
|
77
77
|
@def.define :smoke, :cigar => "cuban", :cigarette => "marlboro" do; end
|
78
78
|
@def.params[:cigar].should eql("cuban")
|
@@ -86,34 +86,34 @@ describe Chef::ResourceDefinition do
|
|
86
86
|
@def.recipe.should be_a_kind_of(Proc)
|
87
87
|
@def.recipe.call.should eql("I am what I am")
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
it "should set paramaters based on method_missing" do
|
91
91
|
@def.mind "to fly"
|
92
92
|
@def.params[:mind].should eql("to fly")
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
it "should raise an exception if prototype_params is not a hash" do
|
96
96
|
lambda {
|
97
97
|
@def.define :monkey, Array.new do
|
98
98
|
end
|
99
99
|
}.should raise_error(ArgumentError)
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
it "should raise an exception if define is called without a block" do
|
103
|
-
lambda {
|
103
|
+
lambda {
|
104
104
|
@def.define :monkey
|
105
105
|
}.should raise_error(ArgumentError)
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
it "should load a description from a file" do
|
109
109
|
@def.from_file(File.join(CHEF_SPEC_DATA, "definitions", "test.rb"))
|
110
110
|
@def.name.should eql(:rico_suave)
|
111
111
|
@def.params[:rich].should eql("smooth")
|
112
|
-
end
|
113
|
-
|
112
|
+
end
|
113
|
+
|
114
114
|
it "should turn itself into a string based on the name with to_s" do
|
115
115
|
@def.name = :woot
|
116
116
|
@def.to_s.should eql("woot")
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
end
|
@@ -464,6 +464,33 @@ describe Chef::ResourceReporter do
|
|
464
464
|
end
|
465
465
|
end
|
466
466
|
|
467
|
+
context "when including a resource that overrides Resource#state" do
|
468
|
+
before do
|
469
|
+
@current_state_resource = Chef::Resource::WithState.new("Stateful", @run_context)
|
470
|
+
@current_state_resource.state = nil
|
471
|
+
|
472
|
+
@new_state_resource = Chef::Resource::WithState.new("Stateful", @run_context)
|
473
|
+
@new_state_resource.state = "Running"
|
474
|
+
@resource_reporter.resource_action_start(@new_state_resource, :create)
|
475
|
+
@resource_reporter.resource_current_state_loaded(@new_state_resource, :create, @current_state_resource)
|
476
|
+
@resource_reporter.resource_updated(@new_state_resource, :create)
|
477
|
+
@resource_reporter.resource_completed(@new_state_resource)
|
478
|
+
@run_status.stop_clock
|
479
|
+
@report = @resource_reporter.prepare_run_data
|
480
|
+
@first_update_report = @report["resources"].first
|
481
|
+
end
|
482
|
+
|
483
|
+
it "sets before to {} instead of nil" do
|
484
|
+
@first_update_report.should have_key("before")
|
485
|
+
@first_update_report['before'].should eq({})
|
486
|
+
end
|
487
|
+
|
488
|
+
it "sets after to {} instead of 'Running'" do
|
489
|
+
@first_update_report.should have_key("after")
|
490
|
+
@first_update_report['after'].should eq({})
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
467
494
|
end
|
468
495
|
|
469
496
|
describe "when updating resource history on the server" do
|
@@ -199,100 +199,6 @@ describe Chef::REST::RESTRequest do
|
|
199
199
|
new_request.http_client.read_timeout.should == 9001
|
200
200
|
end
|
201
201
|
|
202
|
-
describe "for SSL" do
|
203
|
-
before do
|
204
|
-
Chef::Config[:ssl_client_cert] = nil
|
205
|
-
Chef::Config[:ssl_client_key] = nil
|
206
|
-
Chef::Config[:ssl_ca_path] = nil
|
207
|
-
Chef::Config[:ssl_ca_file] = nil
|
208
|
-
end
|
209
|
-
|
210
|
-
after do
|
211
|
-
Chef::Config[:ssl_client_cert] = nil
|
212
|
-
Chef::Config[:ssl_client_key] = nil
|
213
|
-
Chef::Config[:ssl_ca_path] = nil
|
214
|
-
Chef::Config[:ssl_verify_mode] = :verify_none
|
215
|
-
Chef::Config[:ssl_ca_file] = nil
|
216
|
-
end
|
217
|
-
|
218
|
-
describe "when configured with :ssl_verify_mode set to :verify peer" do
|
219
|
-
before do
|
220
|
-
@url = URI.parse("https://chef.example.com:4443/")
|
221
|
-
Chef::Config[:ssl_verify_mode] = :verify_peer
|
222
|
-
@request = new_request
|
223
|
-
end
|
224
|
-
|
225
|
-
it "configures the HTTP client to use SSL when given a URL with the https protocol" do
|
226
|
-
@request.http_client.use_ssl?.should be_true
|
227
|
-
end
|
228
|
-
|
229
|
-
it "sets the OpenSSL verify mode to verify_peer" do
|
230
|
-
@request.http_client.verify_mode.should == OpenSSL::SSL::VERIFY_PEER
|
231
|
-
end
|
232
|
-
|
233
|
-
it "raises a ConfigurationError if :ssl_ca_path is set to a path that doesn't exist" do
|
234
|
-
Chef::Config[:ssl_ca_path] = "/dev/null/nothing_here"
|
235
|
-
lambda {new_request}.should raise_error(Chef::Exceptions::ConfigurationError)
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should set the CA path if that is set in the configuration" do
|
239
|
-
Chef::Config[:ssl_ca_path] = File.join(CHEF_SPEC_DATA, "ssl")
|
240
|
-
new_request.http_client.ca_path.should == File.join(CHEF_SPEC_DATA, "ssl")
|
241
|
-
end
|
242
|
-
|
243
|
-
it "raises a ConfigurationError if :ssl_ca_file is set to a file that does not exist" do
|
244
|
-
Chef::Config[:ssl_ca_file] = "/dev/null/nothing_here"
|
245
|
-
lambda {new_request}.should raise_error(Chef::Exceptions::ConfigurationError)
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should set the CA file if that is set in the configuration" do
|
249
|
-
Chef::Config[:ssl_ca_file] = CHEF_SPEC_DATA + '/ssl/5e707473.0'
|
250
|
-
new_request.http_client.ca_file.should == CHEF_SPEC_DATA + '/ssl/5e707473.0'
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe "when configured with :ssl_verify_mode set to :verify peer" do
|
255
|
-
before do
|
256
|
-
@url = URI.parse("https://chef.example.com:4443/")
|
257
|
-
Chef::Config[:ssl_verify_mode] = :verify_none
|
258
|
-
end
|
259
|
-
|
260
|
-
it "sets the OpenSSL verify mode to :verify_none" do
|
261
|
-
new_request.http_client.verify_mode.should == OpenSSL::SSL::VERIFY_NONE
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
describe "when configured with a client certificate" do
|
266
|
-
before {@url = URI.parse("https://chef.example.com:4443/")}
|
267
|
-
|
268
|
-
it "raises ConfigurationError if the certificate file doesn't exist" do
|
269
|
-
Chef::Config[:ssl_client_cert] = "/dev/null/nothing_here"
|
270
|
-
Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + '/ssl/chef-rspec.key'
|
271
|
-
lambda {new_request}.should raise_error(Chef::Exceptions::ConfigurationError)
|
272
|
-
end
|
273
|
-
|
274
|
-
it "raises ConfigurationError if the certificate file doesn't exist" do
|
275
|
-
Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + '/ssl/chef-rspec.cert'
|
276
|
-
Chef::Config[:ssl_client_key] = "/dev/null/nothing_here"
|
277
|
-
lambda {new_request}.should raise_error(Chef::Exceptions::ConfigurationError)
|
278
|
-
end
|
279
|
-
|
280
|
-
it "raises a ConfigurationError if one of :ssl_client_cert and :ssl_client_key is set but not both" do
|
281
|
-
Chef::Config[:ssl_client_cert] = "/dev/null/nothing_here"
|
282
|
-
Chef::Config[:ssl_client_key] = nil
|
283
|
-
lambda {new_request}.should raise_error(Chef::Exceptions::ConfigurationError)
|
284
|
-
end
|
285
|
-
|
286
|
-
it "configures the HTTP client's cert and private key" do
|
287
|
-
Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + '/ssl/chef-rspec.cert'
|
288
|
-
Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + '/ssl/chef-rspec.key'
|
289
|
-
http_client = new_request.http_client
|
290
|
-
http_client.cert.to_s.should == OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + '/ssl/chef-rspec.cert')).to_s
|
291
|
-
http_client.key.to_s.should == IO.read(CHEF_SPEC_DATA + '/ssl/chef-rspec.key')
|
292
|
-
end
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
202
|
describe "for proxy" do
|
297
203
|
before do
|
298
204
|
Chef::Config[:http_proxy] = "http://proxy.example.com:3128"
|
data/spec/unit/rest_spec.rb
CHANGED
@@ -57,7 +57,7 @@ describe Chef::REST do
|
|
57
57
|
@log_stringio = StringIO.new
|
58
58
|
Chef::Log.init(@log_stringio)
|
59
59
|
|
60
|
-
Chef::REST::CookieJar.stub
|
60
|
+
Chef::REST::CookieJar.stub(:instance).and_return({})
|
61
61
|
@base_url = "http://chef.example.com:4000"
|
62
62
|
@monkey_uri = URI.parse("http://chef.example.com:4000/monkey")
|
63
63
|
@rest = Chef::REST.new(@base_url, nil, nil)
|
@@ -65,6 +65,13 @@ describe Chef::REST do
|
|
65
65
|
Chef::REST::CookieJar.instance.clear
|
66
66
|
end
|
67
67
|
|
68
|
+
describe "legacy API" do
|
69
|
+
it 'responds to raw_http_request as a public method' do
|
70
|
+
@rest.public_methods.map(&:to_s).should include("raw_http_request")
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
68
75
|
|
69
76
|
describe "calling an HTTP verb on a path or absolute URL" do
|
70
77
|
it "adds a relative URL to the base url it was initialized with" do
|
@@ -76,27 +83,46 @@ describe Chef::REST do
|
|
76
83
|
end
|
77
84
|
|
78
85
|
it "makes a :GET request with the composed url object" do
|
79
|
-
@rest.should_receive(:
|
86
|
+
@rest.should_receive(:send_http_request).
|
87
|
+
with(:GET, @monkey_uri, STANDARD_READ_HEADERS, false).
|
88
|
+
and_return([1,2,3])
|
89
|
+
@rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
|
90
|
+
@rest.should_receive('success_response?'.to_sym).with(1).and_return(true)
|
80
91
|
@rest.get_rest("monkey")
|
81
92
|
end
|
82
93
|
|
83
94
|
it "makes a :GET reqest for a streaming download with the composed url" do
|
84
|
-
@rest.should_receive(:streaming_request).with(
|
95
|
+
@rest.should_receive(:streaming_request).with('monkey', {})
|
85
96
|
@rest.get_rest("monkey", true)
|
86
97
|
end
|
87
98
|
|
88
|
-
|
89
|
-
|
99
|
+
STANDARD_READ_HEADERS = {"Accept"=>"application/json", "Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"}
|
100
|
+
STANDARD_WRITE_HEADERS = {"Accept"=>"application/json", "Content-Type"=>"application/json", "Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"}
|
101
|
+
|
102
|
+
it "makes a :DELETE request with the composed url object" do
|
103
|
+
@rest.should_receive(:send_http_request).
|
104
|
+
with(:DELETE, @monkey_uri, STANDARD_READ_HEADERS, false).
|
105
|
+
and_return([1,2,3])
|
106
|
+
@rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
|
107
|
+
@rest.should_receive('success_response?'.to_sym).with(1).and_return(true)
|
90
108
|
@rest.delete_rest("monkey")
|
91
109
|
end
|
92
110
|
|
93
111
|
it "makes a :POST request with the composed url object and data" do
|
94
|
-
@rest.should_receive(:
|
112
|
+
@rest.should_receive(:send_http_request).
|
113
|
+
with(:POST, @monkey_uri, STANDARD_WRITE_HEADERS, "\"data\"").
|
114
|
+
and_return([1,2,3])
|
115
|
+
@rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
|
116
|
+
@rest.should_receive('success_response?'.to_sym).with(1).and_return(true)
|
95
117
|
@rest.post_rest("monkey", "data")
|
96
118
|
end
|
97
119
|
|
98
120
|
it "makes a :PUT request with the composed url object and data" do
|
99
|
-
@rest.should_receive(:
|
121
|
+
@rest.should_receive(:send_http_request).
|
122
|
+
with(:PUT, @monkey_uri, STANDARD_WRITE_HEADERS, "\"data\"").
|
123
|
+
and_return([1,2,3])
|
124
|
+
@rest.should_receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3])
|
125
|
+
@rest.should_receive('success_response?'.to_sym).with(1).and_return(true)
|
100
126
|
@rest.put_rest("monkey", "data")
|
101
127
|
end
|
102
128
|
end
|
@@ -156,13 +182,13 @@ describe Chef::REST do
|
|
156
182
|
@url = URI.parse("https://one:80/?foo=bar")
|
157
183
|
|
158
184
|
@http_response = Net::HTTPSuccess.new("1.1", "200", "successful rest req")
|
159
|
-
@http_response.stub
|
160
|
-
@http_response.stub
|
185
|
+
@http_response.stub(:read_body)
|
186
|
+
@http_response.stub(:body).and_return("ninja")
|
161
187
|
@http_response.add_field("Content-Length", "5")
|
162
188
|
|
163
189
|
@http_client = Net::HTTP.new(@url.host, @url.port)
|
164
|
-
Net::HTTP.stub
|
165
|
-
@http_client.stub
|
190
|
+
Net::HTTP.stub(:new).and_return(@http_client)
|
191
|
+
@http_client.stub(:request).and_yield(@http_response).and_return(@http_response)
|
166
192
|
|
167
193
|
@base_headers = { 'Accept' => 'application/json',
|
168
194
|
'X-Chef-Version' => Chef::VERSION,
|
@@ -172,23 +198,18 @@ describe Chef::REST do
|
|
172
198
|
|
173
199
|
describe "streaming downloads to a tempfile" do
|
174
200
|
before do
|
175
|
-
@tempfile =
|
176
|
-
|
177
|
-
|
201
|
+
@tempfile = StringIO.new
|
202
|
+
@tempfile.stub(:close!)
|
203
|
+
@tempfile.stub(:path).and_return("/a-temporary-file")
|
204
|
+
Tempfile.stub(:new).with("chef-rest").and_return(@tempfile)
|
205
|
+
Tempfile.stub(:open).and_return(@tempfile)
|
178
206
|
|
179
207
|
@request_mock = {}
|
180
|
-
Net::HTTP::Get.stub
|
181
|
-
|
182
|
-
@http_response_mock = mock("Net::HTTP Response mock")
|
183
|
-
end
|
184
|
-
|
185
|
-
after do
|
186
|
-
@tempfile.rspec_reset
|
187
|
-
@tempfile.close!
|
208
|
+
Net::HTTP::Get.stub(:new).and_return(@request_mock)
|
188
209
|
end
|
189
210
|
|
190
211
|
it "should build a new HTTP GET request without the application/json accept header" do
|
191
|
-
expected_headers = {'X-Chef-Version' => Chef::VERSION, 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE}
|
212
|
+
expected_headers = {'Accept' => "*/*", 'X-Chef-Version' => Chef::VERSION, 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE}
|
192
213
|
Net::HTTP::Get.should_receive(:new).with("/?foo=bar", expected_headers).and_return(@request_mock)
|
193
214
|
@rest.streaming_request(@url, {})
|
194
215
|
end
|
@@ -203,9 +224,9 @@ describe Chef::REST do
|
|
203
224
|
end
|
204
225
|
|
205
226
|
it "should populate the tempfile with the value of the raw request" do
|
206
|
-
@
|
207
|
-
@tempfile.should_receive(:write).with("ninja").once.and_return(true)
|
227
|
+
@http_response.should_receive(:read_body).and_yield("ninja")
|
208
228
|
@rest.streaming_request(@url, {})
|
229
|
+
#@tempfile.string.should include("ninja")
|
209
230
|
end
|
210
231
|
|
211
232
|
it "should close the tempfile if we're doing a raw request" do
|
@@ -214,15 +235,15 @@ describe Chef::REST do
|
|
214
235
|
end
|
215
236
|
|
216
237
|
it "should not raise a divide by zero exception if the size is 0" do
|
217
|
-
@
|
218
|
-
@
|
219
|
-
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
238
|
+
@http_response.stub(:header).and_return({ 'Content-Length' => "5" })
|
239
|
+
@http_response.stub(:read_body).and_yield('')
|
240
|
+
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
220
241
|
end
|
221
242
|
|
222
243
|
it "should not raise a divide by zero exception if the Content-Length is 0" do
|
223
|
-
@
|
224
|
-
@
|
225
|
-
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
244
|
+
@http_response.stub(:header).and_return({ 'Content-Length' => "0" })
|
245
|
+
@http_response.stub(:read_body).and_yield("ninja")
|
246
|
+
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
226
247
|
end
|
227
248
|
|
228
249
|
end
|
@@ -230,7 +251,7 @@ describe Chef::REST do
|
|
230
251
|
describe "as JSON API requests" do
|
231
252
|
before do
|
232
253
|
@request_mock = {}
|
233
|
-
Net::HTTP::Get.stub
|
254
|
+
Net::HTTP::Get.stub(:new).and_return(@request_mock)
|
234
255
|
|
235
256
|
@base_headers = {"Accept" => "application/json",
|
236
257
|
"X-Chef-Version" => Chef::VERSION,
|
@@ -240,14 +261,14 @@ describe Chef::REST do
|
|
240
261
|
|
241
262
|
it "should always include the X-Chef-Version header" do
|
242
263
|
Net::HTTP::Get.should_receive(:new).with("/?foo=bar", @base_headers).and_return(@request_mock)
|
243
|
-
@rest.
|
264
|
+
@rest.request(:GET, @url, {})
|
244
265
|
end
|
245
266
|
|
246
267
|
it "sets the user agent to chef-client" do
|
247
268
|
# must reset to default b/c knife changes the UA
|
248
269
|
Chef::REST::RESTRequest.user_agent = Chef::REST::RESTRequest::DEFAULT_UA
|
249
|
-
@rest.
|
250
|
-
@request_mock['User-Agent'].should match
|
270
|
+
@rest.request(:GET, @url, {})
|
271
|
+
@request_mock['User-Agent'].should match(/^Chef Client\/#{Chef::VERSION}/)
|
251
272
|
end
|
252
273
|
|
253
274
|
# CHEF-3140
|
@@ -265,7 +286,7 @@ describe Chef::REST do
|
|
265
286
|
request = Net::HTTP::Get.new(@url.path)
|
266
287
|
Net::HTTP::Get.should_receive(:new).and_return(request)
|
267
288
|
# will raise a Zlib error if incorrect
|
268
|
-
@rest.
|
289
|
+
@rest.request(:GET, @url, {}).should == "ninja"
|
269
290
|
end
|
270
291
|
end
|
271
292
|
context "when configured with custom http headers" do
|
@@ -285,19 +306,19 @@ describe Chef::REST do
|
|
285
306
|
url_string = an_instance_of(String)
|
286
307
|
header_hash = hash_including(@custom_headers)
|
287
308
|
Net::HTTP::Get.should_receive(:new).with(url_string, header_hash)
|
288
|
-
@rest.
|
309
|
+
@rest.request(:GET, @url, {})
|
289
310
|
end
|
290
311
|
end
|
291
312
|
|
292
313
|
it "should set the cookie for this request if one exists for the given host:port" do
|
293
314
|
Chef::REST::CookieJar.instance["#{@url.host}:#{@url.port}"] = "cookie monster"
|
294
315
|
Net::HTTP::Get.should_receive(:new).with("/?foo=bar", @base_headers.merge('Cookie' => "cookie monster")).and_return(@request_mock)
|
295
|
-
@rest.
|
316
|
+
@rest.request(:GET, @url, {})
|
296
317
|
end
|
297
318
|
|
298
319
|
it "should build a new HTTP GET request" do
|
299
320
|
Net::HTTP::Get.should_receive(:new).with("/?foo=bar", @base_headers).and_return(@request_mock)
|
300
|
-
@rest.
|
321
|
+
@rest.request(:GET, @url, {})
|
301
322
|
end
|
302
323
|
|
303
324
|
it "should build a new HTTP POST request" do
|
@@ -305,7 +326,7 @@ describe Chef::REST do
|
|
305
326
|
expected_headers = @base_headers.merge("Content-Type" => 'application/json', 'Content-Length' => '13')
|
306
327
|
|
307
328
|
Net::HTTP::Post.should_receive(:new).with("/?foo=bar", expected_headers).and_return(request)
|
308
|
-
@rest.
|
329
|
+
@rest.request(:POST, @url, {}, {:one=>:two})
|
309
330
|
request.body.should == '{"one":"two"}'
|
310
331
|
end
|
311
332
|
|
@@ -313,54 +334,54 @@ describe Chef::REST do
|
|
313
334
|
request = Net::HTTP::Put.new(@url.path)
|
314
335
|
expected_headers = @base_headers.merge("Content-Type" => 'application/json', 'Content-Length' => '13')
|
315
336
|
Net::HTTP::Put.should_receive(:new).with("/?foo=bar",expected_headers).and_return(request)
|
316
|
-
@rest.
|
337
|
+
@rest.request(:PUT, @url, {}, {:one=>:two})
|
317
338
|
request.body.should == '{"one":"two"}'
|
318
339
|
end
|
319
340
|
|
320
341
|
it "should build a new HTTP DELETE request" do
|
321
342
|
Net::HTTP::Delete.should_receive(:new).with("/?foo=bar", @base_headers).and_return(@request_mock)
|
322
|
-
@rest.
|
343
|
+
@rest.request(:DELETE, @url)
|
323
344
|
end
|
324
345
|
|
325
346
|
it "should raise an error if the method is not GET/PUT/POST/DELETE" do
|
326
|
-
lambda { @rest.
|
347
|
+
lambda { @rest.request(:MONKEY, @url) }.should raise_error(ArgumentError)
|
327
348
|
end
|
328
349
|
|
329
350
|
it "returns nil when the response is successful but content-type is not JSON" do
|
330
|
-
@rest.
|
351
|
+
@rest.request(:GET, @url).should == "ninja"
|
331
352
|
end
|
332
353
|
|
333
354
|
it "should inflate the body as to an object if JSON is returned" do
|
334
355
|
@http_response.add_field('content-type', "application/json")
|
335
|
-
@http_response.stub
|
336
|
-
@rest.
|
356
|
+
@http_response.stub(:body).and_return('{"ohai2u":"json_api"}')
|
357
|
+
@rest.request(:GET, @url, {}).should == {"ohai2u"=>"json_api"}
|
337
358
|
end
|
338
359
|
|
339
360
|
%w[ HTTPFound HTTPMovedPermanently HTTPSeeOther HTTPUseProxy HTTPTemporaryRedirect HTTPMultipleChoice ].each do |resp_name|
|
340
|
-
it "should call
|
361
|
+
it "should call request again on a #{resp_name} response" do
|
341
362
|
resp_cls = Net.const_get(resp_name)
|
342
363
|
resp_code = Net::HTTPResponse::CODE_TO_OBJ.keys.detect { |k| Net::HTTPResponse::CODE_TO_OBJ[k] == resp_cls }
|
343
364
|
http_response = Net::HTTPFound.new("1.1", resp_code, "bob is somewhere else again")
|
344
365
|
http_response.add_field("location", @url.path)
|
345
|
-
http_response.stub
|
366
|
+
http_response.stub(:read_body)
|
346
367
|
|
347
|
-
@http_client.stub
|
368
|
+
@http_client.stub(:request).and_yield(http_response).and_return(http_response)
|
348
369
|
|
349
|
-
lambda { @rest.
|
370
|
+
lambda { @rest.request(:GET, @url) }.should raise_error(Chef::Exceptions::RedirectLimitExceeded)
|
350
371
|
|
351
372
|
[:PUT, :POST, :DELETE].each do |method|
|
352
|
-
lambda { @rest.
|
373
|
+
lambda { @rest.request(method, @url) }.should raise_error(Chef::Exceptions::InvalidRedirect)
|
353
374
|
end
|
354
375
|
end
|
355
376
|
end
|
356
377
|
|
357
378
|
it "should return `false` when response is 304 NotModified" do
|
358
379
|
http_response = Net::HTTPNotModified.new("1.1", "304", "it's the same as when you asked 5 minutes ago")
|
359
|
-
http_response.stub
|
380
|
+
http_response.stub(:read_body)
|
360
381
|
|
361
|
-
@http_client.stub
|
382
|
+
@http_client.stub(:request).and_yield(http_response).and_return(http_response)
|
362
383
|
|
363
|
-
@rest.
|
384
|
+
@rest.request(:GET, @url).should be_false
|
364
385
|
end
|
365
386
|
|
366
387
|
describe "when the request fails" do
|
@@ -376,12 +397,12 @@ describe Chef::REST do
|
|
376
397
|
it "should show the JSON error message on an unsuccessful request" do
|
377
398
|
http_response = Net::HTTPServerError.new("1.1", "500", "drooling from inside of mouth")
|
378
399
|
http_response.add_field("content-type", "application/json")
|
379
|
-
http_response.stub
|
380
|
-
http_response.stub
|
381
|
-
@rest.stub
|
382
|
-
@http_client.stub
|
400
|
+
http_response.stub(:body).and_return('{ "error":[ "Ears get sore!", "Not even four" ] }')
|
401
|
+
http_response.stub(:read_body)
|
402
|
+
@rest.stub(:sleep)
|
403
|
+
@http_client.stub(:request).and_yield(http_response).and_return(http_response)
|
383
404
|
|
384
|
-
lambda {@rest.
|
405
|
+
lambda {@rest.request(:GET, @url)}.should raise_error(Net::HTTPFatalError)
|
385
406
|
@log_stringio.string.should match(Regexp.escape('INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four'))
|
386
407
|
end
|
387
408
|
|
@@ -393,23 +414,23 @@ describe Chef::REST do
|
|
393
414
|
gzipped_body = Zlib::Deflate.deflate(unzipped_body)
|
394
415
|
gzipped_body.force_encoding(Encoding::BINARY) if "strings".respond_to?(:force_encoding)
|
395
416
|
|
396
|
-
http_response.stub
|
397
|
-
http_response.stub
|
398
|
-
@rest.stub
|
399
|
-
@rest.stub
|
400
|
-
@http_client.stub
|
417
|
+
http_response.stub(:body).and_return gzipped_body
|
418
|
+
http_response.stub(:read_body)
|
419
|
+
@rest.stub(:sleep)
|
420
|
+
@rest.stub(:http_retry_count).and_return(0)
|
421
|
+
@http_client.stub(:request).and_yield(http_response).and_return(http_response)
|
401
422
|
|
402
|
-
lambda {@rest.
|
423
|
+
lambda {@rest.request(:GET, @url)}.should raise_error(Net::HTTPFatalError)
|
403
424
|
@log_stringio.string.should match(Regexp.escape('INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four'))
|
404
425
|
end
|
405
426
|
|
406
427
|
it "should raise an exception on an unsuccessful request" do
|
407
428
|
http_response = Net::HTTPServerError.new("1.1", "500", "drooling from inside of mouth")
|
408
|
-
http_response.stub
|
409
|
-
http_response.stub
|
410
|
-
@rest.stub
|
411
|
-
@http_client.stub
|
412
|
-
lambda {@rest.
|
429
|
+
http_response.stub(:body)
|
430
|
+
http_response.stub(:read_body)
|
431
|
+
@rest.stub(:sleep)
|
432
|
+
@http_client.stub(:request).and_yield(http_response).and_return(http_response)
|
433
|
+
lambda {@rest.request(:GET, @url)}.should raise_error(Net::HTTPFatalError)
|
413
434
|
end
|
414
435
|
end
|
415
436
|
|
@@ -419,22 +440,21 @@ describe Chef::REST do
|
|
419
440
|
context "when streaming downloads to a tempfile" do
|
420
441
|
before do
|
421
442
|
@tempfile = Tempfile.open("chef-rspec-rest_spec-line-#{__LINE__}--")
|
422
|
-
Tempfile.stub
|
443
|
+
Tempfile.stub(:new).with("chef-rest").and_return(@tempfile)
|
423
444
|
@request_mock = {}
|
424
|
-
Net::HTTP::Get.stub
|
445
|
+
Net::HTTP::Get.stub(:new).and_return(@request_mock)
|
425
446
|
|
426
447
|
@http_response = Net::HTTPSuccess.new("1.1",200, "it-works")
|
427
|
-
@http_response.stub
|
428
|
-
@http_client.stub
|
448
|
+
@http_response.stub(:read_body)
|
449
|
+
@http_client.stub(:request).and_yield(@http_response).and_return(@http_response)
|
429
450
|
end
|
430
451
|
|
431
452
|
after do
|
432
|
-
@tempfile.rspec_reset
|
433
453
|
@tempfile.close!
|
434
454
|
end
|
435
455
|
|
436
456
|
it " build a new HTTP GET request without the application/json accept header" do
|
437
|
-
expected_headers = {'X-Chef-Version' => Chef::VERSION, 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE}
|
457
|
+
expected_headers = {'Accept' => "*/*", 'X-Chef-Version' => Chef::VERSION, 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE}
|
438
458
|
Net::HTTP::Get.should_receive(:new).with("/?foo=bar", expected_headers).and_return(@request_mock)
|
439
459
|
@rest.streaming_request(@url, {})
|
440
460
|
end
|
@@ -444,7 +464,7 @@ describe Chef::REST do
|
|
444
464
|
end
|
445
465
|
|
446
466
|
it "writes the response body to a tempfile" do
|
447
|
-
@http_response.stub
|
467
|
+
@http_response.stub(:read_body).and_yield("real").and_yield("ultimate").and_yield("power")
|
448
468
|
@rest.streaming_request(@url, {})
|
449
469
|
IO.read(@tempfile.path).chomp.should == "realultimatepower"
|
450
470
|
end
|
@@ -455,7 +475,7 @@ describe Chef::REST do
|
|
455
475
|
end
|
456
476
|
|
457
477
|
it "yields the tempfile containing the streamed response body and then unlinks it when given a block" do
|
458
|
-
@http_response.stub
|
478
|
+
@http_response.stub(:read_body).and_yield("real").and_yield("ultimate").and_yield("power")
|
459
479
|
tempfile_path = nil
|
460
480
|
@rest.streaming_request(@url, {}) do |tempfile|
|
461
481
|
tempfile_path = tempfile.path
|
@@ -467,18 +487,18 @@ describe Chef::REST do
|
|
467
487
|
|
468
488
|
it "does not raise a divide by zero exception if the content's actual size is 0" do
|
469
489
|
@http_response.add_field('Content-Length', "5")
|
470
|
-
@http_response.stub
|
471
|
-
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
490
|
+
@http_response.stub(:read_body).and_yield('')
|
491
|
+
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
472
492
|
end
|
473
493
|
|
474
494
|
it "does not raise a divide by zero exception when the Content-Length is 0" do
|
475
495
|
@http_response.add_field('Content-Length', "0")
|
476
|
-
@http_response.stub
|
477
|
-
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
496
|
+
@http_response.stub(:read_body).and_yield("ninja")
|
497
|
+
lambda { @rest.streaming_request(@url, {}) }.should_not raise_error
|
478
498
|
end
|
479
499
|
|
480
500
|
it "fetches a file and yields the tempfile it is streamed to" do
|
481
|
-
@http_response.stub
|
501
|
+
@http_response.stub(:read_body).and_yield("real").and_yield("ultimate").and_yield("power")
|
482
502
|
tempfile_path = nil
|
483
503
|
@rest.fetch("cookbooks/a_cookbook") do |tempfile|
|
484
504
|
tempfile_path = tempfile.path
|
@@ -490,34 +510,32 @@ describe Chef::REST do
|
|
490
510
|
it "closes and unlinks the tempfile if there is an error while streaming the content to the tempfile" do
|
491
511
|
path = @tempfile.path
|
492
512
|
path.should_not be_nil
|
493
|
-
@tempfile.stub
|
513
|
+
@tempfile.stub(:write).and_raise(IOError)
|
494
514
|
@rest.fetch("cookbooks/a_cookbook") {|tmpfile| "shouldn't get here"}
|
495
515
|
File.exists?(path).should be_false
|
496
516
|
end
|
497
517
|
|
498
518
|
it "closes and unlinks the tempfile when the response is a redirect" do
|
499
|
-
|
500
|
-
tempfile
|
501
|
-
|
502
|
-
Tempfile.stub!(:new).with("chef-rest").and_return(tempfile)
|
519
|
+
tempfile = double("A tempfile", :path => "/tmp/ragefist", :close => true, :binmode => true)
|
520
|
+
tempfile.should_receive(:close!).at_least(1).times
|
521
|
+
Tempfile.stub(:new).with("chef-rest").and_return(tempfile)
|
503
522
|
|
504
|
-
|
505
|
-
|
506
|
-
|
523
|
+
redirect = Net::HTTPFound.new("1.1", "302", "bob is taking care of that one for me today")
|
524
|
+
redirect.add_field("location", @url.path)
|
525
|
+
redirect.stub(:read_body)
|
507
526
|
|
508
|
-
@http_client.
|
527
|
+
@http_client.should_receive(:request).and_yield(redirect).and_return(redirect)
|
528
|
+
@http_client.should_receive(:request).and_yield(@http_response).and_return(@http_response)
|
509
529
|
@rest.fetch("cookbooks/a_cookbook") {|tmpfile| "shouldn't get here"}
|
510
530
|
end
|
511
531
|
|
512
532
|
it "passes the original block to the redirected request" do
|
513
|
-
Tempfile.rspec_reset
|
514
|
-
|
515
533
|
http_response = Net::HTTPFound.new("1.1", "302", "bob is taking care of that one for me today")
|
516
534
|
http_response.add_field("location","/that-thing-is-here-now")
|
517
|
-
http_response.stub
|
535
|
+
http_response.stub(:read_body)
|
518
536
|
|
519
537
|
block_called = false
|
520
|
-
@http_client.stub
|
538
|
+
@http_client.stub(:request).and_yield(@http_response).and_return(http_response, @http_response)
|
521
539
|
@rest.fetch("cookbooks/a_cookbook") do |tmpfile|
|
522
540
|
block_called = true
|
523
541
|
end
|
@@ -546,9 +564,9 @@ describe Chef::REST do
|
|
546
564
|
redirected.call unless total_redirects >= 9
|
547
565
|
end
|
548
566
|
end
|
549
|
-
lambda {redirected.call}.should_not raise_error
|
567
|
+
lambda {redirected.call}.should_not raise_error
|
550
568
|
total_redirects = 0
|
551
|
-
lambda {redirected.call}.should_not raise_error
|
569
|
+
lambda {redirected.call}.should_not raise_error
|
552
570
|
end
|
553
571
|
|
554
572
|
it "does not sign the redirected request when sign_on_redirect is false" do
|
@@ -572,7 +590,7 @@ describe Chef::REST do
|
|
572
590
|
redirected.call unless total_redirects >= 9
|
573
591
|
end
|
574
592
|
end
|
575
|
-
lambda {redirected.call}.should_not raise_error
|
593
|
+
lambda {redirected.call}.should_not raise_error
|
576
594
|
|
577
595
|
total_redirects = 0
|
578
596
|
@rest.redirect_limit = 3
|