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.
Files changed (145) hide show
  1. data/CONTRIBUTING.md +0 -4
  2. data/README.md +1 -1
  3. data/distro/common/man/man1/chef-shell.1 +4 -4
  4. data/distro/common/man/man1/knife-bootstrap.1 +14 -11
  5. data/distro/common/man/man1/knife-client.1 +14 -11
  6. data/distro/common/man/man1/knife-configure.1 +7 -7
  7. data/distro/common/man/man1/knife-cookbook-site.1 +23 -23
  8. data/distro/common/man/man1/knife-cookbook.1 +23 -23
  9. data/distro/common/man/man1/knife-data-bag.1 +13 -13
  10. data/distro/common/man/man1/knife-delete.1 +9 -9
  11. data/distro/common/man/man1/knife-deps.1 +9 -9
  12. data/distro/common/man/man1/knife-diff.1 +10 -10
  13. data/distro/common/man/man1/knife-download.1 +9 -9
  14. data/distro/common/man/man1/knife-edit.1 +7 -7
  15. data/distro/common/man/man1/knife-environment.1 +10 -10
  16. data/distro/common/man/man1/knife-exec.1 +7 -7
  17. data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
  18. data/distro/common/man/man1/knife-list.1 +12 -12
  19. data/distro/common/man/man1/knife-node.1 +12 -9
  20. data/distro/common/man/man1/knife-raw.1 +7 -7
  21. data/distro/common/man/man1/knife-recipe-list.1 +1 -1
  22. data/distro/common/man/man1/knife-role.1 +8 -8
  23. data/distro/common/man/man1/knife-search.1 +9 -9
  24. data/distro/common/man/man1/knife-serve.1 +109 -0
  25. data/distro/common/man/man1/knife-show.1 +8 -8
  26. data/distro/common/man/man1/knife-ssh.1 +9 -9
  27. data/distro/common/man/man1/knife-ssl-check.1 +9 -9
  28. data/distro/common/man/man1/knife-ssl-fetch.1 +10 -10
  29. data/distro/common/man/man1/knife-status.1 +9 -9
  30. data/distro/common/man/man1/knife-tag.1 +7 -7
  31. data/distro/common/man/man1/knife-upload.1 +10 -10
  32. data/distro/common/man/man1/knife-user.1 +9 -9
  33. data/distro/common/man/man1/knife-xargs.1 +7 -7
  34. data/distro/common/man/man1/knife.1 +118 -14
  35. data/distro/common/man/man8/chef-client.8 +13 -10
  36. data/distro/common/man/man8/chef-solo.8 +13 -14
  37. data/distro/common/markdown/man1/knife.mkd +1 -1
  38. data/lib/chef/application/knife.rb +1 -1
  39. data/lib/chef/application/windows_service.rb +0 -1
  40. data/lib/chef/chef_fs/file_system.rb +6 -2
  41. data/lib/chef/config.rb +3 -2
  42. data/lib/chef/config_fetcher.rb +1 -1
  43. data/lib/chef/cookbook/metadata.rb +20 -14
  44. data/lib/chef/cookbook/synchronizer.rb +24 -13
  45. data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
  46. data/lib/chef/encrypted_data_bag_item/encryptor.rb +2 -2
  47. data/lib/chef/exceptions.rb +1 -0
  48. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  49. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
  50. data/lib/chef/http.rb +6 -1
  51. data/lib/chef/http/http_request.rb +9 -1
  52. data/lib/chef/http/simple.rb +2 -1
  53. data/lib/chef/json_compat.rb +5 -16
  54. data/lib/chef/knife/bootstrap.rb +2 -0
  55. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  56. data/lib/chef/knife/core/object_loader.rb +3 -1
  57. data/lib/chef/knife/ssh.rb +14 -7
  58. data/lib/chef/mixin/convert_to_class_name.rb +1 -0
  59. data/lib/chef/mixin/windows_architecture_helper.rb +24 -4
  60. data/lib/chef/platform/provider_mapping.rb +13 -0
  61. data/lib/chef/provider/env/windows.rb +3 -6
  62. data/lib/chef/provider/git.rb +1 -2
  63. data/lib/chef/provider/log.rb +15 -1
  64. data/lib/chef/provider/package/apt.rb +3 -3
  65. data/lib/chef/provider/package/dpkg.rb +35 -16
  66. data/lib/chef/provider/package/paludis.rb +91 -0
  67. data/lib/chef/provider/package/rpm.rb +3 -2
  68. data/lib/chef/provider/package/yum-dump.py +6 -6
  69. data/lib/chef/provider/package/yum.rb +2 -0
  70. data/lib/chef/provider/registry_key.rb +4 -5
  71. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
  72. data/lib/chef/provider/service/solaris.rb +1 -1
  73. data/lib/chef/provider/service/upstart.rb +2 -1
  74. data/lib/chef/provider/service/windows.rb +37 -9
  75. data/lib/chef/provider/user/pw.rb +1 -1
  76. data/lib/chef/provider/user/useradd.rb +1 -1
  77. data/lib/chef/provider/windows_script.rb +2 -1
  78. data/lib/chef/providers.rb +1 -0
  79. data/lib/chef/resource.rb +10 -0
  80. data/lib/chef/resource/file.rb +0 -9
  81. data/lib/chef/resource/package.rb +14 -4
  82. data/lib/chef/resource/paludis_package.rb +33 -0
  83. data/lib/chef/resource/registry_key.rb +62 -3
  84. data/lib/chef/resource/service.rb +21 -4
  85. data/lib/chef/resource_reporter.rb +10 -0
  86. data/lib/chef/resources.rb +1 -0
  87. data/lib/chef/role.rb +14 -10
  88. data/lib/chef/shell.rb +8 -0
  89. data/lib/chef/shell/shell_session.rb +3 -3
  90. data/lib/chef/user.rb +12 -11
  91. data/lib/chef/util/selinux.rb +1 -1
  92. data/lib/chef/version.rb +1 -1
  93. data/lib/chef/version_constraint.rb +6 -5
  94. data/lib/chef/win32/api/process.rb +1 -0
  95. data/lib/chef/win32/api/system.rb +14 -0
  96. data/lib/chef/win32/error.rb +1 -1
  97. data/lib/chef/win32/security.rb +5 -5
  98. data/lib/chef/win32/version.rb +6 -2
  99. data/spec/data/trusted_certs/opscode.pem +57 -35
  100. data/spec/functional/application_spec.rb +2 -2
  101. data/spec/functional/resource/mount_spec.rb +3 -1
  102. data/spec/functional/shell_spec.rb +10 -0
  103. data/spec/functional/tiny_server_spec.rb +2 -2
  104. data/spec/support/chef_helpers.rb +1 -1
  105. data/spec/support/shared/functional/securable_resource.rb +11 -2
  106. data/spec/support/shared/functional/securable_resource_with_reporting.rb +13 -2
  107. data/spec/tiny_server.rb +1 -1
  108. data/spec/unit/config_spec.rb +5 -0
  109. data/spec/unit/cookbook/metadata_spec.rb +24 -0
  110. data/spec/unit/environment_spec.rb +6 -0
  111. data/spec/unit/http/http_request_spec.rb +91 -0
  112. data/spec/unit/http_spec.rb +23 -0
  113. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  114. data/spec/unit/knife/ssh_spec.rb +7 -13
  115. data/spec/unit/knife_spec.rb +1 -1
  116. data/spec/unit/mixin/convert_to_class_name_spec.rb +4 -0
  117. data/spec/unit/provider/git_spec.rb +2 -2
  118. data/spec/unit/provider/log_spec.rb +18 -0
  119. data/spec/unit/provider/mount/solaris_spec.rb +3 -1
  120. data/spec/unit/provider/package/apt_spec.rb +85 -40
  121. data/spec/unit/provider/package/dpkg_spec.rb +24 -48
  122. data/spec/unit/provider/package/paludis_spec.rb +135 -0
  123. data/spec/unit/provider/package/rpm_spec.rb +40 -32
  124. data/spec/unit/provider/package/yum_spec.rb +11 -4
  125. data/spec/unit/provider/registry_key_spec.rb +67 -53
  126. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +10 -1
  127. data/spec/unit/provider/service/solaris_smf_service_spec.rb +23 -2
  128. data/spec/unit/provider/service/upstart_service_spec.rb +7 -0
  129. data/spec/unit/provider/service/windows_spec.rb +72 -0
  130. data/spec/unit/provider/user/pw_spec.rb +21 -4
  131. data/spec/unit/provider/user/useradd_spec.rb +10 -0
  132. data/spec/unit/resource/package_spec.rb +26 -18
  133. data/spec/unit/resource/registry_key_spec.rb +28 -0
  134. data/spec/unit/resource/service_spec.rb +14 -0
  135. data/spec/unit/resource_reporter_spec.rb +37 -12
  136. data/spec/unit/resource_spec.rb +41 -6
  137. data/spec/unit/rest_spec.rb +2 -2
  138. data/spec/unit/role_spec.rb +46 -28
  139. data/spec/unit/shell/shell_session_spec.rb +42 -2
  140. data/spec/unit/shell_spec.rb +1 -1
  141. data/spec/unit/user_spec.rb +12 -0
  142. data/spec/unit/util/selinux_spec.rb +4 -4
  143. data/spec/unit/version_constraint_spec.rb +14 -2
  144. metadata +223 -167
  145. 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("emacs")
28
- @new_resource.source "/tmp/emacs-21.4-20.el5.i386.rpm"
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 == "emacs"
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 == 'emacs'
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("emacs 21.4-20.el5")
57
- @provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/emacs-21.4-20.el5.i386.rpm").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
58
- @provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' emacs").and_return(@status)
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 == "emacs"
61
- @provider.new_resource.version.should == "21.4-20.el5"
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("emacs 21.4-20.el5")
66
- @provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/emacs-21.4-20.el5.i386.rpm").and_return(@status)
67
- @provider.should_receive(:popen4).with("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' emacs").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status)
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 == "21.4-20.el5"
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("emacs")
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("emacs")
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/emacs-21.4-20.el5.i386.rpm"
94
+ :command => "rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
95
95
  })
96
- @provider.install_package("emacs", "21.4-20.el5")
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/emacs-21.4-20.el5.i386.rpm"
102
+ :command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
103
103
  })
104
- @provider.upgrade_package("emacs", "21.4-20.el5")
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/emacs-21.4-20.el5.i386.rpm")
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/emacs-21.4-20.el5.i386.rpm"
111
- @current_resource = Chef::Resource::Package.new("emacs")
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/emacs-21.4-20.el5.i386.rpm"
122
+ :command => "rpm -i /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
115
123
  })
116
- @provider.install_package("/tmp/emacs-21.4-20.el5.i386.rpm", "21.4-20.el5")
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/emacs-21.4-20.el5.i386.rpm")
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/emacs-21.4-20.el5.i386.rpm"
123
- @current_resource = Chef::Resource::Package.new("emacs")
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/emacs-21.4-20.el5.i386.rpm"
135
+ :command => "rpm -U /tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm"
128
136
  })
129
- @provider.upgrade_package("/tmp/emacs-21.4-20.el5.i386.rpm", "21.4-20.el5")
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/emacs-21.4-20.el5.i386.rpm"
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 emacs-21.4-20.el5"
153
+ :command => "rpm -e ImageMagick-c++-6.5.4.7-7.el6_5"
146
154
  })
147
- @provider.remove_package("emacs", "21.4-20.el5")
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
- describe Chef::Provider::RegistryKey do
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 testkey1
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(testkey1).and_return(true)
53
- @double_registry.should_receive(:get_values).with(testkey1).and_return( testval2 )
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.values.should == [ testval2 ]
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(testkey1).and_return(false)
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(testkey1).and_return(true)
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(testkey1).and_return( testval1 )
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(testkey1).and_return( testval2 )
99
- @double_registry.should_receive(:set_value).with(testkey1, testval1)
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(testkey1).and_return( testval1_wrong_data )
105
- @double_registry.should_receive(:set_value).with(testkey1, testval1)
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(testkey1).and_return( testval1_wrong_type )
111
- @double_registry.should_receive(:set_value).with(testkey1, testval1)
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(testkey1).and_return(true)
120
- @double_registry.should_receive(:get_values).with(testkey1).and_return( testval1 )
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(testkey1).and_return(true)
129
- @double_registry.should_receive(:get_values).with(testkey1).and_return( nil )
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(testkey1).and_return(false)
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(testkey1, false)
142
- @double_registry.should_receive(:set_value).with(testkey1, testval1)
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(testkey1).and_return(false)
151
- @double_registry.should_receive(:create_key).with(testkey1, false)
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(testkey1).and_return(true)
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(testkey1).and_return( testval1 )
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(testkey1).and_return( testval2 )
172
- @double_registry.should_receive(:set_value).with(testkey1, testval1)
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(testkey1).and_return( testval1_wrong_data )
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(testkey1).and_return( testval1_wrong_type )
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(testkey1).and_return(false)
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(testkey1, false)
195
- @double_registry.should_receive(:set_value).with(testkey1, testval1)
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(testkey1).and_return(true)
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(testkey1).and_return( testval1 )
209
- @double_registry.should_receive(:delete_value).with(testkey1, testval1)
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(testkey1).and_return( testval1_wrong_type )
215
- @double_registry.should_receive(:delete_value).with(testkey1, testval1)
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(testkey1).and_return( testval1_wrong_data )
221
- @double_registry.should_receive(:delete_value).with(testkey1, testval1)
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(testkey1).and_return( testval2 )
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(testkey1).and_return(false)
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(testkey1).and_return(true)
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(testkey1).and_return( testval1 )
251
- @double_registry.should_receive(:delete_key).with(testkey1, false)
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(testkey1).and_return(false)
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