chef 12.17.44-universal-mingw32 → 12.18.31-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/README.md +3 -2
  4. data/Rakefile +9 -0
  5. data/VERSION +1 -1
  6. data/acceptance/Gemfile.lock +17 -17
  7. data/distro/common/html/knife_environment.html +4 -8
  8. data/distro/common/man/man1/knife-environment.1 +4 -16
  9. data/distro/powershell/chef/chef.psm1 +139 -24
  10. data/lib/chef/application.rb +5 -4
  11. data/lib/chef/application/windows_service_manager.rb +6 -4
  12. data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
  13. data/lib/chef/chef_fs/command_line.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
  17. data/lib/chef/cookbook/chefignore.rb +1 -1
  18. data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
  19. data/lib/chef/cookbook/metadata.rb +2 -2
  20. data/lib/chef/cookbook_loader.rb +1 -1
  21. data/lib/chef/data_collector.rb +24 -13
  22. data/lib/chef/data_collector/messages.rb +8 -6
  23. data/lib/chef/data_collector/messages/helpers.rb +1 -1
  24. data/lib/chef/deprecated.rb +30 -0
  25. data/lib/chef/dsl/platform_introspection.rb +2 -2
  26. data/lib/chef/encrypted_data_bag_item.rb +1 -1
  27. data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
  28. data/lib/chef/environment.rb +1 -1
  29. data/lib/chef/exceptions.rb +5 -5
  30. data/lib/chef/file_access_control/unix.rb +5 -5
  31. data/lib/chef/formatters/error_description.rb +1 -1
  32. data/lib/chef/http/basic_client.rb +1 -1
  33. data/lib/chef/http/json_input.rb +2 -2
  34. data/lib/chef/knife.rb +1 -1
  35. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  36. data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
  37. data/lib/chef/knife/core/ui.rb +1 -1
  38. data/lib/chef/mixin/command.rb +1 -0
  39. data/lib/chef/mixin/deep_merge.rb +1 -1
  40. data/lib/chef/mixin/shell_out.rb +58 -3
  41. data/lib/chef/mixin/which.rb +5 -9
  42. data/lib/chef/mixin/wide_string.rb +1 -1
  43. data/lib/chef/node.rb +1 -1
  44. data/lib/chef/node/attribute.rb +4 -5
  45. data/lib/chef/node_map.rb +18 -2
  46. data/lib/chef/platform/provider_handler_map.rb +2 -2
  47. data/lib/chef/platform/provider_mapping.rb +5 -0
  48. data/lib/chef/platform/resource_handler_map.rb +2 -2
  49. data/lib/chef/provider/env/windows.rb +1 -1
  50. data/lib/chef/provider/git.rb +1 -1
  51. data/lib/chef/provider/group.rb +41 -46
  52. data/lib/chef/provider/group/aix.rb +12 -19
  53. data/lib/chef/provider/group/dscl.rb +46 -43
  54. data/lib/chef/provider/group/gpasswd.rb +7 -7
  55. data/lib/chef/provider/group/groupadd.rb +29 -34
  56. data/lib/chef/provider/group/groupmod.rb +26 -31
  57. data/lib/chef/provider/group/pw.rb +28 -31
  58. data/lib/chef/provider/group/suse.rb +9 -9
  59. data/lib/chef/provider/group/usermod.rb +10 -11
  60. data/lib/chef/provider/group/windows.rb +18 -20
  61. data/lib/chef/provider/ifconfig.rb +52 -63
  62. data/lib/chef/provider/ifconfig/aix.rb +23 -28
  63. data/lib/chef/provider/ifconfig/debian.rb +23 -22
  64. data/lib/chef/provider/ifconfig/redhat.rb +12 -12
  65. data/lib/chef/provider/mount/mount.rb +1 -1
  66. data/lib/chef/provider/osx_profile.rb +4 -2
  67. data/lib/chef/provider/package.rb +16 -7
  68. data/lib/chef/provider/package/chocolatey.rb +3 -1
  69. data/lib/chef/provider/package/dnf.rb +183 -0
  70. data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
  71. data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
  72. data/lib/chef/provider/package/dnf/version.rb +56 -0
  73. data/lib/chef/provider/package/easy_install.rb +1 -1
  74. data/lib/chef/provider/package/freebsd/base.rb +1 -1
  75. data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
  76. data/lib/chef/provider/package/powershell.rb +3 -3
  77. data/lib/chef/provider/package/windows.rb +1 -1
  78. data/lib/chef/provider/package/zypper.rb +1 -1
  79. data/lib/chef/provider/route.rb +186 -184
  80. data/lib/chef/provider/service/arch.rb +2 -2
  81. data/lib/chef/provider/service/freebsd.rb +1 -1
  82. data/lib/chef/provider/service/gentoo.rb +2 -2
  83. data/lib/chef/provider/service/insserv.rb +2 -2
  84. data/lib/chef/provider/service/macosx.rb +2 -2
  85. data/lib/chef/provider/service/openbsd.rb +1 -1
  86. data/lib/chef/provider/service/redhat.rb +2 -2
  87. data/lib/chef/provider/support/yum_repo.erb +10 -3
  88. data/lib/chef/provider/user.rb +17 -20
  89. data/lib/chef/provider/user/aix.rb +23 -24
  90. data/lib/chef/provider/user/dscl.rb +56 -53
  91. data/lib/chef/provider/user/linux.rb +13 -16
  92. data/lib/chef/provider/user/pw.rb +26 -30
  93. data/lib/chef/provider/user/solaris.rb +11 -12
  94. data/lib/chef/provider/user/useradd.rb +20 -22
  95. data/lib/chef/provider/user/windows.rb +19 -22
  96. data/lib/chef/provider_resolver.rb +4 -2
  97. data/lib/chef/providers.rb +1 -0
  98. data/lib/chef/resource.rb +7 -0
  99. data/lib/chef/resource/chocolatey_package.rb +1 -0
  100. data/lib/chef/resource/dnf_package.rb +64 -0
  101. data/lib/chef/resource/file/verification.rb +6 -4
  102. data/lib/chef/resource/yum_package.rb +18 -14
  103. data/lib/chef/resource/yum_repository.rb +1 -1
  104. data/lib/chef/resource_reporter.rb +11 -0
  105. data/lib/chef/resources.rb +1 -0
  106. data/lib/chef/scan_access_control.rb +4 -4
  107. data/lib/chef/util/dsc/resource_store.rb +1 -1
  108. data/lib/chef/version.rb +1 -1
  109. data/lib/chef/win32/memory.rb +1 -1
  110. data/lib/chef/win32/security.rb +2 -2
  111. data/lib/chef/win32/security/sid.rb +2 -2
  112. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
  113. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
  114. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
  115. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
  116. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
  117. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
  118. data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
  119. data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
  120. data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
  121. data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
  122. data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
  123. data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
  124. data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
  125. data/spec/functional/resource/dnf_package_spec.rb +686 -0
  126. data/spec/functional/resource/dsc_script_spec.rb +1 -0
  127. data/spec/functional/resource/user/useradd_spec.rb +10 -1
  128. data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
  129. data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
  130. data/spec/integration/recipes/resource_load_spec.rb +3 -3
  131. data/spec/spec_helper.rb +5 -3
  132. data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
  133. data/spec/support/lib/chef/resource/cat.rb +1 -0
  134. data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
  135. data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
  136. data/spec/support/lib/chef/resource/with_state.rb +2 -0
  137. data/spec/support/lib/chef/resource/zen_master.rb +1 -0
  138. data/spec/unit/cookbook/metadata_spec.rb +3 -3
  139. data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
  140. data/spec/unit/data_collector_spec.rb +56 -0
  141. data/spec/unit/decorator/lazy_spec.rb +1 -1
  142. data/spec/unit/environment_spec.rb +1 -1
  143. data/spec/unit/lwrp_spec.rb +3 -4
  144. data/spec/unit/node_spec.rb +23 -2
  145. data/spec/unit/platform_spec.rb +1 -0
  146. data/spec/unit/provider/group/dscl_spec.rb +29 -29
  147. data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
  148. data/spec/unit/provider/group/groupadd_spec.rb +31 -30
  149. data/spec/unit/provider/group/groupmod_spec.rb +16 -16
  150. data/spec/unit/provider/group/pw_spec.rb +11 -11
  151. data/spec/unit/provider/group/suse_spec.rb +5 -5
  152. data/spec/unit/provider/group/usermod_spec.rb +15 -15
  153. data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
  154. data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
  155. data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
  156. data/spec/unit/provider/ifconfig_spec.rb +18 -19
  157. data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
  158. data/spec/unit/provider/package/msu_spec.rb +1 -1
  159. data/spec/unit/provider/route_spec.rb +21 -21
  160. data/spec/unit/provider/user/dscl_spec.rb +54 -57
  161. data/spec/unit/provider/user/linux_spec.rb +5 -5
  162. data/spec/unit/provider/user/pw_spec.rb +26 -22
  163. data/spec/unit/provider/user/windows_spec.rb +4 -4
  164. data/spec/unit/provider/user_spec.rb +19 -21
  165. data/spec/unit/provider_resolver_spec.rb +1 -0
  166. data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
  167. data/spec/unit/resource/dnf_package_spec.rb +99 -0
  168. data/spec/unit/resource/remote_file_spec.rb +2 -2
  169. data/spec/unit/resource/yum_package_spec.rb +20 -0
  170. data/spec/unit/resource_reporter_spec.rb +24 -0
  171. data/spec/unit/resource_spec.rb +2 -0
  172. data/spec/unit/runner_spec.rb +1 -0
  173. data/tasks/bin/bundle-platform +1 -1
  174. data/tasks/gemfile_util.rb +2 -2
  175. data/tasks/templates/prerelease.md.erb +1 -10
  176. data/tasks/templates/release.md.erb +1 -9
  177. metadata +24 -5
  178. data/lib/chef/platform/handler_map.rb +0 -40
@@ -48,7 +48,7 @@ IFCONFIG
48
48
 
49
49
  describe "#load_current_resource" do
50
50
  before do
51
- @status = double(:stdout => @ifconfig_output, :exitstatus => 0)
51
+ @status = double(stdout: @ifconfig_output, exitstatus: 0)
52
52
  allow(@provider).to receive(:shell_out).and_return(@status)
53
53
  @new_resource.device "en0"
54
54
  end
@@ -68,11 +68,11 @@ IFCONFIG
68
68
  it "should add an interface if it does not exist" do
69
69
  @new_resource.device "en10"
70
70
  allow(@provider).to receive(:load_current_resource) do
71
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
71
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
72
72
  @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
73
73
  end
74
74
  command = "chdev -l #{@new_resource.device} -a netaddr=#{@new_resource.name}"
75
- expect(@provider).to receive(:run_command).with(:command => command)
75
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
76
76
 
77
77
  @provider.run_action(:add)
78
78
  expect(@new_resource).to be_updated
@@ -82,7 +82,7 @@ IFCONFIG
82
82
  @new_resource.device "en0"
83
83
  @new_resource.metric "1"
84
84
  allow(@provider).to receive(:load_current_resource) do
85
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
85
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
86
86
  @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
87
87
  end
88
88
 
@@ -94,11 +94,11 @@ IFCONFIG
94
94
  it "should enable an interface if it does not exist" do
95
95
  @new_resource.device "en10"
96
96
  allow(@provider).to receive(:load_current_resource) do
97
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
97
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
98
98
  @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
99
99
  end
100
100
  command = "ifconfig #{@new_resource.device} #{@new_resource.name}"
101
- expect(@provider).to receive(:run_command).with(:command => command)
101
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
102
102
 
103
103
  @provider.run_action(:enable)
104
104
  expect(@new_resource).to be_updated
@@ -110,11 +110,11 @@ IFCONFIG
110
110
  it "should not disable an interface if it does not exist" do
111
111
  @new_resource.device "en10"
112
112
  allow(@provider).to receive(:load_current_resource) do
113
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
113
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
114
114
  @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
115
115
  end
116
116
 
117
- expect(@provider).not_to receive(:run_command)
117
+ expect(@provider).not_to receive(:shell_out!)
118
118
 
119
119
  @provider.run_action(:disable)
120
120
  expect(@new_resource).not_to be_updated
@@ -124,7 +124,7 @@ IFCONFIG
124
124
  before do
125
125
  @new_resource.device "en10"
126
126
  allow(@provider).to receive(:load_current_resource) do
127
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
127
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
128
128
  current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
129
129
  current_resource.device @new_resource.device
130
130
  @provider.instance_variable_set("@current_resource", current_resource)
@@ -133,7 +133,7 @@ IFCONFIG
133
133
 
134
134
  it "should disable an interface if it exists" do
135
135
  command = "ifconfig #{@new_resource.device} down"
136
- expect(@provider).to receive(:run_command).with(:command => command)
136
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
137
137
 
138
138
  @provider.run_action(:disable)
139
139
  expect(@new_resource).to be_updated
@@ -147,11 +147,11 @@ IFCONFIG
147
147
  it "should not delete an interface if it does not exist" do
148
148
  @new_resource.device "en10"
149
149
  allow(@provider).to receive(:load_current_resource) do
150
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
150
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
151
151
  @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context))
152
152
  end
153
153
 
154
- expect(@provider).not_to receive(:run_command)
154
+ expect(@provider).not_to receive(:shell_out!)
155
155
 
156
156
  @provider.run_action(:delete)
157
157
  expect(@new_resource).not_to be_updated
@@ -161,7 +161,7 @@ IFCONFIG
161
161
  before do
162
162
  @new_resource.device "en10"
163
163
  allow(@provider).to receive(:load_current_resource) do
164
- @provider.instance_variable_set("@status", double("Status", :exitstatus => 0))
164
+ @provider.instance_variable_set("@status", double("Status", exitstatus: 0))
165
165
  current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
166
166
  current_resource.device @new_resource.device
167
167
  @provider.instance_variable_set("@current_resource", current_resource)
@@ -170,7 +170,7 @@ IFCONFIG
170
170
 
171
171
  it "should delete an interface if it exists" do
172
172
  command = "chdev -l #{@new_resource.device} -a state=down"
173
- expect(@provider).to receive(:run_command).with(:command => command)
173
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
174
174
 
175
175
  @provider.run_action(:delete)
176
176
  expect(@new_resource).to be_updated
@@ -40,12 +40,12 @@ describe Chef::Provider::Ifconfig::Debian do
40
40
  let(:current_resource) { Chef::Resource::Ifconfig.new("10.0.0.1", run_context) }
41
41
 
42
42
  let(:provider) do
43
- status = double("Status", :exitstatus => 0)
43
+ status = double("Status", exitstatus: 0)
44
44
  provider = Chef::Provider::Ifconfig::Debian.new(new_resource, run_context)
45
45
  provider.instance_variable_set("@status", status)
46
46
  provider.current_resource = current_resource
47
47
  allow(provider).to receive(:load_current_resource)
48
- allow(provider).to receive(:run_command)
48
+ allow(provider).to receive(:shell_out!)
49
49
  provider
50
50
  end
51
51
 
@@ -77,12 +77,12 @@ describe Chef::Provider::Ifconfig::Debian do
77
77
  context "when the interface_dot_d directory does not exist" do
78
78
  before do
79
79
  FileUtils.rmdir tempdir_path
80
- expect(File.exists?(tempdir_path)).to be_falsey
80
+ expect(File.exist?(tempdir_path)).to be_falsey
81
81
  end
82
82
 
83
83
  it "should create the /etc/network/interfaces.d directory" do
84
84
  provider.run_action(:add)
85
- expect(File.exists?(tempdir_path)).to be_truthy
85
+ expect(File.exist?(tempdir_path)).to be_truthy
86
86
  expect(File.directory?(tempdir_path)).to be_truthy
87
87
  end
88
88
 
@@ -94,7 +94,7 @@ describe Chef::Provider::Ifconfig::Debian do
94
94
 
95
95
  context "when the interface_dot_d directory exists" do
96
96
  before do
97
- expect(File.exists?(tempdir_path)).to be_truthy
97
+ expect(File.exist?(tempdir_path)).to be_truthy
98
98
  end
99
99
 
100
100
  it "should still mark the resource as updated (we still write a file to it)" do
@@ -114,13 +114,7 @@ describe Chef::Provider::Ifconfig::Debian do
114
114
  before do
115
115
  stub_const("Chef::Provider::Ifconfig::Debian::INTERFACES_FILE", tempfile.path)
116
116
  stub_const("Chef::Provider::Ifconfig::Debian::INTERFACES_DOT_D_DIR", tempdir_path)
117
- config_file_ifcfg = StringIO.new(<<-EOF
118
- iface eth0 inet static
119
- address 10.0.0.1
120
- netmask 255.255.254.0
121
- EOF
122
- )
123
- expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
117
+ expect(File.exist?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
124
118
  end
125
119
 
126
120
  context "when the /etc/network/interfaces file has the source line" do
@@ -210,12 +204,12 @@ EOF
210
204
  context "when the interface_dot_d directory does not exist" do
211
205
  before do
212
206
  FileUtils.rmdir tempdir_path
213
- expect(File.exists?(tempdir_path)).to be_falsey
207
+ expect(File.exist?(tempdir_path)).to be_falsey
214
208
  end
215
209
 
216
210
  it "should not create the /etc/network/interfaces.d directory" do
217
211
  provider.run_action(:add)
218
- expect(File.exists?(tempdir_path)).not_to be_truthy
212
+ expect(File.exist?(tempdir_path)).not_to be_truthy
219
213
  end
220
214
 
221
215
  it "should mark the resource as updated" do
@@ -226,7 +220,7 @@ EOF
226
220
 
227
221
  context "when the interface_dot_d directory exists" do
228
222
  before do
229
- expect(File.exists?(tempdir_path)).to be_truthy
223
+ expect(File.exist?(tempdir_path)).to be_truthy
230
224
  end
231
225
 
232
226
  it "should still mark the resource as updated (we still write a file to it)" do
@@ -246,14 +240,8 @@ EOF
246
240
  before do
247
241
  stub_const("Chef::Provider::Ifconfig::Debian::INTERFACES_FILE", tempfile.path)
248
242
  stub_const("Chef::Provider::Ifconfig::Debian::INTERFACES_DOT_D_DIR", tempdir_path)
249
- config_file_ifcfg = StringIO.new(<<-EOF
250
- iface eth0 inet static
251
- address 10.0.0.1
252
- netmask 255.255.254.0
253
- EOF
254
- )
255
243
  expect(File).not_to receive(:new).with(config_filename_ifcfg, "w")
256
- expect(File.exists?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
244
+ expect(File.exist?(tempdir_path)).to be_truthy # since the file exists, the enclosing dir must also exist
257
245
  end
258
246
 
259
247
  context "when the /etc/network/interfaces file has the source line" do
@@ -25,7 +25,7 @@ describe Chef::Provider::Ifconfig::Redhat do
25
25
  @cookbook_collection = Chef::CookbookCollection.new([])
26
26
  @events = Chef::EventDispatch::Dispatcher.new
27
27
  @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
28
- #This new_resource can be called anything --> it is not the same as in ifconfig.rb
28
+ # This new_resource can be called anything --> it is not the same as in ifconfig.rb
29
29
  @new_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
30
30
  @new_resource.mask "255.255.254.0"
31
31
  @new_resource.metric "1"
@@ -34,7 +34,7 @@ describe Chef::Provider::Ifconfig::Redhat do
34
34
  @provider = Chef::Provider::Ifconfig::Redhat.new(@new_resource, @run_context)
35
35
  @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
36
36
 
37
- status = double("Status", :exitstatus => 0)
37
+ status = double("Status", exitstatus: 0)
38
38
  @provider.instance_variable_set("@status", status)
39
39
  @provider.current_resource = @current_resource
40
40
 
@@ -47,7 +47,7 @@ describe Chef::Provider::Ifconfig::Redhat do
47
47
 
48
48
  it "should write network-script for centos" do
49
49
  allow(@provider).to receive(:load_current_resource)
50
- allow(@provider).to receive(:run_command)
50
+ allow(@provider).to receive(:shell_out!)
51
51
  expect(@config).to receive(:content) do |arg|
52
52
  expect(arg).to match(/^\s*DEVICE=eth0\s*$/)
53
53
  expect(arg).to match(/^\s*IPADDR=10\.0\.0\.1\s*$/)
@@ -64,7 +64,7 @@ describe Chef::Provider::Ifconfig::Redhat do
64
64
  it "should delete network-script if it exists for centos" do
65
65
  @current_resource.device @new_resource.device
66
66
  allow(@provider).to receive(:load_current_resource)
67
- allow(@provider).to receive(:run_command)
67
+ allow(@provider).to receive(:shell_out!)
68
68
  expect(@config).to receive(:run_action).with(:delete)
69
69
  expect(@config).to receive(:updated?).and_return(true)
70
70
  @provider.run_action(:delete)
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- #require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
19
+ # require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
20
20
  require "spec_helper"
21
21
  require "chef/exceptions"
22
22
 
@@ -26,7 +26,7 @@ describe Chef::Provider::Ifconfig do
26
26
  @cookbook_collection = Chef::CookbookCollection.new([])
27
27
  @events = Chef::EventDispatch::Dispatcher.new
28
28
  @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
29
- #This new_resource can be called anything --> it is not the same as in ifconfig.rb
29
+ # This new_resource can be called anything --> it is not the same as in ifconfig.rb
30
30
  @new_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
31
31
  @new_resource.mask "255.255.254.0"
32
32
  @new_resource.metric "1"
@@ -35,14 +35,14 @@ describe Chef::Provider::Ifconfig do
35
35
  @provider = Chef::Provider::Ifconfig.new(@new_resource, @run_context)
36
36
  @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)
37
37
 
38
- status = double("Status", :exitstatus => 0)
38
+ status = double("Status", exitstatus: 0)
39
39
  @provider.instance_variable_set("@status", status)
40
40
  @provider.current_resource = @current_resource
41
41
 
42
42
  end
43
43
  describe Chef::Provider::Ifconfig, "load_current_resource" do
44
44
  before do
45
- @status = double(:stdout => "", :exitstatus => 1)
45
+ @status = double(stdout: "", exitstatus: 1)
46
46
  allow(@provider).to receive(:shell_out).and_return(@status)
47
47
  @provider.load_current_resource
48
48
  end
@@ -57,11 +57,10 @@ describe Chef::Provider::Ifconfig do
57
57
  describe Chef::Provider::Ifconfig, "action_add" do
58
58
 
59
59
  it "should add an interface if it does not exist" do
60
- #@provider.stub(:run_command).and_return(true)
61
60
  allow(@provider).to receive(:load_current_resource)
62
61
  @current_resource.inet_addr nil
63
62
  command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
64
- expect(@provider).to receive(:run_command).with(:command => command)
63
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
65
64
  expect(@provider).to receive(:generate_config)
66
65
 
67
66
  @provider.run_action(:add)
@@ -72,7 +71,7 @@ describe Chef::Provider::Ifconfig do
72
71
  allow(@provider).to receive(:load_current_resource)
73
72
  @new_resource.target "172.16.32.2"
74
73
  command = "ifconfig eth0 172.16.32.2 netmask 255.255.254.0 metric 1 mtu 1500"
75
- expect(@provider).to receive(:run_command).with(:command => command)
74
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
76
75
 
77
76
  @provider.run_action(:add)
78
77
  expect(@new_resource).to be_updated
@@ -80,7 +79,7 @@ describe Chef::Provider::Ifconfig do
80
79
 
81
80
  it "should not add an interface if it already exists" do
82
81
  allow(@provider).to receive(:load_current_resource)
83
- expect(@provider).not_to receive(:run_command)
82
+ expect(@provider).not_to receive(:shell_out!)
84
83
  @current_resource.inet_addr "10.0.0.1"
85
84
  expect(@provider).to receive(:generate_config)
86
85
 
@@ -88,9 +87,9 @@ describe Chef::Provider::Ifconfig do
88
87
  expect(@new_resource).not_to be_updated
89
88
  end
90
89
 
91
- #We are not testing this case with the assumption that anyone writing the cookbook would not make a typo == lo
92
- #it "should add a blank command if the #{@new_resource.device} == lo" do
93
- #end
90
+ # We are not testing this case with the assumption that anyone writing the cookbook would not make a typo == lo
91
+ # it "should add a blank command if the #{@new_resource.device} == lo" do
92
+ # end
94
93
  end
95
94
 
96
95
  describe Chef::Provider::Ifconfig, "action_enable" do
@@ -99,7 +98,7 @@ describe Chef::Provider::Ifconfig do
99
98
  allow(@provider).to receive(:load_current_resource)
100
99
  @current_resource.inet_addr nil
101
100
  command = "ifconfig eth0 10.0.0.1 netmask 255.255.254.0 metric 1 mtu 1500"
102
- expect(@provider).to receive(:run_command).with(:command => command)
101
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
103
102
  expect(@provider).not_to receive(:generate_config)
104
103
 
105
104
  @provider.run_action(:enable)
@@ -110,7 +109,7 @@ describe Chef::Provider::Ifconfig do
110
109
  allow(@provider).to receive(:load_current_resource)
111
110
  @new_resource.target "172.16.32.2"
112
111
  command = "ifconfig eth0 172.16.32.2 netmask 255.255.254.0 metric 1 mtu 1500"
113
- expect(@provider).to receive(:run_command).with(:command => command)
112
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
114
113
 
115
114
  @provider.run_action(:enable)
116
115
  expect(@new_resource).to be_updated
@@ -133,7 +132,7 @@ describe Chef::Provider::Ifconfig do
133
132
  allow(@provider).to receive(:load_current_resource)
134
133
  @current_resource.device "eth0"
135
134
  command = "ifconfig #{@new_resource.device} down"
136
- expect(@provider).to receive(:run_command).with(:command => command)
135
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
137
136
  expect(@provider).to receive(:delete_config)
138
137
 
139
138
  @provider.run_action(:delete)
@@ -142,7 +141,7 @@ describe Chef::Provider::Ifconfig do
142
141
 
143
142
  it "should not delete interface if it does not exist" do
144
143
  allow(@provider).to receive(:load_current_resource)
145
- expect(@provider).not_to receive(:run_command)
144
+ expect(@provider).not_to receive(:shell_out!)
146
145
  expect(@provider).to receive(:delete_config)
147
146
 
148
147
  @provider.run_action(:delete)
@@ -156,7 +155,7 @@ describe Chef::Provider::Ifconfig do
156
155
  allow(@provider).to receive(:load_current_resource)
157
156
  @current_resource.device "eth0"
158
157
  command = "ifconfig #{@new_resource.device} down"
159
- expect(@provider).to receive(:run_command).with(:command => command)
158
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
160
159
  expect(@provider).not_to receive(:delete_config)
161
160
 
162
161
  @provider.run_action(:disable)
@@ -165,7 +164,7 @@ describe Chef::Provider::Ifconfig do
165
164
 
166
165
  it "should not delete interface if it does not exist" do
167
166
  allow(@provider).to receive(:load_current_resource)
168
- expect(@provider).not_to receive(:run_command)
167
+ expect(@provider).not_to receive(:shell_out!)
169
168
  expect(@provider).not_to receive(:delete_config)
170
169
 
171
170
  @provider.run_action(:disable)
@@ -179,7 +178,7 @@ describe Chef::Provider::Ifconfig do
179
178
  allow(@provider).to receive(:load_current_resource)
180
179
  @current_resource.device "eth0"
181
180
  command = "ifconfig #{@new_resource.device} down"
182
- expect(@provider).to receive(:run_command).with(:command => command)
181
+ expect(@provider).to receive(:shell_out!).with(*command.split(" "))
183
182
  expect(@provider).to receive(:delete_config)
184
183
 
185
184
  @provider.run_action(:delete)
@@ -190,7 +189,7 @@ describe Chef::Provider::Ifconfig do
190
189
  # This is so that our fake values do not get overwritten
191
190
  allow(@provider).to receive(:load_current_resource)
192
191
  # This is so that nothing actually runs
193
- expect(@provider).not_to receive(:run_command)
192
+ expect(@provider).not_to receive(:shell_out!)
194
193
  expect(@provider).to receive(:delete_config)
195
194
 
196
195
  @provider.run_action(:delete)
@@ -46,7 +46,7 @@ ConEmu|15.10.25.0
46
46
  allow(provider).to receive(:choco_install_path).and_return(choco_install_path)
47
47
  allow(provider).to receive(:choco_exe).and_return(choco_exe)
48
48
  local_list_obj = double(:stdout => local_list_stdout)
49
- allow(provider).to receive(:shell_out!).with("#{choco_exe} list -l -r", { :timeout => timeout }).and_return(local_list_obj)
49
+ allow(provider).to receive(:shell_out!).with("#{choco_exe} list -l -r", { :returns => [0], :timeout => timeout }).and_return(local_list_obj)
50
50
  end
51
51
 
52
52
  def allow_remote_list(package_names, args = nil)
@@ -59,7 +59,7 @@ Git|2.6.2
59
59
  munin-node|1.6.1.20130823
60
60
  EOF
61
61
  remote_list_obj = double(stdout: remote_list_stdout)
62
- allow(provider).to receive(:shell_out!).with("#{choco_exe} list -r #{package_names.join ' '}#{args}", { timeout: timeout }).and_return(remote_list_obj)
62
+ allow(provider).to receive(:shell_out!).with("#{choco_exe} list -r #{package_names.join ' '}#{args}", { :returns => [0], timeout: timeout }).and_return(remote_list_obj)
63
63
  end
64
64
 
65
65
  describe "#initialize" do
@@ -180,7 +180,7 @@ munin-node|1.6.1.20130823
180
180
  it "should install a single package" do
181
181
  allow_remote_list(["git"])
182
182
  provider.load_current_resource
183
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double)
183
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
184
184
  provider.run_action(:install)
185
185
  expect(new_resource).to be_updated_by_last_action
186
186
  end
@@ -191,7 +191,7 @@ munin-node|1.6.1.20130823
191
191
  allow_remote_list(["git"])
192
192
  new_resource.timeout(timeout)
193
193
  provider.load_current_resource
194
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double)
194
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
195
195
  provider.run_action(:install)
196
196
  expect(new_resource).to be_updated_by_last_action
197
197
  end
@@ -220,7 +220,7 @@ munin-node|1.6.1.20130823
220
220
  new_resource.package_name("ConEmu")
221
221
  new_resource.version("15.10.25.1")
222
222
  provider.load_current_resource
223
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
223
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
224
224
  provider.run_action(:install)
225
225
  expect(new_resource).to be_updated_by_last_action
226
226
  end
@@ -233,7 +233,7 @@ munin-node|1.6.1.20130823
233
233
  new_resource.package_name(%w{chocolatey ConEmu})
234
234
  new_resource.version([nil, "15.10.25.1"])
235
235
  provider.load_current_resource
236
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
236
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
237
237
  provider.run_action(:install)
238
238
  expect(new_resource).to be_updated_by_last_action
239
239
  end
@@ -243,7 +243,7 @@ munin-node|1.6.1.20130823
243
243
  new_resource.package_name("conemu")
244
244
  new_resource.version("15.10.25.1")
245
245
  provider.load_current_resource
246
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
246
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
247
247
  provider.run_action(:install)
248
248
  expect(new_resource).to be_updated_by_last_action
249
249
  end
@@ -253,8 +253,8 @@ munin-node|1.6.1.20130823
253
253
  new_resource.package_name(%w{ConEmu git})
254
254
  new_resource.version(["15.10.25.1", nil])
255
255
  provider.load_current_resource
256
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :timeout => timeout }).and_return(double)
257
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :timeout => timeout }).and_return(double)
256
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y --version 15.10.25.1 conemu", { :returns => [0], :timeout => timeout }).and_return(double)
257
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git", { :returns => [0], :timeout => timeout }).and_return(double)
258
258
  provider.run_action(:install)
259
259
  expect(new_resource).to be_updated_by_last_action
260
260
  end
@@ -263,7 +263,7 @@ munin-node|1.6.1.20130823
263
263
  allow_remote_list(["git", "munin-node"])
264
264
  new_resource.package_name(["git", "munin-node"])
265
265
  provider.load_current_resource
266
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git munin-node", { :timeout => timeout }).and_return(double)
266
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y git munin-node", { :returns => [0], :timeout => timeout }).and_return(double)
267
267
  provider.run_action(:install)
268
268
  expect(new_resource).to be_updated_by_last_action
269
269
  end
@@ -273,7 +273,7 @@ munin-node|1.6.1.20130823
273
273
  allow_remote_list(["git"], " -source localpackages")
274
274
  new_resource.source("localpackages")
275
275
  provider.load_current_resource
276
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -source localpackages git", { :timeout => timeout }).and_return(double)
276
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -source localpackages git", { :returns => [0], :timeout => timeout }).and_return(double)
277
277
  provider.run_action(:install)
278
278
  expect(new_resource).to be_updated_by_last_action
279
279
  end
@@ -283,7 +283,7 @@ munin-node|1.6.1.20130823
283
283
  allow_remote_list(["git"])
284
284
  new_resource.options("-force")
285
285
  provider.load_current_resource
286
- expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -force git", { :timeout => timeout }).and_return(double)
286
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} install -y -force git", { :returns => [0], :timeout => timeout }).and_return(double)
287
287
  provider.run_action(:install)
288
288
  expect(new_resource).to be_updated_by_last_action
289
289
  end
@@ -317,7 +317,7 @@ munin-node|1.6.1.20130823
317
317
  it "should install a package that is not installed" do
318
318
  allow_remote_list(["git"])
319
319
  provider.load_current_resource
320
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y git", { :timeout => timeout }).and_return(double)
320
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y git", { :returns => [0], :timeout => timeout }).and_return(double)
321
321
  provider.run_action(:upgrade)
322
322
  expect(new_resource).to be_updated_by_last_action
323
323
  end
@@ -326,7 +326,7 @@ munin-node|1.6.1.20130823
326
326
  allow_remote_list(["ConEmu"])
327
327
  new_resource.package_name("ConEmu")
328
328
  provider.load_current_resource
329
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :timeout => timeout }).and_return(double)
329
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
330
330
  provider.run_action(:upgrade)
331
331
  expect(new_resource).to be_updated_by_last_action
332
332
  end
@@ -335,7 +335,7 @@ munin-node|1.6.1.20130823
335
335
  allow_remote_list(["conemu"])
336
336
  new_resource.package_name("conemu")
337
337
  provider.load_current_resource
338
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :timeout => timeout }).and_return(double)
338
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
339
339
  provider.run_action(:upgrade)
340
340
  expect(new_resource).to be_updated_by_last_action
341
341
  end
@@ -344,7 +344,7 @@ munin-node|1.6.1.20130823
344
344
  allow_remote_list(["chocolatey"])
345
345
  new_resource.package_name("chocolatey")
346
346
  provider.load_current_resource
347
- expect(provider).not_to receive(:shell_out!).with("#{choco_exe} upgrade -y chocolatey", { :timeout => timeout })
347
+ expect(provider).not_to receive(:shell_out!).with("#{choco_exe} upgrade -y chocolatey", { :returns => [0], :timeout => timeout })
348
348
  provider.run_action(:upgrade)
349
349
  expect(new_resource).not_to be_updated_by_last_action
350
350
  end
@@ -353,7 +353,7 @@ munin-node|1.6.1.20130823
353
353
  allow_remote_list(["git"])
354
354
  new_resource.version("2.6.2")
355
355
  provider.load_current_resource
356
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { :timeout => timeout })
356
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y --version 2.6.2 git", { :returns => [0], :timeout => timeout })
357
357
  provider.run_action(:upgrade)
358
358
  expect(new_resource).to be_updated_by_last_action
359
359
  end
@@ -361,7 +361,7 @@ munin-node|1.6.1.20130823
361
361
  it "upgrading multiple packages uses a single command" do
362
362
  allow_remote_list(%w{conemu git})
363
363
  new_resource.package_name(%w{conemu git})
364
- expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", { :timeout => timeout }).and_return(double)
364
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} upgrade -y conemu git", { :returns => [0], :timeout => timeout }).and_return(double)
365
365
  provider.run_action(:upgrade)
366
366
  expect(new_resource).to be_updated_by_last_action
367
367
  end
@@ -413,7 +413,7 @@ munin-node|1.6.1.20130823
413
413
  allow_remote_list(["ConEmu"])
414
414
  new_resource.package_name("ConEmu")
415
415
  provider.load_current_resource
416
- expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y ConEmu", { :timeout => timeout }).and_return(double)
416
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y ConEmu", { :returns => [0], :timeout => timeout }).and_return(double)
417
417
  provider.run_action(:remove)
418
418
  expect(new_resource).to be_updated_by_last_action
419
419
  end
@@ -422,7 +422,7 @@ munin-node|1.6.1.20130823
422
422
  allow_remote_list(["conemu"])
423
423
  new_resource.package_name("conemu")
424
424
  provider.load_current_resource
425
- expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double)
425
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
426
426
  provider.run_action(:remove)
427
427
  expect(new_resource).to be_updated_by_last_action
428
428
  end
@@ -432,7 +432,7 @@ munin-node|1.6.1.20130823
432
432
  allow_remote_list(%w{git conemu})
433
433
  new_resource.package_name(%w{git conemu})
434
434
  provider.load_current_resource
435
- expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :timeout => timeout }).and_return(double)
435
+ expect(provider).to receive(:shell_out!).with("#{choco_exe} uninstall -y conemu", { :returns => [0], :timeout => timeout }).and_return(double)
436
436
  provider.run_action(:remove)
437
437
  expect(new_resource).to be_updated_by_last_action
438
438
  end