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.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +3 -2
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +17 -17
- data/distro/common/html/knife_environment.html +4 -8
- data/distro/common/man/man1/knife-environment.1 +4 -16
- data/distro/powershell/chef/chef.psm1 +139 -24
- data/lib/chef/application.rb +5 -4
- data/lib/chef/application/windows_service_manager.rb +6 -4
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/data_collector.rb +24 -13
- data/lib/chef/data_collector/messages.rb +8 -6
- data/lib/chef/data_collector/messages/helpers.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/platform_introspection.rb +2 -2
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +5 -5
- data/lib/chef/file_access_control/unix.rb +5 -5
- data/lib/chef/formatters/error_description.rb +1 -1
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/json_input.rb +2 -2
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/mixin/command.rb +1 -0
- data/lib/chef/mixin/deep_merge.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +58 -3
- data/lib/chef/mixin/which.rb +5 -9
- data/lib/chef/mixin/wide_string.rb +1 -1
- data/lib/chef/node.rb +1 -1
- data/lib/chef/node/attribute.rb +4 -5
- data/lib/chef/node_map.rb +18 -2
- data/lib/chef/platform/provider_handler_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -0
- data/lib/chef/platform/resource_handler_map.rb +2 -2
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/group.rb +41 -46
- data/lib/chef/provider/group/aix.rb +12 -19
- data/lib/chef/provider/group/dscl.rb +46 -43
- data/lib/chef/provider/group/gpasswd.rb +7 -7
- data/lib/chef/provider/group/groupadd.rb +29 -34
- data/lib/chef/provider/group/groupmod.rb +26 -31
- data/lib/chef/provider/group/pw.rb +28 -31
- data/lib/chef/provider/group/suse.rb +9 -9
- data/lib/chef/provider/group/usermod.rb +10 -11
- data/lib/chef/provider/group/windows.rb +18 -20
- data/lib/chef/provider/ifconfig.rb +52 -63
- data/lib/chef/provider/ifconfig/aix.rb +23 -28
- data/lib/chef/provider/ifconfig/debian.rb +23 -22
- data/lib/chef/provider/ifconfig/redhat.rb +12 -12
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +4 -2
- data/lib/chef/provider/package.rb +16 -7
- data/lib/chef/provider/package/chocolatey.rb +3 -1
- data/lib/chef/provider/package/dnf.rb +183 -0
- data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
- data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
- data/lib/chef/provider/package/dnf/version.rb +56 -0
- data/lib/chef/provider/package/easy_install.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +3 -3
- data/lib/chef/provider/package/windows.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/route.rb +186 -184
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/support/yum_repo.erb +10 -3
- data/lib/chef/provider/user.rb +17 -20
- data/lib/chef/provider/user/aix.rb +23 -24
- data/lib/chef/provider/user/dscl.rb +56 -53
- data/lib/chef/provider/user/linux.rb +13 -16
- data/lib/chef/provider/user/pw.rb +26 -30
- data/lib/chef/provider/user/solaris.rb +11 -12
- data/lib/chef/provider/user/useradd.rb +20 -22
- data/lib/chef/provider/user/windows.rb +19 -22
- data/lib/chef/provider_resolver.rb +4 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +7 -0
- data/lib/chef/resource/chocolatey_package.rb +1 -0
- data/lib/chef/resource/dnf_package.rb +64 -0
- data/lib/chef/resource/file/verification.rb +6 -4
- data/lib/chef/resource/yum_package.rb +18 -14
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_reporter.rb +11 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/scan_access_control.rb +4 -4
- data/lib/chef/util/dsc/resource_store.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/memory.rb +1 -1
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/sid.rb +2 -2
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
- data/spec/functional/resource/dnf_package_spec.rb +686 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/user/useradd_spec.rb +10 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
- data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
- data/spec/integration/recipes/resource_load_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -3
- data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
- data/spec/support/lib/chef/resource/cat.rb +1 -0
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
- data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
- data/spec/support/lib/chef/resource/with_state.rb +2 -0
- data/spec/support/lib/chef/resource/zen_master.rb +1 -0
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
- data/spec/unit/data_collector_spec.rb +56 -0
- data/spec/unit/decorator/lazy_spec.rb +1 -1
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +3 -4
- data/spec/unit/node_spec.rb +23 -2
- data/spec/unit/platform_spec.rb +1 -0
- data/spec/unit/provider/group/dscl_spec.rb +29 -29
- data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
- data/spec/unit/provider/group/groupadd_spec.rb +31 -30
- data/spec/unit/provider/group/groupmod_spec.rb +16 -16
- data/spec/unit/provider/group/pw_spec.rb +11 -11
- data/spec/unit/provider/group/suse_spec.rb +5 -5
- data/spec/unit/provider/group/usermod_spec.rb +15 -15
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
- data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
- data/spec/unit/provider/ifconfig_spec.rb +18 -19
- data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
- data/spec/unit/provider/package/msu_spec.rb +1 -1
- data/spec/unit/provider/route_spec.rb +21 -21
- data/spec/unit/provider/user/dscl_spec.rb +54 -57
- data/spec/unit/provider/user/linux_spec.rb +5 -5
- data/spec/unit/provider/user/pw_spec.rb +26 -22
- data/spec/unit/provider/user/windows_spec.rb +4 -4
- data/spec/unit/provider/user_spec.rb +19 -21
- data/spec/unit/provider_resolver_spec.rb +1 -0
- data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
- data/spec/unit/resource/dnf_package_spec.rb +99 -0
- data/spec/unit/resource/remote_file_spec.rb +2 -2
- data/spec/unit/resource/yum_package_spec.rb +20 -0
- data/spec/unit/resource_reporter_spec.rb +24 -0
- data/spec/unit/resource_spec.rb +2 -0
- data/spec/unit/runner_spec.rb +1 -0
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/gemfile_util.rb +2 -2
- data/tasks/templates/prerelease.md.erb +1 -10
- data/tasks/templates/release.md.erb +1 -9
- metadata +24 -5
- data/lib/chef/platform/handler_map.rb +0 -40
@@ -34,7 +34,7 @@ describe Chef::Provider::User::Pw do
|
|
34
34
|
|
35
35
|
# XXX: rip out in Chef-13
|
36
36
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
37
|
-
@new_resource.supports :
|
37
|
+
@new_resource.supports manage_home: true
|
38
38
|
|
39
39
|
@current_resource = Chef::Resource::User::PwUser.new("adam")
|
40
40
|
@current_resource.comment "Adam Jacob"
|
@@ -65,35 +65,36 @@ describe Chef::Provider::User::Pw do
|
|
65
65
|
|
66
66
|
it "should set the option for #{attribute} if the new resources #{attribute} is not null" do
|
67
67
|
allow(@new_resource).to receive(attribute).and_return("hola")
|
68
|
-
expect(@provider.set_options).to eql(
|
68
|
+
expect(@provider.set_options).to eql([ @new_resource.username, option, @new_resource.send(attribute), "-m"])
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should set the option for #{attribute} if the new resources #{attribute} is not null, without homedir management" do
|
72
|
-
allow(@new_resource).to receive(:supports).and_return(
|
72
|
+
allow(@new_resource).to receive(:supports).and_return(manage_home: false)
|
73
73
|
allow(@new_resource).to receive(attribute).and_return("hola")
|
74
|
-
expect(@provider.set_options).to eql(
|
74
|
+
expect(@provider.set_options).to eql([@new_resource.username, option, @new_resource.send(attribute)])
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should combine all the possible options" do
|
79
|
-
|
79
|
+
match_array = [ "adam" ]
|
80
80
|
field_list.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option|
|
81
81
|
allow(@new_resource).to receive(attribute).and_return("hola")
|
82
|
-
|
82
|
+
match_array << option
|
83
|
+
match_array << "hola"
|
83
84
|
end
|
84
|
-
|
85
|
-
expect(@provider.set_options).to eql(
|
85
|
+
match_array << "-m"
|
86
|
+
expect(@provider.set_options).to eql(match_array)
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
90
|
describe "create_user" do
|
90
91
|
before(:each) do
|
91
|
-
allow(@provider).to receive(:
|
92
|
+
allow(@provider).to receive(:shell_out!).and_return(true)
|
92
93
|
allow(@provider).to receive(:modify_password).and_return(true)
|
93
94
|
end
|
94
95
|
|
95
96
|
it "should run pw useradd with the return of set_options" do
|
96
|
-
expect(@provider).to receive(:
|
97
|
+
expect(@provider).to receive(:shell_out!).with("pw", "useradd", "adam", "-m").and_return(true)
|
97
98
|
@provider.create_user
|
98
99
|
end
|
99
100
|
|
@@ -105,12 +106,12 @@ describe Chef::Provider::User::Pw do
|
|
105
106
|
|
106
107
|
describe "manage_user" do
|
107
108
|
before(:each) do
|
108
|
-
allow(@provider).to receive(:
|
109
|
+
allow(@provider).to receive(:shell_out!).and_return(true)
|
109
110
|
allow(@provider).to receive(:modify_password).and_return(true)
|
110
111
|
end
|
111
112
|
|
112
113
|
it "should run pw usermod with the return of set_options" do
|
113
|
-
expect(@provider).to receive(:
|
114
|
+
expect(@provider).to receive(:shell_out!).with("pw", "usermod", "adam", "-m").and_return(true)
|
114
115
|
@provider.manage_user
|
115
116
|
end
|
116
117
|
|
@@ -122,13 +123,13 @@ describe Chef::Provider::User::Pw do
|
|
122
123
|
|
123
124
|
describe "remove_user" do
|
124
125
|
it "should run pw userdel with the new resources user name" do
|
125
|
-
@new_resource.supports :
|
126
|
-
expect(@provider).to receive(:
|
126
|
+
@new_resource.supports manage_home: false
|
127
|
+
expect(@provider).to receive(:shell_out!).with("pw", "userdel", @new_resource.username).and_return(true)
|
127
128
|
@provider.remove_user
|
128
129
|
end
|
129
130
|
|
130
131
|
it "should run pw userdel with the new resources user name and -r if manage_home is true" do
|
131
|
-
expect(@provider).to receive(:
|
132
|
+
expect(@provider).to receive(:shell_out!).with("pw", "userdel", @new_resource.username, "-r").and_return(true)
|
132
133
|
@provider.remove_user
|
133
134
|
end
|
134
135
|
end
|
@@ -147,23 +148,26 @@ describe Chef::Provider::User::Pw do
|
|
147
148
|
|
148
149
|
describe "when locking the user" do
|
149
150
|
it "should run pw lock with the new resources username" do
|
150
|
-
expect(@provider).to receive(:
|
151
|
+
expect(@provider).to receive(:shell_out!).with("pw", "lock", @new_resource.username)
|
151
152
|
@provider.lock_user
|
152
153
|
end
|
153
154
|
end
|
154
155
|
|
155
156
|
describe "when unlocking the user" do
|
156
157
|
it "should run pw unlock with the new resources username" do
|
157
|
-
expect(@provider).to receive(:
|
158
|
+
expect(@provider).to receive(:shell_out!).with("pw", "unlock", @new_resource.username)
|
158
159
|
@provider.unlock_user
|
159
160
|
end
|
160
161
|
end
|
161
162
|
|
162
163
|
describe "when modifying the password" do
|
163
164
|
before(:each) do
|
164
|
-
@status = double("Status", :
|
165
|
+
@status = double("Status", exitstatus: 0)
|
165
166
|
allow(@provider).to receive(:popen4).and_return(@status)
|
166
|
-
@pid
|
167
|
+
@pid = nil
|
168
|
+
@stdin = nil
|
169
|
+
@stdout = nil
|
170
|
+
@stderr = nil
|
167
171
|
end
|
168
172
|
|
169
173
|
describe "and the new password has not been specified" do
|
@@ -210,7 +214,7 @@ describe Chef::Provider::User::Pw do
|
|
210
214
|
end
|
211
215
|
|
212
216
|
it "should run pw usermod with the username and the option -H 0" do
|
213
|
-
expect(@provider).to receive(:popen4).with("pw usermod adam -H 0", :
|
217
|
+
expect(@provider).to receive(:popen4).with("pw usermod adam -H 0", waitlast: true).and_return(@status)
|
214
218
|
@provider.modify_password
|
215
219
|
end
|
216
220
|
|
@@ -239,12 +243,12 @@ describe Chef::Provider::User::Pw do
|
|
239
243
|
end
|
240
244
|
|
241
245
|
it "should raise an error if the required binary /usr/sbin/pw doesn't exist" do
|
242
|
-
expect(File).to receive(:
|
246
|
+
expect(File).to receive(:exist?).with("/usr/sbin/pw").and_return(false)
|
243
247
|
expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::User)
|
244
248
|
end
|
245
249
|
|
246
250
|
it "shouldn't raise an error if /usr/sbin/pw exists" do
|
247
|
-
allow(File).to receive(:
|
251
|
+
allow(File).to receive(:exist?).and_return(true)
|
248
252
|
expect { @provider.load_current_resource }.not_to raise_error
|
249
253
|
end
|
250
254
|
end
|
@@ -127,19 +127,19 @@ describe Chef::Provider::User::Windows do
|
|
127
127
|
|
128
128
|
describe "when creating the user" do
|
129
129
|
it "should call @net_user.add with the return of set_options" do
|
130
|
-
allow(@provider).to receive(:set_options).and_return(:
|
131
|
-
expect(@net_user).to receive(:add).with(:
|
130
|
+
allow(@provider).to receive(:set_options).and_return(name: "monkey")
|
131
|
+
expect(@net_user).to receive(:add).with(name: "monkey")
|
132
132
|
@provider.create_user
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe "manage_user" do
|
137
137
|
before(:each) do
|
138
|
-
allow(@provider).to receive(:set_options).and_return(:
|
138
|
+
allow(@provider).to receive(:set_options).and_return(name: "monkey")
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should call @net_user.update with the return of set_options" do
|
142
|
-
expect(@net_user).to receive(:update).with(:
|
142
|
+
expect(@net_user).to receive(:update).with(name: "monkey")
|
143
143
|
@provider.manage_user
|
144
144
|
end
|
145
145
|
end
|
@@ -58,7 +58,7 @@ describe Chef::Provider::User do
|
|
58
58
|
describe "executing load_current_resource" do
|
59
59
|
before(:each) do
|
60
60
|
@node = Chef::Node.new
|
61
|
-
|
61
|
+
# @new_resource = double("Chef::Resource::User",
|
62
62
|
# :null_object => true,
|
63
63
|
# :username => "adam",
|
64
64
|
# :comment => "Adam Jacob",
|
@@ -68,7 +68,7 @@ describe Chef::Provider::User do
|
|
68
68
|
# :shell => "/usr/bin/zsh",
|
69
69
|
# :password => nil,
|
70
70
|
# :updated => nil
|
71
|
-
#)
|
71
|
+
# )
|
72
72
|
allow(Chef::Resource::User).to receive(:new).and_return(@current_resource)
|
73
73
|
@pw_user = EtcPwnamIsh.new
|
74
74
|
@pw_user.name = "adam"
|
@@ -110,11 +110,11 @@ describe Chef::Provider::User do
|
|
110
110
|
|
111
111
|
# The mapping between the Chef::Resource::User and Getpwnam struct
|
112
112
|
user_attrib_map = {
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
113
|
+
uid: :uid,
|
114
|
+
gid: :gid,
|
115
|
+
comment: :gecos,
|
116
|
+
home: :dir,
|
117
|
+
shell: :shell,
|
118
118
|
}
|
119
119
|
user_attrib_map.each do |user_attrib, getpwnam_attrib|
|
120
120
|
it "should set the current resources #{user_attrib} based on getpwnam #{getpwnam_attrib}" do
|
@@ -140,18 +140,16 @@ describe Chef::Provider::User do
|
|
140
140
|
|
141
141
|
describe "and running assertions" do
|
142
142
|
def self.shadow_lib_unavail?
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
false
|
151
|
-
end
|
143
|
+
require "rubygems"
|
144
|
+
require "shadow"
|
145
|
+
rescue LoadError
|
146
|
+
skip "ruby-shadow gem not installed for dynamic load test"
|
147
|
+
true
|
148
|
+
else
|
149
|
+
false
|
152
150
|
end
|
153
151
|
|
154
|
-
before
|
152
|
+
before(:each) do
|
155
153
|
user = @pw_user.dup
|
156
154
|
user.name = "root"
|
157
155
|
user.passwd = "x"
|
@@ -161,15 +159,15 @@ describe Chef::Provider::User do
|
|
161
159
|
|
162
160
|
unless shadow_lib_unavail?
|
163
161
|
context "and we have the ruby-shadow gem" do
|
164
|
-
skip "and we are not root (rerun this again as root)", :
|
162
|
+
skip "and we are not root (rerun this again as root)", requires_unprivileged_user: true
|
165
163
|
|
166
|
-
context "and we are root", :
|
164
|
+
context "and we are root", requires_root: true do
|
167
165
|
it "should pass assertions when ruby-shadow can be loaded" do
|
168
166
|
@provider.action = "create"
|
169
167
|
original_method = @provider.method(:require)
|
170
168
|
expect(@provider).to receive(:require) { |*args| original_method.call(*args) }
|
171
|
-
passwd_info = Struct::PasswdEntry.new(:
|
172
|
-
:
|
169
|
+
passwd_info = Struct::PasswdEntry.new(sp_namp: "adm ", sp_pwdp: "$1$T0N0Q.lc$nyG6pFI3Dpqa5cxUz/57j0", sp_lstchg: 14861, sp_min: 0, sp_max: 99999,
|
170
|
+
sp_warn: 7, sp_inact: -1, sp_expire: -1, sp_flag: -1)
|
173
171
|
expect(Shadow::Passwd).to receive(:getspnam).with("adam").and_return(passwd_info)
|
174
172
|
@provider.load_current_resource
|
175
173
|
@provider.define_resource_requirements
|
@@ -135,6 +135,7 @@ describe Chef::ProviderResolver do
|
|
135
135
|
end
|
136
136
|
else
|
137
137
|
it "'#{name}' fails to resolve (since #{name.inspect} is unsupported on #{platform} #{platform_version})", *tags do
|
138
|
+
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
138
139
|
expect(resolved_provider).to be_nil
|
139
140
|
end
|
140
141
|
end
|
@@ -64,4 +64,16 @@ describe Chef::Resource::ChocolateyPackage do
|
|
64
64
|
resource.version(["1.2.3", "4.5.6"])
|
65
65
|
expect(resource.version).to eql(["1.2.3", "4.5.6"])
|
66
66
|
end
|
67
|
+
|
68
|
+
it "the default returns should be 0" do
|
69
|
+
expect(resource.returns).to eql([0])
|
70
|
+
end
|
71
|
+
|
72
|
+
# Integer, Array
|
73
|
+
[ 0, [0, 48, 49] ].each do |val|
|
74
|
+
it "supports setting an alternate return value as a #{val.class}" do
|
75
|
+
resource.returns(val)
|
76
|
+
expect(resource.returns).to eql(val)
|
77
|
+
end
|
78
|
+
end
|
67
79
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2016, Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
require "support/shared/unit/resource/static_provider_resolution"
|
20
|
+
|
21
|
+
describe Chef::Resource::DnfPackage, "initialize" do
|
22
|
+
|
23
|
+
static_provider_resolution(
|
24
|
+
resource: Chef::Resource::DnfPackage,
|
25
|
+
provider: Chef::Provider::Package::Dnf,
|
26
|
+
name: :dnf_package,
|
27
|
+
action: :install,
|
28
|
+
os: "linux",
|
29
|
+
platform_family: "rhel"
|
30
|
+
)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe Chef::Resource::DnfPackage, "arch" do
|
35
|
+
before(:each) do
|
36
|
+
@resource = Chef::Resource::DnfPackage.new("foo")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should set the arch variable to whatever is passed in" do
|
40
|
+
@resource.arch("i386")
|
41
|
+
expect(@resource.arch).to eql(["i386"])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe Chef::Resource::DnfPackage, "flush_cache" do
|
46
|
+
before(:each) do
|
47
|
+
@resource = Chef::Resource::DnfPackage.new("foo")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should default the flush timing to false" do
|
51
|
+
flush_hash = { :before => false, :after => false }
|
52
|
+
expect(@resource.flush_cache).to eq(flush_hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should allow you to set the flush timing with an array" do
|
56
|
+
flush_array = [ :before, :after ]
|
57
|
+
flush_hash = { :before => true, :after => true }
|
58
|
+
@resource.flush_cache(flush_array)
|
59
|
+
expect(@resource.flush_cache).to eq(flush_hash)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should allow you to set the flush timing with a hash" do
|
63
|
+
flush_hash = { :before => true, :after => true }
|
64
|
+
@resource.flush_cache(flush_hash)
|
65
|
+
expect(@resource.flush_cache).to eq(flush_hash)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should allow 'true' for flush_cache" do
|
69
|
+
@resource.flush_cache(true)
|
70
|
+
expect(@resource.flush_cache).to eq({ before: true, after: true })
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should allow 'false' for flush_cache" do
|
74
|
+
@resource.flush_cache(false)
|
75
|
+
expect(@resource.flush_cache).to eq({ before: false, after: false })
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should allow ':before' for flush_cache" do
|
79
|
+
@resource.flush_cache(:before)
|
80
|
+
expect(@resource.flush_cache).to eq({ before: true, after: false })
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should allow ':after' for flush_cache" do
|
84
|
+
@resource.flush_cache(:after)
|
85
|
+
expect(@resource.flush_cache).to eq({ before: false, after: true })
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe Chef::Resource::DnfPackage, "allow_downgrade" do
|
90
|
+
before(:each) do
|
91
|
+
@resource = Chef::Resource::DnfPackage.new("foo")
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should allow you to specify whether allow_downgrade is true or false" do
|
95
|
+
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
96
|
+
expect { @resource.allow_downgrade true }.not_to raise_error
|
97
|
+
expect { @resource.allow_downgrade false }.not_to raise_error
|
98
|
+
end
|
99
|
+
end
|
@@ -36,13 +36,13 @@ describe Chef::Resource::RemoteFile do
|
|
36
36
|
it "says its provider is RemoteFile when the source is an absolute URI" do
|
37
37
|
@resource.source("http://www.google.com/robots.txt")
|
38
38
|
expect(@resource.provider).to eq(Chef::Provider::RemoteFile)
|
39
|
-
expect(
|
39
|
+
expect(@resource.provider_for_action(:create)).to be_kind_of(Chef::Provider::RemoteFile)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "says its provider is RemoteFile when the source is a network share" do
|
43
43
|
@resource.source("\\\\fakey\\fakerton\\fake.txt")
|
44
44
|
expect(@resource.provider).to eq(Chef::Provider::RemoteFile)
|
45
|
-
expect(
|
45
|
+
expect(@resource.provider_for_action(:create)).to be_kind_of(Chef::Provider::RemoteFile)
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "source" do
|
@@ -65,6 +65,26 @@ describe Chef::Resource::YumPackage, "flush_cache" do
|
|
65
65
|
@resource.flush_cache(flush_hash)
|
66
66
|
expect(@resource.flush_cache).to eq(flush_hash)
|
67
67
|
end
|
68
|
+
|
69
|
+
it "should allow 'true' for flush_cache" do
|
70
|
+
@resource.flush_cache(true)
|
71
|
+
expect(@resource.flush_cache).to eq({ before: true, after: true })
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should allow 'false' for flush_cache" do
|
75
|
+
@resource.flush_cache(false)
|
76
|
+
expect(@resource.flush_cache).to eq({ before: false, after: false })
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should allow ':before' for flush_cache" do
|
80
|
+
@resource.flush_cache(:before)
|
81
|
+
expect(@resource.flush_cache).to eq({ before: true, after: false })
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should allow ':after' for flush_cache" do
|
85
|
+
@resource.flush_cache(:after)
|
86
|
+
expect(@resource.flush_cache).to eq({ before: false, after: true })
|
87
|
+
end
|
68
88
|
end
|
69
89
|
|
70
90
|
describe Chef::Resource::YumPackage, "allow_downgrade" do
|
@@ -265,6 +265,30 @@ describe Chef::ResourceReporter do
|
|
265
265
|
@resource_reporter.run_started(@run_status)
|
266
266
|
end
|
267
267
|
|
268
|
+
context "when the new_resource is sensitive" do
|
269
|
+
before do
|
270
|
+
@execute_resource = Chef::Resource::Execute.new("sensitive-resource")
|
271
|
+
@execute_resource.name("sensitive-resource")
|
272
|
+
@execute_resource.command('echo "password: SECRET"')
|
273
|
+
@execute_resource.sensitive(true)
|
274
|
+
@resource_reporter.resource_action_start(@execute_resource, :run)
|
275
|
+
@resource_reporter.resource_current_state_loaded(@execute_resource, :run, @current_resource)
|
276
|
+
@resource_reporter.resource_updated(@execute_resource, :run)
|
277
|
+
@resource_reporter.resource_completed(@execute_resource)
|
278
|
+
@run_status.stop_clock
|
279
|
+
@report = @resource_reporter.prepare_run_data
|
280
|
+
@first_update_report = @report["resources"].first
|
281
|
+
end
|
282
|
+
|
283
|
+
it "resource_name in prepared_run_data should be the same" do
|
284
|
+
expect(@first_update_report["name"]).to eq("sensitive-resource")
|
285
|
+
end
|
286
|
+
|
287
|
+
it "resource_command in prepared_run_data should be blank" do
|
288
|
+
expect(@first_update_report["after"]).to eq({ :command => "sensitive-resource" })
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
268
292
|
context "when the new_resource does not have a string for name and identity" do
|
269
293
|
context "the new_resource name and id are nil" do
|
270
294
|
before do
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -838,6 +838,8 @@ describe Chef::Resource do
|
|
838
838
|
it "should run only_if/not_if conditionals when notified to run another action (CHEF-972)" do
|
839
839
|
snitch_var1 = snitch_var2 = 0
|
840
840
|
runner = Chef::Runner.new(run_context)
|
841
|
+
|
842
|
+
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
841
843
|
Chef::Platform.set(
|
842
844
|
:resource => :cat,
|
843
845
|
:provider => Chef::Provider::SnakeOil
|