chef 13.3.42 → 13.4.19

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/VERSION +1 -1
  4. data/lib/chef/knife/core/ui.rb +1 -1
  5. data/lib/chef/mash.rb +6 -0
  6. data/lib/chef/mixin/deep_merge.rb +1 -1
  7. data/lib/chef/mixin/user_context.rb +52 -0
  8. data/lib/chef/node/attribute.rb +80 -14
  9. data/lib/chef/node/immutable_collections.rb +16 -19
  10. data/lib/chef/provider/apt_repository.rb +12 -10
  11. data/lib/chef/provider/git.rb +20 -3
  12. data/lib/chef/provider/ifconfig/redhat.rb +4 -0
  13. data/lib/chef/provider/launchd.rb +20 -0
  14. data/lib/chef/provider/package/dnf.rb +3 -1
  15. data/lib/chef/provider/remote_file.rb +19 -0
  16. data/lib/chef/provider/remote_file/fetcher.rb +3 -0
  17. data/lib/chef/provider/remote_file/network_file.rb +18 -5
  18. data/lib/chef/provider/service/macosx.rb +4 -3
  19. data/lib/chef/provider/windows_path.rb +62 -0
  20. data/lib/chef/provider/zypper_repository.rb +1 -1
  21. data/lib/chef/providers.rb +1 -0
  22. data/lib/chef/resource.rb +5 -1
  23. data/lib/chef/resource/apt_repository.rb +1 -1
  24. data/lib/chef/resource/ifconfig.rb +36 -0
  25. data/lib/chef/resource/remote_file.rb +60 -0
  26. data/lib/chef/resource/windows_path.rb +41 -0
  27. data/lib/chef/resource/zypper_repository.rb +1 -0
  28. data/lib/chef/resources.rb +1 -0
  29. data/lib/chef/shell.rb +1 -0
  30. data/lib/chef/shell/shell_session.rb +4 -4
  31. data/lib/chef/util/windows/logon_session.rb +126 -0
  32. data/lib/chef/version.rb +4 -3
  33. data/lib/chef/win32/api/security.rb +2 -0
  34. data/spec/functional/mixin/user_context_spec.rb +117 -0
  35. data/spec/functional/resource/remote_file_spec.rb +171 -0
  36. data/spec/functional/resource/windows_path_spec.rb +64 -0
  37. data/spec/unit/knife/client_delete_spec.rb +1 -1
  38. data/spec/unit/mixin/user_context_spec.rb +109 -0
  39. data/spec/unit/node/immutable_collections_spec.rb +12 -4
  40. data/spec/unit/node_spec.rb +7 -0
  41. data/spec/unit/provider/git_spec.rb +55 -0
  42. data/spec/unit/provider/ifconfig/redhat_spec.rb +8 -0
  43. data/spec/unit/provider/remote_file/fetcher_spec.rb +1 -0
  44. data/spec/unit/provider/remote_file/network_file_spec.rb +7 -2
  45. data/spec/unit/provider/service/macosx_spec.rb +4 -1
  46. data/spec/unit/provider/windows_path_spec.rb +65 -0
  47. data/spec/unit/resource/windows_path_spec.rb +38 -0
  48. data/spec/unit/resource_spec.rb +8 -0
  49. data/spec/unit/shell/shell_session_spec.rb +82 -58
  50. data/spec/unit/util/windows/logon_session_spec.rb +284 -0
  51. data/tasks/maintainers.rb +3 -3
  52. metadata +15 -5
@@ -0,0 +1,284 @@
1
+ #
2
+ # Author:: Adam Edwards (<adamed@chef.io>)
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 "chef/util/windows/logon_session"
21
+
22
+ describe ::Chef::Util::Windows::LogonSession do
23
+ before do
24
+ stub_const("Chef::ReservedNames::Win32::API::Security", Class.new)
25
+ stub_const("Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NEW_CREDENTIALS", 314)
26
+ stub_const("Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT", 159)
27
+ stub_const("Chef::ReservedNames::Win32::API::System", Class.new )
28
+ end
29
+
30
+ let(:session) { ::Chef::Util::Windows::LogonSession.new(session_user, password, session_domain) }
31
+
32
+ shared_examples_for "it received syntactically invalid credentials" do
33
+ it "does not raisees an exception when it is initialized" do
34
+ expect { session }.to raise_error(ArgumentError)
35
+ end
36
+ end
37
+
38
+ shared_examples_for "it received an incorrect username and password combination" do
39
+ before do
40
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:LogonUserW).and_return(false)
41
+ end
42
+
43
+ it "raises a Chef::Exceptions::Win32APIError exception when the open method is called" do
44
+ expect { session.open }.to raise_error(Chef::Exceptions::Win32APIError)
45
+ expect(session).not_to receive(:close)
46
+ expect(Chef::ReservedNames::Win32::API::System).not_to receive(:CloseHandle)
47
+ end
48
+ end
49
+
50
+ shared_examples_for "it received valid credentials" do
51
+ it "does not raise an exception when the open method is called" do
52
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:LogonUserW).and_return(true)
53
+ expect { session.open }.not_to raise_error
54
+ end
55
+ end
56
+
57
+ shared_examples_for "the session is not open" do
58
+ it "does not raise an exception when #open is called" do
59
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:LogonUserW).and_return(true)
60
+ expect { session.open }.not_to raise_error
61
+ end
62
+
63
+ it "raises an exception if #close is called" do
64
+ expect { session.close }.to raise_error(RuntimeError)
65
+ end
66
+
67
+ it "raises an exception if #restore_user_context is called" do
68
+ expect { session.restore_user_context }.to raise_error(RuntimeError)
69
+ end
70
+ end
71
+
72
+ shared_examples_for "the session is open" do
73
+ before do
74
+ allow(Chef::ReservedNames::Win32::API::System).to receive(:CloseHandle)
75
+ end
76
+ it "does not result in an exception when #restore_user_context is called" do
77
+ expect { session.restore_user_context }.not_to raise_error
78
+ end
79
+
80
+ it "does not result in an exception when #close is called" do
81
+ expect { session.close }.not_to raise_error
82
+ end
83
+
84
+ it "does close the operating system handle when #close is called" do
85
+ expect(Chef::ReservedNames::Win32::API::System).not_to receive(:CloseHandle)
86
+ expect { session.restore_user_context }.not_to raise_error
87
+ end
88
+ end
89
+
90
+ context "when the session is initialized with a nil user" do
91
+ context "when the password, and domain are all nil" do
92
+ let(:session_user) { nil }
93
+ let(:session_domain) { nil }
94
+ let(:password) { nil }
95
+ it_behaves_like "it received syntactically invalid credentials"
96
+ end
97
+
98
+ context "when the password is non-nil password, and the domain is nil" do
99
+ let(:session_user) { nil }
100
+ let(:password) { "ponies" }
101
+ let(:session_domain) { nil }
102
+ it_behaves_like "it received syntactically invalid credentials"
103
+ end
104
+
105
+ context "when the password is nil and the domain is non-nil" do
106
+ let(:session_user) { nil }
107
+ let(:password) { nil }
108
+ let(:session_domain) { "fairyland" }
109
+ it_behaves_like "it received syntactically invalid credentials"
110
+ end
111
+
112
+ context "when the password and domain are non-nil" do
113
+ let(:session_user) { nil }
114
+ let(:password) { "ponies" }
115
+ let(:session_domain) { "fairyland" }
116
+ it_behaves_like "it received syntactically invalid credentials"
117
+ end
118
+ end
119
+
120
+ context "when the session is initialized with a valid user" do
121
+ let(:session_user) { "chalena" }
122
+
123
+ context "when the password is nil" do
124
+ let(:password) { nil }
125
+ context "when the domain is non-nil" do
126
+ let(:session_domain) { "fairyland" }
127
+ it_behaves_like "it received syntactically invalid credentials"
128
+ end
129
+
130
+ context "when the domain is nil" do
131
+ context "when the domain is non-nil" do
132
+ let(:session_domain) { nil }
133
+ it_behaves_like "it received syntactically invalid credentials"
134
+ end
135
+ end
136
+ end
137
+
138
+ context "when a syntactically valid username and password are supplied" do
139
+ context "when the password is non-nil and the domain is nil" do
140
+ let(:password) { "ponies" }
141
+ let(:session_domain) { nil }
142
+ it "does not raise an exception if it is initialized with a non-nil username, non-nil password, and a nil domain" do
143
+ expect { session }.not_to raise_error
144
+ end
145
+
146
+ it_behaves_like "it received valid credentials"
147
+ it_behaves_like "it received an incorrect username and password combination"
148
+ end
149
+
150
+ context "when the password and domain are non-nil" do
151
+ let(:password) { "ponies" }
152
+ let(:session_domain) { "fairyland" }
153
+ it "does not raise an exception if it is initialized with a non-nil username, non-nil password, and non-nil domain" do
154
+ expect { session }.not_to raise_error
155
+ end
156
+
157
+ it_behaves_like "it received valid credentials"
158
+ it_behaves_like "it received an incorrect username and password combination"
159
+ end
160
+
161
+ context "when the #open method has not been called" do
162
+ let(:password) { "ponies" }
163
+ let(:session_domain) { "fairyland" }
164
+ it_behaves_like "the session is not open"
165
+ end
166
+
167
+ context "when the session was opened" do
168
+ let(:password) { "ponies" }
169
+ let(:session_domain) { "fairyland" }
170
+
171
+ before do
172
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:LogonUserW).and_return(true)
173
+ expect { session.open }.not_to raise_error
174
+ end
175
+
176
+ it "raises an exception if #open is called" do
177
+ expect { session.open }.to raise_error(RuntimeError)
178
+ end
179
+
180
+ context "when the session was opened and then closed with the #close method" do
181
+ before do
182
+ expect(Chef::ReservedNames::Win32::API::System).to receive(:CloseHandle)
183
+ expect { session.close }.not_to raise_error
184
+ end
185
+ it_behaves_like "the session is not open"
186
+ end
187
+
188
+ it "can be closed and close the operating system handle" do
189
+ expect(Chef::ReservedNames::Win32::API::System).to receive(:CloseHandle)
190
+ expect { session.close }.not_to raise_error
191
+ end
192
+
193
+ it "can impersonate the user" do
194
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:ImpersonateLoggedOnUser).and_return(true)
195
+ expect { session.set_user_context }.not_to raise_error
196
+ end
197
+
198
+ context "when #set_user_context fails due to low resources causing a failure to impersonate" do
199
+ before do
200
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:ImpersonateLoggedOnUser).and_return(false)
201
+ end
202
+
203
+ it "raises an exception when #set_user_context fails because impersonation failed" do
204
+ expect { session.set_user_context }.to raise_error(Chef::Exceptions::Win32APIError)
205
+ end
206
+
207
+ context "when calling subsequent methods" do
208
+ before do
209
+ expect { session.set_user_context }.to raise_error(Chef::Exceptions::Win32APIError)
210
+ expect(Chef::ReservedNames::Win32::API::Security).not_to receive(:RevertToSelf)
211
+ end
212
+
213
+ it_behaves_like "the session is open"
214
+ end
215
+ end
216
+
217
+ context "when #set_user_context successfully impersonates the user" do
218
+ before do
219
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:ImpersonateLoggedOnUser).and_return(true)
220
+ expect { session.set_user_context }.not_to raise_error
221
+ end
222
+
223
+ context "when attempting to impersonate while already impersonating" do
224
+ it "raises an error if the #set_user_context is called again" do
225
+ expect { session.set_user_context }.to raise_error(RuntimeError)
226
+ end
227
+ end
228
+
229
+ describe "the impersonation will be reverted" do
230
+ before do
231
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:RevertToSelf).and_return(true)
232
+ end
233
+ it_behaves_like "the session is open"
234
+ end
235
+
236
+ context "when the attempt to revert impersonation fails" do
237
+ before do
238
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:RevertToSelf).and_return(false)
239
+ end
240
+
241
+ it "raises an exception when #restore_user_context is called" do
242
+ expect { session.restore_user_context }.to raise_error(Chef::Exceptions::Win32APIError)
243
+ end
244
+
245
+ it "raises an exception when #close is called and impersonation fails" do
246
+ expect { session.close }.to raise_error(Chef::Exceptions::Win32APIError)
247
+ end
248
+
249
+ context "when calling methods after revert fails in #restore_user_context" do
250
+ before do
251
+ expect { session.restore_user_context }.to raise_error(Chef::Exceptions::Win32APIError)
252
+ end
253
+
254
+ context "when revert continues to fail" do
255
+ before do
256
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:RevertToSelf).and_return(false)
257
+ end
258
+ it "raises an exception when #close is called and impersonation fails" do
259
+ expect { session.close }.to raise_error(Chef::Exceptions::Win32APIError)
260
+ end
261
+ end
262
+
263
+ context "when revert stops failing and succeeds" do
264
+ before do
265
+ expect(Chef::ReservedNames::Win32::API::Security).to receive(:RevertToSelf).and_return(true)
266
+ end
267
+
268
+ it "does not raise an exception when #restore_user_context is called" do
269
+ expect { session.restore_user_context }.not_to raise_error
270
+ end
271
+
272
+ it "does not raise an exception when #close is called" do
273
+ expect(Chef::ReservedNames::Win32::API::System).to receive(:CloseHandle)
274
+ expect { session.close }.not_to raise_error
275
+ end
276
+ end
277
+ end
278
+ end
279
+ end
280
+
281
+ end
282
+ end
283
+ end
284
+ end
@@ -21,7 +21,7 @@ SOURCE = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.toml")
21
21
  TARGET = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.md")
22
22
 
23
23
  # The list of repositories that teams should own
24
- REPOSITORIES = ["chef/chef", "chef/chef-census", "chef/chef-repo",
24
+ REPOSITORIES = ["chef/chef", "chef/chef-dk", "chef/chef-census", "chef/chef-repo",
25
25
  "chef/client-docs", "chef/ffi-yajl", "chef/libyajl2-gem",
26
26
  "chef/mixlib-authentication", "chef/mixlib-cli",
27
27
  "chef/mixlib-config", "chef/mixlib-install", "chef/mixlib-log",
@@ -139,8 +139,8 @@ begin
139
139
  update_team_privacy(team)
140
140
  add_team_members(team, additions)
141
141
  remove_team_members(team, deletions)
142
- rescue
143
- puts "failed for #{team}"
142
+ rescue => e
143
+ puts "failed for #{team}: #{e.message}"
144
144
  end
145
145
 
146
146
  def update_team_privacy(team)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.3.42
4
+ version: 13.4.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 13.3.42
19
+ version: 13.4.19
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 13.3.42
26
+ version: 13.4.19
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -1146,6 +1146,7 @@ files:
1146
1146
  - lib/chef/mixin/template.rb
1147
1147
  - lib/chef/mixin/unformatter.rb
1148
1148
  - lib/chef/mixin/uris.rb
1149
+ - lib/chef/mixin/user_context.rb
1149
1150
  - lib/chef/mixin/versioned_api.rb
1150
1151
  - lib/chef/mixin/which.rb
1151
1152
  - lib/chef/mixin/why_run.rb
@@ -1325,6 +1326,7 @@ files:
1325
1326
  - lib/chef/provider/user/useradd.rb
1326
1327
  - lib/chef/provider/user/windows.rb
1327
1328
  - lib/chef/provider/whyrun_safe_ruby_block.rb
1329
+ - lib/chef/provider/windows_path.rb
1328
1330
  - lib/chef/provider/windows_script.rb
1329
1331
  - lib/chef/provider/windows_task.rb
1330
1332
  - lib/chef/provider/yum_repository.rb
@@ -1421,6 +1423,7 @@ files:
1421
1423
  - lib/chef/resource/user/windows_user.rb
1422
1424
  - lib/chef/resource/whyrun_safe_ruby_block.rb
1423
1425
  - lib/chef/resource/windows_package.rb
1426
+ - lib/chef/resource/windows_path.rb
1424
1427
  - lib/chef/resource/windows_script.rb
1425
1428
  - lib/chef/resource/windows_service.rb
1426
1429
  - lib/chef/resource/windows_task.rb
@@ -1476,6 +1479,7 @@ files:
1476
1479
  - lib/chef/util/selinux.rb
1477
1480
  - lib/chef/util/threaded_job_queue.rb
1478
1481
  - lib/chef/util/windows.rb
1482
+ - lib/chef/util/windows/logon_session.rb
1479
1483
  - lib/chef/util/windows/net_group.rb
1480
1484
  - lib/chef/util/windows/net_use.rb
1481
1485
  - lib/chef/util/windows/net_user.rb
@@ -1902,6 +1906,7 @@ files:
1902
1906
  - spec/functional/knife/ssh_spec.rb
1903
1907
  - spec/functional/mixin/powershell_out_spec.rb
1904
1908
  - spec/functional/mixin/shell_out_spec.rb
1909
+ - spec/functional/mixin/user_context_spec.rb
1905
1910
  - spec/functional/notifications_spec.rb
1906
1911
  - spec/functional/provider/remote_file/cache_control_data_spec.rb
1907
1912
  - spec/functional/provider/whyrun_safe_ruby_block_spec.rb
@@ -1943,6 +1948,7 @@ files:
1943
1948
  - spec/functional/resource/user/useradd_spec.rb
1944
1949
  - spec/functional/resource/user/windows_spec.rb
1945
1950
  - spec/functional/resource/windows_package_spec.rb
1951
+ - spec/functional/resource/windows_path_spec.rb
1946
1952
  - spec/functional/resource/windows_service_spec.rb
1947
1953
  - spec/functional/resource/windows_task_spec.rb
1948
1954
  - spec/functional/root_alias_spec.rb
@@ -2329,6 +2335,7 @@ files:
2329
2335
  - spec/unit/mixin/template_spec.rb
2330
2336
  - spec/unit/mixin/unformatter_spec.rb
2331
2337
  - spec/unit/mixin/uris_spec.rb
2338
+ - spec/unit/mixin/user_context_spec.rb
2332
2339
  - spec/unit/mixin/versioned_api_spec.rb
2333
2340
  - spec/unit/mixin/which.rb
2334
2341
  - spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -2469,6 +2476,7 @@ files:
2469
2476
  - spec/unit/provider/user/windows_spec.rb
2470
2477
  - spec/unit/provider/user_spec.rb
2471
2478
  - spec/unit/provider/whyrun_safe_ruby_block_spec.rb
2479
+ - spec/unit/provider/windows_path_spec.rb
2472
2480
  - spec/unit/provider/windows_task_spec.rb
2473
2481
  - spec/unit/provider/yum_repository_spec.rb
2474
2482
  - spec/unit/provider_resolver_spec.rb
@@ -2548,6 +2556,7 @@ files:
2548
2556
  - spec/unit/resource/timestamped_deploy_spec.rb
2549
2557
  - spec/unit/resource/user_spec.rb
2550
2558
  - spec/unit/resource/windows_package_spec.rb
2559
+ - spec/unit/resource/windows_path_spec.rb
2551
2560
  - spec/unit/resource/windows_service_spec.rb
2552
2561
  - spec/unit/resource/windows_task_spec.rb
2553
2562
  - spec/unit/resource/yum_package_spec.rb
@@ -2595,6 +2604,7 @@ files:
2595
2604
  - spec/unit/util/powershell/ps_credential_spec.rb
2596
2605
  - spec/unit/util/selinux_spec.rb
2597
2606
  - spec/unit/util/threaded_job_queue_spec.rb
2607
+ - spec/unit/util/windows/logon_session_spec.rb
2598
2608
  - spec/unit/version/platform_spec.rb
2599
2609
  - spec/unit/version_class_spec.rb
2600
2610
  - spec/unit/version_constraint/platform_spec.rb
@@ -2633,7 +2643,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2633
2643
  version: '0'
2634
2644
  requirements: []
2635
2645
  rubyforge_project:
2636
- rubygems_version: 2.6.11
2646
+ rubygems_version: 2.6.13
2637
2647
  signing_key:
2638
2648
  specification_version: 4
2639
2649
  summary: A systems integration framework, built to bring the benefits of configuration