chef 12.5.0.alpha.1 → 12.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +5 -110
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- 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/windows_service_manager.rb +9 -7
- data/lib/chef/chef_class.rb +39 -0
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- 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 +3 -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/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- 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/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 +6 -5
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +12 -7
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/exceptions.rb +22 -0
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +53 -5
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- 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/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/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 +2 -2
- 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 +97 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- 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 +38 -9
- data/lib/chef/provider.rb +104 -12
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +2 -2
- 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/mount.rb +7 -3
- 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 +27 -4
- 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/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/resource.rb +85 -27
- 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 +1 -1
- 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 +6 -8
- 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 +25 -28
- 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/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/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/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_script_spec.rb +104 -15
- 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} +4 -23
- data/spec/integration/client/client_spec.rb +51 -0
- 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 -1
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +42 -22
- 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 +8 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/{lib/chef/mixin/wstring.rb → spec/support/shared/context/win32.rb} +15 -12
- 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/chef_class_spec.rb +0 -4
- 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 +0 -4
- 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/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/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- 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 +213 -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/validation_spec.rb +5 -0
- data/spec/unit/property_spec.rb +152 -26
- 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 +52 -26
- 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/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/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +1 -1
- data/spec/unit/resource/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/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 +51 -26
- 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/registry_helper_spec.rb +0 -390
@@ -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,390 +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(:value1_upcase_name) { {:name => "ONE", :type => :string, :data => "1"} }
|
25
|
-
let(:key_path) { 'HKCU\Software\OpscodeNumbers' }
|
26
|
-
let(:key) { 'Software\OpscodeNumbers' }
|
27
|
-
let(:key_parent) { 'Software' }
|
28
|
-
let(:key_to_delete) { 'OpscodeNumbers' }
|
29
|
-
let(:sub_key) {'OpscodePrimes'}
|
30
|
-
let(:missing_key_path) {'HKCU\Software'}
|
31
|
-
|
32
|
-
before(:each) do
|
33
|
-
allow_any_instance_of(Chef::Win32::Registry).to receive(:machine_architecture).and_return(:x86_64)
|
34
|
-
@registry = Chef::Win32::Registry.new()
|
35
|
-
|
36
|
-
#Making the values for registry constants available on unix
|
37
|
-
Object.send(:remove_const, 'Win32') if defined?(Win32)
|
38
|
-
Win32 = Module.new
|
39
|
-
Win32::Registry = Class.new
|
40
|
-
Win32::Registry::KEY_SET_VALUE = 0x0002
|
41
|
-
Win32::Registry::KEY_QUERY_VALUE = 0x0001
|
42
|
-
Win32::Registry::KEY_WRITE = 0x00020000 | 0x0002 | 0x0004
|
43
|
-
Win32::Registry::KEY_READ = 0x00020000 | 0x0001 | 0x0008 | 0x0010
|
44
|
-
|
45
|
-
Win32::Registry::Error = Class.new(RuntimeError)
|
46
|
-
|
47
|
-
@hive_mock = double("::Win32::Registry::HKEY_CURRENT_USER")
|
48
|
-
@reg_mock = double("reg")
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "get_values" do
|
52
|
-
it "gets all values for a key if the key exists" do
|
53
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
54
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
55
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
56
|
-
expect(@reg_mock).to receive(:map)
|
57
|
-
@registry.get_values(key_path)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "throws an exception if key does not exist" do
|
61
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
62
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
63
|
-
expect{@registry.get_values(key_path)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "set_value" do
|
68
|
-
it "does nothing if key and hive and value exist" do
|
69
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
70
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
71
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
72
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(true)
|
73
|
-
@registry.set_value(key_path, value1)
|
74
|
-
end
|
75
|
-
it "does nothing if case insensitive key and hive and value exist" do
|
76
|
-
expect(@registry).to receive(:key_exists!).with(key_path.downcase).and_return(true)
|
77
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path.downcase).and_return([@hive_mock, key])
|
78
|
-
expect(@registry).to receive(:value_exists?).with(key_path.downcase, value1).and_return(true)
|
79
|
-
expect(@registry).to receive(:data_exists?).with(key_path.downcase, value1).and_return(true)
|
80
|
-
@registry.set_value(key_path.downcase, value1)
|
81
|
-
end
|
82
|
-
it "does nothing if key and hive and value with a case insensitive name exist" do
|
83
|
-
expect(@registry).to receive(:key_exists!).with(key_path.downcase).and_return(true)
|
84
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path.downcase).and_return([@hive_mock, key])
|
85
|
-
expect(@registry).to receive(:value_exists?).with(key_path.downcase, value1_upcase_name).and_return(true)
|
86
|
-
expect(@registry).to receive(:data_exists?).with(key_path.downcase, value1_upcase_name).and_return(true)
|
87
|
-
@registry.set_value(key_path.downcase, value1_upcase_name)
|
88
|
-
end
|
89
|
-
it "updates value if key and hive and value exist, but data is different" do
|
90
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
91
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
92
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
93
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(false)
|
94
|
-
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)
|
95
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
96
|
-
expect(@reg_mock).to receive(:write).with("one", 1, "1")
|
97
|
-
@registry.set_value(key_path, value1)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "creates value if the key exists and the value does not exist" do
|
101
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
102
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
103
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
104
|
-
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)
|
105
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
106
|
-
expect(@reg_mock).to receive(:write).with("one", 1, "1")
|
107
|
-
@registry.set_value(key_path, value1)
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should raise an exception if the key does not exist" do
|
111
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
112
|
-
expect {@registry.set_value(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "delete_value" do
|
117
|
-
it "deletes value if value exists" do
|
118
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
119
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
120
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_SET_VALUE | @registry.registry_system_architecture).and_yield(@reg_mock)
|
121
|
-
expect(@reg_mock).to receive(:delete_value).with("one").and_return(true)
|
122
|
-
@registry.delete_value(key_path, value1)
|
123
|
-
end
|
124
|
-
|
125
|
-
it "raises an exception if the key does not exist" do
|
126
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
127
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
128
|
-
@registry.delete_value(key_path, value1)
|
129
|
-
end
|
130
|
-
|
131
|
-
it "does nothing if the value does not exist" do
|
132
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
133
|
-
@registry.delete_value(key_path, value1)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "create_key" do
|
138
|
-
it "creates key if intermediate keys are missing and recursive is set to true" 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(false)
|
142
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
143
|
-
expect(@hive_mock).to receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
|
144
|
-
@registry.create_key(key_path, true)
|
145
|
-
end
|
146
|
-
|
147
|
-
it "raises an exception if intermediate keys are missing and recursive is set to false" do
|
148
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(true)
|
149
|
-
expect{@registry.create_key(key_path, false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
|
150
|
-
end
|
151
|
-
|
152
|
-
it "does nothing if the key exists" do
|
153
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(true)
|
154
|
-
expect(@registry).to receive(:create_missing).with(key_path)
|
155
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
156
|
-
@registry.create_key(key_path, true)
|
157
|
-
end
|
158
|
-
|
159
|
-
it "create key if intermediate keys not missing and recursive is set to false" do
|
160
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(false)
|
161
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
162
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
163
|
-
expect(@hive_mock).to receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
|
164
|
-
@registry.create_key(key_path, false)
|
165
|
-
end
|
166
|
-
|
167
|
-
it "create key if intermediate keys not missing and recursive is set to true" do
|
168
|
-
expect(@registry).to receive(:keys_missing?).with(key_path).and_return(false)
|
169
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
170
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
171
|
-
expect(@hive_mock).to receive(:create).with(key, ::Win32::Registry::KEY_WRITE | @registry.registry_system_architecture)
|
172
|
-
@registry.create_key(key_path, true)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "delete_key", :windows_only do
|
177
|
-
it "deletes key if it has subkeys and recursive is set to true" do
|
178
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
179
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
180
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path).and_return(true)
|
181
|
-
expect(@registry).to receive(:get_subkeys).with(key_path).and_return([sub_key])
|
182
|
-
expect(@registry).to receive(:key_exists?).with(key_path+"\\"+sub_key).and_return(true)
|
183
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path+"\\"+sub_key).and_return([@hive_mock, key+"\\"+sub_key])
|
184
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path+"\\"+sub_key).and_return(false)
|
185
|
-
expect(@registry).to receive(:delete_key_ex).twice
|
186
|
-
@registry.delete_key(key_path, true)
|
187
|
-
end
|
188
|
-
|
189
|
-
it "raises an exception if it has subkeys but recursive is set to false" do
|
190
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
191
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
192
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path).and_return(true)
|
193
|
-
expect{@registry.delete_key(key_path, false)}.to raise_error(Chef::Exceptions::Win32RegNoRecursive)
|
194
|
-
end
|
195
|
-
|
196
|
-
it "deletes key if the key exists and has no subkeys" do
|
197
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(true)
|
198
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
199
|
-
expect(@registry).to receive(:has_subkeys?).with(key_path).and_return(false)
|
200
|
-
expect(@registry).to receive(:delete_key_ex)
|
201
|
-
@registry.delete_key(key_path, true)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "key_exists?" do
|
206
|
-
it "returns true if key_exists" do
|
207
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
208
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
209
|
-
expect(@registry.key_exists?(key_path)).to eq(true)
|
210
|
-
end
|
211
|
-
|
212
|
-
it "returns false if key does not exist" do
|
213
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
214
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_raise(::Win32::Registry::Error)
|
215
|
-
expect(@registry.key_exists?(key_path)).to eq(false)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "key_exists!" do
|
220
|
-
it "throws an exception if the key_parent does not exist" do
|
221
|
-
expect(@registry).to receive(:key_exists?).with(key_path).and_return(false)
|
222
|
-
expect{@registry.key_exists!(key_path)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
describe "hive_exists?" do
|
227
|
-
it "returns true if the hive exists" do
|
228
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
229
|
-
@registry.hive_exists?(key_path) == true
|
230
|
-
end
|
231
|
-
|
232
|
-
it "returns false if the hive does not exist" do
|
233
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_raise(Chef::Exceptions::Win32RegHiveMissing)
|
234
|
-
@registry.hive_exists?(key_path) == false
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
describe "has_subkeys?" do
|
239
|
-
it "returns true if the key has subkeys" do
|
240
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
241
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
242
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
243
|
-
expect(@reg_mock).to receive(:each_key).and_yield(key)
|
244
|
-
@registry.has_subkeys?(key_path) == true
|
245
|
-
end
|
246
|
-
|
247
|
-
it "returns false if the key does not have subkeys" do
|
248
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
249
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
250
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
251
|
-
expect(@reg_mock).to receive(:each_key).and_return(no_args())
|
252
|
-
expect(@registry.has_subkeys?(key_path)).to eq(false)
|
253
|
-
end
|
254
|
-
|
255
|
-
it "throws an exception if the key does not exist" do
|
256
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
257
|
-
expect {@registry.set_value(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe "get_subkeys" do
|
262
|
-
it "returns the subkeys if they exist" do
|
263
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
264
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
265
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
266
|
-
expect(@reg_mock).to receive(:each_key).and_yield(sub_key)
|
267
|
-
@registry.get_subkeys(key_path)
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe "value_exists?" do
|
272
|
-
it "throws an exception if the key does not exist" do
|
273
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
274
|
-
expect {@registry.value_exists?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
275
|
-
end
|
276
|
-
|
277
|
-
it "returns true if the value exists" do
|
278
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
279
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
280
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
281
|
-
expect(@reg_mock).to receive(:any?).and_yield("one")
|
282
|
-
@registry.value_exists?(key_path, value1) == true
|
283
|
-
end
|
284
|
-
|
285
|
-
it "returns false if the value does not exist" do
|
286
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
287
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
288
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
289
|
-
expect(@reg_mock).to receive(:any?).and_yield(no_args())
|
290
|
-
@registry.value_exists?(key_path, value1) == false
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
describe "data_exists?" do
|
295
|
-
it "throws an exception if the key does not exist" do
|
296
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_raise(Chef::Exceptions::Win32RegKeyMissing)
|
297
|
-
expect {@registry.data_exists?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegKeyMissing)
|
298
|
-
end
|
299
|
-
|
300
|
-
it "returns true if the data exists" do
|
301
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
302
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
303
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
304
|
-
expect(@reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "1")
|
305
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
306
|
-
expect(@registry.data_exists?(key_path, value1)).to eq(true)
|
307
|
-
end
|
308
|
-
|
309
|
-
it "returns false if the data does not exist" do
|
310
|
-
expect(@registry).to receive(:key_exists!).with(key_path).and_return(true)
|
311
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
312
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
313
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
314
|
-
expect(@reg_mock).to receive(:each).with(no_args()).and_yield("one", 1, "2")
|
315
|
-
expect(@registry.data_exists?(key_path, value1)).to eq(false)
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "value_exists!" do
|
320
|
-
it "does nothing if the value exists" do
|
321
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(true)
|
322
|
-
@registry.value_exists!(key_path, value1)
|
323
|
-
end
|
324
|
-
|
325
|
-
it "throws an exception if the value does not exist" do
|
326
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
327
|
-
expect{@registry.value_exists!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
describe "data_exists!" do
|
332
|
-
it "does nothing if the data exists" do
|
333
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(true)
|
334
|
-
@registry.data_exists!(key_path, value1)
|
335
|
-
end
|
336
|
-
|
337
|
-
it "throws an exception if the data does not exist" do
|
338
|
-
expect(@registry).to receive(:data_exists?).with(key_path, value1).and_return(false)
|
339
|
-
expect{@registry.data_exists!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegDataMissing)
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
describe "type_matches?" do
|
344
|
-
it "returns true if type matches" do
|
345
|
-
expect(@registry).to receive(:value_exists!).with(key_path, value1).and_return(true)
|
346
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
347
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
348
|
-
expect(@registry).to receive(:get_type_from_name).with(:string).and_return(1)
|
349
|
-
expect(@reg_mock).to receive(:each).and_yield("one", 1)
|
350
|
-
expect(@registry.type_matches?(key_path, value1)).to eq(true)
|
351
|
-
end
|
352
|
-
|
353
|
-
it "returns false if type does not match" do
|
354
|
-
expect(@registry).to receive(:value_exists!).with(key_path, value1).and_return(true)
|
355
|
-
expect(@registry).to receive(:get_hive_and_key).with(key_path).and_return([@hive_mock, key])
|
356
|
-
expect(@hive_mock).to receive(:open).with(key, ::Win32::Registry::KEY_READ | @registry.registry_system_architecture).and_yield(@reg_mock)
|
357
|
-
expect(@reg_mock).to receive(:each).and_yield("two", 2)
|
358
|
-
expect(@registry.type_matches?(key_path, value1)).to eq(false)
|
359
|
-
end
|
360
|
-
|
361
|
-
it "throws an exception if value does not exist" do
|
362
|
-
expect(@registry).to receive(:value_exists?).with(key_path, value1).and_return(false)
|
363
|
-
expect{@registry.type_matches?(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegValueMissing)
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
describe "type_matches!" do
|
368
|
-
it "does nothing if the type_matches" do
|
369
|
-
expect(@registry).to receive(:type_matches?).with(key_path, value1).and_return(true)
|
370
|
-
@registry.type_matches!(key_path, value1)
|
371
|
-
end
|
372
|
-
|
373
|
-
it "throws an exception if the type does not match" do
|
374
|
-
expect(@registry).to receive(:type_matches?).with(key_path, value1).and_return(false)
|
375
|
-
expect{@registry.type_matches!(key_path, value1)}.to raise_error(Chef::Exceptions::Win32RegTypesMismatch)
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
describe "keys_missing?" do
|
380
|
-
it "returns true if the keys are missing" do
|
381
|
-
expect(@registry).to receive(:key_exists?).with(missing_key_path).and_return(false)
|
382
|
-
expect(@registry.keys_missing?(key_path)).to eq(true)
|
383
|
-
end
|
384
|
-
|
385
|
-
it "returns false if no keys in the path are missing" do
|
386
|
-
expect(@registry).to receive(:key_exists?).with(missing_key_path).and_return(true)
|
387
|
-
expect(@registry.keys_missing?(key_path)).to eq(false)
|
388
|
-
end
|
389
|
-
end
|
390
|
-
end
|