chef 13.6.4 → 13.7.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +6 -6
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
@@ -19,197 +19,183 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Chef::Resource::RegistryKey, "initialize" do
|
22
|
-
|
23
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
24
|
-
end
|
22
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
25
23
|
|
26
|
-
it "
|
27
|
-
expect(
|
28
|
-
expect(
|
24
|
+
it "creates a new Chef::Resource::RegistryKey" do
|
25
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
26
|
+
expect(resource).to be_a_kind_of(Chef::Resource::RegistryKey)
|
29
27
|
end
|
30
28
|
|
31
|
-
it "
|
32
|
-
expect(
|
29
|
+
it "sets the resource_name to :registry_key" do
|
30
|
+
expect(resource.resource_name).to eql(:registry_key)
|
33
31
|
end
|
34
32
|
|
35
|
-
it "
|
36
|
-
expect(
|
33
|
+
it "sets the key equal to the argument to initialize" do
|
34
|
+
expect(resource.key).to eql('HKCU\Software\Raxicoricofallapatorius')
|
37
35
|
end
|
38
36
|
|
39
|
-
it "
|
40
|
-
expect(
|
37
|
+
it "defaults recursive to false" do
|
38
|
+
expect(resource.recursive).to eql(false)
|
41
39
|
end
|
42
40
|
|
43
|
-
it "
|
44
|
-
expect(
|
41
|
+
it "defaults architecture to :machine" do
|
42
|
+
expect(resource.architecture).to eql(:machine)
|
45
43
|
end
|
46
44
|
|
47
|
-
it "
|
48
|
-
expect(
|
45
|
+
it "sets action to :create" do
|
46
|
+
expect(resource.action).to eql([:create])
|
49
47
|
end
|
50
48
|
|
51
49
|
%w{create create_if_missing delete delete_key}.each do |action|
|
52
|
-
it "
|
53
|
-
expect(
|
50
|
+
it "allows action #{action}" do
|
51
|
+
expect(resource.allowed_actions.detect { |a| a == action.to_sym }).to eql(action.to_sym)
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
56
|
describe Chef::Resource::RegistryKey, "key" do
|
59
|
-
|
60
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
61
|
-
end
|
57
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
62
58
|
|
63
|
-
it "
|
64
|
-
|
65
|
-
expect(
|
59
|
+
it "allows a string" do
|
60
|
+
resource.key 'HKCU\Software\Poosh'
|
61
|
+
expect(resource.key).to eql('HKCU\Software\Poosh')
|
66
62
|
end
|
67
63
|
|
68
|
-
it "
|
69
|
-
expect {
|
64
|
+
it "does not allow an integer" do
|
65
|
+
expect { resource.send(:key, 100) }.to raise_error(ArgumentError)
|
70
66
|
end
|
71
67
|
|
72
|
-
it "
|
73
|
-
expect {
|
68
|
+
it "does not allow a hash" do
|
69
|
+
expect { resource.send(:key, { :sonic => "screwdriver" }) }.to raise_error(ArgumentError)
|
74
70
|
end
|
75
71
|
end
|
76
72
|
|
77
73
|
describe Chef::Resource::RegistryKey, "values" do
|
78
|
-
|
79
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
80
|
-
end
|
74
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
81
75
|
|
82
|
-
it "
|
83
|
-
|
84
|
-
expect(
|
76
|
+
it "allows a single proper hash of registry values" do
|
77
|
+
resource.values( { :name => "poosh", :type => :string, :data => "carmen" } )
|
78
|
+
expect(resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ])
|
85
79
|
end
|
86
80
|
|
87
|
-
it "
|
88
|
-
|
89
|
-
expect(
|
81
|
+
it "allows an array of proper hashes of registry values" do
|
82
|
+
resource.values [ { :name => "poosh", :type => :string, :data => "carmen" } ]
|
83
|
+
expect(resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ])
|
90
84
|
end
|
91
85
|
|
92
|
-
it "
|
93
|
-
|
94
|
-
expect(
|
86
|
+
it "returns checksummed data if the type is unsafe" do
|
87
|
+
resource.values( { :name => "poosh", :type => :binary, :data => 255.chr * 1 })
|
88
|
+
expect(resource.values).to eql([ { :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ])
|
95
89
|
end
|
96
90
|
|
97
|
-
it "
|
98
|
-
expect {
|
91
|
+
it "raises an exception if the name field is missing" do
|
92
|
+
expect { resource.values [ { :type => :string, :data => "carmen" } ] }.to raise_error(ArgumentError)
|
99
93
|
end
|
100
94
|
|
101
|
-
it "
|
102
|
-
expect {
|
95
|
+
it "raises an exception if extra fields are present" do
|
96
|
+
expect { resource.values [ { :name => "poosh", :type => :string, :data => "carmen", :screwdriver => "sonic" } ] }.to raise_error(ArgumentError)
|
103
97
|
end
|
104
98
|
|
105
|
-
it "
|
106
|
-
expect {
|
99
|
+
it "does not allow a string" do
|
100
|
+
expect { resource.send(:values, "souffle") }.to raise_error(ArgumentError)
|
107
101
|
end
|
108
102
|
|
109
|
-
it "
|
110
|
-
expect {
|
103
|
+
it "does not allow an integer" do
|
104
|
+
expect { resource.send(:values, 100) }.to raise_error(ArgumentError)
|
111
105
|
end
|
112
106
|
|
113
|
-
it "
|
114
|
-
expect {
|
107
|
+
it "raises an exception if type of name is not string" do
|
108
|
+
expect { resource.values([ { :name => 123, :type => :string, :data => "carmen" } ]) }.to raise_error(ArgumentError)
|
115
109
|
end
|
116
110
|
|
117
|
-
it "
|
118
|
-
expect {
|
111
|
+
it "does not raise an exception if type of name is string" do
|
112
|
+
expect { resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error
|
119
113
|
end
|
120
114
|
|
121
115
|
context "type key not given" do
|
122
|
-
it "
|
123
|
-
expect {
|
116
|
+
it "does not raise an exception" do
|
117
|
+
expect { resource.values([ { :name => "123", :data => "carmen" } ]) }.to_not raise_error
|
124
118
|
end
|
125
119
|
end
|
126
120
|
|
127
121
|
context "type key given" do
|
128
|
-
it "
|
129
|
-
expect {
|
122
|
+
it "raises an exception if type of type is not symbol" do
|
123
|
+
expect { resource.values([ { :name => "123", :type => "string", :data => "carmen" } ]) }.to raise_error(ArgumentError)
|
130
124
|
end
|
131
125
|
|
132
|
-
it "
|
133
|
-
expect {
|
126
|
+
it "does not raise an exception if type of type is symbol" do
|
127
|
+
expect { resource.values([ { :name => "123", :type => :string, :data => "carmen" } ]) }.to_not raise_error
|
134
128
|
end
|
135
129
|
end
|
136
130
|
end
|
137
131
|
|
138
132
|
describe Chef::Resource::RegistryKey, "recursive" do
|
139
|
-
|
140
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
141
|
-
end
|
133
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
142
134
|
|
143
|
-
it "
|
144
|
-
|
145
|
-
expect(
|
135
|
+
it "allows a boolean" do
|
136
|
+
resource.recursive(true)
|
137
|
+
expect(resource.recursive).to eql(true)
|
146
138
|
end
|
147
139
|
|
148
|
-
it "
|
149
|
-
expect {
|
140
|
+
it "does not allow a hash" do
|
141
|
+
expect { resource.recursive({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
|
150
142
|
end
|
151
143
|
|
152
|
-
it "
|
153
|
-
expect {
|
144
|
+
it "does not allow an array" do
|
145
|
+
expect { resource.recursive([:nose, :chin]) }.to raise_error(ArgumentError)
|
154
146
|
end
|
155
147
|
|
156
|
-
it "
|
157
|
-
expect {
|
148
|
+
it "does not allow a string" do
|
149
|
+
expect { resource.recursive("souffle") }.to raise_error(ArgumentError)
|
158
150
|
end
|
159
151
|
|
160
|
-
it "
|
161
|
-
expect {
|
152
|
+
it "does not allow an integer" do
|
153
|
+
expect { resource.recursive(100) }.to raise_error(ArgumentError)
|
162
154
|
end
|
163
155
|
end
|
164
156
|
|
165
157
|
describe Chef::Resource::RegistryKey, "architecture" do
|
166
|
-
|
167
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
168
|
-
end
|
158
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
169
159
|
|
170
160
|
[ :i386, :x86_64, :machine ].each do |arch|
|
171
|
-
it "
|
172
|
-
|
173
|
-
expect(
|
161
|
+
it "allows #{arch} as a symbol" do
|
162
|
+
resource.architecture(arch)
|
163
|
+
expect(resource.architecture).to eql(arch)
|
174
164
|
end
|
175
165
|
end
|
176
166
|
|
177
|
-
it "
|
178
|
-
expect {
|
167
|
+
it "does not allow a hash" do
|
168
|
+
expect { resource.architecture({ :sonic => :screwdriver }) }.to raise_error(ArgumentError)
|
179
169
|
end
|
180
170
|
|
181
|
-
it "
|
182
|
-
expect {
|
171
|
+
it "does not allow an array" do
|
172
|
+
expect { resource.architecture([:nose, :chin]) }.to raise_error(ArgumentError)
|
183
173
|
end
|
184
174
|
|
185
|
-
it "
|
186
|
-
expect {
|
175
|
+
it "does not allow a string" do
|
176
|
+
expect { resource.architecture("souffle") }.to raise_error(ArgumentError)
|
187
177
|
end
|
188
178
|
|
189
|
-
it "
|
190
|
-
expect {
|
179
|
+
it "does not allow an integer" do
|
180
|
+
expect { resource.architecture(100) }.to raise_error(ArgumentError)
|
191
181
|
end
|
192
182
|
end
|
193
183
|
|
194
184
|
describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
|
195
|
-
|
196
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
197
|
-
end
|
185
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
198
186
|
|
199
|
-
it "
|
187
|
+
it "returns unsafe data as-is" do
|
200
188
|
key_values = [ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ]
|
201
|
-
|
202
|
-
expect(
|
189
|
+
resource.values(key_values)
|
190
|
+
expect(resource.unscrubbed_values).to eql(key_values)
|
203
191
|
end
|
204
192
|
end
|
205
193
|
|
206
194
|
describe Chef::Resource::RegistryKey, "state" do
|
207
|
-
|
208
|
-
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
209
|
-
end
|
195
|
+
let(:resource) { Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius') }
|
210
196
|
|
211
|
-
it "
|
212
|
-
|
213
|
-
expect(
|
197
|
+
it "returns scrubbed values" do
|
198
|
+
resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ])
|
199
|
+
expect(resource.state_for_resource_reporter).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" }] } )
|
214
200
|
end
|
215
201
|
end
|
@@ -20,78 +20,76 @@ require "spec_helper"
|
|
20
20
|
|
21
21
|
describe Chef::Resource::RemoteDirectory do
|
22
22
|
|
23
|
-
|
24
|
-
@resource = Chef::Resource::RemoteDirectory.new("/etc/dunk")
|
25
|
-
end
|
23
|
+
let(:resource) { Chef::Resource::RemoteDirectory.new("/etc/dunk") }
|
26
24
|
|
27
|
-
it "
|
28
|
-
expect(
|
29
|
-
expect(
|
25
|
+
it "creates a new Chef::Resource::RemoteDirectory" do
|
26
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
27
|
+
expect(resource).to be_a_kind_of(Chef::Resource::RemoteDirectory)
|
30
28
|
end
|
31
29
|
|
32
|
-
it "
|
33
|
-
expect(
|
30
|
+
it "sets the path to the first argument to new" do
|
31
|
+
expect(resource.path).to eql("/etc/dunk")
|
34
32
|
end
|
35
33
|
|
36
|
-
it "
|
37
|
-
|
38
|
-
expect(
|
34
|
+
it "accepts a string for the remote directory source" do
|
35
|
+
resource.source "foo"
|
36
|
+
expect(resource.source).to eql("foo")
|
39
37
|
end
|
40
38
|
|
41
|
-
it "
|
42
|
-
expect(
|
39
|
+
it "has the basename of the remote directory resource as the default source" do
|
40
|
+
expect(resource.source).to eql("dunk")
|
43
41
|
end
|
44
42
|
|
45
|
-
it "
|
46
|
-
|
47
|
-
expect(
|
43
|
+
it "accepts a number for the remote files backup" do
|
44
|
+
resource.files_backup 1
|
45
|
+
expect(resource.files_backup).to eql(1)
|
48
46
|
end
|
49
47
|
|
50
|
-
it "
|
51
|
-
|
52
|
-
expect(
|
48
|
+
it "accepts false for the remote files backup" do
|
49
|
+
resource.files_backup false
|
50
|
+
expect(resource.files_backup).to eql(false)
|
53
51
|
end
|
54
52
|
|
55
|
-
it "
|
56
|
-
|
57
|
-
expect(
|
58
|
-
|
59
|
-
expect(
|
53
|
+
it "accepts 3 or 4 digets for the files_mode" do
|
54
|
+
resource.files_mode 100
|
55
|
+
expect(resource.files_mode).to eql(100)
|
56
|
+
resource.files_mode 1000
|
57
|
+
expect(resource.files_mode).to eql(1000)
|
60
58
|
end
|
61
59
|
|
62
|
-
it "
|
63
|
-
|
64
|
-
expect(
|
65
|
-
|
66
|
-
expect(
|
60
|
+
it "accepts a string or number for the files group" do
|
61
|
+
resource.files_group "heart"
|
62
|
+
expect(resource.files_group).to eql("heart")
|
63
|
+
resource.files_group 1000
|
64
|
+
expect(resource.files_group).to eql(1000)
|
67
65
|
end
|
68
66
|
|
69
|
-
it "
|
70
|
-
|
71
|
-
expect(
|
72
|
-
|
73
|
-
expect(
|
67
|
+
it "accepts a string or number for the files owner" do
|
68
|
+
resource.files_owner "heart"
|
69
|
+
expect(resource.files_owner).to eql("heart")
|
70
|
+
resource.files_owner 1000
|
71
|
+
expect(resource.files_owner).to eql(1000)
|
74
72
|
end
|
75
73
|
|
76
74
|
describe "when it has cookbook, files owner, files mode, and source" do
|
77
75
|
before do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
resource.path("/var/path/")
|
77
|
+
resource.cookbook("pokemon.rb")
|
78
|
+
resource.files_owner("root")
|
79
|
+
resource.files_group("supergroup")
|
80
|
+
resource.files_mode("0664")
|
81
|
+
resource.source("/var/source/")
|
84
82
|
end
|
85
83
|
|
86
84
|
it "describes its state" do
|
87
|
-
state =
|
85
|
+
state = resource.state_for_resource_reporter
|
88
86
|
expect(state[:files_owner]).to eq("root")
|
89
87
|
expect(state[:files_group]).to eq("supergroup")
|
90
88
|
expect(state[:files_mode]).to eq("0664")
|
91
89
|
end
|
92
90
|
|
93
91
|
it "returns the path as its identity" do
|
94
|
-
expect(
|
92
|
+
expect(resource.identity).to eq("/var/path/")
|
95
93
|
end
|
96
94
|
end
|
97
95
|
end
|
@@ -21,147 +21,145 @@ require "spec_helper"
|
|
21
21
|
|
22
22
|
describe Chef::Resource::RemoteFile do
|
23
23
|
|
24
|
-
|
25
|
-
@resource = Chef::Resource::RemoteFile.new("fakey_fakerton")
|
26
|
-
end
|
24
|
+
let(:resource) { Chef::Resource::RemoteFile.new("fakey_fakerton") }
|
27
25
|
|
28
26
|
describe "initialize" do
|
29
|
-
it "
|
30
|
-
expect(
|
31
|
-
expect(
|
32
|
-
expect(
|
27
|
+
it "creates a new Chef::Resource::RemoteFile" do
|
28
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
29
|
+
expect(resource).to be_a_kind_of(Chef::Resource::File)
|
30
|
+
expect(resource).to be_a_kind_of(Chef::Resource::RemoteFile)
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
it "says its provider is RemoteFile when the source is an absolute URI" do
|
37
|
-
|
38
|
-
expect(
|
39
|
-
expect(
|
35
|
+
resource.source("http://www.google.com/robots.txt")
|
36
|
+
expect(resource.provider).to eq(Chef::Provider::RemoteFile)
|
37
|
+
expect(resource.provider_for_action(:create)).to be_kind_of(Chef::Provider::RemoteFile)
|
40
38
|
end
|
41
39
|
|
42
40
|
it "says its provider is RemoteFile when the source is a network share" do
|
43
|
-
|
44
|
-
expect(
|
45
|
-
expect(
|
41
|
+
resource.source("\\\\fakey\\fakerton\\fake.txt")
|
42
|
+
expect(resource.provider).to eq(Chef::Provider::RemoteFile)
|
43
|
+
expect(resource.provider_for_action(:create)).to be_kind_of(Chef::Provider::RemoteFile)
|
46
44
|
end
|
47
45
|
|
48
46
|
describe "source" do
|
49
47
|
it "does not have a default value for 'source'" do
|
50
|
-
expect(
|
48
|
+
expect(resource.source).to eql([])
|
51
49
|
end
|
52
50
|
|
53
|
-
it "
|
54
|
-
|
55
|
-
expect(
|
51
|
+
it "accepts a URI for the remote file source" do
|
52
|
+
resource.source "http://opscode.com/"
|
53
|
+
expect(resource.source).to eql([ "http://opscode.com/" ])
|
56
54
|
end
|
57
55
|
|
58
|
-
it "
|
59
|
-
|
60
|
-
expect(
|
56
|
+
it "accepts a windows network share source" do
|
57
|
+
resource.source "\\\\fakey\\fakerton\\fake.txt"
|
58
|
+
expect(resource.source).to eql([ "\\\\fakey\\fakerton\\fake.txt" ])
|
61
59
|
end
|
62
60
|
|
63
|
-
it "
|
64
|
-
|
65
|
-
expect(
|
61
|
+
it "accepts file URIs with spaces" do
|
62
|
+
resource.source("file:///C:/foo bar")
|
63
|
+
expect(resource.source).to eql(["file:///C:/foo bar"])
|
66
64
|
end
|
67
65
|
|
68
|
-
it "
|
69
|
-
|
70
|
-
expect(
|
66
|
+
it "accepts a delayed evalutator (string) for the remote file source" do
|
67
|
+
resource.source Chef::DelayedEvaluator.new { "http://opscode.com/" }
|
68
|
+
expect(resource.source).to eql([ "http://opscode.com/" ])
|
71
69
|
end
|
72
70
|
|
73
|
-
it "
|
74
|
-
|
75
|
-
expect(
|
71
|
+
it "accepts an array of URIs for the remote file source" do
|
72
|
+
resource.source([ "http://opscode.com/", "http://puppetlabs.com/" ])
|
73
|
+
expect(resource.source).to eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
|
76
74
|
end
|
77
75
|
|
78
|
-
it "
|
79
|
-
|
80
|
-
expect(
|
76
|
+
it "accepts a delated evaluator (array) for the remote file source" do
|
77
|
+
resource.source Chef::DelayedEvaluator.new { [ "http://opscode.com/", "http://puppetlabs.com/" ] }
|
78
|
+
expect(resource.source).to eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
|
81
79
|
end
|
82
80
|
|
83
|
-
it "
|
84
|
-
|
85
|
-
expect(
|
81
|
+
it "accepts an multiple URIs as arguments for the remote file source" do
|
82
|
+
resource.source("http://opscode.com/", "http://puppetlabs.com/")
|
83
|
+
expect(resource.source).to eql([ "http://opscode.com/", "http://puppetlabs.com/" ])
|
86
84
|
end
|
87
85
|
|
88
|
-
it "
|
86
|
+
it "only accept a single argument if a delayed evalutor is used" do
|
89
87
|
expect do
|
90
|
-
|
88
|
+
resource.source("http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" })
|
91
89
|
end.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
|
92
90
|
end
|
93
91
|
|
94
|
-
it "
|
92
|
+
it "only accept a single array item if a delayed evalutor is used" do
|
95
93
|
expect do
|
96
|
-
|
94
|
+
resource.source(["http://opscode.com/", Chef::DelayedEvaluator.new { "http://opscode.com/" }])
|
97
95
|
end.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
|
98
96
|
end
|
99
97
|
|
100
98
|
it "does not accept a non-URI as the source" do
|
101
|
-
expect {
|
99
|
+
expect { resource.source("not-a-uri") }.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
|
102
100
|
end
|
103
101
|
|
104
102
|
it "does not accept a non-URI as the source when read from a delayed evaluator" do
|
105
103
|
expect do
|
106
|
-
|
107
|
-
|
104
|
+
resource.source(Chef::DelayedEvaluator.new { "not-a-uri" })
|
105
|
+
resource.source
|
108
106
|
end.to raise_error(Chef::Exceptions::InvalidRemoteFileURI)
|
109
107
|
end
|
110
108
|
|
111
|
-
it "
|
112
|
-
expect {
|
109
|
+
it "raises an exception when source is an empty array" do
|
110
|
+
expect { resource.source([]) }.to raise_error(ArgumentError)
|
113
111
|
end
|
114
112
|
|
115
113
|
end
|
116
114
|
|
117
115
|
describe "checksum" do
|
118
|
-
it "
|
119
|
-
|
120
|
-
expect(
|
116
|
+
it "accepts a string for the checksum object" do
|
117
|
+
resource.checksum "asdf"
|
118
|
+
expect(resource.checksum).to eql("asdf")
|
121
119
|
end
|
122
120
|
|
123
|
-
it "
|
124
|
-
expect(
|
121
|
+
it "defaults to nil" do
|
122
|
+
expect(resource.checksum).to eq(nil)
|
125
123
|
end
|
126
124
|
end
|
127
125
|
|
128
126
|
describe "ftp_active_mode" do
|
129
|
-
it "
|
130
|
-
|
131
|
-
expect(
|
127
|
+
it "accepts a boolean for the ftp_active_mode object" do
|
128
|
+
resource.ftp_active_mode true
|
129
|
+
expect(resource.ftp_active_mode).to be_truthy
|
132
130
|
end
|
133
131
|
|
134
|
-
it "
|
135
|
-
expect(
|
132
|
+
it "defaults to false" do
|
133
|
+
expect(resource.ftp_active_mode).to be_falsey
|
136
134
|
end
|
137
135
|
end
|
138
136
|
|
139
137
|
describe "conditional get options" do
|
140
138
|
it "defaults to using etags and last modified" do
|
141
|
-
expect(
|
142
|
-
expect(
|
139
|
+
expect(resource.use_etags).to be_truthy
|
140
|
+
expect(resource.use_last_modified).to be_truthy
|
143
141
|
end
|
144
142
|
|
145
143
|
it "enable or disables etag and last modified options as a group" do
|
146
|
-
|
147
|
-
expect(
|
148
|
-
expect(
|
144
|
+
resource.use_conditional_get(false)
|
145
|
+
expect(resource.use_etags).to be_falsey
|
146
|
+
expect(resource.use_last_modified).to be_falsey
|
149
147
|
|
150
|
-
|
151
|
-
expect(
|
152
|
-
expect(
|
148
|
+
resource.use_conditional_get(true)
|
149
|
+
expect(resource.use_etags).to be_truthy
|
150
|
+
expect(resource.use_last_modified).to be_truthy
|
153
151
|
end
|
154
152
|
|
155
153
|
it "disables etags indivdually" do
|
156
|
-
|
157
|
-
expect(
|
158
|
-
expect(
|
154
|
+
resource.use_etags(false)
|
155
|
+
expect(resource.use_etags).to be_falsey
|
156
|
+
expect(resource.use_last_modified).to be_truthy
|
159
157
|
end
|
160
158
|
|
161
159
|
it "disables last modified individually" do
|
162
|
-
|
163
|
-
expect(
|
164
|
-
expect(
|
160
|
+
resource.use_last_modified(false)
|
161
|
+
expect(resource.use_last_modified).to be_falsey
|
162
|
+
expect(resource.use_etags).to be_truthy
|
165
163
|
end
|
166
164
|
|
167
165
|
end
|
@@ -169,21 +167,21 @@ describe Chef::Resource::RemoteFile do
|
|
169
167
|
describe "when it has group, mode, owner, source, and checksum" do
|
170
168
|
before do
|
171
169
|
if Chef::Platform.windows?
|
172
|
-
|
173
|
-
|
174
|
-
|
170
|
+
resource.path("C:/temp/origin/file.txt")
|
171
|
+
resource.rights(:read, "Everyone")
|
172
|
+
resource.deny_rights(:full_control, "Clumsy_Sam")
|
175
173
|
else
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
174
|
+
resource.path("/this/path/")
|
175
|
+
resource.group("pokemon")
|
176
|
+
resource.mode("0664")
|
177
|
+
resource.owner("root")
|
180
178
|
end
|
181
|
-
|
182
|
-
|
179
|
+
resource.source("https://www.google.com/images/srpr/logo3w.png")
|
180
|
+
resource.checksum("1" * 26)
|
183
181
|
end
|
184
182
|
|
185
183
|
it "describes its state" do
|
186
|
-
state =
|
184
|
+
state = resource.state_for_resource_reporter
|
187
185
|
if Chef::Platform.windows?
|
188
186
|
puts state
|
189
187
|
expect(state[:rights]).to eq([{ :permissions => :read, :principals => "Everyone" }])
|
@@ -198,9 +196,9 @@ describe Chef::Resource::RemoteFile do
|
|
198
196
|
|
199
197
|
it "returns the path as its identity" do
|
200
198
|
if Chef::Platform.windows?
|
201
|
-
expect(
|
199
|
+
expect(resource.identity).to eq("C:/temp/origin/file.txt")
|
202
200
|
else
|
203
|
-
expect(
|
201
|
+
expect(resource.identity).to eq("/this/path/")
|
204
202
|
end
|
205
203
|
end
|
206
204
|
end
|