chef 12.16.42 → 12.17.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/README.md +20 -5
  4. data/Rakefile +17 -0
  5. data/VERSION +1 -1
  6. data/acceptance/Gemfile.lock +32 -23
  7. data/distro/common/markdown/man1/knife-configure.mkd +3 -2
  8. data/lib-backcompat/chef/chef_fs/file_system/already_exists_error.rb +1 -1
  9. data/lib-backcompat/chef/chef_fs/file_system/cookbook_frozen_error.rb +1 -1
  10. data/lib-backcompat/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +1 -1
  11. data/lib-backcompat/chef/chef_fs/file_system/file_system_error.rb +1 -1
  12. data/lib-backcompat/chef/chef_fs/file_system/must_delete_recursively_error.rb +1 -1
  13. data/lib-backcompat/chef/chef_fs/file_system/not_found_error.rb +1 -1
  14. data/lib-backcompat/chef/chef_fs/file_system/operation_failed_error.rb +1 -1
  15. data/lib-backcompat/chef/chef_fs/file_system/operation_not_allowed_error.rb +1 -1
  16. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +1 -1
  17. data/lib-backcompat/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -1
  18. data/lib/chef/api_client.rb +1 -1
  19. data/lib/chef/application.rb +1 -1
  20. data/lib/chef/application/exit_code.rb +3 -3
  21. data/lib/chef/chef_class.rb +15 -5
  22. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +12 -1
  23. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +19 -0
  24. data/lib/chef/client.rb +1 -0
  25. data/lib/chef/cookbook/metadata.rb +2 -2
  26. data/lib/chef/cookbook_version.rb +4 -4
  27. data/lib/chef/data_bag.rb +1 -1
  28. data/lib/chef/data_bag_item.rb +1 -1
  29. data/lib/chef/data_collector.rb +20 -13
  30. data/lib/chef/data_collector/messages.rb +0 -1
  31. data/lib/chef/data_collector/messages/helpers.rb +2 -2
  32. data/lib/chef/decorator/unchain.rb +2 -2
  33. data/lib/chef/deprecated.rb +190 -0
  34. data/lib/chef/deprecation/provider/remote_directory.rb +1 -1
  35. data/lib/chef/deprecation/warnings.rb +3 -4
  36. data/lib/chef/dsl/method_missing.rb +2 -2
  37. data/lib/chef/dsl/resources.rb +2 -2
  38. data/lib/chef/environment.rb +1 -1
  39. data/lib/chef/exceptions.rb +1 -1
  40. data/lib/chef/formatters/base.rb +11 -1
  41. data/lib/chef/formatters/doc.rb +13 -4
  42. data/lib/chef/key.rb +1 -1
  43. data/lib/chef/knife/client_delete.rb +12 -9
  44. data/lib/chef/knife/configure.rb +1 -1
  45. data/lib/chef/knife/core/bootstrap_context.rb +25 -1
  46. data/lib/chef/knife/core/subcommand_loader.rb +3 -3
  47. data/lib/chef/knife/core/ui.rb +1 -1
  48. data/lib/chef/knife/node_delete.rb +6 -6
  49. data/lib/chef/log.rb +1 -1
  50. data/lib/chef/mixin/deprecation.rb +4 -10
  51. data/lib/chef/mixin/powershell_type_coercions.rb +19 -19
  52. data/lib/chef/mixin/shell_out.rb +1 -1
  53. data/lib/chef/node.rb +2 -2
  54. data/lib/chef/node/attribute.rb +3 -4
  55. data/lib/chef/node/common_api.rb +1 -1
  56. data/lib/chef/node/mixin/state_tracking.rb +5 -2
  57. data/lib/chef/node_map.rb +2 -2
  58. data/lib/chef/org.rb +1 -1
  59. data/lib/chef/platform/rebooter.rb +3 -1
  60. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  61. data/lib/chef/property.rb +5 -5
  62. data/lib/chef/provider.rb +4 -4
  63. data/lib/chef/provider/launchd.rb +1 -1
  64. data/lib/chef/provider/link.rb +6 -0
  65. data/lib/chef/provider/mount.rb +2 -0
  66. data/lib/chef/provider/mount/mount.rb +1 -1
  67. data/lib/chef/provider/ohai.rb +5 -3
  68. data/lib/chef/provider/package/cab.rb +1 -1
  69. data/lib/chef/provider/package/chocolatey.rb +2 -2
  70. data/lib/chef/provider/package/easy_install.rb +2 -2
  71. data/lib/chef/provider/package/msu.rb +162 -0
  72. data/lib/chef/provider/package/powershell.rb +114 -0
  73. data/lib/chef/provider/package/yum.rb +1 -1
  74. data/lib/chef/provider/yum_repository.rb +6 -7
  75. data/lib/chef/provider_resolver.rb +2 -2
  76. data/lib/chef/providers.rb +2 -0
  77. data/lib/chef/resource.rb +3 -5
  78. data/lib/chef/resource/apt_update.rb +1 -1
  79. data/lib/chef/resource/chef_gem.rb +2 -3
  80. data/lib/chef/resource/file/verification.rb +1 -1
  81. data/lib/chef/resource/launchd.rb +48 -8
  82. data/lib/chef/resource/mount.rb +1 -1
  83. data/lib/chef/resource/msu_package.rb +47 -0
  84. data/lib/chef/resource/ohai.rb +5 -25
  85. data/lib/chef/resource/powershell_package.rb +41 -0
  86. data/lib/chef/resource/reboot.rb +1 -1
  87. data/lib/chef/resource/user.rb +2 -2
  88. data/lib/chef/resource_builder.rb +4 -4
  89. data/lib/chef/resource_resolver.rb +2 -3
  90. data/lib/chef/resources.rb +2 -0
  91. data/lib/chef/rest.rb +1 -1
  92. data/lib/chef/role.rb +1 -1
  93. data/lib/chef/run_context.rb +3 -3
  94. data/lib/chef/shell/ext.rb +2 -2
  95. data/lib/chef/user.rb +3 -3
  96. data/lib/chef/user_v1.rb +1 -1
  97. data/lib/chef/version.rb +1 -1
  98. data/lib/chef/win32/api/security.rb +12 -12
  99. data/spec/data/sample_msu1.xml +10 -0
  100. data/spec/data/sample_msu2.xml +14 -0
  101. data/spec/data/sample_msu3.xml +16 -0
  102. data/spec/functional/rebooter_spec.rb +3 -3
  103. data/spec/functional/resource/link_spec.rb +62 -1
  104. data/spec/functional/resource/msu_package_spec.rb +84 -0
  105. data/spec/functional/resource/registry_spec.rb +3 -3
  106. data/spec/functional/resource/rpm_spec.rb +7 -10
  107. data/spec/integration/solo/solo_spec.rb +50 -0
  108. data/spec/spec_helper.rb +3 -0
  109. data/spec/support/platform_helpers.rb +16 -8
  110. data/spec/unit/application/exit_code_spec.rb +3 -15
  111. data/spec/unit/data_collector_spec.rb +6 -16
  112. data/spec/unit/deprecated_spec.rb +59 -0
  113. data/spec/unit/deprecation_spec.rb +1 -8
  114. data/spec/unit/handler_spec.rb +2 -2
  115. data/spec/unit/knife/client_delete_spec.rb +16 -0
  116. data/spec/unit/knife/configure_spec.rb +1 -1
  117. data/spec/unit/knife/cookbook_metadata_spec.rb +116 -113
  118. data/spec/unit/knife/core/bootstrap_context_spec.rb +55 -5
  119. data/spec/unit/knife/node_delete_spec.rb +19 -10
  120. data/spec/unit/mixin/shell_out_spec.rb +0 -1
  121. data/spec/unit/node/immutable_collections_spec.rb +5 -0
  122. data/spec/unit/node/vivid_mash_spec.rb +11 -0
  123. data/spec/unit/node_spec.rb +2 -2
  124. data/spec/unit/provider/launchd_spec.rb +81 -3
  125. data/spec/unit/provider/mount/mount_spec.rb +1 -1
  126. data/spec/unit/provider/mount_spec.rb +7 -0
  127. data/spec/unit/provider/package/chocolatey_spec.rb +5 -5
  128. data/spec/unit/provider/package/easy_install_spec.rb +6 -6
  129. data/spec/unit/provider/package/msu_spec.rb +283 -0
  130. data/spec/unit/provider/package/powershell_spec.rb +337 -0
  131. data/spec/unit/provider/service/macosx_spec.rb +1 -1
  132. data/spec/unit/provider/subversion_spec.rb +9 -0
  133. data/spec/unit/provider/user/linux_spec.rb +7 -1
  134. data/spec/unit/recipe_spec.rb +43 -11
  135. data/spec/unit/resource/apt_update_spec.rb +17 -25
  136. data/spec/unit/resource/file/verification_spec.rb +1 -1
  137. data/spec/unit/resource/mount_spec.rb +2 -1
  138. data/spec/unit/resource/msu_package_spec.rb +49 -0
  139. data/spec/unit/resource/ohai_spec.rb +1 -1
  140. data/spec/unit/resource/powershell_package_spec.rb +68 -0
  141. data/spec/unit/resource_reporter_spec.rb +4 -4
  142. data/spec/unit/run_status_spec.rb +1 -1
  143. data/tasks/announce.rb +58 -0
  144. data/tasks/changelog.rb +26 -6
  145. data/tasks/templates/prerelease.md.erb +35 -0
  146. data/tasks/templates/release.md.erb +34 -0
  147. metadata +21 -4
@@ -211,8 +211,8 @@ module Shell
211
211
  def version
212
212
  puts "This is the chef-shell.\n" +
213
213
  " Chef Version: #{::Chef::VERSION}\n" +
214
- " http://www.chef.io/\n" +
215
- " http://docs.chef.io/"
214
+ " https://www.chef.io/\n" +
215
+ " https://docs.chef.io/"
216
216
  :ucanhaz_automation
217
217
  end
218
218
  alias :shell :version
@@ -26,13 +26,13 @@ require "chef/server_api"
26
26
  # TODO
27
27
  # DEPRECATION NOTE
28
28
  # This class will be replaced by Chef::UserV1 in Chef 13. It is the code to support the User object
29
- # corrosponding to the Open Source Chef Server 11 and only still exists to support
29
+ # corresponding to the Open Source Chef Server 11 and only still exists to support
30
30
  # users still on OSC 11.
31
31
  #
32
32
  # Chef::UserV1 now supports Chef Server 12 and will be moved to this namespace in Chef 13.
33
33
  #
34
34
  # New development should occur in Chef::UserV1.
35
- # This file and corrosponding osc_user knife files
35
+ # This file and corresponding osc_user knife files
36
36
  # should be removed once client support for Open Source Chef Server 11 expires.
37
37
  class Chef
38
38
  class User
@@ -155,7 +155,7 @@ class Chef
155
155
  end
156
156
 
157
157
  def self.json_create(json)
158
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::User#from_json or Chef::User#load.")
158
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::User#from_json or Chef::User#load.")
159
159
  Chef::User.from_json(json)
160
160
  end
161
161
 
@@ -277,7 +277,7 @@ class Chef
277
277
  end
278
278
 
279
279
  def self.json_create(json)
280
- Chef.log_deprecation("Auto inflation of JSON data is deprecated. Please use Chef::UserV1#from_json or Chef::UserV1#load.")
280
+ Chef.deprecated(:json_auto_inflate, "Auto inflation of JSON data is deprecated. Please use Chef::UserV1#from_json or Chef::UserV1#load.")
281
281
  Chef::UserV1.from_json(json)
282
282
  end
283
283
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.16.42"
24
+ VERSION = "12.17.44"
25
25
  end
26
26
 
27
27
  #
@@ -182,18 +182,18 @@ class Chef
182
182
  MAXDWORD = 0xffffffff
183
183
 
184
184
  # LOGON32 constants for LogonUser
185
- LOGON32_LOGON_INTERACTIVE = 2;
186
- LOGON32_LOGON_NETWORK = 3;
187
- LOGON32_LOGON_BATCH = 4;
188
- LOGON32_LOGON_SERVICE = 5;
189
- LOGON32_LOGON_UNLOCK = 7;
190
- LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
191
- LOGON32_LOGON_NEW_CREDENTIALS = 9;
192
-
193
- LOGON32_PROVIDER_DEFAULT = 0;
194
- LOGON32_PROVIDER_WINNT35 = 1;
195
- LOGON32_PROVIDER_WINNT40 = 2;
196
- LOGON32_PROVIDER_WINNT50 = 3;
185
+ LOGON32_LOGON_INTERACTIVE = 2
186
+ LOGON32_LOGON_NETWORK = 3
187
+ LOGON32_LOGON_BATCH = 4
188
+ LOGON32_LOGON_SERVICE = 5
189
+ LOGON32_LOGON_UNLOCK = 7
190
+ LOGON32_LOGON_NETWORK_CLEARTEXT = 8
191
+ LOGON32_LOGON_NEW_CREDENTIALS = 9
192
+
193
+ LOGON32_PROVIDER_DEFAULT = 0
194
+ LOGON32_PROVIDER_WINNT35 = 1
195
+ LOGON32_PROVIDER_WINNT40 = 2
196
+ LOGON32_PROVIDER_WINNT50 = 3
197
197
 
198
198
  # LSA access policy
199
199
  POLICY_VIEW_LOCAL_INFORMATION = 0x00000001
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <unattend xmlns="urn:schemas-microsoft-com:unattend">
3
+ <servicing>
4
+ <package action="install">
5
+ <assemblyIdentity name="Package_for_KB2859903" version="10.2.1.0" language="neutral" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"/>
6
+ <source location="%configsetroot%\IE10-Windows6.1-KB2859903-x86.CAB" />
7
+ </package>
8
+ </servicing>
9
+ </unattend>
10
+
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <unattend xmlns="urn:schemas-microsoft-com:unattend">
3
+ <servicing>
4
+ <package action="install">
5
+ <assemblyIdentity name="Package_for_KB2859903" version="10.2.1.0" language="neutral" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"/>
6
+ <source location="%configsetroot%\IE10-Windows6.1-KB2859903-x86.CAB" />
7
+ </package>
8
+ <package action="install">
9
+ <assemblyIdentity name="Package_for_abc" version="10.2.1.0" language="neutral" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"/>
10
+ <source location="%configsetroot%\abc.CAB" />
11
+ </package>
12
+ </servicing>
13
+ </unattend>
14
+
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <unattend xmlns="urn:schemas-microsoft-com:unattend">
3
+ <servicing>
4
+ <package action="install">
5
+ <assemblyIdentity name="Package_for_KB2859903" version="10.2.1.0" language="neutral" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"/>
6
+ <source location="%configsetroot%\IE10-Windows6.1-KB2859903-x86.CAB" />
7
+ </package>
8
+ </servicing>
9
+ <servicing>
10
+ <package action="install">
11
+ <assemblyIdentity name="Package_for_abc" version="10.2.1.0" language="neutral" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"/>
12
+ <source location="%configsetroot%\abc.CAB" />
13
+ </package>
14
+ </servicing>
15
+ </unattend>
16
+
@@ -43,7 +43,7 @@ describe Chef::Platform::Rebooter do
43
43
 
44
44
  let(:expected) do
45
45
  {
46
- :windows => 'shutdown /r /t 300 /c "rebooter spec test"',
46
+ :windows => "#{ENV['SYSTEMROOT']}/System32/shutdown.exe /r /t 300 /c \"rebooter spec test\"",
47
47
  :linux => 'shutdown -r +5 "rebooter spec test"',
48
48
  }
49
49
  end
@@ -80,7 +80,7 @@ describe Chef::Platform::Rebooter do
80
80
  describe "when using #reboot_if_needed!" do
81
81
  include_context "test a reboot method"
82
82
 
83
- it "should produce the correct string on Windows" do
83
+ it "should produce the correct string on Windows", :windows_only do
84
84
  test_rebooter_method(:reboot_if_needed!, true, expected[:windows])
85
85
  end
86
86
 
@@ -92,7 +92,7 @@ describe Chef::Platform::Rebooter do
92
92
  describe "when using #reboot!" do
93
93
  include_context "test a reboot method"
94
94
 
95
- it "should produce the correct string on Windows" do
95
+ it "should produce the correct string on Windows", :windows_only do
96
96
  test_rebooter_method(:reboot!, true, expected[:windows])
97
97
  end
98
98
 
@@ -20,6 +20,7 @@ require "spec_helper"
20
20
 
21
21
  if windows?
22
22
  require "chef/win32/file" #probably need this in spec_helper
23
+ require "chef/win32/security"
23
24
  end
24
25
 
25
26
  describe Chef::Resource::Link do
@@ -62,6 +63,18 @@ describe Chef::Resource::Link do
62
63
  end
63
64
  end
64
65
 
66
+ def node
67
+ node = Chef::Node.new
68
+ node.consume_external_attrs(ohai.data, {})
69
+ node
70
+ end
71
+
72
+ def user(user)
73
+ usr = Chef::Resource.resource_for_node(:user, node).new(user, run_context)
74
+ usr.password("ComplexPass11!") if windows?
75
+ usr
76
+ end
77
+
65
78
  def cleanup_link(path)
66
79
  if windows? && File.directory?(path)
67
80
  # If the link target is a directory rm_rf doesn't work all the
@@ -108,6 +121,42 @@ describe Chef::Resource::Link do
108
121
  end
109
122
  end
110
123
 
124
+ let(:test_user) { windows? ? nil : ENV["USER"] }
125
+
126
+ def expected_owner
127
+ if windows?
128
+ get_sid(test_user)
129
+ else
130
+ test_user
131
+ end
132
+ end
133
+
134
+ def get_sid(value)
135
+ if value.kind_of?(String)
136
+ Chef::ReservedNames::Win32::Security::SID.from_account(value)
137
+ elsif value.kind_of?(Chef::ReservedNames::Win32::Security::SID)
138
+ value
139
+ else
140
+ raise "Must specify username or SID: #{value}"
141
+ end
142
+ end
143
+
144
+ def chown(file, user)
145
+ if windows?
146
+ Chef::ReservedNames::Win32::Security::SecurableObject.new(file).owner = get_sid(user)
147
+ else
148
+ File.lchown(Etc.getpwnam(user).uid, Etc.getpwnam(user).gid, file)
149
+ end
150
+ end
151
+
152
+ def owner(file)
153
+ if windows?
154
+ Chef::ReservedNames::Win32::Security::SecurableObject.new(file).security_descriptor.owner
155
+ else
156
+ Etc.getpwuid(File.lstat(file).uid).name
157
+ end
158
+ end
159
+
111
160
  def create_resource
112
161
  node = Chef::Node.new
113
162
  events = Chef::EventDispatch::Dispatcher.new
@@ -184,6 +233,7 @@ describe Chef::Resource::Link do
184
233
  it "links to the target file" do
185
234
  expect(symlink?(target_file)).to be_truthy
186
235
  expect(readlink(target_file)).to eq(canonicalize(to))
236
+ expect(owner(target_file)).to eq(expected_owner) unless test_user.nil?
187
237
  end
188
238
  it "marks the resource updated" do
189
239
  expect(resource).to be_updated
@@ -205,6 +255,7 @@ describe Chef::Resource::Link do
205
255
  it "leaves the file linked" do
206
256
  expect(symlink?(target_file)).to be_truthy
207
257
  expect(readlink(target_file)).to eq(canonicalize(to))
258
+ expect(owner(target_file)).to eq(expected_owner) unless test_user.nil?
208
259
  end
209
260
  it "does not mark the resource updated" do
210
261
  expect(resource).not_to be_updated
@@ -291,13 +342,23 @@ describe Chef::Resource::Link do
291
342
  expect(File.exists?(to)).to be_truthy
292
343
  end
293
344
  end
294
- context "pointing somewhere else" do
345
+ context "pointing somewhere else", :requires_root_or_running_windows do
346
+ let(:test_user) { "test-link-user" }
347
+ before do
348
+ user(test_user).run_action(:create)
349
+ end
350
+ after do
351
+ user(test_user).run_action(:remove)
352
+ end
295
353
  before(:each) do
354
+ resource.owner(test_user)
296
355
  @other_target = File.join(test_file_dir, make_tmpname("other_spec"))
297
356
  File.open(@other_target, "w") { |file| file.write("eek") }
298
357
  symlink(@other_target, target_file)
358
+ chown(target_file, test_user)
299
359
  expect(symlink?(target_file)).to be_truthy
300
360
  expect(readlink(target_file)).to eq(canonicalize(@other_target))
361
+ expect(owner(target_file)).to eq(expected_owner)
301
362
  end
302
363
  after(:each) do
303
364
  File.delete(@other_target)
@@ -0,0 +1,84 @@
1
+ #
2
+ # Author:: Nimisha Sharad (<nimisha.sharad@msystechnologies.com>)
3
+ # Copyright:: Copyright (c) 2016 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+ require "chef/provider/package/cab"
21
+
22
+ describe Chef::Resource::MsuPackage, :win2012r2_only do
23
+
24
+ let(:package_name) { "Package_for_KB2959977" }
25
+ let(:package_source) { "https://download.microsoft.com/download/3/B/3/3B320C07-B7B1-41E5-81F4-79EBC02DF7D3/Windows8.1-KB2959977-x64.msu" }
26
+
27
+ let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") }
28
+ let(:cab_provider) do
29
+ node = Chef::Node.new
30
+ events = Chef::EventDispatch::Dispatcher.new
31
+ run_context = Chef::RunContext.new(node, {}, events)
32
+ Chef::Provider::Package::Cab.new(new_resource, run_context)
33
+ end
34
+
35
+ subject do
36
+ new_resource = Chef::Resource::MsuPackage.new("test msu package", run_context)
37
+ new_resource.package_name package_name
38
+ new_resource.source package_source
39
+ new_resource
40
+ end
41
+
42
+ context "installing package" do
43
+ after { remove_package }
44
+
45
+ it "installs the package successfully" do
46
+ subject.run_action(:install)
47
+ found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ }
48
+ expect(found_packages.length).to be == 1
49
+ end
50
+ end
51
+
52
+ context "removing a package" do
53
+ it "removes an installed package" do
54
+ subject.run_action(:install)
55
+ remove_package
56
+ found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ }
57
+ expect(found_packages.length).to be == 0
58
+ end
59
+ end
60
+
61
+ context "when an invalid msu package is given" do
62
+ def package_name
63
+ "Package_for_KB2859903"
64
+ end
65
+
66
+ def package_source
67
+ "https://download.microsoft.com/download/5/2/B/52BE95BF-22D8-4415-B644-0FDF398F6D96/IE10-Windows6.1-KB2859903-x86.msu"
68
+ end
69
+
70
+ it "raises error while installing" do
71
+ expect { subject.run_action(:install) }.to raise_error(Chef::Exceptions::Package)
72
+ end
73
+
74
+ it "raises error while removing" do
75
+ expect { subject.run_action(:remove) }.to raise_error(Chef::Exceptions::Package)
76
+ end
77
+ end
78
+
79
+ def remove_package
80
+ pkg_to_remove = Chef::Resource::MsuPackage.new(package_name, run_context)
81
+ pkg_to_remove.source = package_source
82
+ pkg_to_remove.run_action(:remove)
83
+ end
84
+ end
@@ -112,9 +112,9 @@ describe Chef::Resource::RegistryKey, :windows_only, :broken => true do
112
112
  @node.name("windowsbox")
113
113
 
114
114
  @rest_client = double("Chef::ServerAPI (mock)")
115
- allow(@rest_client).to receive(:create_url).and_return("reports/nodes/windowsbox/runs/#{@run_id}");
116
- allow(@rest_client).to receive(:raw_http_request).and_return({ "result" => "ok" });
117
- allow(@rest_client).to receive(:post_rest).and_return({ "uri" => "https://example.com/reports/nodes/windowsbox/runs/#{@run_id}" });
115
+ allow(@rest_client).to receive(:create_url).and_return("reports/nodes/windowsbox/runs/#{@run_id}")
116
+ allow(@rest_client).to receive(:raw_http_request).and_return({ "result" => "ok" })
117
+ allow(@rest_client).to receive(:post_rest).and_return({ "uri" => "https://example.com/reports/nodes/windowsbox/runs/#{@run_id}" })
118
118
 
119
119
  @resource_reporter = Chef::ResourceReporter.new(@rest_client)
120
120
  @events.register(@resource_reporter)
@@ -21,7 +21,7 @@ require "functional/resource/base"
21
21
  require "chef/mixin/shell_out"
22
22
 
23
23
  # run this test only for following platforms.
24
- exclude_test = !%w{aix centos redhat suse}.include?(ohai[:platform])
24
+ exclude_test = !%w{aix rhel fedora suse}.include?(ohai[:platform_family])
25
25
  describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test do
26
26
  include Chef::Mixin::ShellOut
27
27
 
@@ -32,37 +32,34 @@ describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test d
32
32
  end
33
33
 
34
34
  def rpm_pkg_should_be_installed(resource)
35
- case ohai[:platform]
36
35
  # Due to dependency issues , different rpm pkgs are used in different platforms.
37
36
  # dummy rpm package works in aix, without any dependency issues.
38
- when "aix"
37
+ if ohai[:platform] == "aix"
39
38
  expect(shell_out("rpm -qa | grep dummy").exitstatus).to eq(0)
40
39
  # mytest rpm package works in centos, redhat and in suse without any dependency issues.
41
- when "centos", "redhat", "suse"
40
+ else
42
41
  expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(0)
43
42
  ::File.exists?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
44
43
  end
45
44
  end
46
45
 
47
46
  def rpm_pkg_should_not_be_installed(resource)
48
- case ohai[:platform]
49
- when "aix"
47
+ if ohai[:platform] == "aix"
50
48
  expect(shell_out("rpm -qa | grep dummy").exitstatus).to eq(1)
51
- when "centos", "redhat", "suse"
49
+ else
52
50
  expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(1)
53
51
  !::File.exists?("/opt/mytest/mytest.sh")
54
52
  end
55
53
  end
56
54
 
57
55
  before(:all) do
58
- case ohai[:platform]
59
56
  # Due to dependency issues , different rpm pkgs are used in different platforms.
60
- when "aix"
57
+ if ohai[:platform] == "aix"
61
58
  @pkg_name = "dummy"
62
59
  @pkg_version = "1-0"
63
60
  @pkg_path = "#{Dir.tmpdir}/dummy-1-0.aix6.1.noarch.rpm"
64
61
  FileUtils.cp(File.join(CHEF_SPEC_ASSETS, "dummy-1-0.aix6.1.noarch.rpm") , @pkg_path)
65
- when "centos", "redhat", "suse"
62
+ else
66
63
  @pkg_name = "mytest"
67
64
  @pkg_version = "1.0-1"
68
65
  @pkg_path = "#{Dir.tmpdir}/mytest-1.0-1.noarch.rpm"
@@ -4,6 +4,7 @@ require "chef/run_lock"
4
4
  require "chef/config"
5
5
  require "timeout"
6
6
  require "fileutils"
7
+ require "chef/win32/security" if Chef::Platform.windows?
7
8
 
8
9
  describe "chef-solo" do
9
10
  include IntegrationSupport
@@ -17,6 +18,55 @@ describe "chef-solo" do
17
18
 
18
19
  let(:chef_solo) { "ruby bin/chef-solo --legacy-mode --minimal-ohai" }
19
20
 
21
+ when_the_repository "creates nodes" do
22
+ let(:nodes_dir) { File.join(@repository_dir, "nodes") }
23
+ let(:node_file) { Dir[File.join(nodes_dir, "*.json")][0] }
24
+
25
+ before do
26
+ file "config/solo.rb", <<EOM
27
+ chef_repo_path "#{@repository_dir}"
28
+ EOM
29
+ result = shell_out("ruby bin/chef-solo -c \"#{path_to('config/solo.rb')}\" -l debug", :cwd => chef_dir)
30
+ result.error!
31
+ end
32
+
33
+ describe "on unix", :unix_only do
34
+ describe "the nodes directory" do
35
+ it "has the correct permissions" do
36
+ expect(File.stat(nodes_dir).mode.to_s(8)[2..5]).to eq("700")
37
+ end
38
+ end
39
+
40
+ describe "the node file" do
41
+ it "has the correct permissions" do
42
+ expect(File.stat(node_file).mode.to_s(8)[2..5]).to eq("0600")
43
+ end
44
+ end
45
+ end
46
+
47
+ describe "on windows", :windows_only do
48
+ let(:read_mask) { Chef::ReservedNames::Win32::API::Security::GENERIC_READ }
49
+ let(:write_mask) { Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE }
50
+ let(:execute_mask) { Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE }
51
+
52
+ describe "the nodes directory" do
53
+ it "has the correct permissions" do
54
+ expect(Chef::ReservedNames::Win32::File.file_access_check(nodes_dir, read_mask)).to be(true)
55
+ expect(Chef::ReservedNames::Win32::File.file_access_check(nodes_dir, write_mask)).to be(true)
56
+ expect(Chef::ReservedNames::Win32::File.file_access_check(nodes_dir, execute_mask)).to be(true)
57
+ end
58
+ end
59
+
60
+ describe "the node file" do
61
+ it "has the correct permissions" do
62
+ expect(Chef::ReservedNames::Win32::File.file_access_check(node_file, read_mask)).to be(true)
63
+ expect(Chef::ReservedNames::Win32::File.file_access_check(node_file, write_mask)).to be(true)
64
+ expect(Chef::ReservedNames::Win32::File.file_access_check(node_file, execute_mask)).to be(false)
65
+ end
66
+ end
67
+ end
68
+ end
69
+
20
70
  when_the_repository "has a cookbook with a basic recipe" do
21
71
  before do
22
72
  file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb