chef 12.17.44-universal-mingw32 → 12.18.31-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 +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
@@ -148,7 +148,7 @@ The operation completed successfully.
|
|
148
148
|
expect(source_resource.name).to be == "windows_test_pkg"
|
149
149
|
expect(source_resource.source).to be == [new_resource.source]
|
150
150
|
expect(source_resource.cookbook_name).to be == "Msu_package"
|
151
|
-
expect(source_resource.checksum).to be
|
151
|
+
expect(source_resource.checksum).to be nil
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
@@ -51,7 +51,7 @@ describe Chef::Provider::Route do
|
|
51
51
|
context "on linux" do
|
52
52
|
before do
|
53
53
|
@node.automatic_attrs[:os] = "linux"
|
54
|
-
routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n"
|
54
|
+
routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n" \
|
55
55
|
"eth0 0064A8C0 0984A8C0 0003 0 0 0 00FFFFFF 0 0 0\n"
|
56
56
|
route_file = StringIO.new(routing_table)
|
57
57
|
allow(File).to receive(:open).with("/proc/net/route", "r").and_return(route_file)
|
@@ -91,16 +91,16 @@ describe Chef::Provider::Route do
|
|
91
91
|
|
92
92
|
describe Chef::Provider::Route, "action_add" do
|
93
93
|
it "should add the route if it does not exist" do
|
94
|
-
allow(@provider).to receive(:
|
94
|
+
allow(@provider).to receive(:shell_out!)
|
95
95
|
allow(@current_resource).to receive(:gateway).and_return(nil)
|
96
|
-
expect(@provider).to receive(:generate_command).
|
96
|
+
expect(@provider).to receive(:generate_command).with(:add).and_return(["command"])
|
97
97
|
expect(@provider).to receive(:generate_config)
|
98
98
|
@provider.run_action(:add)
|
99
99
|
expect(@new_resource).to be_updated
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should not add the route if it exists" do
|
103
|
-
allow(@provider).to receive(:
|
103
|
+
allow(@provider).to receive(:shell_out!)
|
104
104
|
allow(@provider).to receive(:is_running).and_return(true)
|
105
105
|
expect(@provider).not_to receive(:generate_command).with(:add)
|
106
106
|
expect(@provider).to receive(:generate_config)
|
@@ -115,7 +115,7 @@ describe Chef::Provider::Route do
|
|
115
115
|
expect(File).to receive(:new).and_return(route_file)
|
116
116
|
@resource_add = Chef::Resource::Route.new("192.168.1.0/24 via 192.168.0.1")
|
117
117
|
@run_context.resource_collection << @resource_add
|
118
|
-
allow(@provider).to receive(:
|
118
|
+
allow(@provider).to receive(:shell_out!).and_return(true)
|
119
119
|
|
120
120
|
@resource_add.action(:add)
|
121
121
|
@provider.run_action(:add)
|
@@ -126,8 +126,8 @@ describe Chef::Provider::Route do
|
|
126
126
|
|
127
127
|
describe Chef::Provider::Route, "action_delete" do
|
128
128
|
it "should delete the route if it exists" do
|
129
|
-
allow(@provider).to receive(:
|
130
|
-
expect(@provider).to receive(:generate_command).
|
129
|
+
allow(@provider).to receive(:shell_out!).and_return(true)
|
130
|
+
expect(@provider).to receive(:generate_command).with(:delete).and_return(["command"])
|
131
131
|
allow(@provider).to receive(:is_running).and_return(true)
|
132
132
|
@provider.run_action(:delete)
|
133
133
|
expect(@new_resource).to be_updated
|
@@ -135,7 +135,7 @@ describe Chef::Provider::Route do
|
|
135
135
|
|
136
136
|
it "should not delete the route if it does not exist" do
|
137
137
|
allow(@current_resource).to receive(:gateway).and_return(nil)
|
138
|
-
allow(@provider).to receive(:
|
138
|
+
allow(@provider).to receive(:shell_out!).and_return(true)
|
139
139
|
expect(@provider).not_to receive(:generate_command).with(:add)
|
140
140
|
@provider.run_action(:delete)
|
141
141
|
expect(@new_resource).not_to be_updated
|
@@ -145,61 +145,61 @@ describe Chef::Provider::Route do
|
|
145
145
|
describe Chef::Provider::Route, "generate_command for action_add" do
|
146
146
|
it "should include a netmask when a one is specified" do
|
147
147
|
allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
|
148
|
-
expect(@provider.generate_command(:add)).to match(/\/\d{1,2}
|
148
|
+
expect(@provider.generate_command(:add).join(" ")).to match(/\/\d{1,2}/)
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should not include a netmask when a one is specified" do
|
152
152
|
allow(@new_resource).to receive(:netmask).and_return(nil)
|
153
|
-
expect(@provider.generate_command(:add)).not_to match(/\/\d{1,2}
|
153
|
+
expect(@provider.generate_command(:add).join(" ")).not_to match(/\/\d{1,2}/)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should include ' via $gateway ' when a gateway is specified" do
|
157
|
-
expect(@provider.generate_command(:add)).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}
|
157
|
+
expect(@provider.generate_command(:add).join(" ")).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should not include ' via $gateway ' when a gateway is not specified" do
|
161
161
|
allow(@new_resource).to receive(:gateway).and_return(nil)
|
162
|
-
expect(@provider.generate_command(:add)).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}
|
162
|
+
expect(@provider.generate_command(:add).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
166
|
describe Chef::Provider::Route, "generate_command for action_delete" do
|
167
167
|
it "should include a netmask when a one is specified" do
|
168
168
|
allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
|
169
|
-
expect(@provider.generate_command(:delete)).to match(/\/\d{1,2}
|
169
|
+
expect(@provider.generate_command(:delete).join(" ")).to match(/\/\d{1,2}/)
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should not include a netmask when a one is specified" do
|
173
173
|
allow(@new_resource).to receive(:netmask).and_return(nil)
|
174
|
-
expect(@provider.generate_command(:delete)).not_to match(/\/\d{1,2}
|
174
|
+
expect(@provider.generate_command(:delete).join(" ")).not_to match(/\/\d{1,2}/)
|
175
175
|
end
|
176
176
|
|
177
177
|
it "should include ' via $gateway ' when a gateway is specified" do
|
178
|
-
expect(@provider.generate_command(:delete)).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}
|
178
|
+
expect(@provider.generate_command(:delete).join(" ")).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should not include ' via $gateway ' when a gateway is not specified" do
|
182
182
|
allow(@new_resource).to receive(:gateway).and_return(nil)
|
183
|
-
expect(@provider.generate_command(:delete)).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}
|
183
|
+
expect(@provider.generate_command(:delete).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
187
|
describe Chef::Provider::Route, "config_file_contents for action_add" do
|
188
188
|
it "should include a netmask when a one is specified" do
|
189
189
|
allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
|
190
|
-
expect(@provider.config_file_contents(:add,
|
190
|
+
expect(@provider.config_file_contents(:add, target: @new_resource.target, netmask: @new_resource.netmask)).to match(/\/\d{1,2}.*\n$/)
|
191
191
|
end
|
192
192
|
|
193
193
|
it "should not include a netmask when a one is specified" do
|
194
|
-
expect(@provider.config_file_contents(:add,
|
194
|
+
expect(@provider.config_file_contents(:add, target: @new_resource.target)).not_to match(/\/\d{1,2}.*\n$/)
|
195
195
|
end
|
196
196
|
|
197
197
|
it "should include ' via $gateway ' when a gateway is specified" do
|
198
|
-
expect(@provider.config_file_contents(:add,
|
198
|
+
expect(@provider.config_file_contents(:add, target: @new_resource.target, gateway: @new_resource.gateway)).to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/)
|
199
199
|
end
|
200
200
|
|
201
201
|
it "should not include ' via $gateway ' when a gateway is not specified" do
|
202
|
-
expect(@provider.generate_command(:add)).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/)
|
202
|
+
expect(@provider.generate_command(:add).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}\n/)
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
@@ -216,7 +216,7 @@ describe Chef::Provider::Route do
|
|
216
216
|
|
217
217
|
route_file = StringIO.new
|
218
218
|
expect(File).to receive(:new).with("/etc/sysconfig/network-scripts/route-eth0", "w").and_return(route_file)
|
219
|
-
#Chef::Log.should_receive(:debug).with("route[10.0.0.10] writing route.eth0\n10.0.0.10 via 10.0.0.9\n")
|
219
|
+
# Chef::Log.should_receive(:debug).with("route[10.0.0.10] writing route.eth0\n10.0.0.10 via 10.0.0.9\n")
|
220
220
|
@run_context.resource_collection << @new_resource
|
221
221
|
@provider.generate_config
|
222
222
|
end
|
@@ -116,38 +116,38 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
116
116
|
describe "when shelling out to dscl" do
|
117
117
|
it "should run dscl with the supplied cmd /Path args" do
|
118
118
|
shell_return = shellcmdresult.new("stdout", "err", 0)
|
119
|
-
expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
|
120
|
-
expect(provider.run_dscl("cmd /Path args")).to eq("stdout")
|
119
|
+
expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
|
120
|
+
expect(provider.run_dscl("cmd", "/Path", "args")).to eq("stdout")
|
121
121
|
end
|
122
122
|
|
123
123
|
it "returns an empty string from delete commands" do
|
124
124
|
shell_return = shellcmdresult.new("out", "err", 23)
|
125
|
-
expect(provider).to receive(:shell_out).with("dscl . -delete /Path args").and_return(shell_return)
|
126
|
-
expect(provider.run_dscl("delete /Path args")).to eq("")
|
125
|
+
expect(provider).to receive(:shell_out).with("dscl", ".", "-delete", "/Path", "args").and_return(shell_return)
|
126
|
+
expect(provider.run_dscl("delete", "/Path", "args")).to eq("")
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should raise an exception for any other command" do
|
130
130
|
shell_return = shellcmdresult.new("out", "err", 23)
|
131
|
-
expect(provider).to receive(:shell_out).with("dscl . -cmd /Path arguments").and_return(shell_return)
|
132
|
-
expect { provider.run_dscl("cmd /Path arguments") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
|
131
|
+
expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "arguments").and_return(shell_return)
|
132
|
+
expect { provider.run_dscl("cmd", "/Path", "arguments") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
|
133
133
|
end
|
134
134
|
|
135
135
|
it "raises an exception when dscl reports 'no such key'" do
|
136
136
|
shell_return = shellcmdresult.new("No such key: ", "err", 23)
|
137
|
-
expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
|
138
|
-
expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
|
137
|
+
expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
|
138
|
+
expect { provider.run_dscl("cmd", "/Path", "args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
|
139
139
|
end
|
140
140
|
|
141
141
|
it "raises an exception when dscl reports 'eDSRecordNotFound'" do
|
142
142
|
shell_return = shellcmdresult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
|
143
|
-
expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return)
|
144
|
-
expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
|
143
|
+
expect(provider).to receive(:shell_out).with("dscl", ".", "-cmd", "/Path", "args").and_return(shell_return)
|
144
|
+
expect { provider.run_dscl("cmd", "/Path", "args") }.to raise_error(Chef::Exceptions::DsclCommandFailed)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
148
|
describe "get_free_uid" do
|
149
149
|
before do
|
150
|
-
expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("\nwheel 200\nstaff 201\nbrahms 500\nchopin 501\n")
|
150
|
+
expect(provider).to receive(:run_dscl).with("list", "/Users", "uid").and_return("\nwheel 200\nstaff 201\nbrahms 500\nchopin 501\n")
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "when resource is configured as system" do
|
@@ -177,7 +177,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
177
177
|
|
178
178
|
describe "when called with a user id" do
|
179
179
|
before do
|
180
|
-
expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("\naj 500\n")
|
180
|
+
expect(provider).to receive(:run_dscl).with("list", "/Users", "uid").and_return("\naj 500\n")
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should return true for a used uid number" do
|
@@ -198,8 +198,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
198
198
|
end
|
199
199
|
|
200
200
|
it "finds a valid, unused uid when none is specified" do
|
201
|
-
expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("")
|
202
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 501
|
201
|
+
expect(provider).to receive(:run_dscl).with("list", "/Users", "uid").and_return("")
|
202
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "UniqueID", 501)
|
203
203
|
expect(provider).to receive(:get_free_uid).and_return(501)
|
204
204
|
provider.dscl_set_uid
|
205
205
|
expect(new_resource.uid).to eq(501)
|
@@ -207,8 +207,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
207
207
|
|
208
208
|
it "sets the uid specified in the resource" do
|
209
209
|
new_resource.uid(1000)
|
210
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 1000
|
211
|
-
expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("")
|
210
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "UniqueID", 1000).and_return(true)
|
211
|
+
expect(provider).to receive(:run_dscl).with("list", "/Users", "uid").and_return("")
|
212
212
|
provider.dscl_set_uid
|
213
213
|
end
|
214
214
|
end
|
@@ -219,9 +219,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
219
219
|
end
|
220
220
|
|
221
221
|
before do
|
222
|
-
|
223
|
-
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
224
|
-
new_resource.supports({ :manage_home => true })
|
222
|
+
new_resource.manage_home true
|
225
223
|
new_resource.home("/Users/toor")
|
226
224
|
|
227
225
|
provider.current_resource = current_resource
|
@@ -229,7 +227,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
229
227
|
|
230
228
|
it "deletes the home directory when resource#home is nil" do
|
231
229
|
new_resource.instance_variable_set(:@home, nil)
|
232
|
-
expect(provider).to receive(:run_dscl).with("delete /Users/toor NFSHomeDirectory").and_return(true)
|
230
|
+
expect(provider).to receive(:run_dscl).with("delete", "/Users/toor", "NFSHomeDirectory").and_return(true)
|
233
231
|
provider.dscl_set_home
|
234
232
|
end
|
235
233
|
|
@@ -239,40 +237,40 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
239
237
|
end
|
240
238
|
|
241
239
|
it "moves the users home to the new location if it exists and the target location is different" do
|
242
|
-
|
243
|
-
new_resource.supports(:manage_home => true)
|
240
|
+
new_resource.manage_home true
|
244
241
|
|
245
242
|
current_home = CHEF_SPEC_DATA + "/old_home_dir"
|
246
243
|
current_home_files = [current_home + "/my-dot-emacs", current_home + "/my-dot-vim"]
|
247
244
|
current_resource.home(current_home)
|
248
245
|
new_resource.gid(23)
|
249
|
-
allow(::File).to receive(:
|
250
|
-
allow(::File).to receive(:
|
246
|
+
allow(::File).to receive(:exist?).with("/old/home/toor").and_return(true)
|
247
|
+
allow(::File).to receive(:exist?).with("/Users/toor").and_return(true)
|
248
|
+
allow(::File).to receive(:exist?).with(current_home).and_return(true)
|
251
249
|
|
252
250
|
expect(FileUtils).to receive(:mkdir_p).with("/Users/toor").and_return(true)
|
253
251
|
expect(FileUtils).to receive(:rmdir).with(current_home)
|
254
252
|
expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*", ::File::FNM_DOTMATCH).and_return(current_home_files)
|
255
|
-
expect(FileUtils).to receive(:mv).with(current_home_files, "/Users/toor", :
|
253
|
+
expect(FileUtils).to receive(:mv).with(current_home_files, "/Users/toor", force: true)
|
256
254
|
expect(FileUtils).to receive(:chown_R).with("toor", "23", "/Users/toor")
|
257
255
|
|
258
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor NFSHomeDirectory
|
256
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "NFSHomeDirectory", "/Users/toor")
|
259
257
|
provider.dscl_set_home
|
260
258
|
end
|
261
259
|
|
262
260
|
it "should raise an exception when the systems user template dir (skel) cannot be found" do
|
263
|
-
allow(::File).to receive(:
|
261
|
+
allow(::File).to receive(:exist?).and_return(false, false, false)
|
264
262
|
expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::User)
|
265
263
|
end
|
266
264
|
|
267
265
|
it "should run ditto to copy any missing files from skel to the new home dir" do
|
268
|
-
expect(::File).to receive(:
|
266
|
+
expect(::File).to receive(:exist?).with("/System/Library/User\ Template/English.lproj").and_return(true)
|
269
267
|
expect(FileUtils).to receive(:chown_R).with("toor", "", "/Users/toor")
|
270
|
-
expect(provider).to receive(:shell_out!).with("ditto
|
268
|
+
expect(provider).to receive(:shell_out!).with("ditto", "/System/Library/User Template/English.lproj", "/Users/toor")
|
271
269
|
provider.ditto_home
|
272
270
|
end
|
273
271
|
|
274
272
|
it "creates the user's NFSHomeDirectory and home directory" do
|
275
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor NFSHomeDirectory
|
273
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "NFSHomeDirectory", "/Users/toor").and_return(true)
|
276
274
|
expect(provider).to receive(:ditto_home)
|
277
275
|
provider.dscl_set_home
|
278
276
|
end
|
@@ -283,8 +281,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
283
281
|
let(:plutil_exists) { true }
|
284
282
|
|
285
283
|
before do
|
286
|
-
allow(::File).to receive(:
|
287
|
-
allow(::File).to receive(:
|
284
|
+
allow(::File).to receive(:exist?).with("/usr/bin/dscl").and_return(dscl_exists)
|
285
|
+
allow(::File).to receive(:exist?).with("/usr/bin/plutil").and_return(plutil_exists)
|
288
286
|
end
|
289
287
|
|
290
288
|
def run_requirements
|
@@ -382,8 +380,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
382
380
|
let(:user_plist_file) { nil }
|
383
381
|
|
384
382
|
before do
|
385
|
-
expect(provider).to receive(:shell_out).with("dscacheutil
|
386
|
-
expect(provider).to receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
|
383
|
+
expect(provider).to receive(:shell_out).with("dscacheutil", "-flushcache")
|
384
|
+
expect(provider).to receive(:shell_out).with("plutil", "-convert", "xml1", "-o", "-", "/var/db/dslocal/nodes/Default/users/toor.plist") do
|
387
385
|
if user_plist_file.nil?
|
388
386
|
shellcmdresult.new("Can not find the file", "Sorry!!", 1)
|
389
387
|
else
|
@@ -391,7 +389,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
391
389
|
end
|
392
390
|
end
|
393
391
|
|
394
|
-
|
392
|
+
unless user_plist_file.nil?
|
395
393
|
expect(provider).to receive(:convert_binary_plist_to_xml).and_return(File.read(File.join(CHEF_SPEC_DATA, "mac_users/#{user_plist_file}.shadow.xml")))
|
396
394
|
end
|
397
395
|
end
|
@@ -726,7 +724,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
726
724
|
expect(provider).to receive(:prepare_password_shadow_info).and_return({})
|
727
725
|
mock_shellout = double("Mock::Shellout")
|
728
726
|
allow(mock_shellout).to receive(:run_command)
|
729
|
-
expect(
|
727
|
+
expect(provider).to receive(:shell_out).and_return(mock_shellout)
|
730
728
|
expect(provider).to receive(:read_user_info)
|
731
729
|
expect(provider).to receive(:dscl_set)
|
732
730
|
expect(provider).to receive(:sleep).with(3)
|
@@ -754,29 +752,29 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
754
752
|
end
|
755
753
|
|
756
754
|
it "creates the user and sets the comment field" do
|
757
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor").and_return(true)
|
755
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor").and_return(true)
|
758
756
|
provider.dscl_create_user
|
759
757
|
end
|
760
758
|
|
761
759
|
it "sets the comment field" do
|
762
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor RealName
|
760
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "RealName", "#mockssuck").and_return(true)
|
763
761
|
provider.dscl_create_comment
|
764
762
|
end
|
765
763
|
|
766
764
|
it "sets the comment field to username" do
|
767
765
|
new_resource.comment nil
|
768
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor RealName
|
766
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "RealName", "#mockssuck").and_return(true)
|
769
767
|
provider.dscl_create_comment
|
770
768
|
expect(new_resource.comment).to eq("#mockssuck")
|
771
769
|
end
|
772
770
|
|
773
771
|
it "should run run_dscl with create /Users/user PrimaryGroupID to set the users primary group" do
|
774
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor PrimaryGroupID
|
772
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "PrimaryGroupID", 1001).and_return(true)
|
775
773
|
provider.dscl_set_gid
|
776
774
|
end
|
777
775
|
|
778
776
|
it "should run run_dscl with create /Users/user UserShell to set the users login shell" do
|
779
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor UserShell
|
777
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "UserShell", "/usr/bin/false").and_return(true)
|
780
778
|
provider.dscl_set_shell
|
781
779
|
end
|
782
780
|
end
|
@@ -788,21 +786,21 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
788
786
|
end
|
789
787
|
|
790
788
|
it "should map the group name to a numeric ID when the group exists" do
|
791
|
-
expect(provider).to receive(:run_dscl).with("read /Groups/newgroup PrimaryGroupID").ordered.and_return("PrimaryGroupID: 1001\n")
|
792
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor PrimaryGroupID
|
789
|
+
expect(provider).to receive(:run_dscl).with("read", "/Groups/newgroup", "PrimaryGroupID").ordered.and_return("PrimaryGroupID: 1001\n")
|
790
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "PrimaryGroupID", "1001").ordered.and_return(true)
|
793
791
|
provider.dscl_set_gid
|
794
792
|
end
|
795
793
|
|
796
794
|
it "should raise an exception when the group does not exist" do
|
797
795
|
shell_return = shellcmdresult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136)
|
798
|
-
expect(provider).to receive(:shell_out).with("dscl . -read /Groups/newgroup PrimaryGroupID").and_return(shell_return)
|
796
|
+
expect(provider).to receive(:shell_out).with("dscl", ".", "-read", "/Groups/newgroup", "PrimaryGroupID").and_return(shell_return)
|
799
797
|
expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound)
|
800
798
|
end
|
801
799
|
end
|
802
800
|
|
803
801
|
it "should set group ID to 20 if it's not specified" do
|
804
802
|
new_resource.gid nil
|
805
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor PrimaryGroupID
|
803
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "PrimaryGroupID", 20).ordered.and_return(true)
|
806
804
|
provider.dscl_set_gid
|
807
805
|
expect(new_resource.gid).to eq(20)
|
808
806
|
end
|
@@ -850,8 +848,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
850
848
|
|
851
849
|
describe "when the user exists" do
|
852
850
|
before do
|
853
|
-
expect(provider).to receive(:shell_out).with("dscacheutil
|
854
|
-
expect(provider).to receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do
|
851
|
+
expect(provider).to receive(:shell_out).with("dscacheutil", "-flushcache")
|
852
|
+
expect(provider).to receive(:shell_out).with("plutil", "-convert", "xml1", "-o", "-", "/var/db/dslocal/nodes/Default/users/toor.plist") do
|
855
853
|
shellcmdresult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/10.9.plist.xml")), "", 0)
|
856
854
|
end
|
857
855
|
provider.load_current_resource
|
@@ -859,14 +857,13 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
859
857
|
|
860
858
|
describe "when Chef is removing the user" do
|
861
859
|
it "removes the user from the groups and deletes home directory when the resource is configured to manage home" do
|
862
|
-
|
863
|
-
|
864
|
-
expect(provider).to receive(:run_dscl).with("
|
865
|
-
expect(provider).to receive(:run_dscl).with("read /Groups/
|
866
|
-
expect(provider).to receive(:run_dscl).with("read /Groups/
|
867
|
-
expect(provider).to receive(:run_dscl).with("
|
868
|
-
expect(provider).to receive(:run_dscl).with("delete /
|
869
|
-
expect(provider).to receive(:run_dscl).with("delete /Users/toor")
|
860
|
+
new_resource.manage_home true
|
861
|
+
expect(provider).to receive(:run_dscl).with("list", "/Groups").and_return("my_group\nyour_group\nreal_group\n")
|
862
|
+
expect(provider).to receive(:run_dscl).with("read", "/Groups/my_group").and_raise(Chef::Exceptions::DsclCommandFailed) # Empty group
|
863
|
+
expect(provider).to receive(:run_dscl).with("read", "/Groups/your_group").and_return("GroupMembership: not_you")
|
864
|
+
expect(provider).to receive(:run_dscl).with("read", "/Groups/real_group").and_return("GroupMembership: toor")
|
865
|
+
expect(provider).to receive(:run_dscl).with("delete", "/Groups/real_group", "GroupMembership", "toor")
|
866
|
+
expect(provider).to receive(:run_dscl).with("delete", "/Users/toor")
|
870
867
|
expect(FileUtils).to receive(:rm_rf).with("/Users/vagrant")
|
871
868
|
provider.remove_user
|
872
869
|
end
|
@@ -889,7 +886,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
889
886
|
end
|
890
887
|
|
891
888
|
it "can unlock the user" do
|
892
|
-
expect(provider).to receive(:run_dscl).with("create /Users/toor AuthenticationAuthority
|
889
|
+
expect(provider).to receive(:run_dscl).with("create", "/Users/toor", "AuthenticationAuthority", ";ShadowHash;HASHLIST:<SALTED-SHA512-PBKDF2>")
|
893
890
|
provider.unlock_user
|
894
891
|
end
|
895
892
|
end
|
@@ -897,7 +894,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
|
|
897
894
|
|
898
895
|
describe "when locking the user" do
|
899
896
|
it "should run run_dscl with append /Users/user AuthenticationAuthority ;DisabledUser; to lock the user account" do
|
900
|
-
expect(provider).to receive(:run_dscl).with("append /Users/toor AuthenticationAuthority
|
897
|
+
expect(provider).to receive(:run_dscl).with("append", "/Users/toor", "AuthenticationAuthority", ";DisabledUser;")
|
901
898
|
provider.lock_user
|
902
899
|
end
|
903
900
|
end
|
@@ -55,7 +55,7 @@ describe Chef::Provider::User::Linux do
|
|
55
55
|
|
56
56
|
# supports is a method on the superclass so can't totally be removed, but we should aggressively NOP it to decisively break it
|
57
57
|
it "disables the supports API", chef: ">= 13" do
|
58
|
-
@new_resource.supports(
|
58
|
+
@new_resource.supports( manage_home: true )
|
59
59
|
expect( @new_resource.supports.key?(:manage_home) ).to be false
|
60
60
|
end
|
61
61
|
|
@@ -70,13 +70,13 @@ describe Chef::Provider::User::Linux do
|
|
70
70
|
it "throws a deprecation warning on setting supports[:non_unique]" do
|
71
71
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
72
72
|
expect(Chef).to receive(:deprecated).with(:supports_property, "supports { non_unique: true } on the user resource is deprecated and will be removed in Chef 13, set non_unique true instead")
|
73
|
-
@new_resource.supports(
|
73
|
+
@new_resource.supports( non_unique: true )
|
74
74
|
end
|
75
75
|
|
76
76
|
it "throws a deprecation warning on setting supports[:manage_home]" do
|
77
77
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
78
78
|
expect(Chef).to receive(:deprecated).with(:supports_property, "supports { manage_home: true } on the user resource is deprecated and will be removed in Chef 13, set manage_home true instead")
|
79
|
-
@new_resource.supports(
|
79
|
+
@new_resource.supports( manage_home: true )
|
80
80
|
end
|
81
81
|
|
82
82
|
it "defaults manage_home to false" do
|
@@ -85,13 +85,13 @@ describe Chef::Provider::User::Linux do
|
|
85
85
|
|
86
86
|
it "supports[:manage_home] (incorectly) acts like manage_home" do
|
87
87
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
88
|
-
@new_resource.supports(
|
88
|
+
@new_resource.supports(manage_home: true)
|
89
89
|
expect( provider.useradd_options ).to eql(["-m"])
|
90
90
|
end
|
91
91
|
|
92
92
|
it "supports[:manage_home] does not change behavior of manage_home: false", chef: ">= 13" do
|
93
93
|
Chef::Config[:treat_deprecation_warnings_as_errors] = false
|
94
|
-
@new_resource.supports(
|
94
|
+
@new_resource.supports(manage_home: true)
|
95
95
|
expect( provider.useradd_options ).to eql(["-M"])
|
96
96
|
end
|
97
97
|
|