chef 11.14.0.alpha.4-x86-mingw32 → 11.14.0.rc.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +0 -4
- data/README.md +1 -1
- data/distro/common/man/man1/chef-shell.1 +4 -4
- data/distro/common/man/man1/knife-bootstrap.1 +14 -11
- data/distro/common/man/man1/knife-client.1 +14 -11
- data/distro/common/man/man1/knife-configure.1 +7 -7
- data/distro/common/man/man1/knife-cookbook-site.1 +23 -23
- data/distro/common/man/man1/knife-cookbook.1 +23 -23
- data/distro/common/man/man1/knife-data-bag.1 +13 -13
- data/distro/common/man/man1/knife-delete.1 +9 -9
- data/distro/common/man/man1/knife-deps.1 +9 -9
- data/distro/common/man/man1/knife-diff.1 +10 -10
- data/distro/common/man/man1/knife-download.1 +9 -9
- data/distro/common/man/man1/knife-edit.1 +7 -7
- data/distro/common/man/man1/knife-environment.1 +10 -10
- data/distro/common/man/man1/knife-exec.1 +7 -7
- data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
- data/distro/common/man/man1/knife-list.1 +12 -12
- data/distro/common/man/man1/knife-node.1 +12 -9
- data/distro/common/man/man1/knife-raw.1 +7 -7
- data/distro/common/man/man1/knife-recipe-list.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +8 -8
- data/distro/common/man/man1/knife-search.1 +9 -9
- data/distro/common/man/man1/knife-serve.1 +109 -0
- data/distro/common/man/man1/knife-show.1 +8 -8
- data/distro/common/man/man1/knife-ssh.1 +9 -9
- data/distro/common/man/man1/knife-ssl-check.1 +9 -9
- data/distro/common/man/man1/knife-ssl-fetch.1 +10 -10
- data/distro/common/man/man1/knife-status.1 +9 -9
- data/distro/common/man/man1/knife-tag.1 +7 -7
- data/distro/common/man/man1/knife-upload.1 +10 -10
- data/distro/common/man/man1/knife-user.1 +9 -9
- data/distro/common/man/man1/knife-xargs.1 +7 -7
- data/distro/common/man/man1/knife.1 +118 -14
- data/distro/common/man/man8/chef-client.8 +13 -10
- data/distro/common/man/man8/chef-solo.8 +13 -14
- data/distro/common/markdown/man1/knife.mkd +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/application/windows_service.rb +0 -1
- data/lib/chef/chef_fs/file_system.rb +6 -2
- data/lib/chef/config.rb +3 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +20 -14
- data/lib/chef/cookbook/synchronizer.rb +24 -13
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +2 -2
- data/lib/chef/exceptions.rb +1 -0
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
- data/lib/chef/http.rb +6 -1
- data/lib/chef/http/http_request.rb +9 -1
- data/lib/chef/http/simple.rb +2 -1
- data/lib/chef/json_compat.rb +5 -16
- data/lib/chef/knife/bootstrap.rb +2 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/core/object_loader.rb +3 -1
- data/lib/chef/knife/ssh.rb +14 -7
- data/lib/chef/mixin/convert_to_class_name.rb +1 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +24 -4
- data/lib/chef/platform/provider_mapping.rb +13 -0
- data/lib/chef/provider/env/windows.rb +3 -6
- data/lib/chef/provider/git.rb +1 -2
- data/lib/chef/provider/log.rb +15 -1
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +35 -16
- data/lib/chef/provider/package/paludis.rb +91 -0
- data/lib/chef/provider/package/rpm.rb +3 -2
- data/lib/chef/provider/package/yum-dump.py +6 -6
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/registry_key.rb +4 -5
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +2 -1
- data/lib/chef/provider/service/windows.rb +37 -9
- data/lib/chef/provider/user/pw.rb +1 -1
- data/lib/chef/provider/user/useradd.rb +1 -1
- data/lib/chef/provider/windows_script.rb +2 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +10 -0
- data/lib/chef/resource/file.rb +0 -9
- data/lib/chef/resource/package.rb +14 -4
- data/lib/chef/resource/paludis_package.rb +33 -0
- data/lib/chef/resource/registry_key.rb +62 -3
- data/lib/chef/resource/service.rb +21 -4
- data/lib/chef/resource_reporter.rb +10 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +14 -10
- data/lib/chef/shell.rb +8 -0
- data/lib/chef/shell/shell_session.rb +3 -3
- data/lib/chef/user.rb +12 -11
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +6 -5
- data/lib/chef/win32/api/process.rb +1 -0
- data/lib/chef/win32/api/system.rb +14 -0
- data/lib/chef/win32/error.rb +1 -1
- data/lib/chef/win32/security.rb +5 -5
- data/lib/chef/win32/version.rb +6 -2
- data/spec/data/trusted_certs/opscode.pem +57 -35
- data/spec/functional/application_spec.rb +2 -2
- data/spec/functional/resource/mount_spec.rb +3 -1
- data/spec/functional/shell_spec.rb +10 -0
- data/spec/functional/tiny_server_spec.rb +2 -2
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/securable_resource.rb +11 -2
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +13 -2
- data/spec/tiny_server.rb +1 -1
- data/spec/unit/config_spec.rb +5 -0
- data/spec/unit/cookbook/metadata_spec.rb +24 -0
- data/spec/unit/environment_spec.rb +6 -0
- data/spec/unit/http/http_request_spec.rb +91 -0
- data/spec/unit/http_spec.rb +23 -0
- data/spec/unit/knife/bootstrap_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +7 -13
- data/spec/unit/knife_spec.rb +1 -1
- data/spec/unit/mixin/convert_to_class_name_spec.rb +4 -0
- data/spec/unit/provider/git_spec.rb +2 -2
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/mount/solaris_spec.rb +3 -1
- data/spec/unit/provider/package/apt_spec.rb +85 -40
- data/spec/unit/provider/package/dpkg_spec.rb +24 -48
- data/spec/unit/provider/package/paludis_spec.rb +135 -0
- data/spec/unit/provider/package/rpm_spec.rb +40 -32
- data/spec/unit/provider/package/yum_spec.rb +11 -4
- data/spec/unit/provider/registry_key_spec.rb +67 -53
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +10 -1
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +23 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +7 -0
- data/spec/unit/provider/service/windows_spec.rb +72 -0
- data/spec/unit/provider/user/pw_spec.rb +21 -4
- data/spec/unit/provider/user/useradd_spec.rb +10 -0
- data/spec/unit/resource/package_spec.rb +26 -18
- data/spec/unit/resource/registry_key_spec.rb +28 -0
- data/spec/unit/resource/service_spec.rb +14 -0
- data/spec/unit/resource_reporter_spec.rb +37 -12
- data/spec/unit/resource_spec.rb +41 -6
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/role_spec.rb +46 -28
- data/spec/unit/shell/shell_session_spec.rb +42 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/user_spec.rb +12 -0
- data/spec/unit/util/selinux_spec.rb +4 -4
- data/spec/unit/version_constraint_spec.rb +14 -2
- metadata +223 -167
- checksums.yaml +0 -7
@@ -24,8 +24,8 @@ describe Chef::Provider::Package::Rpm do
|
|
24
24
|
@events = Chef::EventDispatch::Dispatcher.new
|
25
25
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
26
26
|
|
27
|
-
@new_resource = Chef::Resource::Package.new("
|
28
|
-
@new_resource.source "/tmp/
|
27
|
+
@new_resource = Chef::Resource::Package.new("ImageMagick-c++")
|
28
|
+
@new_resource.source "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
29
29
|
|
30
30
|
@provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context)
|
31
31
|
|
@@ -38,13 +38,13 @@ describe Chef::Provider::Package::Rpm do
|
|
38
38
|
it "should create a current resource with the name of new_resource" do
|
39
39
|
@provider.stub(:popen4).and_return(@status)
|
40
40
|
@provider.load_current_resource
|
41
|
-
@provider.current_resource.name.should == "
|
41
|
+
@provider.current_resource.name.should == "ImageMagick-c++"
|
42
42
|
end
|
43
43
|
|
44
44
|
it "should set the current reource package name to the new resource package name" do
|
45
45
|
@provider.stub(:popen4).and_return(@status)
|
46
46
|
@provider.load_current_resource
|
47
|
-
@provider.current_resource.package_name.should == '
|
47
|
+
@provider.current_resource.package_name.should == 'ImageMagick-c++'
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should raise an exception if a source is supplied but not found" do
|
@@ -53,24 +53,24 @@ describe Chef::Provider::Package::Rpm do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should get the source package version from rpm if provided" do
|
56
|
-
@stdout = StringIO.new("
|
57
|
-
@provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/
|
58
|
-
@provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n'
|
56
|
+
@stdout = StringIO.new("ImageMagick-c++ 6.5.4.7-7.el6_5")
|
57
|
+
@provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
58
|
+
@provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' ImageMagick-c++").and_return(@status)
|
59
59
|
@provider.load_current_resource
|
60
|
-
@provider.current_resource.package_name.should == "
|
61
|
-
@provider.new_resource.version.should == "
|
60
|
+
@provider.current_resource.package_name.should == "ImageMagick-c++"
|
61
|
+
@provider.new_resource.version.should == "6.5.4.7-7.el6_5"
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should return the current version installed if found by rpm" do
|
65
|
-
@stdout = StringIO.new("
|
66
|
-
@provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/
|
67
|
-
@provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n'
|
65
|
+
@stdout = StringIO.new("ImageMagick-c++ 6.5.4.7-7.el6_5")
|
66
|
+
@provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm").and_return(@status)
|
67
|
+
@provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' ImageMagick-c++").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
|
68
68
|
@provider.load_current_resource
|
69
|
-
@provider.current_resource.version.should == "
|
69
|
+
@provider.current_resource.version.should == "6.5.4.7-7.el6_5"
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should raise an exception if the source is not set but we are installing" do
|
73
|
-
new_resource = Chef::Resource::Package.new("
|
73
|
+
new_resource = Chef::Resource::Package.new("ImageMagick-c++")
|
74
74
|
provider = Chef::Provider::Package::Rpm.new(new_resource, @run_context)
|
75
75
|
lambda { provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package)
|
76
76
|
end
|
@@ -84,56 +84,64 @@ describe Chef::Provider::Package::Rpm do
|
|
84
84
|
|
85
85
|
describe "after the current resource is loaded" do
|
86
86
|
before do
|
87
|
-
@current_resource = Chef::Resource::Package.new("
|
87
|
+
@current_resource = Chef::Resource::Package.new("ImageMagick-c++")
|
88
88
|
@provider.current_resource = @current_resource
|
89
89
|
end
|
90
90
|
|
91
91
|
describe "when installing or upgrading" do
|
92
92
|
it "should run rpm -i with the package source to install" do
|
93
93
|
@provider.should_receive(:run_command_with_systems_locale).with({
|
94
|
-
:command => "rpm -i /tmp/
|
94
|
+
:command => "rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
95
95
|
})
|
96
|
-
@provider.install_package("
|
96
|
+
@provider.install_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should run rpm -U with the package source to upgrade" do
|
100
100
|
@current_resource.version("21.4-19.el5")
|
101
101
|
@provider.should_receive(:run_command_with_systems_locale).with({
|
102
|
-
:command => "rpm -U /tmp/
|
102
|
+
:command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
103
103
|
})
|
104
|
-
@provider.upgrade_package("
|
104
|
+
@provider.upgrade_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should install package if missing and set to upgrade" do
|
108
|
+
@current_resource.version("ImageMagick-c++")
|
109
|
+
@provider.should_receive(:run_command_with_systems_locale).with({
|
110
|
+
:command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
111
|
+
})
|
112
|
+
@provider.upgrade_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
|
105
113
|
end
|
106
114
|
|
107
115
|
it "should install from a path when the package is a path and the source is nil" do
|
108
|
-
@new_resource = Chef::Resource::Package.new("/tmp/
|
116
|
+
@new_resource = Chef::Resource::Package.new("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
|
109
117
|
@provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context)
|
110
|
-
@new_resource.source.should == "/tmp/
|
111
|
-
@current_resource = Chef::Resource::Package.new("
|
118
|
+
@new_resource.source.should == "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
119
|
+
@current_resource = Chef::Resource::Package.new("ImageMagick-c++")
|
112
120
|
@provider.current_resource = @current_resource
|
113
121
|
@provider.should_receive(:run_command_with_systems_locale).with({
|
114
|
-
:command => "rpm -i /tmp/
|
122
|
+
:command => "rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
115
123
|
})
|
116
|
-
@provider.install_package("/tmp/
|
124
|
+
@provider.install_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
|
117
125
|
end
|
118
126
|
|
119
127
|
it "should uprgrade from a path when the package is a path and the source is nil" do
|
120
|
-
@new_resource = Chef::Resource::Package.new("/tmp/
|
128
|
+
@new_resource = Chef::Resource::Package.new("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
|
121
129
|
@provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context)
|
122
|
-
@new_resource.source.should == "/tmp/
|
123
|
-
@current_resource = Chef::Resource::Package.new("
|
130
|
+
@new_resource.source.should == "/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
131
|
+
@current_resource = Chef::Resource::Package.new("ImageMagick-c++")
|
124
132
|
@current_resource.version("21.4-19.el5")
|
125
133
|
@provider.current_resource = @current_resource
|
126
134
|
@provider.should_receive(:run_command_with_systems_locale).with({
|
127
|
-
:command => "rpm -U /tmp/
|
135
|
+
:command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
128
136
|
})
|
129
|
-
@provider.upgrade_package("/tmp/
|
137
|
+
@provider.upgrade_package("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm", "6.5.4.7-7.el6_5")
|
130
138
|
end
|
131
139
|
|
132
140
|
it "installs with custom options specified in the resource" do
|
133
141
|
@provider.candidate_version = '11'
|
134
142
|
@new_resource.options("--dbpath /var/lib/rpm")
|
135
143
|
@provider.should_receive(:run_command_with_systems_locale).with({
|
136
|
-
:command => "rpm --dbpath /var/lib/rpm -i /tmp/
|
144
|
+
:command => "rpm --dbpath /var/lib/rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
|
137
145
|
})
|
138
146
|
@provider.install_package(@new_resource.name, @provider.candidate_version)
|
139
147
|
end
|
@@ -142,9 +150,9 @@ describe Chef::Provider::Package::Rpm do
|
|
142
150
|
describe "when removing the package" do
|
143
151
|
it "should run rpm -e to remove the package" do
|
144
152
|
@provider.should_receive(:run_command_with_systems_locale).with({
|
145
|
-
:command => "rpm -e
|
153
|
+
:command => "rpm -e ImageMagick-c++-6.5.4.7-7.el6_5"
|
146
154
|
})
|
147
|
-
@provider.remove_package("
|
155
|
+
@provider.remove_package("ImageMagick-c++", "6.5.4.7-7.el6_5")
|
148
156
|
end
|
149
157
|
end
|
150
158
|
end
|
@@ -1619,25 +1619,32 @@ EOF
|
|
1619
1619
|
|
1620
1620
|
it "should run yum-dump.py using the system python when next_refresh is for :all" do
|
1621
1621
|
@yc.reload
|
1622
|
-
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides$}, :timeout=>Chef::Config[:yum_timeout])
|
1622
|
+
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
|
1623
1623
|
@yc.refresh
|
1624
1624
|
end
|
1625
1625
|
|
1626
1626
|
it "should run yum-dump.py with the installed flag when next_refresh is for :installed" do
|
1627
1627
|
@yc.reload_installed
|
1628
|
-
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed$}, :timeout=>Chef::Config[:yum_timeout])
|
1628
|
+
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --installed --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
|
1629
1629
|
@yc.refresh
|
1630
1630
|
end
|
1631
1631
|
|
1632
1632
|
it "should run yum-dump.py with the all-provides flag when next_refresh is for :provides" do
|
1633
1633
|
@yc.reload_provides
|
1634
|
-
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides$}, :timeout=>Chef::Config[:yum_timeout])
|
1634
|
+
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --all-provides --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
|
1635
1635
|
@yc.refresh
|
1636
1636
|
end
|
1637
1637
|
|
1638
1638
|
it "should pass extra_repo_control args to yum-dump.py" do
|
1639
1639
|
@yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
|
1640
|
-
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar$}, :timeout=>Chef::Config[:yum_timeout])
|
1640
|
+
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 30$}, :timeout=>Chef::Config[:yum_timeout])
|
1641
|
+
@yc.refresh
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
it "should pass extra_repo_control args and configured yum lock timeout to yum-dump.py" do
|
1645
|
+
Chef::Config[:yum_lock_timeout] = 999
|
1646
|
+
@yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
|
1647
|
+
@yc.should_receive(:shell_out!).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar --yum-lock-timeout 999$}, :timeout=>Chef::Config[:yum_timeout])
|
1641
1648
|
@yc.refresh
|
1642
1649
|
end
|
1643
1650
|
|
@@ -18,21 +18,14 @@
|
|
18
18
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
let(:testval1) { { :name => "one", :type => :string, :data => "1" } }
|
24
|
-
let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } }
|
25
|
-
let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } }
|
26
|
-
let(:testval2) { { :name => "two", :type => :string, :data => "2" } }
|
27
|
-
let(:testkey1) { 'HKLM\Software\Opscode\Testing' }
|
28
|
-
|
21
|
+
shared_examples_for "a registry key" do
|
29
22
|
before(:each) do
|
30
23
|
@node = Chef::Node.new
|
31
24
|
@events = Chef::EventDispatch::Dispatcher.new
|
32
25
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
33
26
|
|
34
27
|
@new_resource = Chef::Resource::RegistryKey.new("windows is fun", @run_context)
|
35
|
-
@new_resource.key
|
28
|
+
@new_resource.key keyname
|
36
29
|
@new_resource.values( testval1 )
|
37
30
|
@new_resource.recursive false
|
38
31
|
|
@@ -49,8 +42,8 @@ describe Chef::Provider::RegistryKey do
|
|
49
42
|
describe "executing load_current_resource" do
|
50
43
|
describe "when the key exists" do
|
51
44
|
before(:each) do
|
52
|
-
@double_registry.should_receive(:key_exists?).with(
|
53
|
-
@double_registry.should_receive(:get_values).with(
|
45
|
+
@double_registry.should_receive(:key_exists?).with(keyname).and_return(true)
|
46
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval2 )
|
54
47
|
@provider.load_current_resource
|
55
48
|
end
|
56
49
|
|
@@ -66,14 +59,14 @@ describe Chef::Provider::RegistryKey do
|
|
66
59
|
@provider.current_resource.recursive.should == @new_resource.recursive
|
67
60
|
end
|
68
61
|
|
69
|
-
it "should set the values of the current resource to the values it got from the registry" do
|
70
|
-
@provider.current_resource.
|
62
|
+
it "should set the unscrubbed values of the current resource to the values it got from the registry" do
|
63
|
+
@provider.current_resource.unscrubbed_values.should == [ testval2 ]
|
71
64
|
end
|
72
65
|
end
|
73
66
|
|
74
67
|
describe "when the key does not exist" do
|
75
68
|
before(:each) do
|
76
|
-
@double_registry.should_receive(:key_exists?).with(
|
69
|
+
@double_registry.should_receive(:key_exists?).with(keyname).and_return(false)
|
77
70
|
@provider.load_current_resource
|
78
71
|
end
|
79
72
|
|
@@ -86,29 +79,29 @@ describe Chef::Provider::RegistryKey do
|
|
86
79
|
describe "action_create" do
|
87
80
|
context "when the key exists" do
|
88
81
|
before(:each) do
|
89
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
82
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(true)
|
90
83
|
end
|
91
84
|
it "should do nothing if the key and the value both exist" do
|
92
|
-
@double_registry.should_receive(:get_values).with(
|
85
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1 )
|
93
86
|
@double_registry.should_not_receive(:set_value)
|
94
87
|
@provider.load_current_resource
|
95
88
|
@provider.action_create
|
96
89
|
end
|
97
90
|
it "should create the value if the key exists but the value does not" do
|
98
|
-
@double_registry.should_receive(:get_values).with(
|
99
|
-
@double_registry.should_receive(:set_value).with(
|
91
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval2 )
|
92
|
+
@double_registry.should_receive(:set_value).with(keyname, testval1)
|
100
93
|
@provider.load_current_resource
|
101
94
|
@provider.action_create
|
102
95
|
end
|
103
96
|
it "should set the value if the key exists but the data does not match" do
|
104
|
-
@double_registry.should_receive(:get_values).with(
|
105
|
-
@double_registry.should_receive(:set_value).with(
|
97
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1_wrong_data )
|
98
|
+
@double_registry.should_receive(:set_value).with(keyname, testval1)
|
106
99
|
@provider.load_current_resource
|
107
100
|
@provider.action_create
|
108
101
|
end
|
109
102
|
it "should set the value if the key exists but the type does not match" do
|
110
|
-
@double_registry.should_receive(:get_values).with(
|
111
|
-
@double_registry.should_receive(:set_value).with(
|
103
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1_wrong_type )
|
104
|
+
@double_registry.should_receive(:set_value).with(keyname, testval1)
|
112
105
|
@provider.load_current_resource
|
113
106
|
@provider.action_create
|
114
107
|
end
|
@@ -116,8 +109,8 @@ describe Chef::Provider::RegistryKey do
|
|
116
109
|
context "when the key exists and the values in the new resource are empty" do
|
117
110
|
it "when a value is in the key, it should do nothing" do
|
118
111
|
@provider.new_resource.values([])
|
119
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
120
|
-
@double_registry.should_receive(:get_values).with(
|
112
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(true)
|
113
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1 )
|
121
114
|
@double_registry.should_not_receive(:create_key)
|
122
115
|
@double_registry.should_not_receive(:set_value)
|
123
116
|
@provider.load_current_resource
|
@@ -125,8 +118,8 @@ describe Chef::Provider::RegistryKey do
|
|
125
118
|
end
|
126
119
|
it "when no value is in the key, it should do nothing" do
|
127
120
|
@provider.new_resource.values([])
|
128
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
129
|
-
@double_registry.should_receive(:get_values).with(
|
121
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(true)
|
122
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( nil )
|
130
123
|
@double_registry.should_not_receive(:create_key)
|
131
124
|
@double_registry.should_not_receive(:set_value)
|
132
125
|
@provider.load_current_resource
|
@@ -135,11 +128,11 @@ describe Chef::Provider::RegistryKey do
|
|
135
128
|
end
|
136
129
|
context "when the key does not exist" do
|
137
130
|
before(:each) do
|
138
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
131
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(false)
|
139
132
|
end
|
140
133
|
it "should create the key and the value" do
|
141
|
-
@double_registry.should_receive(:create_key).with(
|
142
|
-
@double_registry.should_receive(:set_value).with(
|
134
|
+
@double_registry.should_receive(:create_key).with(keyname, false)
|
135
|
+
@double_registry.should_receive(:set_value).with(keyname, testval1)
|
143
136
|
@provider.load_current_resource
|
144
137
|
@provider.action_create
|
145
138
|
end
|
@@ -147,8 +140,8 @@ describe Chef::Provider::RegistryKey do
|
|
147
140
|
context "when the key does not exist and the values in the new resource are empty" do
|
148
141
|
it "should create the key" do
|
149
142
|
@new_resource.values([])
|
150
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
151
|
-
@double_registry.should_receive(:create_key).with(
|
143
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(false)
|
144
|
+
@double_registry.should_receive(:create_key).with(keyname, false)
|
152
145
|
@double_registry.should_not_receive(:set_value)
|
153
146
|
@provider.load_current_resource
|
154
147
|
@provider.action_create
|
@@ -159,28 +152,28 @@ describe Chef::Provider::RegistryKey do
|
|
159
152
|
describe "action_create_if_missing" do
|
160
153
|
context "when the key exists" do
|
161
154
|
before(:each) do
|
162
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
155
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(true)
|
163
156
|
end
|
164
157
|
it "should do nothing if the key and the value both exist" do
|
165
|
-
@double_registry.should_receive(:get_values).with(
|
158
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1 )
|
166
159
|
@double_registry.should_not_receive(:set_value)
|
167
160
|
@provider.load_current_resource
|
168
161
|
@provider.action_create_if_missing
|
169
162
|
end
|
170
163
|
it "should create the value if the key exists but the value does not" do
|
171
|
-
@double_registry.should_receive(:get_values).with(
|
172
|
-
@double_registry.should_receive(:set_value).with(
|
164
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval2 )
|
165
|
+
@double_registry.should_receive(:set_value).with(keyname, testval1)
|
173
166
|
@provider.load_current_resource
|
174
167
|
@provider.action_create_if_missing
|
175
168
|
end
|
176
169
|
it "should not set the value if the key exists but the data does not match" do
|
177
|
-
@double_registry.should_receive(:get_values).with(
|
170
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1_wrong_data )
|
178
171
|
@double_registry.should_not_receive(:set_value)
|
179
172
|
@provider.load_current_resource
|
180
173
|
@provider.action_create_if_missing
|
181
174
|
end
|
182
175
|
it "should not set the value if the key exists but the type does not match" do
|
183
|
-
@double_registry.should_receive(:get_values).with(
|
176
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1_wrong_type )
|
184
177
|
@double_registry.should_not_receive(:set_value)
|
185
178
|
@provider.load_current_resource
|
186
179
|
@provider.action_create_if_missing
|
@@ -188,11 +181,11 @@ describe Chef::Provider::RegistryKey do
|
|
188
181
|
end
|
189
182
|
context "when the key does not exist" do
|
190
183
|
before(:each) do
|
191
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
184
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(false)
|
192
185
|
end
|
193
186
|
it "should create the key and the value" do
|
194
|
-
@double_registry.should_receive(:create_key).with(
|
195
|
-
@double_registry.should_receive(:set_value).with(
|
187
|
+
@double_registry.should_receive(:create_key).with(keyname, false)
|
188
|
+
@double_registry.should_receive(:set_value).with(keyname, testval1)
|
196
189
|
@provider.load_current_resource
|
197
190
|
@provider.action_create_if_missing
|
198
191
|
end
|
@@ -202,28 +195,28 @@ describe Chef::Provider::RegistryKey do
|
|
202
195
|
describe "action_delete" do
|
203
196
|
context "when the key exists" do
|
204
197
|
before(:each) do
|
205
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
198
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(true)
|
206
199
|
end
|
207
200
|
it "deletes the value when the value exists" do
|
208
|
-
@double_registry.should_receive(:get_values).with(
|
209
|
-
@double_registry.should_receive(:delete_value).with(
|
201
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1 )
|
202
|
+
@double_registry.should_receive(:delete_value).with(keyname, testval1)
|
210
203
|
@provider.load_current_resource
|
211
204
|
@provider.action_delete
|
212
205
|
end
|
213
206
|
it "deletes the value when the value exists, but the type is wrong" do
|
214
|
-
@double_registry.should_receive(:get_values).with(
|
215
|
-
@double_registry.should_receive(:delete_value).with(
|
207
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1_wrong_type )
|
208
|
+
@double_registry.should_receive(:delete_value).with(keyname, testval1)
|
216
209
|
@provider.load_current_resource
|
217
210
|
@provider.action_delete
|
218
211
|
end
|
219
212
|
it "deletes the value when the value exists, but the data is wrong" do
|
220
|
-
@double_registry.should_receive(:get_values).with(
|
221
|
-
@double_registry.should_receive(:delete_value).with(
|
213
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1_wrong_data )
|
214
|
+
@double_registry.should_receive(:delete_value).with(keyname, testval1)
|
222
215
|
@provider.load_current_resource
|
223
216
|
@provider.action_delete
|
224
217
|
end
|
225
218
|
it "does not delete the value when the value does not exist" do
|
226
|
-
@double_registry.should_receive(:get_values).with(
|
219
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval2 )
|
227
220
|
@double_registry.should_not_receive(:delete_value)
|
228
221
|
@provider.load_current_resource
|
229
222
|
@provider.action_delete
|
@@ -231,7 +224,7 @@ describe Chef::Provider::RegistryKey do
|
|
231
224
|
end
|
232
225
|
context "when the key does not exist" do
|
233
226
|
before(:each) do
|
234
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
227
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(false)
|
235
228
|
end
|
236
229
|
it "does nothing" do
|
237
230
|
@double_registry.should_not_receive(:delete_value)
|
@@ -244,18 +237,18 @@ describe Chef::Provider::RegistryKey do
|
|
244
237
|
describe "action_delete_key" do
|
245
238
|
context "when the key exists" do
|
246
239
|
before(:each) do
|
247
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
240
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(true)
|
248
241
|
end
|
249
242
|
it "deletes the key" do
|
250
|
-
@double_registry.should_receive(:get_values).with(
|
251
|
-
@double_registry.should_receive(:delete_key).with(
|
243
|
+
@double_registry.should_receive(:get_values).with(keyname).and_return( testval1 )
|
244
|
+
@double_registry.should_receive(:delete_key).with(keyname, false)
|
252
245
|
@provider.load_current_resource
|
253
246
|
@provider.action_delete_key
|
254
247
|
end
|
255
248
|
end
|
256
249
|
context "when the key does not exist" do
|
257
250
|
before(:each) do
|
258
|
-
@double_registry.should_receive(:key_exists?).twice.with(
|
251
|
+
@double_registry.should_receive(:key_exists?).twice.with(keyname).and_return(false)
|
259
252
|
end
|
260
253
|
it "does nothing" do
|
261
254
|
@double_registry.should_not_receive(:delete_key)
|
@@ -267,3 +260,24 @@ describe Chef::Provider::RegistryKey do
|
|
267
260
|
|
268
261
|
end
|
269
262
|
|
263
|
+
describe Chef::Provider::RegistryKey do
|
264
|
+
context "when the key data is safe" do
|
265
|
+
let(:keyname) { 'HKLM\Software\Opscode\Testing\Safe' }
|
266
|
+
let(:testval1) { { :name => "one", :type => :string, :data => "1" } }
|
267
|
+
let(:testval1_wrong_type) { { :name => "one", :type => :multi_string, :data => "1" } }
|
268
|
+
let(:testval1_wrong_data) { { :name => "one", :type => :string, :data => "2" } }
|
269
|
+
let(:testval2) { { :name => "two", :type => :string, :data => "2" } }
|
270
|
+
|
271
|
+
it_should_behave_like "a registry key"
|
272
|
+
end
|
273
|
+
|
274
|
+
context "when the key data is unsafe" do
|
275
|
+
let(:keyname) { 'HKLM\Software\Opscode\Testing\Unsafe' }
|
276
|
+
let(:testval1) { { :name => "one", :type => :binary, :data => 255.chr * 1 } }
|
277
|
+
let(:testval1_wrong_type) { { :name => "one", :type => :string, :data => 255.chr * 1 } }
|
278
|
+
let(:testval1_wrong_data) { { :name => "one", :type => :binary, :data => 254.chr * 1 } }
|
279
|
+
let(:testval2) { { :name => "two", :type => :binary, :data => 0.chr * 1 } }
|
280
|
+
|
281
|
+
it_should_behave_like "a registry key"
|
282
|
+
end
|
283
|
+
end
|