chef 14.5.33-universal-mingw32 → 14.6.47-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 +5 -3
- data/chef-universal-mingw32.gemspec +3 -2
- data/chef.gemspec +3 -4
- data/lib/chef/api_client.rb +5 -3
- data/lib/chef/api_client_v1.rb +6 -4
- data/lib/chef/application.rb +1 -1
- data/lib/chef/audit/audit_reporter.rb +1 -1
- data/lib/chef/audit/control_group_data.rb +12 -6
- data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +1 -1
- data/lib/chef/cookbook/manifest_v0.rb +34 -29
- data/lib/chef/cookbook/manifest_v2.rb +15 -11
- data/lib/chef/cookbook/metadata.rb +4 -2
- data/lib/chef/cookbook_manifest.rb +8 -5
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_bag.rb +4 -2
- data/lib/chef/data_bag_item.rb +5 -3
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/resource_report.rb +4 -4
- data/lib/chef/encrypted_data_bag_item.rb +4 -2
- data/lib/chef/environment.rb +4 -2
- data/lib/chef/file_content_management/deploy/mv_unix.rb +5 -4
- data/lib/chef/handler.rb +2 -2
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/key.rb +7 -5
- data/lib/chef/knife/bootstrap.rb +7 -1
- data/lib/chef/knife/client_edit.rb +2 -2
- data/lib/chef/knife/data_bag_show.rb +2 -2
- data/lib/chef/knife/osc_user_edit.rb +2 -2
- data/lib/chef/knife/user_edit.rb +2 -2
- data/lib/chef/mixin/params_validate.rb +4 -2
- data/lib/chef/node/attribute.rb +4 -4
- data/lib/chef/org.rb +6 -4
- data/lib/chef/policy_builder/policyfile.rb +5 -3
- data/lib/chef/provider/package.rb +9 -4
- data/lib/chef/provider/package/windows.rb +23 -1
- data/lib/chef/provider/package/yum/yum_helper.py +3 -2
- data/lib/chef/provider/package/zypper.rb +12 -8
- data/lib/chef/provider/registry_key.rb +15 -6
- data/lib/chef/provider/user/windows.rb +4 -3
- data/lib/chef/provider/windows_task.rb +11 -2
- data/lib/chef/resource.rb +3 -1
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/ohai_hint.rb +4 -4
- data/lib/chef/resource/rhsm_errata_level.rb +1 -1
- data/lib/chef/resource/timezone.rb +91 -0
- data/lib/chef/resource/user/windows_user.rb +4 -0
- data/lib/chef/resource/windows_task.rb +240 -238
- data/lib/chef/resource/zypper_package.rb +5 -0
- data/lib/chef/resource_collection/resource_collection_serialization.rb +4 -2
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +4 -2
- data/lib/chef/run_list/run_list_expansion.rb +5 -3
- data/lib/chef/run_status.rb +4 -2
- data/lib/chef/user.rb +7 -5
- data/lib/chef/user_v1.rb +8 -6
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/security/sid.rb +39 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.aarch64.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.i686.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.ppc64.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.ppc64le.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.s390x.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.src.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.x86_64.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.aarch64.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.i686.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.ppc64.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.ppc64le.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.s390x.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.src.rpm +0 -0
- data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.x86_64.rpm +0 -0
- data/spec/functional/http/simple_spec.rb +2 -2
- data/spec/functional/resource/remote_file_spec.rb +2 -2
- data/spec/functional/resource/user/windows_spec.rb +1 -1
- data/spec/functional/resource/windows_task_spec.rb +1 -1
- data/spec/functional/resource/zypper_package_spec.rb +233 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/audit/audit_reporter_spec.rb +4 -4
- data/spec/unit/audit/control_group_data_spec.rb +17 -17
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/file_content_management/deploy/mv_unix_spec.rb +13 -1
- data/spec/unit/node_spec.rb +33 -0
- data/spec/unit/provider/package/rpm_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +51 -0
- data/spec/unit/provider/package_spec.rb +32 -2
- data/spec/unit/provider/registry_key_spec.rb +74 -0
- data/spec/unit/provider/user/windows_spec.rb +12 -3
- data/spec/unit/provider/windows_task_spec.rb +1 -0
- data/spec/unit/resource/timezone.rb +39 -0
- data/spec/unit/resource/windows_task_spec.rb +1 -1
- data/spec/unit/resource_collection_spec.rb +1 -1
- data/spec/unit/run_context/child_run_context_spec.rb +3 -3
- data/spec/unit/shell/shell_session_spec.rb +3 -2
- metadata +37 -41
- data/CONTRIBUTING.md +0 -152
- data/VERSION +0 -1
data/spec/spec_helper.rb
CHANGED
@@ -171,6 +171,7 @@ RSpec.configure do |config|
|
|
171
171
|
config.filter_run_excluding unix_only: true unless unix?
|
172
172
|
config.filter_run_excluding linux_only: true unless linux?
|
173
173
|
config.filter_run_excluding aix_only: true unless aix?
|
174
|
+
config.filter_run_excluding suse_only: true unless suse?
|
174
175
|
config.filter_run_excluding debian_family_only: true unless debian_family?
|
175
176
|
config.filter_run_excluding supports_cloexec: true unless supports_cloexec?
|
176
177
|
config.filter_run_excluding selinux_only: true unless selinux_enabled?
|
@@ -53,7 +53,7 @@ describe Chef::Audit::AuditReporter do
|
|
53
53
|
describe "#run_completed" do
|
54
54
|
|
55
55
|
let(:audit_data) { Chef::Audit::AuditData.new(node.name, run_id) }
|
56
|
-
let(:run_data) { audit_data.
|
56
|
+
let(:run_data) { audit_data.to_h }
|
57
57
|
|
58
58
|
before do
|
59
59
|
allow(reporter).to receive(:auditing_enabled?).and_return(true)
|
@@ -61,7 +61,7 @@ describe Chef::Audit::AuditReporter do
|
|
61
61
|
allow(rest).to receive(:post).and_return(true)
|
62
62
|
allow(reporter).to receive(:audit_data).and_return(audit_data)
|
63
63
|
allow(reporter).to receive(:run_status).and_return(run_status)
|
64
|
-
allow(audit_data).to receive(:
|
64
|
+
allow(audit_data).to receive(:to_h).and_return(run_data)
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "a successful run with auditing enabled" do
|
@@ -233,7 +233,7 @@ EOM
|
|
233
233
|
describe "#run_failed" do
|
234
234
|
|
235
235
|
let(:audit_data) { Chef::Audit::AuditData.new(node.name, run_id) }
|
236
|
-
let(:run_data) { audit_data.
|
236
|
+
let(:run_data) { audit_data.to_h }
|
237
237
|
|
238
238
|
let(:audit_error) do
|
239
239
|
double("AuditError", class: "Chef::Exceptions::AuditError",
|
@@ -249,7 +249,7 @@ EOM
|
|
249
249
|
allow(reporter).to receive(:auditing_enabled?).and_return(true)
|
250
250
|
allow(reporter).to receive(:run_status).and_return(run_status)
|
251
251
|
allow(reporter).to receive(:audit_data).and_return(audit_data)
|
252
|
-
allow(audit_data).to receive(:
|
252
|
+
allow(audit_data).to receive(:to_h).and_return(run_data)
|
253
253
|
end
|
254
254
|
|
255
255
|
context "when no prior exception is stored" do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# Author:: Tyler Ball (<tball@chef.io>)
|
3
3
|
# Author:: Claire McQuin (<claire@chef.io>)
|
4
4
|
#
|
5
|
-
# Copyright:: Copyright 2014-
|
5
|
+
# Copyright:: Copyright 2014-2018, Chef Software Inc.
|
6
6
|
# License:: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -57,9 +57,9 @@ describe Chef::Audit::AuditData do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe "#
|
60
|
+
describe "#to_h" do
|
61
61
|
|
62
|
-
let(:audit_data_hash) { audit_data.
|
62
|
+
let(:audit_data_hash) { audit_data.to_h }
|
63
63
|
|
64
64
|
it "returns a hash" do
|
65
65
|
expect(audit_data_hash).to be_a(Hash)
|
@@ -90,7 +90,7 @@ describe Chef::Audit::AuditData do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "is a one-element list containing the control group hash" do
|
93
|
-
expect(control_group_1).to receive(:
|
93
|
+
expect(control_group_1).to receive(:to_h).once.and_return(control_hash_1)
|
94
94
|
expect(control_groups.size).to eq 1
|
95
95
|
expect(control_groups).to include(control_hash_1)
|
96
96
|
end
|
@@ -103,8 +103,8 @@ describe Chef::Audit::AuditData do
|
|
103
103
|
end
|
104
104
|
|
105
105
|
it "is a list of control group hashes" do
|
106
|
-
expect(control_group_1).to receive(:
|
107
|
-
expect(control_group_2).to receive(:
|
106
|
+
expect(control_group_1).to receive(:to_h).and_return(control_hash_1)
|
107
|
+
expect(control_group_2).to receive(:to_h).and_return(control_hash_2)
|
108
108
|
expect(control_groups.size).to eq 2
|
109
109
|
expect(control_groups).to include(control_hash_1)
|
110
110
|
expect(control_groups).to include(control_hash_2)
|
@@ -127,9 +127,9 @@ describe Chef::Audit::ControlData do
|
|
127
127
|
resource_type: resource_type, resource_name: resource_name,
|
128
128
|
context: context, line_number: line_number) end
|
129
129
|
|
130
|
-
describe "#
|
130
|
+
describe "#to_h" do
|
131
131
|
|
132
|
-
let(:control_data_hash) { control_data.
|
132
|
+
let(:control_data_hash) { control_data.to_h }
|
133
133
|
|
134
134
|
it "returns a hash" do
|
135
135
|
expect(control_data_hash).to be_a(Hash)
|
@@ -385,9 +385,9 @@ describe Chef::Audit::ControlGroupData do
|
|
385
385
|
end
|
386
386
|
end
|
387
387
|
|
388
|
-
describe "#
|
388
|
+
describe "#to_h" do
|
389
389
|
|
390
|
-
let(:control_group_data_hash) { control_group_data.
|
390
|
+
let(:control_group_data_hash) { control_group_data.to_h }
|
391
391
|
|
392
392
|
it "returns a hash" do
|
393
393
|
expect(control_group_data_hash).to be_a(Hash)
|
@@ -413,11 +413,11 @@ describe Chef::Audit::ControlGroupData do
|
|
413
413
|
include_context "control"
|
414
414
|
|
415
415
|
let(:control_list) { [control_data] }
|
416
|
-
let(:control_hash) { control.
|
416
|
+
let(:control_hash) { control.to_h }
|
417
417
|
|
418
418
|
before do
|
419
419
|
expect(control_group_data).to receive(:controls).twice.and_return(control_list)
|
420
|
-
expect(control_data).to receive(:
|
420
|
+
expect(control_data).to receive(:to_h).and_return(control_hash)
|
421
421
|
end
|
422
422
|
|
423
423
|
it "is a one-element list containing the control hash" do
|
@@ -426,7 +426,7 @@ describe Chef::Audit::ControlGroupData do
|
|
426
426
|
end
|
427
427
|
|
428
428
|
it "adds a sequence number to the control" do
|
429
|
-
control_group_data.
|
429
|
+
control_group_data.to_h
|
430
430
|
expect(control_hash).to have_key(:sequence_number)
|
431
431
|
end
|
432
432
|
|
@@ -441,15 +441,15 @@ describe Chef::Audit::ControlGroupData do
|
|
441
441
|
let(:control_1) do
|
442
442
|
double("control 1",
|
443
443
|
line_number: control_hash_1[:line_number],
|
444
|
-
|
444
|
+
to_h: control_hash_1) end
|
445
445
|
let(:control_2) do
|
446
446
|
double("control 2",
|
447
447
|
line_number: control_hash_2[:line_number],
|
448
|
-
|
448
|
+
to_h: control_hash_2) end
|
449
449
|
let(:control_3) do
|
450
450
|
double("control 3",
|
451
451
|
line_number: control_hash_3[:line_number],
|
452
|
-
|
452
|
+
to_h: control_hash_3) end
|
453
453
|
|
454
454
|
let(:control_list) { [control_1, control_2, control_3] }
|
455
455
|
let(:ordered_control_hashes) { [control_hash_2, control_hash_1, control_hash_3] }
|
@@ -470,7 +470,7 @@ describe Chef::Audit::ControlGroupData do
|
|
470
470
|
end
|
471
471
|
|
472
472
|
it "assigns sequence numbers in order" do
|
473
|
-
control_group_data.
|
473
|
+
control_group_data.to_h
|
474
474
|
ordered_control_hashes.each_with_index do |control_hash, idx|
|
475
475
|
expect(control_hash[:sequence_number]).to eq idx + 1
|
476
476
|
end
|
@@ -317,7 +317,7 @@ describe Chef::Environment do
|
|
317
317
|
|
318
318
|
it "validates the name given in the params" do
|
319
319
|
expect(@environment.update_from_params(name: "@$%^&*()")).to be_falsey
|
320
|
-
expect(@environment.invalid_fields[:name]).to eq(%q{
|
320
|
+
expect(@environment.invalid_fields[:name]).to eq(%q{Property name's value @$%^&*() does not match regular expression /^[\-[:alnum:]_]+$/})
|
321
321
|
end
|
322
322
|
|
323
323
|
it "updates the description from parameters[:description]" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
3
|
-
# Copyright:: Copyright 2013-
|
3
|
+
# Copyright:: Copyright 2013-2018, 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");
|
@@ -98,4 +98,16 @@ describe Chef::FileContentManagement::Deploy::MvUnix do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
end
|
101
|
+
|
102
|
+
describe "when testing against real files", unix_only: true do
|
103
|
+
it "preserves sticky bits" do
|
104
|
+
staging_file = Tempfile.new("staging_file")
|
105
|
+
target_file = Tempfile.new("target_file")
|
106
|
+
File.chmod(04755, target_file.path)
|
107
|
+
content_deployer.deploy(staging_file.path, target_file.path)
|
108
|
+
expect(::File.stat(target_file.path).mode & 07777).to eql(04755)
|
109
|
+
staging_file.unlink
|
110
|
+
target_file.unlink
|
111
|
+
end
|
112
|
+
end
|
101
113
|
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -1818,4 +1818,37 @@ describe Chef::Node do
|
|
1818
1818
|
expect(node["a"]["key"]).to eql(1)
|
1819
1819
|
end
|
1820
1820
|
end
|
1821
|
+
|
1822
|
+
describe "when abusing the deep merge cache" do
|
1823
|
+
# https://github.com/chef/chef/issues/7738
|
1824
|
+
it "do not corrupt VividMashes that are part of the merge set and not the merge_onto set" do
|
1825
|
+
# need to have a merge two-deep (not at the top-level) between at least two default (or two override)
|
1826
|
+
# levels where the lowest priority one is the one that is going to be corrupted
|
1827
|
+
node.default["foo"]["bar"]["baz"] = "fizz"
|
1828
|
+
node.env_default["foo"]["bar"]["quux"] = "buzz"
|
1829
|
+
node.default["foo"]["bar"].tap do |bar|
|
1830
|
+
bar["test"] = "wrong"
|
1831
|
+
# this triggers a deep merge
|
1832
|
+
node["foo"]["bar"]["test"]
|
1833
|
+
# this should correctly write and dirty the cache so the next read does another deep merge on the correct __root__
|
1834
|
+
bar["test"] = "right"
|
1835
|
+
end
|
1836
|
+
expect(node["foo"]["bar"]["test"]).to eql("right")
|
1837
|
+
end
|
1838
|
+
|
1839
|
+
it "do not corrupt VividMashes that are part of the merge set and not the merge_onto set (when priorities are reversed)" do
|
1840
|
+
# need to have a merge two-deep (not at the top-level) between at least two default (or two override)
|
1841
|
+
# levels where the *HIGHEST* priority one is the one that is going to be corrupted
|
1842
|
+
node.env_default["foo"]["bar"]["baz"] = "fizz"
|
1843
|
+
node.default["foo"]["bar"]["quux"] = "buzz"
|
1844
|
+
node.env_default["foo"]["bar"].tap do |bar|
|
1845
|
+
bar["test"] = "wrong"
|
1846
|
+
# this triggers a deep merge
|
1847
|
+
node["foo"]["bar"]["test"]
|
1848
|
+
# this should correctly write and dirty the cache so the next read does another deep merge on the correct __root__
|
1849
|
+
bar["test"] = "right"
|
1850
|
+
end
|
1851
|
+
expect(node["foo"]["bar"]["test"]).to eql("right")
|
1852
|
+
end
|
1853
|
+
end
|
1821
1854
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Joshua Timberman (<joshua@chef.io>)
|
3
3
|
# Author:: Daniel DeLeo (<dan@chef.io>)
|
4
|
-
# Copyright:: Copyright 2008-
|
4
|
+
# Copyright:: Copyright 2008-2018, 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");
|
@@ -29,7 +29,7 @@ describe Chef::Provider::Package::Rpm do
|
|
29
29
|
let(:package_name) { "ImageMagick-c++" }
|
30
30
|
|
31
31
|
let(:new_resource) do
|
32
|
-
Chef::Resource::
|
32
|
+
Chef::Resource::RpmPackage.new(package_name).tap do |resource|
|
33
33
|
resource.source(package_source)
|
34
34
|
end
|
35
35
|
end
|
@@ -51,7 +51,7 @@ describe Chef::Provider::Package::Rpm do
|
|
51
51
|
describe "when the package source is not valid" do
|
52
52
|
|
53
53
|
context "when source is not defiend" do
|
54
|
-
let(:new_resource) { Chef::Resource::
|
54
|
+
let(:new_resource) { Chef::Resource::RpmPackage.new("ImageMagick-c++") }
|
55
55
|
|
56
56
|
it "should raise an exception when attempting any action" do
|
57
57
|
expect { provider.run_action(:any) }.to raise_error(Chef::Exceptions::Package)
|
@@ -405,10 +405,10 @@ describe Chef::Provider::Package::Rpm do
|
|
405
405
|
# let() bindings and such, we have to set the stub here and not in a
|
406
406
|
# before block.
|
407
407
|
allow(::File).to receive(:exist?).with(package_source).and_return(true)
|
408
|
-
Chef::Resource::
|
408
|
+
Chef::Resource::RpmPackage.new("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
|
409
409
|
end
|
410
410
|
|
411
|
-
let(:current_resource) { Chef::Resource::
|
411
|
+
let(:current_resource) { Chef::Resource::RpmPackage.new("ImageMagick-c++") }
|
412
412
|
|
413
413
|
it "should install from a path when the package is a path and the source is nil" do
|
414
414
|
expect(new_resource.source).to eq("/tmp/ImageMagick-c++-6.5.4.7-7.el6_5.x86_64.rpm")
|
@@ -163,6 +163,22 @@ describe Chef::Provider::Package::Zypper do
|
|
163
163
|
)
|
164
164
|
provider.install_package(["emacs"], ["1.0"])
|
165
165
|
end
|
166
|
+
|
167
|
+
it "should add user provided global options" do
|
168
|
+
new_resource.global_options "--user-provided"
|
169
|
+
shell_out_expectation!(
|
170
|
+
"zypper", "--user-provided", "--non-interactive", "install", "--auto-agree-with-licenses", "emacs=1.0"
|
171
|
+
)
|
172
|
+
provider.install_package(["emacs"], ["1.0"])
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should add multiple user provided global options" do
|
176
|
+
new_resource.global_options "--user-provided1 --user-provided2"
|
177
|
+
shell_out_expectation!(
|
178
|
+
"zypper", "--user-provided1", "--user-provided2", "--non-interactive", "install", "--auto-agree-with-licenses", "emacs=1.0"
|
179
|
+
)
|
180
|
+
provider.install_package(["emacs"], ["1.0"])
|
181
|
+
end
|
166
182
|
end
|
167
183
|
|
168
184
|
describe "upgrade_package" do
|
@@ -193,6 +209,13 @@ describe Chef::Provider::Package::Zypper do
|
|
193
209
|
)
|
194
210
|
provider.upgrade_package(["emacs"], ["1.0"])
|
195
211
|
end
|
212
|
+
it "should add user provided global options" do
|
213
|
+
new_resource.global_options "--user-provided"
|
214
|
+
shell_out_expectation!(
|
215
|
+
"zypper", "--user-provided", "--non-interactive", "install", "--auto-agree-with-licenses", "emacs=1.0"
|
216
|
+
)
|
217
|
+
provider.upgrade_package(["emacs"], ["1.0"])
|
218
|
+
end
|
196
219
|
end
|
197
220
|
|
198
221
|
describe "remove_package" do
|
@@ -234,6 +257,13 @@ describe Chef::Provider::Package::Zypper do
|
|
234
257
|
)
|
235
258
|
provider.remove_package(["emacs"], ["1.0"])
|
236
259
|
end
|
260
|
+
it "should add user provided global options" do
|
261
|
+
new_resource.global_options "--user-provided"
|
262
|
+
shell_out_expectation!(
|
263
|
+
"zypper", "--user-provided", "--non-interactive", "remove", "emacs=1.0"
|
264
|
+
)
|
265
|
+
provider.remove_package(["emacs"], ["1.0"])
|
266
|
+
end
|
237
267
|
end
|
238
268
|
end
|
239
269
|
|
@@ -265,6 +295,13 @@ describe Chef::Provider::Package::Zypper do
|
|
265
295
|
)
|
266
296
|
provider.purge_package(["emacs"], ["1.0"])
|
267
297
|
end
|
298
|
+
it "should add user provided global options" do
|
299
|
+
new_resource.global_options "--user-provided"
|
300
|
+
shell_out_expectation!(
|
301
|
+
"zypper", "--user-provided", "--non-interactive", "remove", "--clean-deps", "emacs=1.0"
|
302
|
+
)
|
303
|
+
provider.purge_package(["emacs"], ["1.0"])
|
304
|
+
end
|
268
305
|
end
|
269
306
|
|
270
307
|
describe "action_lock" do
|
@@ -320,6 +357,13 @@ describe Chef::Provider::Package::Zypper do
|
|
320
357
|
)
|
321
358
|
provider.lock_package(["emacs"], [nil])
|
322
359
|
end
|
360
|
+
it "should add user provided global options" do
|
361
|
+
new_resource.global_options "--user-provided"
|
362
|
+
shell_out_expectation!(
|
363
|
+
"zypper", "--user-provided", "--non-interactive", "addlock", "emacs"
|
364
|
+
)
|
365
|
+
provider.lock_package(["emacs"], [nil])
|
366
|
+
end
|
323
367
|
end
|
324
368
|
|
325
369
|
describe "action_unlock" do
|
@@ -374,6 +418,13 @@ describe Chef::Provider::Package::Zypper do
|
|
374
418
|
)
|
375
419
|
provider.unlock_package(["emacs"], [nil])
|
376
420
|
end
|
421
|
+
it "should add user provided global options" do
|
422
|
+
new_resource.global_options "--user-provided"
|
423
|
+
shell_out_expectation!(
|
424
|
+
"zypper", "--user-provided", "--non-interactive", "removelock", "emacs"
|
425
|
+
)
|
426
|
+
provider.unlock_package(["emacs"], [nil])
|
427
|
+
end
|
377
428
|
end
|
378
429
|
|
379
430
|
describe "on an older zypper" do
|
@@ -171,7 +171,7 @@ describe Chef::Provider::Package do
|
|
171
171
|
|
172
172
|
it "should print the word 'uninstalled' if there was no original version" do
|
173
173
|
allow(current_resource).to receive(:version).and_return(nil)
|
174
|
-
expect(logger).to receive(:info).with("package[install emacs] upgraded emacs to 1.0")
|
174
|
+
expect(logger).to receive(:info).with("package[install emacs] upgraded(allow_downgrade) emacs to 1.0")
|
175
175
|
provider.run_action(:upgrade)
|
176
176
|
expect(new_resource).to be_updated_by_last_action
|
177
177
|
end
|
@@ -714,7 +714,15 @@ describe "Chef::Provider::Package - Multi" do
|
|
714
714
|
expect(new_resource).not_to be_updated_by_last_action
|
715
715
|
end
|
716
716
|
|
717
|
-
it "does
|
717
|
+
it "does install an older version by default" do
|
718
|
+
current_resource.version(["1.1", "6.2"])
|
719
|
+
new_resource.version(["1.0", "6.1"])
|
720
|
+
provider.run_action(:install)
|
721
|
+
expect(new_resource).to be_updated_by_last_action
|
722
|
+
end
|
723
|
+
|
724
|
+
it "does not install an older version if the resource subclass has allow_downgrade set to false" do
|
725
|
+
allow(new_resource).to receive(:allow_downgrade).and_return(false)
|
718
726
|
current_resource.version(["1.1", "6.2"])
|
719
727
|
new_resource.version(["1.0", "6.1"])
|
720
728
|
provider.run_action(:install)
|
@@ -980,4 +988,26 @@ describe "Chef::Provider::Package - Multi" do
|
|
980
988
|
end
|
981
989
|
end
|
982
990
|
end
|
991
|
+
|
992
|
+
describe "version_compare" do
|
993
|
+
it "tests equality" do
|
994
|
+
expect(provider.version_compare("1.3", "1.3")).to eql(0)
|
995
|
+
end
|
996
|
+
|
997
|
+
it "tests less than" do
|
998
|
+
expect(provider.version_compare("1.2", "1.3")).to eql(-1)
|
999
|
+
end
|
1000
|
+
|
1001
|
+
it "tests greater than" do
|
1002
|
+
expect(provider.version_compare("1.5", "1.3")).to eql(1)
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
it "x.10 is greater than x.2 (so does not do floating point comparisons)" do
|
1006
|
+
expect(provider.version_compare("1.10", "1.2")).to eql(1)
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
it "sanitizes inputs" do
|
1010
|
+
expect(provider.version_compare("1.3_3", "1.3")).to eql(0)
|
1011
|
+
end
|
1012
|
+
end
|
983
1013
|
end
|
@@ -309,6 +309,80 @@ describe Chef::Provider::RegistryKey do
|
|
309
309
|
@provider.action_create
|
310
310
|
end
|
311
311
|
end
|
312
|
+
|
313
|
+
context "when sensitive is true" do
|
314
|
+
before(:each) do
|
315
|
+
@new_resource.sensitive(true)
|
316
|
+
end
|
317
|
+
|
318
|
+
context "and key exists" do
|
319
|
+
let(:keyname) { 'hklm\\software\\opscode\\testing\\sensitive\exists' }
|
320
|
+
before(:each) do
|
321
|
+
expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
|
322
|
+
expect(@double_registry).to receive(:get_values).with(keyname).and_return(
|
323
|
+
[
|
324
|
+
{ name: "one", type: :string, data: "initial value" },
|
325
|
+
{ name: "two", type: :dword, data: 9001 }
|
326
|
+
]
|
327
|
+
)
|
328
|
+
end
|
329
|
+
|
330
|
+
context "and type is a string" do
|
331
|
+
let(:testval1) { { name: "one", type: :string, data: "first_value" } }
|
332
|
+
|
333
|
+
it "sets the unscrubbed value" do
|
334
|
+
expect(@double_registry).to receive(:set_value).with(keyname, testval1)
|
335
|
+
@provider.load_current_resource
|
336
|
+
@provider.action_create
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
context "and type is a dword" do
|
341
|
+
let(:testval1) { { name: "two", type: :dword, data: 12345 } }
|
342
|
+
|
343
|
+
it "sets the unscrubbed value" do
|
344
|
+
expect(@double_registry).to receive(:set_value).with(keyname, testval1)
|
345
|
+
@provider.load_current_resource
|
346
|
+
@provider.action_create
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
context "and key does not exist" do
|
352
|
+
let(:keyname) { 'hklm\\software\\opscode\\testing\\sensitive\missing' }
|
353
|
+
let(:testval1) { { name: "one", type: :string, data: "first_value" } }
|
354
|
+
|
355
|
+
before(:each) do
|
356
|
+
expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(false)
|
357
|
+
expect(@double_registry).to receive(:create_key).with(keyname, false)
|
358
|
+
end
|
359
|
+
|
360
|
+
it "sets the unscrubbed value" do
|
361
|
+
expect(@double_registry).to receive(:set_value).with(keyname, testval1)
|
362
|
+
@provider.load_current_resource
|
363
|
+
@provider.action_create
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
describe "action_create_if_missing" do
|
370
|
+
context "when sensitive is true" do
|
371
|
+
let(:keyname) { 'hklm\\software\\opscode\\testing\\create_if_missing\\sensitive' }
|
372
|
+
let(:testval1) { { name: "one", type: :string, data: "first_value" } }
|
373
|
+
|
374
|
+
before(:each) do
|
375
|
+
expect(@double_registry).to receive(:key_exists?).twice.with(keyname).and_return(true)
|
376
|
+
expect(@double_registry).to receive(:get_values).with(keyname).and_return([])
|
377
|
+
@new_resource.sensitive(true)
|
378
|
+
end
|
379
|
+
|
380
|
+
it "sets the unscrubbed value" do
|
381
|
+
expect(@double_registry).to receive(:set_value).with(keyname, testval1)
|
382
|
+
@provider.load_current_resource
|
383
|
+
@provider.action_create_if_missing
|
384
|
+
end
|
385
|
+
end
|
312
386
|
end
|
313
387
|
end
|
314
388
|
|