chef 14.8.12-universal-mingw32 → 14.9.13-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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/chef.gemspec +1 -1
- data/distro/ruby_bin_folder/msvcp140.dll +0 -0
- data/distro/ruby_bin_folder/vcruntime140.dll +0 -0
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/api_client/registration.rb +1 -1
- data/lib/chef/api_client_v1.rb +4 -4
- data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +4 -4
- data/lib/chef/client.rb +2 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook_uploader.rb +3 -3
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +1 -1
- data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +1 -1
- data/lib/chef/http.rb +3 -3
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
- data/lib/chef/knife/cookbook_delete.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +1 -1
- data/lib/chef/knife/data_bag_create.rb +1 -1
- data/lib/chef/knife/raw.rb +1 -1
- data/lib/chef/knife/search.rb +1 -1
- data/lib/chef/knife/supermarket_share.rb +1 -1
- data/lib/chef/knife/supermarket_unshare.rb +1 -1
- data/lib/chef/mixin/api_version_request_handling.rb +1 -1
- data/lib/chef/monkey_patches/net_http.rb +5 -1
- data/lib/chef/node.rb +4 -4
- data/lib/chef/node/mixin/immutablize_array.rb +5 -0
- data/lib/chef/node/mixin/immutablize_hash.rb +3 -0
- data/lib/chef/org.rb +1 -1
- data/lib/chef/policy_builder/policyfile.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/group/windows.rb +1 -0
- data/lib/chef/provider/remote_file/content.rb +1 -1
- data/lib/chef/provider/windows_task.rb +2 -2
- data/lib/chef/resource/group.rb +4 -0
- data/lib/chef/resource/homebrew_cask.rb +8 -8
- data/lib/chef/resource/homebrew_tap.rb +6 -6
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
- data/lib/chef/resource/openssl_x509_request.rb +1 -1
- data/lib/chef/resource/powershell_package_source.rb +11 -7
- data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
- data/lib/chef/resource/sysctl.rb +6 -6
- data/lib/chef/resource/timezone.rb +17 -1
- data/lib/chef/resource/windows_ad_join.rb +11 -1
- data/lib/chef/resource/windows_certificate.rb +7 -4
- data/lib/chef/resource/windows_printer.rb +3 -3
- data/lib/chef/resource/windows_task.rb +17 -8
- data/lib/chef/role.rb +1 -1
- data/lib/chef/run_list/run_list_expansion.rb +1 -1
- data/lib/chef/user.rb +1 -1
- data/lib/chef/user_v1.rb +4 -4
- data/lib/chef/util/windows/net_group.rb +6 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/net.rb +16 -0
- data/lib/chef/win32/net.rb +15 -0
- data/lib/chef/win32/version.rb +15 -15
- data/spec/functional/http/simple_spec.rb +10 -10
- data/spec/functional/resource/timezone_spec.rb +39 -0
- data/spec/functional/resource/windows_task_spec.rb +51 -7
- data/spec/integration/knife/client_create_spec.rb +1 -1
- data/spec/integration/knife/client_key_create_spec.rb +1 -1
- data/spec/integration/knife/cookbook_download_spec.rb +1 -1
- data/spec/integration/knife/cookbook_show_spec.rb +2 -2
- data/spec/integration/knife/data_bag_create_spec.rb +1 -1
- data/spec/integration/knife/environment_create_spec.rb +1 -1
- data/spec/integration/knife/node_create_spec.rb +1 -1
- data/spec/integration/knife/role_create_spec.rb +1 -1
- data/spec/support/shared/context/client.rb +1 -1
- data/spec/support/shared/unit/api_error_inspector.rb +5 -5
- data/spec/support/shared/unit/api_versioning.rb +2 -2
- data/spec/unit/api_client/registration_spec.rb +1 -1
- data/spec/unit/api_client_spec.rb +2 -2
- data/spec/unit/api_client_v1_spec.rb +3 -3
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +1 -1
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/data_bag_item_spec.rb +1 -1
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +4 -4
- data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +1 -1
- data/spec/unit/knife/cookbook_delete_spec.rb +3 -3
- data/spec/unit/knife/data_bag_create_spec.rb +2 -2
- data/spec/unit/knife/supermarket_share_spec.rb +1 -1
- data/spec/unit/knife/supermarket_unshare_spec.rb +3 -3
- data/spec/unit/knife_spec.rb +7 -7
- data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/policy_builder/policyfile_spec.rb +2 -2
- data/spec/unit/provider/group/windows_spec.rb +15 -0
- data/spec/unit/provider/remote_file/content_spec.rb +2 -2
- data/spec/unit/resource/group_spec.rb +17 -0
- data/spec/unit/resource/powershell_package_source_spec.rb +2 -2
- data/spec/unit/resource/windows_certificate.rb +7 -0
- data/spec/unit/resource/windows_task_spec.rb +61 -20
- data/spec/unit/resource_reporter_spec.rb +7 -7
- data/spec/unit/user_v1_spec.rb +2 -2
- metadata +15 -6
@@ -63,7 +63,7 @@ describe Chef::Knife::DataBagCreate do
|
|
63
63
|
exception = double("404 error", code: "404")
|
64
64
|
allow(rest).to receive(:get)
|
65
65
|
.with("data/#{bag_name}")
|
66
|
-
.and_raise(Net::
|
66
|
+
.and_raise(Net::HTTPClientException.new("404", exception))
|
67
67
|
end
|
68
68
|
|
69
69
|
it "tries to create a data bag with an invalid name when given one argument" do
|
@@ -86,7 +86,7 @@ describe Chef::Knife::DataBagCreate do
|
|
86
86
|
%w{node role client environment}.each do |name|
|
87
87
|
allow(rest).to receive(:get)
|
88
88
|
.with("data/sudoing_#{name}_admins")
|
89
|
-
.and_raise(Net::
|
89
|
+
.and_raise(Net::HTTPClientException.new("404", exception))
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -85,7 +85,7 @@ describe Chef::Knife::SupermarketShare do
|
|
85
85
|
|
86
86
|
it "should use a default category when given only 1 argument and cannot determine category" do
|
87
87
|
@knife.name_args = ["cookbook_name"]
|
88
|
-
expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name") { raise Net::
|
88
|
+
expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name") { raise Net::HTTPClientException.new("404 Not Found", OpenStruct.new(code: "404")) }
|
89
89
|
expect(@knife).to receive(:do_upload)
|
90
90
|
expect { @knife.run }.to_not raise_error
|
91
91
|
end
|
@@ -57,15 +57,15 @@ describe Chef::Knife::SupermarketUnshare do
|
|
57
57
|
|
58
58
|
it "should log an error and exit when forbidden" do
|
59
59
|
exception = double('403 "Forbidden"', code: "403")
|
60
|
-
allow(@rest).to receive(:delete).and_raise(Net::
|
60
|
+
allow(@rest).to receive(:delete).and_raise(Net::HTTPClientException.new('403 "Forbidden"', exception))
|
61
61
|
expect(@knife.ui).to receive(:error)
|
62
62
|
expect { @knife.run }.to raise_error(SystemExit)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should re-raise any non-forbidden errors on delete" do
|
66
66
|
exception = double('500 "Application Error"', code: "500")
|
67
|
-
allow(@rest).to receive(:delete).and_raise(Net::
|
68
|
-
expect { @knife.run }.to raise_error(Net::
|
67
|
+
allow(@rest).to receive(:delete).and_raise(Net::HTTPClientException.new('500 "Application Error"', exception))
|
68
|
+
expect { @knife.run }.to raise_error(Net::HTTPClientException)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should log a success message" do
|
data/spec/unit/knife_spec.rb
CHANGED
@@ -424,7 +424,7 @@ describe Chef::Knife do
|
|
424
424
|
response = Net::HTTPUnauthorized.new("1.1", "401", "Unauthorized")
|
425
425
|
response.instance_variable_set(:@read, true) # I hate you, net/http.
|
426
426
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no syncronize your clock?"))
|
427
|
-
allow(knife).to receive(:run).and_raise(Net::
|
427
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("401 Unauthorized", response))
|
428
428
|
knife.run_with_pretty_exceptions
|
429
429
|
expect(stderr.string).to match(/ERROR: Failed to authenticate to/)
|
430
430
|
expect(stderr.string).to match(/Response: y u no syncronize your clock\?/)
|
@@ -434,7 +434,7 @@ describe Chef::Knife do
|
|
434
434
|
response = Net::HTTPForbidden.new("1.1", "403", "Forbidden")
|
435
435
|
response.instance_variable_set(:@read, true) # I hate you, net/http.
|
436
436
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator"))
|
437
|
-
allow(knife).to receive(:run).and_raise(Net::
|
437
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response))
|
438
438
|
allow(knife).to receive(:username).and_return("sadpanda")
|
439
439
|
knife.run_with_pretty_exceptions
|
440
440
|
expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
|
@@ -454,7 +454,7 @@ describe Chef::Knife do
|
|
454
454
|
response = Net::HTTPForbidden.new("1.1", "403", "Forbidden")
|
455
455
|
response.instance_variable_set(:@read, true)
|
456
456
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator"))
|
457
|
-
allow(knife).to receive(:run).and_raise(Net::
|
457
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response))
|
458
458
|
allow(knife).to receive(:username).and_return("sadpanda")
|
459
459
|
knife.run_with_pretty_exceptions
|
460
460
|
expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
|
@@ -467,7 +467,7 @@ describe Chef::Knife do
|
|
467
467
|
response = Net::HTTPBadRequest.new("1.1", "400", "Bad Request")
|
468
468
|
response.instance_variable_set(:@read, true) # I hate you, net/http.
|
469
469
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u search wrong"))
|
470
|
-
allow(knife).to receive(:run).and_raise(Net::
|
470
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("400 Bad Request", response))
|
471
471
|
knife.run_with_pretty_exceptions
|
472
472
|
expect(stderr.string).to match(%r{ERROR: The data in your request was invalid})
|
473
473
|
expect(stderr.string).to match(%r{Response: y u search wrong})
|
@@ -477,7 +477,7 @@ describe Chef::Knife do
|
|
477
477
|
response = Net::HTTPNotFound.new("1.1", "404", "Not Found")
|
478
478
|
response.instance_variable_set(:@read, true) # I hate you, net/http.
|
479
479
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nothing to see here"))
|
480
|
-
allow(knife).to receive(:run).and_raise(Net::
|
480
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("404 Not Found", response))
|
481
481
|
knife.run_with_pretty_exceptions
|
482
482
|
expect(stderr.string).to match(%r{ERROR: The object you are looking for could not be found})
|
483
483
|
expect(stderr.string).to match(%r{Response: nothing to see here})
|
@@ -491,7 +491,7 @@ describe Chef::Knife do
|
|
491
491
|
response["x-ops-server-api-version"] = Chef::JSONCompat.to_json(min_version: "0", max_version: "1", request_version: "10000000")
|
492
492
|
|
493
493
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "sad trombone"))
|
494
|
-
allow(knife).to receive(:run).and_raise(Net::
|
494
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("406 Not Acceptable", response))
|
495
495
|
|
496
496
|
knife.run_with_pretty_exceptions
|
497
497
|
expect(stderr.string).to include("The request that Knife sent was using API version 10000000")
|
@@ -533,7 +533,7 @@ describe Chef::Knife do
|
|
533
533
|
response = Net::HTTPPaymentRequired.new("1.1", "402", "Payment Required")
|
534
534
|
response.instance_variable_set(:@read, true) # I hate you, net/http.
|
535
535
|
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nobugfixtillyoubuy"))
|
536
|
-
allow(knife).to receive(:run).and_raise(Net::
|
536
|
+
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("402 Payment Required", response))
|
537
537
|
knife.run_with_pretty_exceptions
|
538
538
|
expect(stderr.string).to match(%r{ERROR: Payment Required})
|
539
539
|
expect(stderr.string).to match(%r{Response: nobugfixtillyoubuy})
|
@@ -27,7 +27,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
|
|
27
27
|
|
28
28
|
context "when the response code is not 406" do
|
29
29
|
let(:response) { OpenStruct.new(code: "405") }
|
30
|
-
let(:exception) { Net::
|
30
|
+
let(:exception) { Net::HTTPClientException.new("405 Something Else", response) }
|
31
31
|
|
32
32
|
it "returns nil" do
|
33
33
|
expect(object.server_client_api_version_intersection(exception, default_supported_client_versions))
|
@@ -38,7 +38,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
|
|
38
38
|
|
39
39
|
context "when the response code is 406" do
|
40
40
|
let(:response) { OpenStruct.new(code: "406") }
|
41
|
-
let(:exception) { Net::
|
41
|
+
let(:exception) { Net::HTTPClientException.new("406 Not Acceptable", response) }
|
42
42
|
|
43
43
|
context "when x-ops-server-api-version header does not exist" do
|
44
44
|
it "returns nil" do
|
data/spec/unit/node_spec.rb
CHANGED
@@ -53,7 +53,7 @@ describe Chef::Node do
|
|
53
53
|
describe "when the node does not exist on the server" do
|
54
54
|
before do
|
55
55
|
response = OpenStruct.new(code: "404")
|
56
|
-
exception = Net::
|
56
|
+
exception = Net::HTTPClientException.new("404 not found", response)
|
57
57
|
allow(Chef::Node).to receive(:load).and_raise(exception)
|
58
58
|
node.name("created-node")
|
59
59
|
end
|
@@ -1447,7 +1447,7 @@ describe Chef::Node do
|
|
1447
1447
|
node.name("monkey")
|
1448
1448
|
allow(node).to receive(:data_for_save).and_return({})
|
1449
1449
|
exception = double("404 error", code: "404")
|
1450
|
-
expect(@rest).to receive(:put).and_raise(Net::
|
1450
|
+
expect(@rest).to receive(:put).and_raise(Net::HTTPClientException.new("foo", exception))
|
1451
1451
|
expect(@rest).to receive(:post).with("nodes", {})
|
1452
1452
|
node.save
|
1453
1453
|
end
|
@@ -218,7 +218,7 @@ describe Chef::PolicyBuilder::Policyfile do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
context "when the deployment group cannot be loaded" do
|
221
|
-
let(:error404) { Net::
|
221
|
+
let(:error404) { Net::HTTPClientException.new("404 message", :body) }
|
222
222
|
|
223
223
|
before do
|
224
224
|
expect(api_service).to receive(:get)
|
@@ -738,7 +738,7 @@ describe Chef::PolicyBuilder::Policyfile do
|
|
738
738
|
shared_examples "fetching cookbooks when they don't exist" do
|
739
739
|
context "and a cookbook is missing" do
|
740
740
|
|
741
|
-
let(:error404) { Net::
|
741
|
+
let(:error404) { Net::HTTPClientException.new("404 message", :body) }
|
742
742
|
|
743
743
|
before do
|
744
744
|
policy_builder.finish_load_node(node)
|
@@ -49,6 +49,7 @@ describe Chef::Provider::Group::Windows do
|
|
49
49
|
describe "manage_group" do
|
50
50
|
before do
|
51
51
|
@new_resource.members([ "us" ])
|
52
|
+
@new_resource.comment = "this is group comment"
|
52
53
|
@current_resource = Chef::Resource::Group.new("staff")
|
53
54
|
@current_resource.members %w{all your base}
|
54
55
|
@new_resource.excluded_members %w{all}
|
@@ -57,6 +58,7 @@ describe Chef::Provider::Group::Windows do
|
|
57
58
|
allow(@net_group).to receive(:local_add_members)
|
58
59
|
allow(@net_group).to receive(:local_set_members)
|
59
60
|
allow(@provider).to receive(:lookup_account_name)
|
61
|
+
allow(@net_group).to receive(:local_group_set_info)
|
60
62
|
allow(@provider).to receive(:validate_member!).and_return(true)
|
61
63
|
@provider.current_resource = @current_resource
|
62
64
|
end
|
@@ -73,6 +75,19 @@ describe Chef::Provider::Group::Windows do
|
|
73
75
|
@provider.manage_group
|
74
76
|
end
|
75
77
|
|
78
|
+
it "when comment is present, should call @net_group.local_group_set_info" do
|
79
|
+
@new_resource.append(true)
|
80
|
+
expect(@net_group).to receive(:local_group_set_info).with(@new_resource.comment)
|
81
|
+
@provider.manage_group
|
82
|
+
end
|
83
|
+
|
84
|
+
it "when comment is not present, should not call @net_group.local_group_set_info" do
|
85
|
+
@new_resource.comment = nil
|
86
|
+
@new_resource.append(true)
|
87
|
+
expect(@net_group).not_to receive(:local_group_set_info).with(@new_resource.comment)
|
88
|
+
@provider.manage_group
|
89
|
+
end
|
90
|
+
|
76
91
|
it "should call @net_group.local_delete_members" do
|
77
92
|
@new_resource.append(true)
|
78
93
|
allow(@provider).to receive(:lookup_account_name).with("all").and_return("all")
|
@@ -161,7 +161,7 @@ describe Chef::Provider::RemoteFile::Content do
|
|
161
161
|
|
162
162
|
# https://github.com/chef/chef/pull/1358#issuecomment-40853299
|
163
163
|
def create_exception(exception_class)
|
164
|
-
if [ Net::
|
164
|
+
if [ Net::HTTPClientException, Net::HTTPFatalError ].include? exception_class
|
165
165
|
exception_class.new("message", { "something" => 1 })
|
166
166
|
else
|
167
167
|
exception_class.new
|
@@ -177,7 +177,7 @@ describe Chef::Provider::RemoteFile::Content do
|
|
177
177
|
Errno::ENOENT,
|
178
178
|
Errno::EACCES,
|
179
179
|
Timeout::Error,
|
180
|
-
Net::
|
180
|
+
Net::HTTPClientException,
|
181
181
|
Net::HTTPFatalError,
|
182
182
|
Net::FTPError,
|
183
183
|
Errno::ETIMEDOUT,
|
@@ -49,6 +49,10 @@ describe Chef::Resource::Group, "initialize" do
|
|
49
49
|
expect(resource.members).to eql([])
|
50
50
|
end
|
51
51
|
|
52
|
+
it "defaults comment to be nil" do
|
53
|
+
expect(resource.comment).to eql(nil)
|
54
|
+
end
|
55
|
+
|
52
56
|
it "aliases users to members, also an empty array" do
|
53
57
|
expect(resource.users).to eql([])
|
54
58
|
end
|
@@ -146,3 +150,16 @@ describe Chef::Resource::Group, "append" do
|
|
146
150
|
end
|
147
151
|
end
|
148
152
|
end
|
153
|
+
|
154
|
+
describe Chef::Resource::Group, "comment" do
|
155
|
+
let(:resource) { Chef::Resource::Group.new("fakey_fakerton") }
|
156
|
+
|
157
|
+
it "allows an string" do
|
158
|
+
resource.comment "this is a group comment"
|
159
|
+
expect(resource.comment).to eql("this is a group comment")
|
160
|
+
end
|
161
|
+
|
162
|
+
it "does not allow a hash" do
|
163
|
+
expect { resource.send(:comment, { some_other_user: "is freakin awesome" }) }.to raise_error(ArgumentError)
|
164
|
+
end
|
165
|
+
end
|
@@ -205,13 +205,13 @@ describe Chef::Resource::PowershellPackageSource do
|
|
205
205
|
|
206
206
|
describe "#package_source_exists?" do
|
207
207
|
it "returns true if it exists" do
|
208
|
-
allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", stdout: "MyGallery\r\n"))
|
208
|
+
allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery' -WarningAction SilentlyContinue).Name").and_return(double("powershell_out!", stdout: "MyGallery\r\n"))
|
209
209
|
resource.source_name("MyGallery")
|
210
210
|
expect(provider.package_source_exists?).to eql(true)
|
211
211
|
end
|
212
212
|
|
213
213
|
it "returns false if it doesn't exist" do
|
214
|
-
allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery').Name").and_return(double("powershell_out!", stdout: ""))
|
214
|
+
allow(provider).to receive(:powershell_out!).with("(Get-PackageSource -Name 'MyGallery' -WarningAction SilentlyContinue).Name").and_return(double("powershell_out!", stdout: ""))
|
215
215
|
resource.source_name("MyGallery")
|
216
216
|
expect(provider.package_source_exists?).to eql(false)
|
217
217
|
end
|
@@ -73,4 +73,11 @@ describe Chef::Resource::WindowsCertificate do
|
|
73
73
|
resource.pfx_password "foo"
|
74
74
|
expect(resource.sensitive).to be_truthy
|
75
75
|
end
|
76
|
+
|
77
|
+
it "doesn't raise error if pfx_password contains special characters" do
|
78
|
+
resource.pfx_password "chef$123"
|
79
|
+
resource.source "C:\\certs\\test-cert.pfx"
|
80
|
+
resource.store_name "MY"
|
81
|
+
expect { resource.action :create }.not_to raise_error
|
82
|
+
end
|
76
83
|
end
|
@@ -67,23 +67,70 @@ describe Chef::Resource::WindowsTask, :windows_only do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
expect { resource.after_created }.to raise_error(ArgumentError, %q{Cannot specify a user other than the system users without specifying a password!. Valid passwordless users: 'SYSTEM', 'NT AUTHORITY\SYSTEM', 'LOCAL SERVICE', 'NT AUTHORITY\LOCAL SERVICE', 'NETWORK SERVICE', 'NT AUTHORITY\NETWORK SERVICE', 'ADMINISTRATORS', 'BUILTIN\ADMINISTRATORS', 'USERS', 'BUILTIN\USERS', 'GUESTS', 'BUILTIN\GUESTS'})
|
77
|
-
end
|
70
|
+
describe "#validate_user_and_password" do
|
71
|
+
context "a System User" do
|
72
|
+
before do
|
73
|
+
resource.frequency :hourly
|
74
|
+
resource.user 'NT AUTHORITY\SYSTEM'
|
75
|
+
end
|
78
76
|
|
79
|
-
|
80
|
-
|
81
|
-
|
77
|
+
context "for an interactive task" do
|
78
|
+
before { resource.interactive_enabled true }
|
79
|
+
it "does not require a password" do
|
80
|
+
expect { resource.after_created }.to_not raise_error
|
81
|
+
end
|
82
|
+
it "raises an error when a password is given" do
|
83
|
+
resource.password "XXXX"
|
84
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "Password is not required for system users.")
|
85
|
+
end
|
86
|
+
it "does not raises an error even when user is in lowercase" do
|
87
|
+
resource.user 'nt authority\system'
|
88
|
+
expect { resource.after_created }.to_not raise_error
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "for a non-interactive task" do
|
93
|
+
before { resource.interactive_enabled false }
|
94
|
+
it "does not require a password" do
|
95
|
+
expect { resource.after_created }.to_not raise_error
|
96
|
+
end
|
97
|
+
it "raises an error when a password is given" do
|
98
|
+
resource.password "XXXX"
|
99
|
+
expect { resource.after_created }.to raise_error(ArgumentError, "Password is not required for system users.")
|
100
|
+
end
|
101
|
+
it "does not raises an error even when user is in lowercase" do
|
102
|
+
resource.user 'nt authority\system'
|
103
|
+
expect { resource.after_created }.to_not raise_error
|
104
|
+
end
|
105
|
+
end
|
82
106
|
end
|
83
107
|
|
84
|
-
|
85
|
-
|
86
|
-
|
108
|
+
context "a Non-System User" do
|
109
|
+
before do
|
110
|
+
resource.frequency :hourly
|
111
|
+
resource.user "bob"
|
112
|
+
end
|
113
|
+
context "for an interactive task" do
|
114
|
+
before { resource.interactive_enabled true }
|
115
|
+
it "does not require a password" do
|
116
|
+
expect { resource.after_created }.to_not raise_error
|
117
|
+
end
|
118
|
+
it "does not raises an error when a password is given" do
|
119
|
+
resource.password "XXXX"
|
120
|
+
expect { resource.after_created }.to_not raise_error
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "for a non-interactive task" do
|
125
|
+
before { resource.interactive_enabled false }
|
126
|
+
it "require a password" do
|
127
|
+
expect { resource.after_created }.to raise_error(ArgumentError, %q{Please provide a password or check if this task needs to be interactive! Valid passwordless users are: 'SYSTEM', 'NT AUTHORITY\SYSTEM', 'LOCAL SERVICE', 'NT AUTHORITY\LOCAL SERVICE', 'NETWORK SERVICE', 'NT AUTHORITY\NETWORK SERVICE', 'ADMINISTRATORS', 'BUILTIN\ADMINISTRATORS', 'USERS', 'BUILTIN\USERS', 'GUESTS', 'BUILTIN\GUESTS'})
|
128
|
+
end
|
129
|
+
it "does not raises an error when a password is given" do
|
130
|
+
resource.password "XXXX"
|
131
|
+
expect { resource.after_created }.to_not raise_error
|
132
|
+
end
|
133
|
+
end
|
87
134
|
end
|
88
135
|
end
|
89
136
|
|
@@ -231,12 +278,6 @@ describe Chef::Resource::WindowsTask, :windows_only do
|
|
231
278
|
end
|
232
279
|
end
|
233
280
|
|
234
|
-
context "#validate_interactive_setting" do
|
235
|
-
it "raises error when interactive_enabled is passed without password" do
|
236
|
-
expect { resource.send(:validate_interactive_setting, true, nil) }.to raise_error("Please provide the password when attempting to set interactive/non-interactive.")
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
281
|
context "#validate_create_frequency_modifier" do
|
241
282
|
context "when frequency is :minute" do
|
242
283
|
it "raises error if frequency_modifier > 1439" do
|
@@ -494,7 +494,7 @@ describe Chef::ResourceReporter do
|
|
494
494
|
@node = Chef::Node.new
|
495
495
|
@node.name("spitfire")
|
496
496
|
@exception = ArgumentError.new
|
497
|
-
allow(@exception).to receive(:inspect).and_return("Net::
|
497
|
+
allow(@exception).to receive(:inspect).and_return("Net::HTTPClientException")
|
498
498
|
allow(@exception).to receive(:message).and_return("Object not found")
|
499
499
|
allow(@exception).to receive(:backtrace).and_return(@backtrace)
|
500
500
|
@resource_reporter.run_list_expand_failed(@node, @exception)
|
@@ -505,7 +505,7 @@ describe Chef::ResourceReporter do
|
|
505
505
|
it "includes the exception type in the event data" do
|
506
506
|
expect(@report).to have_key("data")
|
507
507
|
expect(@report["data"]["exception"]).to have_key("class")
|
508
|
-
expect(@report["data"]["exception"]["class"]).to eq("Net::
|
508
|
+
expect(@report["data"]["exception"]["class"]).to eq("Net::HTTPClientException")
|
509
509
|
end
|
510
510
|
|
511
511
|
it "includes the exception message in the event data" do
|
@@ -615,7 +615,7 @@ describe Chef::ResourceReporter do
|
|
615
615
|
before do
|
616
616
|
# 404 getting the run_id
|
617
617
|
@response = Net::HTTPNotFound.new("a response body", "404", "Not Found")
|
618
|
-
@error = Net::
|
618
|
+
@error = Net::HTTPClientException.new("404 message", @response)
|
619
619
|
expect(@rest_client).to receive(:post)
|
620
620
|
.with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id,
|
621
621
|
start_time: @start_time.to_s },
|
@@ -645,7 +645,7 @@ describe Chef::ResourceReporter do
|
|
645
645
|
before do
|
646
646
|
# 500 getting the run_id
|
647
647
|
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
|
648
|
-
@error = Net::
|
648
|
+
@error = Net::HTTPClientException.new("500 message", @response)
|
649
649
|
expect(@rest_client).to receive(:post)
|
650
650
|
.with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
|
651
651
|
{ "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
|
@@ -675,7 +675,7 @@ describe Chef::ResourceReporter do
|
|
675
675
|
Chef::Config[:enable_reporting_url_fatals] = true
|
676
676
|
# 500 getting the run_id
|
677
677
|
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
|
678
|
-
@error = Net::
|
678
|
+
@error = Net::HTTPClientException.new("500 message", @response)
|
679
679
|
expect(@rest_client).to receive(:post)
|
680
680
|
.with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
|
681
681
|
{ "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
|
@@ -690,7 +690,7 @@ describe Chef::ResourceReporter do
|
|
690
690
|
expect(Chef::Log).to receive(:error).with(/500/)
|
691
691
|
expect do
|
692
692
|
@resource_reporter.run_started(@run_status)
|
693
|
-
end.to raise_error(Net::
|
693
|
+
end.to raise_error(Net::HTTPClientException)
|
694
694
|
end
|
695
695
|
end
|
696
696
|
|
@@ -746,7 +746,7 @@ describe Chef::ResourceReporter do
|
|
746
746
|
|
747
747
|
it "should log 4xx errors" do
|
748
748
|
response = Net::HTTPClientError.new("forbidden", "403", "Forbidden")
|
749
|
-
error = Net::
|
749
|
+
error = Net::HTTPClientException.new("403 message", response)
|
750
750
|
allow(@rest_client).to receive(:raw_request).and_raise(error)
|
751
751
|
expect(Chef::Log).to receive(:error).with(/403/)
|
752
752
|
|
data/spec/unit/user_v1_spec.rb
CHANGED
@@ -312,7 +312,7 @@ describe Chef::UserV1 do
|
|
312
312
|
|
313
313
|
describe "Versioned API Interactions" do
|
314
314
|
let(:response_406) { OpenStruct.new(code: "406") }
|
315
|
-
let(:exception_406) { Net::
|
315
|
+
let(:exception_406) { Net::HTTPClientException.new("406 Not Acceptable", response_406) }
|
316
316
|
|
317
317
|
before (:each) do
|
318
318
|
@user = Chef::UserV1.new
|
@@ -374,7 +374,7 @@ describe Chef::UserV1 do
|
|
374
374
|
|
375
375
|
context "when the server returns a 400" do
|
376
376
|
let(:response_400) { OpenStruct.new(code: "400") }
|
377
|
-
let(:exception_400) { Net::
|
377
|
+
let(:exception_400) { Net::HTTPClientException.new("400 Bad Request", response_400) }
|
378
378
|
|
379
379
|
context "when the 400 was due to public / private key fields no longer being supported" do
|
380
380
|
let(:response_body_400) { '{"error":["Since Server API v1, all keys must be updated via the keys endpoint. "]}' }
|