chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -1
  3. data/README.md +6 -4
  4. data/Rakefile +1 -4
  5. data/chef-windows.gemspec +21 -0
  6. data/chef.gemspec +58 -0
  7. data/lib/chef/api_client/registration.rb +9 -4
  8. data/lib/chef/application.rb +3 -84
  9. data/lib/chef/application/apply.rb +9 -2
  10. data/lib/chef/application/client.rb +8 -3
  11. data/lib/chef/application/solo.rb +7 -1
  12. data/lib/chef/application/windows_service.rb +21 -6
  13. data/lib/chef/application/windows_service_manager.rb +2 -3
  14. data/lib/chef/audit/runner.rb +1 -0
  15. data/lib/chef/chef_class.rb +1 -11
  16. data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
  17. data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
  18. data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
  19. data/lib/chef/client.rb +28 -1
  20. data/lib/chef/cookbook/cookbook_collection.rb +14 -1
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +115 -9
  23. data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
  24. data/lib/chef/cookbook_version.rb +6 -2
  25. data/lib/chef/data_bag.rb +1 -1
  26. data/lib/chef/data_bag_item.rb +1 -1
  27. data/lib/chef/digester.rb +5 -1
  28. data/lib/chef/dsl/chef_provisioning.rb +57 -0
  29. data/lib/chef/dsl/cheffish.rb +64 -0
  30. data/lib/chef/dsl/declare_resource.rb +108 -0
  31. data/lib/chef/dsl/platform_introspection.rb +3 -3
  32. data/lib/chef/dsl/recipe.rb +3 -73
  33. data/lib/chef/dsl/resources.rb +27 -1
  34. data/lib/chef/event_dispatch/base.rb +3 -0
  35. data/lib/chef/event_dispatch/dispatcher.rb +5 -0
  36. data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
  37. data/lib/chef/exceptions.rb +21 -1
  38. data/lib/chef/file_access_control/unix.rb +12 -12
  39. data/lib/chef/file_content_management/deploy/cp.rb +2 -2
  40. data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
  41. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  42. data/lib/chef/formatters/base.rb +7 -0
  43. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
  44. data/lib/chef/formatters/indentable_output_stream.rb +5 -0
  45. data/lib/chef/http.rb +19 -3
  46. data/lib/chef/http/decompressor.rb +2 -2
  47. data/lib/chef/json_compat.rb +1 -0
  48. data/lib/chef/knife.rb +16 -2
  49. data/lib/chef/knife/bootstrap.rb +55 -10
  50. data/lib/chef/knife/cookbook_site_install.rb +5 -1
  51. data/lib/chef/knife/core/bootstrap_context.rb +2 -1
  52. data/lib/chef/knife/core/node_presenter.rb +1 -1
  53. data/lib/chef/knife/ssh.rb +30 -16
  54. data/lib/chef/knife/ssl_check.rb +4 -2
  55. data/lib/chef/knife/ssl_fetch.rb +3 -2
  56. data/lib/chef/knife/status.rb +14 -1
  57. data/lib/chef/log.rb +14 -0
  58. data/lib/chef/mixin/get_source_from_package.rb +7 -2
  59. data/lib/chef/mixin/properties.rb +302 -0
  60. data/lib/chef/mixin/proxified_socket.rb +38 -0
  61. data/lib/chef/mixin/subclass_directive.rb +37 -0
  62. data/lib/chef/node.rb +13 -5
  63. data/lib/chef/platform/query_helpers.rb +14 -3
  64. data/lib/chef/platform/service_helpers.rb +20 -38
  65. data/lib/chef/policy_builder/expand_node_object.rb +3 -0
  66. data/lib/chef/policy_builder/policyfile.rb +1 -0
  67. data/lib/chef/property.rb +51 -12
  68. data/lib/chef/provider.rb +40 -35
  69. data/lib/chef/provider/deploy.rb +1 -1
  70. data/lib/chef/provider/dsc_resource.rb +54 -20
  71. data/lib/chef/provider/execute.rb +25 -4
  72. data/lib/chef/provider/group.rb +1 -1
  73. data/lib/chef/provider/lwrp_base.rb +1 -0
  74. data/lib/chef/provider/package.rb +76 -30
  75. data/lib/chef/provider/package/dpkg.rb +152 -69
  76. data/lib/chef/provider/package/openbsd.rb +6 -8
  77. data/lib/chef/provider/package/solaris.rb +2 -0
  78. data/lib/chef/provider/package/windows.rb +95 -14
  79. data/lib/chef/provider/package/windows/exe.rb +129 -0
  80. data/lib/chef/provider/package/windows/msi.rb +37 -13
  81. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
  82. data/lib/chef/provider/package/yum.rb +13 -3
  83. data/lib/chef/provider/powershell_script.rb +3 -0
  84. data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
  85. data/lib/chef/provider/remote_file/http.rb +1 -1
  86. data/lib/chef/provider/script.rb +1 -0
  87. data/lib/chef/provider/service.rb +13 -10
  88. data/lib/chef/provider/service/solaris.rb +43 -17
  89. data/lib/chef/provider/service/upstart.rb +3 -3
  90. data/lib/chef/provider/user.rb +1 -1
  91. data/lib/chef/provider/user/dscl.rb +111 -100
  92. data/lib/chef/provider/user/windows.rb +5 -3
  93. data/lib/chef/recipe.rb +3 -5
  94. data/lib/chef/resource.rb +77 -320
  95. data/lib/chef/resource/action_class.rb +4 -0
  96. data/lib/chef/resource/dpkg_package.rb +4 -3
  97. data/lib/chef/resource/dsc_resource.rb +40 -2
  98. data/lib/chef/resource/execute.rb +9 -1
  99. data/lib/chef/resource/ksh.rb +32 -0
  100. data/lib/chef/resource/lwrp_base.rb +6 -10
  101. data/lib/chef/resource/package.rb +8 -9
  102. data/lib/chef/resource/registry_key.rb +1 -1
  103. data/lib/chef/resource/resource_notification.rb +14 -1
  104. data/lib/chef/resource/script.rb +1 -1
  105. data/lib/chef/resource/windows_package.rb +1 -1
  106. data/lib/chef/resource_builder.rb +14 -7
  107. data/lib/chef/resource_reporter.rb +6 -0
  108. data/lib/chef/resources.rb +1 -7
  109. data/lib/chef/rest.rb +1 -1
  110. data/lib/chef/run_context.rb +45 -2
  111. data/lib/chef/run_list/run_list_expansion.rb +47 -0
  112. data/lib/chef/runner.rb +25 -0
  113. data/lib/chef/search/query.rb +16 -2
  114. data/lib/chef/util/diff.rb +2 -2
  115. data/lib/chef/util/powershell/ps_credential.rb +2 -3
  116. data/lib/chef/version.rb +1 -1
  117. data/lib/chef/win32/api/file.rb +51 -1
  118. data/lib/chef/win32/file.rb +5 -0
  119. data/lib/chef/win32/file/version_info.rb +93 -0
  120. data/lib/chef/win32/mutex.rb +1 -1
  121. data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
  122. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
  123. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
  124. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
  125. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
  126. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
  127. data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
  128. data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
  129. data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
  130. data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
  131. data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
  132. data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
  133. data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
  134. data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
  135. data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
  136. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
  137. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
  138. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
  139. data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
  140. data/spec/functional/application_spec.rb +1 -1
  141. data/spec/functional/audit/runner_spec.rb +4 -0
  142. data/spec/functional/knife/ssh_spec.rb +5 -5
  143. data/spec/functional/notifications_spec.rb +74 -4
  144. data/spec/functional/resource/aix_service_spec.rb +2 -2
  145. data/spec/functional/resource/dpkg_package_spec.rb +339 -0
  146. data/spec/functional/resource/ifconfig_spec.rb +3 -1
  147. data/spec/functional/resource/mount_spec.rb +5 -2
  148. data/spec/functional/resource/package_spec.rb +1 -1
  149. data/spec/functional/resource/user/windows_spec.rb +8 -0
  150. data/spec/functional/resource/windows_package_spec.rb +177 -0
  151. data/spec/functional/win32/version_info_spec.rb +50 -0
  152. data/spec/integration/client/client_spec.rb +80 -0
  153. data/spec/integration/knife/download_spec.rb +9 -0
  154. data/spec/integration/knife/upload_spec.rb +28 -1
  155. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
  156. data/spec/integration/recipes/resource_action_spec.rb +211 -116
  157. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
  158. data/spec/integration/solo/solo_spec.rb +34 -0
  159. data/spec/spec_helper.rb +11 -1
  160. data/spec/support/platform_helpers.rb +8 -0
  161. data/spec/support/shared/integration/integration_helper.rb +6 -0
  162. data/spec/support/shared/unit/execute_resource.rb +5 -0
  163. data/spec/support/shared/unit/platform_introspector.rb +7 -0
  164. data/spec/tiny_server.rb +6 -2
  165. data/spec/unit/api_client/registration_spec.rb +5 -4
  166. data/spec/unit/application_spec.rb +1 -181
  167. data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
  168. data/spec/unit/cookbook/metadata_spec.rb +122 -2
  169. data/spec/unit/http_spec.rb +102 -0
  170. data/spec/unit/knife/bootstrap_spec.rb +55 -13
  171. data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
  172. data/spec/unit/knife/ssl_check_spec.rb +7 -3
  173. data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
  174. data/spec/unit/knife/status_spec.rb +13 -13
  175. data/spec/unit/knife_spec.rb +26 -2
  176. data/spec/unit/lwrp_spec.rb +1 -1
  177. data/spec/unit/mixin/properties_spec.rb +97 -0
  178. data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
  179. data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
  180. data/spec/unit/node_spec.rb +9 -1
  181. data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
  182. data/spec/unit/property/validation_spec.rb +14 -12
  183. data/spec/unit/property_spec.rb +56 -0
  184. data/spec/unit/provider/deploy_spec.rb +1 -1
  185. data/spec/unit/provider/dsc_resource_spec.rb +63 -24
  186. data/spec/unit/provider/execute_spec.rb +95 -28
  187. data/spec/unit/provider/package/dpkg_spec.rb +185 -96
  188. data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
  189. data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
  190. data/spec/unit/provider/package/windows_spec.rb +227 -26
  191. data/spec/unit/provider/package/yum_spec.rb +6 -0
  192. data/spec/unit/provider/package_spec.rb +495 -366
  193. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
  194. data/spec/unit/provider/script_spec.rb +2 -2
  195. data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
  196. data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
  197. data/spec/unit/provider/user/dscl_spec.rb +14 -0
  198. data/spec/unit/provider/user/windows_spec.rb +2 -2
  199. data/spec/unit/provider/user_spec.rb +9 -0
  200. data/spec/unit/provider_resolver_spec.rb +6 -30
  201. data/spec/unit/recipe_spec.rb +46 -20
  202. data/spec/unit/resource/chef_gem_spec.rb +1 -1
  203. data/spec/unit/resource/dsc_resource_spec.rb +14 -3
  204. data/spec/unit/resource/ksh_spec.rb +40 -0
  205. data/spec/unit/resource/registry_key_spec.rb +2 -2
  206. data/spec/unit/resource/resource_notification_spec.rb +44 -45
  207. data/spec/unit/resource_reporter_spec.rb +7 -0
  208. data/spec/unit/resource_spec.rb +268 -253
  209. data/spec/unit/rest_spec.rb +2 -2
  210. data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
  211. data/spec/unit/search/query_spec.rb +19 -1
  212. data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
  213. data/spec/unit/windows_service_spec.rb +83 -38
  214. data/tasks/external_tests.rb +19 -9
  215. data/tasks/rspec.rb +1 -1
  216. metadata +70 -21
  217. data/spec/support/pedant/Gemfile +0 -3
  218. data/spec/support/pedant/pedant_config.rb +0 -129
  219. data/spec/support/pedant/run_pedant.rb +0 -63
  220. data/spec/support/pedant/stickywicket.pem +0 -27
  221. data/spec/unit/provider/package_spec.rbe +0 -0
@@ -22,7 +22,9 @@ require 'chef/mixin/shell_out'
22
22
  # run this test only for following platforms.
23
23
  include_flag = !(['ubuntu', 'centos', 'aix'].include?(ohai[:platform]))
24
24
 
25
- describe Chef::Resource::Ifconfig, :requires_root, :external => include_flag do
25
+ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do
26
+ # This test does not work in travis because there is no eth0
27
+
26
28
  include Chef::Mixin::ShellOut
27
29
 
28
30
  let(:new_resource) do
@@ -21,9 +21,11 @@ require 'chef/mixin/shell_out'
21
21
  require 'tmpdir'
22
22
 
23
23
  # run this test only for following platforms.
24
- include_flag = !(['ubuntu', 'centos', 'aix', 'solaris2'].include?(ohai[:platform]))
24
+ include_flag = !(['ubuntu', 'centos', 'solaris2'].include?(ohai[:platform]))
25
25
 
26
- describe Chef::Resource::Mount, :requires_root, :external => include_flag do
26
+ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => include_flag do
27
+ # Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not
28
+ # exist even after loading the kernel module
27
29
 
28
30
  include Chef::Mixin::ShellOut
29
31
 
@@ -32,6 +34,7 @@ describe Chef::Resource::Mount, :requires_root, :external => include_flag do
32
34
  def setup_device_for_mount
33
35
  # use ramdisk for creating a test device for mount.
34
36
  # This can cleaner if we have chef resource/provider for ramdisk.
37
+ # TODO: These tests only work in LPARs, not WPARs on AIX.
35
38
  case ohai[:platform]
36
39
  when "aix"
37
40
  ramdisk = shell_out!("mkramdisk 16M").stdout
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  #
3
3
  # Author:: Daniel DeLeo (<dan@opscode.com>)
4
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
4
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -66,6 +66,14 @@ describe Chef::Provider::User::Windows, :windows_only do
66
66
  new_resource.run_action(:create)
67
67
  expect(new_resource).to be_updated_by_last_action
68
68
  end
69
+
70
+ context 'with a gid specified' do
71
+ it 'warns unsupported' do
72
+ expect(Chef::Log).to receive(:warn).with(/not implemented/)
73
+ new_resource.gid('agroup')
74
+ new_resource.run_action(:create)
75
+ end
76
+ end
69
77
  end
70
78
 
71
79
  describe 'action :remove' do
@@ -0,0 +1,177 @@
1
+ #
2
+ # Author:: Matt Wrock (<matt@mattwrock.com>)
3
+ # Copyright:: Copyright (c) 2015 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 'functional/resource/base'
21
+
22
+ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do
23
+ let(:pkg_name) { nil }
24
+ let(:pkg_path) { nil }
25
+ let(:pkg_checksum) { nil }
26
+ let(:pkg_version) { nil }
27
+ let(:pkg_type) { nil }
28
+ let(:pkg_options) { nil }
29
+
30
+ subject do
31
+ new_resource = Chef::Resource::WindowsPackage.new(pkg_name, run_context)
32
+ new_resource.source pkg_path
33
+ new_resource.version pkg_version
34
+ new_resource.installer_type pkg_type
35
+ new_resource.options pkg_options
36
+ new_resource.checksum pkg_checksum
37
+ new_resource
38
+ end
39
+
40
+ describe "multi package scenario" do
41
+ let(:pkg_name) { 'Microsoft Visual C++ 2005 Redistributable' }
42
+ let(:pkg_path) { 'https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe' }
43
+ let(:pkg_checksum) { nil }
44
+ let(:pkg_version) { '8.0.59193' }
45
+ let(:pkg_type) { :custom }
46
+ let(:pkg_options) { "/Q" }
47
+
48
+ it "updates resource on first install" do
49
+ subject.run_action(:install)
50
+ expect(subject).to be_updated_by_last_action
51
+ end
52
+
53
+ it "does not update resource when already installed" do
54
+ subject.run_action(:install)
55
+ expect(subject).not_to be_updated_by_last_action
56
+ end
57
+
58
+ context "installing additional version" do
59
+ let(:pkg_path) { 'https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe' }
60
+ let(:pkg_version) { '8.0.56336' }
61
+
62
+ it "installs older version" do
63
+ subject.run_action(:install)
64
+ expect(subject).to be_updated_by_last_action
65
+ end
66
+ end
67
+
68
+ describe "removing package" do
69
+ subject { Chef::Resource::WindowsPackage.new(pkg_name, run_context) }
70
+
71
+ context "multiple versions and a version given to remove" do
72
+ before { subject.version('8.0.56336')}
73
+
74
+ it "removes specified version" do
75
+ subject.run_action(:remove)
76
+ expect(subject).to be_updated_by_last_action
77
+ prov = subject.provider_for_action(:remove)
78
+ prov.load_current_resource
79
+ expect(prov.current_version_array).to eq([['8.0.59193']])
80
+ end
81
+ end
82
+
83
+ context "single version installed and no version given to remove" do
84
+ it "removes last remaining version" do
85
+ subject.run_action(:remove)
86
+ expect(subject).to be_updated_by_last_action
87
+ prov = subject.provider_for_action(:remove)
88
+ prov.load_current_resource
89
+ expect(prov.current_version_array).to eq([nil])
90
+ end
91
+ end
92
+
93
+ describe "removing multiple versions at once" do
94
+ let(:pkg_version) { nil }
95
+ before do
96
+ install1 = Chef::Resource::WindowsPackage.new(pkg_name, run_context)
97
+ install1.source pkg_path
98
+ install1.version pkg_version
99
+ install1.installer_type pkg_type
100
+ install1.options pkg_options
101
+ install1.run_action(:install)
102
+
103
+ install2 = Chef::Resource::WindowsPackage.new(pkg_name, run_context)
104
+ install2.source 'https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe'
105
+ install2.version '8.0.56336'
106
+ install2.installer_type pkg_type
107
+ install2.options pkg_options
108
+ install2.run_action(:install)
109
+ end
110
+
111
+ it "removes all versions" do
112
+ subject.run_action(:remove)
113
+ expect(subject).to be_updated_by_last_action
114
+ prov = subject.provider_for_action(:remove)
115
+ prov.load_current_resource
116
+ expect(prov.current_version_array).to eq([nil])
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ describe "package version and installer type" do
123
+ after { subject.run_action(:remove) }
124
+
125
+ context "null soft" do
126
+ let(:pkg_name) { 'Ultra Defragmenter' }
127
+ let(:pkg_path) { 'http://iweb.dl.sourceforge.net/project/ultradefrag/stable-release/6.1.1/ultradefrag-6.1.1.bin.amd64.exe' }
128
+ let(:pkg_checksum) { '11d53ed4c426c8c867ad43f142b7904226ffd9938c02e37086913620d79e3c09' }
129
+
130
+ it "finds the correct package version" do
131
+ subject.run_action(:install)
132
+ expect(subject.version).to eq('6.1.1')
133
+ end
134
+
135
+ it "finds the correct installer type" do
136
+ subject.run_action(:install)
137
+ expect(subject.provider_for_action(:install).installer_type).to eq(:nsis)
138
+ end
139
+ end
140
+
141
+ context "inno" do
142
+ let(:pkg_name) { 'Mercurial 3.6.1 (64-bit)' }
143
+ let(:pkg_path) { 'http://mercurial.selenic.com/release/windows/Mercurial-3.6.1-x64.exe' }
144
+ let(:pkg_checksum) { 'febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d' }
145
+
146
+ it "finds the correct package version" do
147
+ subject.run_action(:install)
148
+ expect(subject.version).to eq(nil) # Mercurial does not include versioning
149
+ end
150
+
151
+ it "finds the correct installer type" do
152
+ subject.run_action(:install)
153
+ expect(subject.provider_for_action(:install).installer_type).to eq(:inno)
154
+ end
155
+ end
156
+ end
157
+
158
+ describe "install from local file" do
159
+ let(:pkg_name) { 'Mercurial 3.6.1 (64-bit)' }
160
+ let(:pkg_path) { ::File.join(Chef::Config[:file_cache_path], "package", "Mercurial-3.6.1-x64.exe") }
161
+ let(:pkg_checksum) { 'febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d' }
162
+
163
+ it "installs the app" do
164
+ subject.run_action(:install)
165
+ expect(subject).to be_updated_by_last_action
166
+ end
167
+ end
168
+
169
+ describe "uninstall exe without source" do
170
+ let(:pkg_name) { 'Mercurial 3.6.1 (64-bit)' }
171
+
172
+ it "uninstalls the app" do
173
+ subject.run_action(:remove)
174
+ expect(subject).to be_updated_by_last_action
175
+ end
176
+ end
177
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ # Author:: Matt Wrock (<matt@mattwrock.com>)
3
+ # Copyright:: Copyright 2015 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
+ if Chef::Platform.windows?
21
+ require 'chef/win32/file/version_info'
22
+ end
23
+
24
+ describe "Chef::ReservedNames::Win32::File::VersionInfo", :windows_only do
25
+ require 'wmi-lite/wmi'
26
+ let(:file_path) { ENV['ComSpec'] }
27
+ let(:os_version) do
28
+ wmi = WmiLite::Wmi.new
29
+ os_info = wmi.first_of('Win32_OperatingSystem')
30
+ os_info['version']
31
+ end
32
+
33
+ subject { Chef::ReservedNames::Win32::File::VersionInfo.new(file_path) }
34
+
35
+ it "file version has the same version as windows" do
36
+ expect(subject.FileVersion).to start_with(os_version)
37
+ end
38
+
39
+ it "product version has the same version as windows" do
40
+ expect(subject.ProductVersion).to start_with(os_version)
41
+ end
42
+
43
+ it "company is microsoft" do
44
+ expect(subject.CompanyName).to eq("Microsoft Corporation")
45
+ end
46
+
47
+ it "file description is command processor" do
48
+ expect(subject.FileDescription).to eq("Windows Command Processor")
49
+ end
50
+ end
@@ -301,6 +301,86 @@ EOM
301
301
  result.error!
302
302
  end
303
303
 
304
+ it "should complete with success when using --profile-ruby and output a profile file" do
305
+ file 'config/client.rb', <<EOM
306
+ local_mode true
307
+ cookbook_path "#{path_to('cookbooks')}"
308
+ EOM
309
+ result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z --profile-ruby", :cwd => chef_dir)
310
+ expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be true
311
+ end
312
+
313
+ it "doesn't produce a profile when --profile-ruby is not present" do
314
+ file 'config/client.rb', <<EOM
315
+ local_mode true
316
+ cookbook_path "#{path_to('cookbooks')}"
317
+ EOM
318
+ result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' -z", :cwd => chef_dir)
319
+ expect(File.exist?(path_to("config/local-mode-cache/cache/graph_profile.out"))).to be false
320
+ end
321
+ end
322
+
323
+ when_the_repository "has a cookbook that should fail chef_version checks" do
324
+ before do
325
+ file 'cookbooks/x/recipes/default.rb', ''
326
+ file 'cookbooks/x/metadata.rb', <<EOM
327
+ name 'x'
328
+ version '0.0.1'
329
+ chef_version '~> 999.99'
330
+ EOM
331
+ file 'config/client.rb', <<EOM
332
+ local_mode true
333
+ cookbook_path "#{path_to('cookbooks')}"
334
+ EOM
335
+ end
336
+ it "should fail the chef client run" do
337
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
338
+ expect(command.exitstatus).to eql(1)
339
+ expect(command.stdout).to match(/Chef::Exceptions::CookbookChefVersionMismatch/)
340
+ end
341
+ end
342
+
343
+ when_the_repository "has a cookbook that uses cheffish resources" do
344
+ before do
345
+ file 'cookbooks/x/recipes/default.rb', <<-EOM
346
+ raise "Cheffish was loaded before we used any cheffish things!" if defined?(Cheffish::VERSION)
347
+ ran_block = false
348
+ got_server = with_chef_server 'https://blah.com' do
349
+ ran_block = true
350
+ run_context.cheffish.current_chef_server
351
+ end
352
+ raise "with_chef_server block was not run!" if !ran_block
353
+ raise "Cheffish was not loaded when we did cheffish things!" if !defined?(Cheffish::VERSION)
354
+ raise "current_chef_server did not return its value!" if got_server[:chef_server_url] != 'https://blah.com'
355
+ EOM
356
+ file 'config/client.rb', <<-EOM
357
+ local_mode true
358
+ cookbook_path "#{path_to('cookbooks')}"
359
+ EOM
360
+ end
361
+
362
+ it "the cheffish DSL is loaded lazily" do
363
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
364
+ expect(command.exitstatus).to eql(0)
365
+ end
366
+ end
367
+
368
+ when_the_repository "has a cookbook that uses chef-provisioning resources" do
369
+ before do
370
+ file 'cookbooks/x/recipes/default.rb', <<-EOM
371
+ with_driver 'blah'
372
+ EOM
373
+ file 'config/client.rb', <<-EOM
374
+ local_mode true
375
+ cookbook_path "#{path_to('cookbooks')}"
376
+ EOM
377
+ end
378
+
379
+ it "the cheffish DSL tries to load but fails (because chef-provisioning is not there)" do
380
+ command = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default' --no-fork", :cwd => chef_dir)
381
+ expect(command.exitstatus).to eql(1)
382
+ expect(command.stdout).to match(/cannot load such file -- chef\/provisioning/)
383
+ end
304
384
  end
305
385
 
306
386
  when_the_repository "has a cookbook that generates deprecation warnings" do
@@ -1103,6 +1103,15 @@ EOM
1103
1103
  before :each do
1104
1104
  Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo')
1105
1105
  end
1106
+ when_the_repository 'has existing top level files' do
1107
+ before do
1108
+ file 'invitations.json', {}
1109
+ end
1110
+
1111
+ it "can still download top level files" do
1112
+ knife('download /invitations.json').should_succeed
1113
+ end
1114
+ end
1106
1115
 
1107
1116
  when_the_repository 'is empty' do
1108
1117
  it 'knife download / downloads everything' do
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -699,6 +699,19 @@ EOH
699
699
  end
700
700
  end
701
701
  end
702
+ when_the_chef_server "is empty" do
703
+ when_the_repository 'has a cookbook with an invalid chef_version constraint in it' do
704
+ before do
705
+ file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'")
706
+ end
707
+ it 'knife upload succeeds' do
708
+ knife('upload /cookbooks/x').should_succeed <<EOM
709
+ Created /cookbooks/x
710
+ EOM
711
+ knife('diff --name-status /cookbooks').should_succeed ''
712
+ end
713
+ end
714
+ end
702
715
  end # without versioned cookbooks
703
716
 
704
717
  with_versioned_cookbooks do
@@ -1219,6 +1232,20 @@ EOM
1219
1232
  end
1220
1233
  end
1221
1234
  end
1235
+
1236
+ when_the_chef_server "is empty" do
1237
+ when_the_repository 'has a cookbook with an invalid chef_version constraint in it' do
1238
+ before do
1239
+ file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'")
1240
+ end
1241
+ it 'knife upload succeeds' do
1242
+ knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM
1243
+ Created /cookbooks/x-1.0.0
1244
+ EOM
1245
+ knife('diff --name-status /cookbooks').should_succeed ''
1246
+ end
1247
+ end
1248
+ end
1222
1249
  end # with versioned cookbooks
1223
1250
 
1224
1251
  when_the_chef_server 'has a user' do
@@ -18,35 +18,105 @@ describe "LWRPs with inline resources" do
18
18
  # cf. CHEF-4914
19
19
  let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" }
20
20
 
21
+ context "with a use_inline_resources provider with 'def action_a' instead of action :a" do
22
+ class LwrpInlineResourcesTest < Chef::Resource::LWRPBase
23
+ resource_name :lwrp_inline_resources_test
24
+ actions :a, :nothing
25
+ default_action :a
26
+ property :ran_a
27
+ class Provider < Chef::Provider::LWRPBase
28
+ provides :lwrp_inline_resources_test
29
+ use_inline_resources
30
+ def action_a
31
+ r = new_resource
32
+ ruby_block 'run a' do
33
+ block { r.ran_a "ran a" }
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ it "this is totally a bug, but for backcompat purposes, it adds the resources to the main resource collection and does not get marked updated" do
40
+ r = nil
41
+ expect_recipe {
42
+ r = lwrp_inline_resources_test 'hi'
43
+ }.to have_updated('ruby_block[run a]', :run)
44
+ expect(r.ran_a).to eq "ran a"
45
+ end
46
+ end
47
+
48
+ context "with an inline_resources provider with two actions, one calling the other" do
49
+ class LwrpInlineResourcesTest2 < Chef::Resource::LWRPBase
50
+ resource_name :lwrp_inline_resources_test2
51
+ actions :a, :b, :nothing
52
+ default_action :b
53
+ property :ran_a
54
+ property :ran_b
55
+ class Provider < Chef::Provider::LWRPBase
56
+ provides :lwrp_inline_resources_test2
57
+ use_inline_resources
58
+
59
+ action :a do
60
+ r = new_resource
61
+ ruby_block 'run a' do
62
+ block { r.ran_a "ran a" }
63
+ end
64
+ end
65
+
66
+ action :b do
67
+ action_a
68
+ r = new_resource
69
+ # Grab ran_a right now, before we converge
70
+ ran_a = r.ran_a
71
+ ruby_block 'run b' do
72
+ block { r.ran_b "ran b: ran_a value was #{ran_a.inspect}" }
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ it "resources declared in b are executed immediately inline" do
79
+ r = nil
80
+ expect_recipe {
81
+ r = lwrp_inline_resources_test2 'hi' do
82
+ action :b
83
+ end
84
+ }.to have_updated('lwrp_inline_resources_test2[hi]', :b).
85
+ and have_updated('ruby_block[run a]', :run).
86
+ and have_updated('ruby_block[run b]', :run)
87
+ expect(r.ran_b).to eq "ran b: ran_a value was \"ran a\""
88
+ end
89
+ end
90
+
21
91
  when_the_repository "has a cookbook with a nested LWRP" do
22
92
  before do
23
93
  directory 'cookbooks/x' do
24
94
 
25
- file 'resources/do_nothing.rb', <<EOM
26
- actions :create, :nothing
27
- default_action :create
28
- EOM
29
- file 'providers/do_nothing.rb', <<EOM
30
- action :create do
31
- end
32
- EOM
95
+ file 'resources/do_nothing.rb', <<-EOM
96
+ actions :create, :nothing
97
+ default_action :create
98
+ EOM
99
+ file 'providers/do_nothing.rb', <<-EOM
100
+ action :create do
101
+ end
102
+ EOM
33
103
 
34
- file 'resources/my_machine.rb', <<EOM
35
- actions :create, :nothing
36
- default_action :create
37
- EOM
38
- file 'providers/my_machine.rb', <<EOM
39
- use_inline_resources
40
- action :create do
41
- x_do_nothing 'a'
42
- x_do_nothing 'b'
43
- end
44
- EOM
104
+ file 'resources/my_machine.rb', <<-EOM
105
+ actions :create, :nothing
106
+ default_action :create
107
+ EOM
108
+ file 'providers/my_machine.rb', <<-EOM
109
+ use_inline_resources
110
+ action :create do
111
+ x_do_nothing 'a'
112
+ x_do_nothing 'b'
113
+ end
114
+ EOM
45
115
 
46
- file 'recipes/default.rb', <<EOM
47
- x_my_machine "me"
48
- x_my_machine "you"
49
- EOM
116
+ file 'recipes/default.rb', <<-EOM
117
+ x_my_machine "me"
118
+ x_my_machine "you"
119
+ EOM
50
120
 
51
121
  end # directory 'cookbooks/x'
52
122
  end