chef 12.4.3-universal-mingw32 → 12.5.1-universal-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 +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +4 -110
- data/bin/chef-service-manager +3 -1
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- data/lib/chef.rb +1 -1
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +19 -1
- data/lib/chef/application/client.rb +11 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/application/windows_service_manager.rb +19 -12
- data/lib/chef/chef_class.rb +46 -0
- data/lib/chef/chef_fs/config.rb +22 -24
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- data/lib/chef/chef_fs/file_pattern.rb +4 -15
- data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +4 -4
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
- data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
- data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
- data/lib/chef/chef_fs/knife.rb +35 -7
- data/lib/chef/chef_fs/path_utils.rb +65 -34
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- data/lib/chef/{mixin/wstring.rb → constants.rb} +9 -13
- data/lib/chef/cookbook/metadata.rb +25 -3
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/delayed_evaluator.rb +21 -0
- data/lib/chef/deprecation/mixin/template.rb +1 -2
- data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
- data/lib/chef/deprecation/provider/file.rb +1 -1
- data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -2
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/reboot_pending.rb +3 -2
- data/lib/chef/dsl/recipe.rb +26 -7
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +51 -22
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/event_dispatch/dsl.rb +64 -0
- data/lib/chef/exceptions.rb +28 -1
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +56 -6
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/knife.rb +35 -55
- data/lib/chef/knife/bootstrap.rb +41 -0
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
- data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
- data/lib/chef/knife/bootstrap/templates/README.md +3 -4
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +6 -6
- data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
- data/lib/chef/knife/core/bootstrap_context.rb +12 -4
- data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
- data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
- data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
- data/lib/chef/knife/core/node_presenter.rb +24 -1
- data/lib/chef/knife/core/object_loader.rb +1 -0
- data/lib/chef/knife/core/subcommand_loader.rb +131 -146
- data/lib/chef/knife/node_run_list_remove.rb +12 -1
- data/lib/chef/knife/null.rb +10 -0
- data/lib/chef/knife/rehash.rb +62 -0
- data/lib/chef/knife/search.rb +3 -3
- data/lib/chef/knife/ssh.rb +52 -30
- data/lib/chef/knife/ssl_check.rb +3 -2
- data/lib/chef/knife/user_edit.rb +1 -2
- data/lib/chef/local_mode.rb +5 -0
- data/lib/chef/log.rb +5 -1
- data/lib/chef/mixin/deprecation.rb +8 -8
- data/lib/chef/mixin/params_validate.rb +362 -135
- data/lib/chef/mixin/template.rb +48 -0
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +72 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
- data/lib/chef/mixin/windows_env_helper.rb +4 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
- data/lib/chef/monkey_patches/win32/registry.rb +72 -0
- data/lib/chef/node.rb +116 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/handler_map.rb +0 -5
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +30 -32
- data/lib/chef/policy_builder.rb +1 -8
- data/lib/chef/policy_builder/dynamic.rb +186 -0
- data/lib/chef/policy_builder/expand_node_object.rb +30 -15
- data/lib/chef/policy_builder/policyfile.rb +155 -18
- data/lib/chef/property.rb +568 -0
- data/lib/chef/provider.rb +222 -13
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +5 -7
- data/lib/chef/provider/directory.rb +14 -2
- data/lib/chef/provider/dsc_resource.rb +5 -9
- data/lib/chef/provider/group/pw.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/lwrp_base.rb +1 -75
- data/lib/chef/provider/mount.rb +7 -3
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +5 -11
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +17 -5
- data/lib/chef/provider/powershell_script.rb +59 -23
- data/lib/chef/provider/registry_key.rb +5 -5
- data/lib/chef/provider/remote_directory.rb +190 -102
- data/lib/chef/provider/service.rb +12 -2
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/debian.rb +3 -5
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +3 -3
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +2 -4
- data/lib/chef/provider/service/invokercd.rb +2 -4
- data/lib/chef/provider/service/macosx.rb +5 -1
- data/lib/chef/provider/service/openbsd.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +52 -16
- data/lib/chef/provider/service/simple.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +3 -5
- data/lib/chef/provider/service/upstart.rb +4 -6
- data/lib/chef/provider/subversion.rb +13 -7
- data/lib/chef/provider/template/content.rb +16 -6
- data/lib/chef/provider/user/solaris.rb +32 -4
- data/lib/chef/provider/windows_script.rb +3 -5
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/recipe.rb +1 -8
- data/lib/chef/resource.rb +563 -90
- data/lib/chef/resource/action_class.rb +83 -0
- data/lib/chef/resource/chef_gem.rb +3 -3
- data/lib/chef/resource/deploy.rb +8 -2
- data/lib/chef/resource/dsc_script.rb +2 -0
- data/lib/chef/resource/file/verification.rb +7 -1
- data/lib/chef/resource/lwrp_base.rb +1 -7
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/service.rb +10 -2
- data/lib/chef/resource/subversion.rb +5 -0
- data/lib/chef/resource/windows_script.rb +6 -2
- data/lib/chef/resource/yum_package.rb +10 -1
- data/lib/chef/resource_resolver.rb +3 -3
- data/lib/chef/run_context.rb +402 -83
- data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
- data/lib/chef/run_lock.rb +30 -21
- data/lib/chef/util/powershell/ps_credential.rb +4 -0
- data/lib/chef/util/windows.rb +0 -32
- data/lib/chef/util/windows/net_group.rb +85 -106
- data/lib/chef/util/windows/net_use.rb +35 -71
- data/lib/chef/util/windows/net_user.rb +0 -1
- data/lib/chef/util/windows/volume.rb +19 -19
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api.rb +1 -0
- data/lib/chef/win32/api/file.rb +20 -0
- data/lib/chef/win32/api/net.rb +163 -43
- data/lib/chef/win32/api/registry.rb +51 -0
- data/lib/chef/win32/api/system.rb +23 -0
- data/lib/chef/win32/api/unicode.rb +0 -43
- data/lib/chef/win32/crypto.rb +2 -1
- data/lib/chef/win32/file.rb +28 -3
- data/lib/chef/win32/mutex.rb +1 -2
- data/lib/chef/win32/net.rb +162 -8
- data/lib/chef/win32/process.rb +13 -0
- data/lib/chef/win32/registry.rb +35 -30
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/system.rb +62 -0
- data/lib/chef/win32/unicode.rb +7 -2
- data/lib/chef/win32/version.rb +0 -4
- data/lib/chef/workstation_config_loader.rb +3 -158
- data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
- data/spec/data/dsc_lcm.pfx +0 -0
- data/spec/data/run_context/cookbooks/include/recipes/default.rb +24 -0
- data/spec/data/run_context/cookbooks/include/recipes/includee.rb +3 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
- data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
- data/spec/functional/knife/ssh_spec.rb +16 -0
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +2 -0
- data/spec/functional/resource/dsc_script_spec.rb +91 -2
- data/spec/functional/resource/group_spec.rb +67 -44
- data/spec/functional/resource/{powershell_spec.rb → powershell_script_spec.rb} +107 -18
- data/spec/functional/resource/windows_service_spec.rb +1 -1
- data/spec/functional/run_lock_spec.rb +368 -189
- data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +16 -23
- data/spec/functional/win32/service_manager_spec.rb +2 -2
- data/spec/integration/client/client_spec.rb +51 -0
- data/spec/integration/knife/chef_repo_path_spec.rb +13 -11
- data/spec/integration/knife/download_spec.rb +4 -0
- data/spec/integration/knife/list_spec.rb +8 -0
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -16
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +363 -0
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
- data/spec/integration/recipes/resource_load_spec.rb +206 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/spec/support/shared/context/win32.rb +34 -0
- data/spec/support/shared/functional/win32_service.rb +2 -1
- data/spec/support/shared/functional/windows_script.rb +63 -26
- data/spec/support/shared/unit/mock_shellout.rb +46 -0
- data/spec/support/shared/unit/provider/file.rb +10 -4
- data/spec/unit/application/client_spec.rb +16 -3
- data/spec/unit/application/knife_spec.rb +2 -2
- data/spec/unit/application/solo_spec.rb +4 -3
- data/spec/unit/chef_class_spec.rb +23 -4
- data/spec/unit/chef_fs/path_util_spec.rb +108 -0
- data/spec/unit/client_spec.rb +6 -1
- data/spec/unit/config_spec.rb +31 -0
- data/spec/unit/cookbook/metadata_spec.rb +23 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/deprecation_spec.rb +3 -6
- data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
- data/spec/unit/event_dispatch/dsl_spec.rb +83 -0
- data/spec/unit/formatters/doc_spec.rb +32 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
- data/spec/unit/json_compat_spec.rb +4 -3
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -3
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
- data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
- data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
- data/spec/unit/knife/ssl_check_spec.rb +4 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/template_spec.rb +5 -1
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
- data/spec/unit/node_spec.rb +220 -0
- data/spec/unit/platform/query_helpers_spec.rb +146 -3
- data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
- data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
- data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
- data/spec/unit/property/state_spec.rb +506 -0
- data/spec/unit/property/validation_spec.rb +663 -0
- data/spec/unit/property_spec.rb +1094 -0
- data/spec/unit/provider/deploy_spec.rb +5 -5
- data/spec/unit/provider/directory_spec.rb +35 -0
- data/spec/unit/provider/dsc_resource_spec.rb +3 -10
- data/spec/unit/provider/ifconfig_spec.rb +22 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +6 -0
- data/spec/unit/provider/mount/windows_spec.rb +14 -0
- data/spec/unit/provider/mount_spec.rb +12 -1
- data/spec/unit/provider/package/dpkg_spec.rb +8 -1
- data/spec/unit/provider/package/rpm_spec.rb +18 -1
- data/spec/unit/provider/package/rubygems_spec.rb +18 -0
- data/spec/unit/provider/package/yum_spec.rb +97 -24
- data/spec/unit/provider/powershell_script_spec.rb +106 -0
- data/spec/unit/provider/registry_key_spec.rb +12 -0
- data/spec/unit/provider/remote_directory_spec.rb +1 -2
- data/spec/unit/provider/service/aix_service_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +4 -4
- data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
- data/spec/unit/provider/service/redhat_spec.rb +88 -8
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
- data/spec/unit/provider/service/windows_spec.rb +211 -200
- data/spec/unit/provider/subversion_spec.rb +50 -31
- data/spec/unit/provider/template/content_spec.rb +93 -2
- data/spec/unit/provider/user/solaris_spec.rb +66 -9
- data/spec/unit/provider_resolver_spec.rb +707 -650
- data/spec/unit/provider_spec.rb +1 -3
- data/spec/unit/recipe_spec.rb +0 -4
- data/spec/unit/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +33 -5
- data/spec/unit/resource/{powershell_spec.rb → powershell_script_spec.rb} +17 -13
- data/spec/unit/resource/service_spec.rb +4 -4
- data/spec/unit/resource/subversion_spec.rb +4 -0
- data/spec/unit/resource/yum_package_spec.rb +10 -1
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/run_context/child_run_context_spec.rb +133 -0
- data/spec/unit/run_context_spec.rb +7 -0
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
- data/spec/unit/win32/registry_spec.rb +394 -0
- data/tasks/external_tests.rb +47 -23
- data/tasks/maintainers.rb +155 -14
- metadata +64 -53
- data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
- data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
- data/spec/unit/provider/powershell_spec.rb +0 -80
- data/spec/unit/registry_helper_spec.rb +0 -376
- data/spec/unit/workstation_config_loader_spec.rb +0 -283
@@ -1,76 +0,0 @@
|
|
1
|
-
bash -c '
|
2
|
-
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
|
3
|
-
|
4
|
-
if [ ! -f /usr/bin/chef-client ]; then
|
5
|
-
pacman -Syy
|
6
|
-
pacman -S --noconfirm ruby ntp base-devel
|
7
|
-
ntpdate -u pool.ntp.org
|
8
|
-
gem install ohai --no-user-install --no-document --verbose
|
9
|
-
gem install chef --no-user-install --no-document --verbose <%= Chef::VERSION %>
|
10
|
-
fi
|
11
|
-
|
12
|
-
mkdir -p /etc/chef
|
13
|
-
|
14
|
-
<% if validation_key -%>
|
15
|
-
cat > /etc/chef/validation.pem <<'EOP'
|
16
|
-
<%= validation_key %>
|
17
|
-
EOP
|
18
|
-
chmod 0600 /etc/chef/validation.pem
|
19
|
-
<% end -%>
|
20
|
-
|
21
|
-
<% if encrypted_data_bag_secret -%>
|
22
|
-
cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
|
23
|
-
<%= encrypted_data_bag_secret %>
|
24
|
-
EOP
|
25
|
-
chmod 0600 /etc/chef/encrypted_data_bag_secret
|
26
|
-
<% end -%>
|
27
|
-
|
28
|
-
<% unless trusted_certs.empty? -%>
|
29
|
-
mkdir -p /etc/chef/trusted_certs
|
30
|
-
<%= trusted_certs %>
|
31
|
-
<% end -%>
|
32
|
-
|
33
|
-
<%# Generate Ohai Hints -%>
|
34
|
-
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
|
35
|
-
mkdir -p /etc/chef/ohai/hints
|
36
|
-
|
37
|
-
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
38
|
-
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
39
|
-
<%= Chef::JSONCompat.to_json(hash) %>
|
40
|
-
EOP
|
41
|
-
<% end -%>
|
42
|
-
<% end -%>
|
43
|
-
|
44
|
-
<% if client_pem -%>
|
45
|
-
cat > /etc/chef/client.pem <<'EOP'
|
46
|
-
<%= ::File.read(::File.expand_path(client_pem)) %>
|
47
|
-
EOP
|
48
|
-
chmod 0600 /etc/chef/client.pem
|
49
|
-
<% end -%>
|
50
|
-
|
51
|
-
cat > /etc/chef/client.rb <<'EOP'
|
52
|
-
log_level :info
|
53
|
-
log_location STDOUT
|
54
|
-
chef_server_url "<%= @chef_config[:chef_server_url] %>"
|
55
|
-
validation_client_name "<%= @chef_config[:validation_client_name] %>"
|
56
|
-
<% if @config[:chef_node_name] -%>
|
57
|
-
node_name "<%= @config[:chef_node_name] %>"
|
58
|
-
<% else -%>
|
59
|
-
# Using default node name (fqdn)
|
60
|
-
<% end -%>
|
61
|
-
# ArchLinux follows the Filesystem Hierarchy Standard
|
62
|
-
file_cache_path "/var/cache/chef"
|
63
|
-
file_backup_path "/var/lib/chef/backup"
|
64
|
-
pid_file "/var/run/chef/client.pid"
|
65
|
-
cache_options({ :path => "/var/cache/chef/checksums", :skip_expires => true})
|
66
|
-
<% if knife_config[:bootstrap_proxy] %>
|
67
|
-
http_proxy "<%= knife_config[:bootstrap_proxy] %>"
|
68
|
-
https_proxy "<%= knife_config[:bootstrap_proxy] %>"
|
69
|
-
<% end -%>
|
70
|
-
EOP
|
71
|
-
|
72
|
-
cat > /etc/chef/first-boot.json <<'EOP'
|
73
|
-
<%= Chef::JSONCompat.to_json(first_boot) %>
|
74
|
-
EOP
|
75
|
-
|
76
|
-
<%= start_chef %>'
|
@@ -1,72 +0,0 @@
|
|
1
|
-
ksh -c '
|
2
|
-
|
3
|
-
function exists {
|
4
|
-
if type $1 >/dev/null 2>&1
|
5
|
-
then
|
6
|
-
return 0
|
7
|
-
else
|
8
|
-
return 1
|
9
|
-
fi
|
10
|
-
}
|
11
|
-
|
12
|
-
if ! exists /usr/bin/chef-client; then
|
13
|
-
<% if @chef_config[:aix_package] -%>
|
14
|
-
# Read the download URL/location from knife.rb with option aix_package
|
15
|
-
rm -rf /tmp/chef_installer # ensure there no older pkg
|
16
|
-
echo "<%= @chef_config[:aix_package] %>"
|
17
|
-
perl -e '\''use LWP::Simple; getprint($ARGV[0]);'\'' <%= @chef_config[:aix_package] %> > /tmp/chef_installer
|
18
|
-
installp -aYF -d /tmp/chef_installer chef
|
19
|
-
<% else -%>
|
20
|
-
echo ":aix_package location is not set in knife.rb"
|
21
|
-
exit
|
22
|
-
<% end -%>
|
23
|
-
fi
|
24
|
-
|
25
|
-
mkdir -p /etc/chef
|
26
|
-
|
27
|
-
<% if client_pem -%>
|
28
|
-
cat > /etc/chef/client.pem <<'EOP'
|
29
|
-
<%= ::File.read(::File.expand_path(client_pem)) %>
|
30
|
-
EOP
|
31
|
-
chmod 0600 /etc/chef/client.pem
|
32
|
-
<% end -%>
|
33
|
-
|
34
|
-
<% if validation_key -%>
|
35
|
-
cat > /etc/chef/validation.pem <<'EOP'
|
36
|
-
<%= validation_key %>
|
37
|
-
EOP
|
38
|
-
chmod 0600 /etc/chef/validation.pem
|
39
|
-
<% end -%>
|
40
|
-
|
41
|
-
<% if encrypted_data_bag_secret -%>
|
42
|
-
cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
|
43
|
-
<%= encrypted_data_bag_secret %>
|
44
|
-
EOP
|
45
|
-
chmod 0600 /etc/chef/encrypted_data_bag_secret
|
46
|
-
<% end -%>
|
47
|
-
|
48
|
-
<% unless trusted_certs.empty? -%>
|
49
|
-
mkdir -p /etc/chef/trusted_certs
|
50
|
-
<%= trusted_certs %>
|
51
|
-
<% end -%>
|
52
|
-
|
53
|
-
<%# Generate Ohai Hints -%>
|
54
|
-
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
|
55
|
-
mkdir -p /etc/chef/ohai/hints
|
56
|
-
|
57
|
-
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
58
|
-
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
59
|
-
<%= Chef::JSONCompat.to_json(hash) %>
|
60
|
-
EOP
|
61
|
-
<% end -%>
|
62
|
-
<% end -%>
|
63
|
-
|
64
|
-
cat > /etc/chef/client.rb <<'EOP'
|
65
|
-
<%= config_content %>
|
66
|
-
EOP
|
67
|
-
|
68
|
-
cat > /etc/chef/first-boot.json <<'EOP'
|
69
|
-
<%= Chef::JSONCompat.to_json(first_boot) %>
|
70
|
-
EOP
|
71
|
-
|
72
|
-
<%= start_chef %>'
|
@@ -1,80 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Edwards (<adamed@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2013 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
|
-
describe Chef::Provider::PowershellScript, "action_run" do
|
21
|
-
|
22
|
-
let(:powershell_version) { nil }
|
23
|
-
let(:node) {
|
24
|
-
node = Chef::Node.new
|
25
|
-
node.default["kernel"] = Hash.new
|
26
|
-
node.default["kernel"][:machine] = :x86_64.to_s
|
27
|
-
if ! powershell_version.nil?
|
28
|
-
node.default[:languages] = { :powershell => { :version => powershell_version } }
|
29
|
-
end
|
30
|
-
node
|
31
|
-
}
|
32
|
-
|
33
|
-
let(:provider) {
|
34
|
-
empty_events = Chef::EventDispatch::Dispatcher.new
|
35
|
-
run_context = Chef::RunContext.new(node, {}, empty_events)
|
36
|
-
new_resource = Chef::Resource::PowershellScript.new('run some powershell code', run_context)
|
37
|
-
Chef::Provider::PowershellScript.new(new_resource, run_context)
|
38
|
-
}
|
39
|
-
|
40
|
-
context 'when setting interpreter flags' do
|
41
|
-
it "should set the -File flag as the last flag" do
|
42
|
-
expect(provider.flags.split(' ').pop).to eq("-File")
|
43
|
-
end
|
44
|
-
|
45
|
-
let(:execution_policy_flag) do
|
46
|
-
execution_policy_index = 0
|
47
|
-
provider_flags = provider.flags.split(' ')
|
48
|
-
execution_policy_specified = false
|
49
|
-
|
50
|
-
provider_flags.find do | value |
|
51
|
-
execution_policy_index += 1
|
52
|
-
execution_policy_specified = value.downcase == '-ExecutionPolicy'.downcase
|
53
|
-
end
|
54
|
-
|
55
|
-
execution_policy = execution_policy_specified ? provider_flags[execution_policy_index] : nil
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'when running with an unspecified PowerShell version' do
|
59
|
-
let(:powershell_version) { nil }
|
60
|
-
it "should set the -ExecutionPolicy flag to 'Unrestricted' by default" do
|
61
|
-
expect(execution_policy_flag.downcase).to eq('unrestricted'.downcase)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
{ '2.0' => 'Unrestricted',
|
66
|
-
'2.5' => 'Unrestricted',
|
67
|
-
'3.0' => 'Bypass',
|
68
|
-
'3.6' => 'Bypass',
|
69
|
-
'4.0' => 'Bypass',
|
70
|
-
'5.0' => 'Bypass' }.each do | version_policy |
|
71
|
-
let(:powershell_version) { version_policy[0].to_f }
|
72
|
-
context "when running PowerShell version #{version_policy[0]}" do
|
73
|
-
let(:powershell_version) { version_policy[0].to_f }
|
74
|
-
it "should set the -ExecutionPolicy flag to '#{version_policy[1]}'" do
|
75
|
-
expect(execution_policy_flag.downcase).to eq(version_policy[1].downcase)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,376 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Prajakta Purohit (prajakta@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
|
-
|
21
|
-
describe Chef::Provider::RegistryKey do
|
22
|
-
|
23
|
-
let(:value1) { { :name => "one", :type => :string, :data => "1" } }
|
24
|
-
let(:key_path) { 'HKCU\Software\OpscodeNumbers' }
|
25
|
-
let(:key) { 'Software\OpscodeNumbers' }
|
26
|
-
let(:key_parent) { 'Software' }
|
27
|
-
let(:key_to_delete) { 'OpscodeNumbers' }
|
28
|
-
let(:sub_key) {'OpscodePrimes'}
|
29
|
-
let(:missing_key_path) {'HKCU\Software'}
|
30
|
-
|
31
|
-
before(:each) do
|
32
|
-
allow_any_instance_of(Chef::Win32::Registry).to receive(:machine_architecture).and_return(:x86_64)
|
33
|
-
@registry = Chef::Win32::Registry.new()
|
34
|
-
|
35
|
-
#Making the values for registry constants available on unix
|
36
|
-
Object.send(:remove_const, 'Win32') if defined?(Win32)
|
37
|
-
Win32 = Module.new
|
38
|
-
Win32::Registry = Class.new
|
39
|
-
Win32::Registry::KEY_SET_VALUE = 0x0002
|
40
|
-
Win32::Registry::KEY_QUERY_VALUE = 0x0001
|
41
|
-
Win32::Registry::KEY_WRITE = 0x00020000 | 0x0002 | 0x0004
|
42
|
-
Win32::Registry::KEY_READ = 0x00020000 | 0x0001 | 0x0008 | 0x0010
|
43
|
-
|
44
|
-
Win32::Registry::Error = Class.new(RuntimeError)
|
45
|
-
|
46
|
-
@hive_mock = double("::Win32::Registry::HKEY_CURRENT_USER")
|
47
|
-
@reg_mock = double("reg")
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "get_values" do
|
51
|
-
it "gets all values for a key if the key exists" do
|
52
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
53
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
54
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
55
|
-
expect(@reg_mock).to receive(:map)
|
56
|
-
@registry.get_values(key_path)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "throws an exception if key does not exist" do
|
60
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
61
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
62
|
-
expect{@registry.get_values(key_path)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "set_value" do
|
67
|
-
it "does nothing if key and hive and value exist" do
|
68
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
69
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
70
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
71
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(true)
|
72
|
-
@registry.set_value(key_path, value1)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "updates value if key and hive and value exist, but data is different" do
|
76
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
77
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
78
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
79
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(false)
|
80
|
-
expect(@hive_mock).to receive(:open).with(key, Win32::Registry::KEY_SET_VALUE | ::Win32::Registry::KEY_QUERY_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
|
81
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
82
|
-
expect(@reg_mock).to receive(:write).with("one", 1, "1")
|
83
|
-
@registry.set_value(key_path, value1)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "creates value if the key exists and the value does not exist" do
|
87
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
88
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
89
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
90
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_SET_VALUE | ::Win32::Registry::KEY_QUERY_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
|
91
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
92
|
-
expect(@reg_mock).to receive(:write).with("one", 1, "1")
|
93
|
-
@registry.set_value(key_path, value1)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should raise an exception if the key does not exist" do
|
97
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
98
|
-
expect {@registry.set_value(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "delete_value" do
|
103
|
-
it "deletes value if value exists" do
|
104
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
105
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
106
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_SET_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
|
107
|
-
expect(@reg_mock).to receive(:delete_value).with("one").and_return(true)
|
108
|
-
@registry.delete_value(key_path, value1)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "raises an exception if the key does not exist" do
|
112
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
113
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
114
|
-
@registry.delete_value(key_path, value1)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "does nothing if the value does not exist" do
|
118
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
119
|
-
@registry.delete_value(key_path, value1)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe "create_key" do
|
124
|
-
it "creates key if intermediate keys are missing and recursive is set to true" do
|
125
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(true)
|
126
|
-
expect(@registry).to receive(:create_missing).with(key_path)
|
127
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
128
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
129
|
-
expect(@hive_mock).to receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
|
130
|
-
@registry.create_key(key_path, true)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "raises an exception if intermediate keys are missing and recursive is set to false" do
|
134
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(true)
|
135
|
-
expect{@registry.create_key(key_path, false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
|
136
|
-
end
|
137
|
-
|
138
|
-
it "does nothing if the key exists" do
|
139
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(true)
|
140
|
-
expect(@registry).to receive(:create_missing).with(key_path)
|
141
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
142
|
-
@registry.create_key(key_path, true)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "create key if intermediate keys not missing and recursive is set to false" do
|
146
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(false)
|
147
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
148
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
149
|
-
expect(@hive_mock).to receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
|
150
|
-
@registry.create_key(key_path, false)
|
151
|
-
end
|
152
|
-
|
153
|
-
it "create key if intermediate keys not missing and recursive is set to true" do
|
154
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(false)
|
155
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
156
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
157
|
-
expect(@hive_mock).to receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
|
158
|
-
@registry.create_key(key_path, true)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "delete_key", :windows_only do
|
163
|
-
it "deletes key if it has subkeys and recursive is set to true" do
|
164
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
165
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
166
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path).and_return(true)
|
167
|
-
expect(@registry).to receive(:get_subkeys).with(key_path).and_return([sub_key])
|
168
|
-
expect(@registry).to receive(:key_exists?).with(key_path+"\\"+sub_key).and_return(true)
|
169
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path+"\\"+sub_key).and_return([@hive_mock, key+"\\"+sub_key])
|
170
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path+"\\"+sub_key).and_return(false)
|
171
|
-
expect(@registry).to receive(:delete_key_ex).twice
|
172
|
-
@registry.delete_key(key_path, true)
|
173
|
-
end
|
174
|
-
|
175
|
-
it "raises an exception if it has subkeys but recursive is set to false" do
|
176
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
177
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
178
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path).and_return(true)
|
179
|
-
expect{@registry.delete_key(key_path, false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
|
180
|
-
end
|
181
|
-
|
182
|
-
it "deletes key if the key exists and has no subkeys" do
|
183
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
184
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
185
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path).and_return(false)
|
186
|
-
expect(@registry).to receive(:delete_key_ex)
|
187
|
-
@registry.delete_key(key_path, true)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe "key_exists?" do
|
192
|
-
it "returns true if key_exists" do
|
193
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
194
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
195
|
-
expect(@registry.key_exists?(key_path)).to eq(true)
|
196
|
-
end
|
197
|
-
|
198
|
-
it "returns false if key does not exist" do
|
199
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
200
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_raise(::Win32::Registry::Error)
|
201
|
-
expect(@registry.key_exists?(key_path)).to eq(false)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "key_exists!" do
|
206
|
-
it "throws an exception if the key_parent does not exist" do
|
207
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
208
|
-
expect{@registry.key_exists!(key_path)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "hive_exists?" do
|
213
|
-
it "returns true if the hive exists" do
|
214
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
215
|
-
@registry.hive_exists?(key_path) == true
|
216
|
-
end
|
217
|
-
|
218
|
-
it "returns false if the hive does not exist" do
|
219
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_raise(Chef::Exceptions::Win32RegHiveMissing)
|
220
|
-
@registry.hive_exists?(key_path) == false
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
describe "has_subkeys?" do
|
225
|
-
it "returns true if the key has subkeys" do
|
226
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
227
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
228
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
229
|
-
expect(@reg_mock).to receive(:each_key).and_yield(key)
|
230
|
-
@registry.has_subkeys?(key_path) == true
|
231
|
-
end
|
232
|
-
|
233
|
-
it "returns false if the key does not have subkeys" do
|
234
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
235
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
236
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
237
|
-
expect(@reg_mock).to receive(:each_key).and_return(no_args())
|
238
|
-
expect(@registry.has_subkeys?(key_path)).to eq(false)
|
239
|
-
end
|
240
|
-
|
241
|
-
it "throws an exception if the key does not exist" do
|
242
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
243
|
-
expect {@registry.set_value(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe "get_subkeys" do
|
248
|
-
it "returns the subkeys if they exist" do
|
249
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
250
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
251
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
252
|
-
expect(@reg_mock).to receive(:each_key).and_yield(sub_key)
|
253
|
-
@registry.get_subkeys(key_path)
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
describe "value_exists?" do
|
258
|
-
it "throws an exception if the key does not exist" do
|
259
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
260
|
-
expect {@registry.value_exists?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
261
|
-
end
|
262
|
-
|
263
|
-
it "returns true if the value exists" do
|
264
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
265
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
266
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
267
|
-
expect(@reg_mock).to receive(:any?).and_yield("one")
|
268
|
-
@registry.value_exists?(key_path, value1) == true
|
269
|
-
end
|
270
|
-
|
271
|
-
it "returns false if the value does not exist" do
|
272
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
273
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
274
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
275
|
-
expect(@reg_mock).to receive(:any?).and_yield(no_args())
|
276
|
-
@registry.value_exists?(key_path, value1) == false
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
describe "data_exists?" do
|
281
|
-
it "throws an exception if the key does not exist" do
|
282
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
283
|
-
expect {@registry.data_exists?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
284
|
-
end
|
285
|
-
|
286
|
-
it "returns true if the data exists" do
|
287
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
288
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
289
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
290
|
-
expect(@reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "1")
|
291
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
292
|
-
expect(@registry.data_exists?(key_path, value1)).to eq(true)
|
293
|
-
end
|
294
|
-
|
295
|
-
it "returns false if the data does not exist" do
|
296
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
297
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
298
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
299
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
300
|
-
expect(@reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "2")
|
301
|
-
expect(@registry.data_exists?(key_path, value1)).to eq(false)
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe "value_exists!" do
|
306
|
-
it "does nothing if the value exists" do
|
307
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
308
|
-
@registry.value_exists!(key_path, value1)
|
309
|
-
end
|
310
|
-
|
311
|
-
it "throws an exception if the value does not exist" do
|
312
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
313
|
-
expect{@registry.value_exists!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
describe "data_exists!" do
|
318
|
-
it "does nothing if the data exists" do
|
319
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(true)
|
320
|
-
@registry.data_exists!(key_path, value1)
|
321
|
-
end
|
322
|
-
|
323
|
-
it "throws an exception if the data does not exist" do
|
324
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(false)
|
325
|
-
expect{@registry.data_exists!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
describe "type_matches?" do
|
330
|
-
it "returns true if type matches" do
|
331
|
-
expect(@registry).to receive(:value_exists!).with(key_path, value1).and_return(true)
|
332
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
333
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
334
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
335
|
-
expect(@reg_mock).to receive(:each).and_yield("one", 1)
|
336
|
-
expect(@registry.type_matches?(key_path, value1)).to eq(true)
|
337
|
-
end
|
338
|
-
|
339
|
-
it "returns false if type does not match" do
|
340
|
-
expect(@registry).to receive(:value_exists!).with(key_path, value1).and_return(true)
|
341
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
342
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
343
|
-
expect(@reg_mock).to receive(:each).and_yield("two", 2)
|
344
|
-
expect(@registry.type_matches?(key_path, value1)).to eq(false)
|
345
|
-
end
|
346
|
-
|
347
|
-
it "throws an exception if value does not exist" do
|
348
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
349
|
-
expect{@registry.type_matches?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
describe "type_matches!" do
|
354
|
-
it "does nothing if the type_matches" do
|
355
|
-
expect(@registry).to receive(:type_matches?).with(key_path, value1).and_return(true)
|
356
|
-
@registry.type_matches!(key_path, value1)
|
357
|
-
end
|
358
|
-
|
359
|
-
it "throws an exception if the type does not match" do
|
360
|
-
expect(@registry).to receive(:type_matches?).with(key_path, value1).and_return(false)
|
361
|
-
expect{@registry.type_matches!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegTypesMismatch)
|
362
|
-
end
|
363
|
-
end
|
364
|
-
|
365
|
-
describe "keys_missing?" do
|
366
|
-
it "returns true if the keys are missing" do
|
367
|
-
expect(@registry).to receive(:key_exists?).with(missing_key_path).and_return(false)
|
368
|
-
expect(@registry.keys_missing?(key_path)).to eq(true)
|
369
|
-
end
|
370
|
-
|
371
|
-
it "returns false if no keys in the path are missing" do
|
372
|
-
expect(@registry).to receive(:key_exists?).with(missing_key_path).and_return(true)
|
373
|
-
expect(@registry.keys_missing?(key_path)).to eq(false)
|
374
|
-
end
|
375
|
-
end
|
376
|
-
end
|