ohai 15.2.5 → 15.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ohai/application.rb +2 -2
- data/lib/ohai/mixin/dmi_decode.rb +4 -1
- data/lib/ohai/plugins/linux/sysctl.rb +38 -0
- data/lib/ohai/plugins/linux/virtualization.rb +11 -10
- data/lib/ohai/plugins/openstack.rb +8 -3
- data/lib/ohai/plugins/passwd.rb +4 -0
- data/lib/ohai/version.rb +1 -1
- data/spec/functional/application_spec.rb +5 -5
- data/spec/functional/loader_spec.rb +2 -2
- data/spec/functional/plugins/powershell_spec.rb +11 -5
- data/spec/functional/plugins/root_group_spec.rb +1 -1
- data/spec/functional/plugins/windows/uptime_spec.rb +3 -3
- data/spec/ohai_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -8
- data/spec/support/integration_helper.rb +3 -3
- data/spec/unit/application_spec.rb +5 -5
- data/spec/unit/dsl/plugin_spec.rb +8 -7
- data/spec/unit/mixin/command_spec.rb +2 -2
- data/spec/unit/mixin/dmi_decode.rb +8 -1
- data/spec/unit/plugins/abort_spec.rb +4 -4
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/aix/hostname_spec.rb +2 -2
- data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
- data/spec/unit/plugins/aix/memory_spec.rb +5 -5
- data/spec/unit/plugins/aix/network_spec.rb +4 -1
- data/spec/unit/plugins/aix/platform_spec.rb +4 -4
- data/spec/unit/plugins/aix/uptime_spec.rb +3 -3
- data/spec/unit/plugins/aix/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/azure_spec.rb +8 -8
- data/spec/unit/plugins/bsd/filesystem_spec.rb +17 -16
- data/spec/unit/plugins/bsd/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/c_spec.rb +6 -5
- data/spec/unit/plugins/chef_spec.rb +2 -2
- data/spec/unit/plugins/cloud_spec.rb +4 -4
- data/spec/unit/plugins/darwin/cpu_spec.rb +11 -11
- data/spec/unit/plugins/darwin/filesystem_spec.rb +14 -13
- data/spec/unit/plugins/darwin/hardware_spec.rb +2 -1
- data/spec/unit/plugins/darwin/hostname_spec.rb +3 -3
- data/spec/unit/plugins/darwin/kernel_spec.rb +5 -5
- data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
- data/spec/unit/plugins/darwin/network_spec.rb +3 -3
- data/spec/unit/plugins/darwin/platform_spec.rb +9 -9
- data/spec/unit/plugins/darwin/virtualization_spec.rb +10 -10
- data/spec/unit/plugins/digital_ocean_spec.rb +14 -12
- data/spec/unit/plugins/dmi_spec.rb +1 -1
- data/spec/unit/plugins/docker_spec.rb +2 -2
- data/spec/unit/plugins/ec2_spec.rb +41 -30
- data/spec/unit/plugins/elixir_spec.rb +2 -2
- data/spec/unit/plugins/erlang_spec.rb +1 -1
- data/spec/unit/plugins/eucalyptus_spec.rb +17 -13
- data/spec/unit/plugins/fail_spec.rb +15 -15
- data/spec/unit/plugins/freebsd/cpu_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
- data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -2
- data/spec/unit/plugins/freebsd/platform_spec.rb +3 -3
- data/spec/unit/plugins/gce_spec.rb +9 -7
- data/spec/unit/plugins/go_spec.rb +2 -2
- data/spec/unit/plugins/groovy_spec.rb +1 -1
- data/spec/unit/plugins/haskell_spec.rb +10 -10
- data/spec/unit/plugins/hostname_spec.rb +15 -14
- data/spec/unit/plugins/init_package_spec.rb +4 -4
- data/spec/unit/plugins/java_spec.rb +7 -3
- data/spec/unit/plugins/joyent_spec.rb +4 -4
- data/spec/unit/plugins/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
- data/spec/unit/plugins/linux/cpu_spec.rb +9 -8
- data/spec/unit/plugins/linux/filesystem_spec.rb +36 -35
- data/spec/unit/plugins/linux/fips_spec.rb +7 -5
- data/spec/unit/plugins/linux/hostname_spec.rb +4 -4
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +3 -3
- data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
- data/spec/unit/plugins/linux/lsb_spec.rb +18 -18
- data/spec/unit/plugins/linux/lspci_spec.rb +2 -1
- data/spec/unit/plugins/linux/machineid_spec.rb +3 -3
- data/spec/unit/plugins/linux/mdadm_spec.rb +13 -13
- data/spec/unit/plugins/linux/memory_spec.rb +39 -39
- data/spec/unit/plugins/linux/network_spec.rb +20 -19
- data/spec/unit/plugins/linux/platform_spec.rb +60 -57
- data/spec/unit/plugins/linux/sessions_spec.rb +3 -3
- data/spec/unit/plugins/linux/sysctl_spec.rb +53 -0
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +3 -3
- data/spec/unit/plugins/linux/uptime_spec.rb +5 -5
- data/spec/unit/plugins/linux/virtualization_spec.rb +4 -4
- data/spec/unit/plugins/lua_spec.rb +1 -1
- data/spec/unit/plugins/mono_spec.rb +1 -1
- data/spec/unit/plugins/netbsd/hostname_spec.rb +3 -3
- data/spec/unit/plugins/netbsd/kernel_spec.rb +2 -2
- data/spec/unit/plugins/netbsd/platform_spec.rb +3 -3
- data/spec/unit/plugins/network_spec.rb +3 -3
- data/spec/unit/plugins/nodejs_spec.rb +1 -1
- data/spec/unit/plugins/ohai_spec.rb +2 -2
- data/spec/unit/plugins/ohai_time_spec.rb +4 -4
- data/spec/unit/plugins/openbsd/hostname_spec.rb +3 -3
- data/spec/unit/plugins/openbsd/kernel_spec.rb +2 -2
- data/spec/unit/plugins/openbsd/platform_spec.rb +2 -2
- data/spec/unit/plugins/openstack_spec.rb +13 -8
- data/spec/unit/plugins/os_spec.rb +12 -12
- data/spec/unit/plugins/packages_spec.rb +10 -7
- data/spec/unit/plugins/passwd_spec.rb +18 -19
- data/spec/unit/plugins/perl_spec.rb +1 -1
- data/spec/unit/plugins/php_spec.rb +1 -1
- data/spec/unit/plugins/platform_spec.rb +7 -7
- data/spec/unit/plugins/powershell_spec.rb +1 -1
- data/spec/unit/plugins/rackspace_spec.rb +25 -20
- data/spec/unit/plugins/root_group_spec.rb +14 -10
- data/spec/unit/plugins/ruby_spec.rb +2 -2
- data/spec/unit/plugins/rust_spec.rb +3 -3
- data/spec/unit/plugins/scala_spec.rb +2 -2
- data/spec/unit/plugins/scaleway_spec.rb +14 -12
- data/spec/unit/plugins/scsi_spec.rb +2 -1
- data/spec/unit/plugins/shard_spec.rb +18 -16
- data/spec/unit/plugins/solaris2/cpu_spec.rb +29 -29
- data/spec/unit/plugins/solaris2/dmi_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/filesystem.rb +3 -3
- data/spec/unit/plugins/solaris2/hostname_spec.rb +2 -2
- data/spec/unit/plugins/solaris2/kernel_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/memory_spec.rb +4 -4
- data/spec/unit/plugins/solaris2/platform_spec.rb +9 -9
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +6 -6
- data/spec/unit/plugins/ssh_host_keys_spec.rb +4 -1
- data/spec/unit/plugins/sysconf_spec.rb +2 -2
- data/spec/unit/plugins/timezone_spec.rb +2 -2
- data/spec/unit/plugins/virtualbox_spec.rb +10 -10
- data/spec/unit/plugins/vmware_spec.rb +4 -4
- data/spec/unit/plugins/windows/cpu_spec.rb +13 -13
- data/spec/unit/plugins/windows/filesystem_spec.rb +1 -1
- data/spec/unit/plugins/windows/fips_spec.rb +7 -5
- data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
- data/spec/unit/plugins/windows/memory_spec.rb +4 -4
- data/spec/unit/plugins/windows/network_spec.rb +1 -1
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +2 -2
- data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
- data/spec/unit/plugins/zpools_spec.rb +2 -0
- data/spec/unit/provides_map_spec.rb +18 -18
- data/spec/unit/runner_spec.rb +29 -29
- data/spec/unit/system_spec.rb +13 -13
- data/spec/unit/util/file_helper_spec.rb +1 -1
- data/spec/unit/util/ip_helper_spec.rb +6 -6
- metadata +4 -2
@@ -33,7 +33,7 @@ describe Ohai::System, "plugin packages" do
|
|
33
33
|
File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output"))
|
34
34
|
end
|
35
35
|
|
36
|
-
before
|
36
|
+
before do
|
37
37
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
38
38
|
allow(plugin).to receive(:shell_out)
|
39
39
|
.with("dpkg-query -W -f='#{format}'")
|
@@ -72,7 +72,7 @@ describe Ohai::System, "plugin packages" do
|
|
72
72
|
File.read(File.join(SPEC_PLUGIN_PATH, "rpmquery.output"))
|
73
73
|
end
|
74
74
|
|
75
|
-
before
|
75
|
+
before do
|
76
76
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
77
77
|
allow(plugin).to receive(:shell_out).with("rpm -qa --qf '#{format}'").and_return(mock_shell_out(0, stdout, ""))
|
78
78
|
plugin.run
|
@@ -133,7 +133,7 @@ describe Ohai::System, "plugin packages" do
|
|
133
133
|
File.read(File.join(SPEC_PLUGIN_PATH, "pacman.output"))
|
134
134
|
end
|
135
135
|
|
136
|
-
before
|
136
|
+
before do
|
137
137
|
allow(plugin).to receive(:collect_os).and_return(:linux)
|
138
138
|
allow(plugin).to receive(:shell_out).with("LANG=C pacman -Qi").and_return(mock_shell_out(0, stdout, ""))
|
139
139
|
plugin.run
|
@@ -209,7 +209,7 @@ describe Ohai::System, "plugin packages" do
|
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
before
|
212
|
+
before do
|
213
213
|
allow(plugin).to receive(:collect_os).and_return(:windows)
|
214
214
|
allow(win_reg_double).to receive(:open).with(win_reg_keys[0]).and_return(win_reg_output[0])
|
215
215
|
allow(win_reg_double).to receive(:open).with(win_reg_keys[1]).and_return(win_reg_output[1])
|
@@ -222,6 +222,7 @@ describe Ohai::System, "plugin packages" do
|
|
222
222
|
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Microsoft\Windows\CurrentVersion\Uninstall', i386_reg_type).and_yield(win_reg_double)
|
223
223
|
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall', i386_reg_type).and_yield(win_reg_double)
|
224
224
|
end
|
225
|
+
|
225
226
|
it_behaves_like "windows_package_plugin"
|
226
227
|
end
|
227
228
|
|
@@ -231,6 +232,7 @@ describe Ohai::System, "plugin packages" do
|
|
231
232
|
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Microsoft\Windows\CurrentVersion\Uninstall', x86_64_reg_type).and_yield(win_reg_double)
|
232
233
|
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall', x86_64_reg_type).and_yield(win_reg_double)
|
233
234
|
end
|
235
|
+
|
234
236
|
it_behaves_like "windows_package_plugin"
|
235
237
|
end
|
236
238
|
|
@@ -240,6 +242,7 @@ describe Ohai::System, "plugin packages" do
|
|
240
242
|
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Microsoft\Windows\CurrentVersion\Uninstall', Win32::Registry::KEY_READ).and_yield(win_reg_double)
|
241
243
|
allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with('Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall', Win32::Registry::KEY_READ).and_yield(win_reg_double)
|
242
244
|
end
|
245
|
+
|
243
246
|
it_behaves_like "windows_package_plugin"
|
244
247
|
end
|
245
248
|
end
|
@@ -251,7 +254,7 @@ describe Ohai::System, "plugin packages" do
|
|
251
254
|
File.read(File.join(SPEC_PLUGIN_PATH, "lslpp.output"))
|
252
255
|
end
|
253
256
|
|
254
|
-
before
|
257
|
+
before do
|
255
258
|
allow(plugin).to receive(:collect_os).and_return(:aix)
|
256
259
|
allow(plugin).to receive(:shell_out).with("lslpp -L -q -c").and_return(mock_shell_out(0, stdout, ""))
|
257
260
|
plugin.run
|
@@ -280,7 +283,7 @@ describe Ohai::System, "plugin packages" do
|
|
280
283
|
File.read(File.join(SPEC_PLUGIN_PATH, "pkg-query.output"))
|
281
284
|
end
|
282
285
|
|
283
|
-
before
|
286
|
+
before do
|
284
287
|
allow(plugin).to receive(:collect_os).and_return(:freebsd)
|
285
288
|
allow(plugin).to receive(:shell_out).with('pkg query -a "%n %v"').and_return(mock_shell_out(0, stdout, ""))
|
286
289
|
plugin.run
|
@@ -309,7 +312,7 @@ describe Ohai::System, "plugin packages" do
|
|
309
312
|
File.read(File.join(SPEC_PLUGIN_PATH, "pkginfo.output"))
|
310
313
|
end
|
311
314
|
|
312
|
-
before
|
315
|
+
before do
|
313
316
|
allow(plugin).to receive(:collect_os).and_return(:solaris2)
|
314
317
|
allow(plugin).to receive(:shell_out).with("pkg list -H").and_return(mock_shell_out(0, pkglist_output, ""))
|
315
318
|
allow(plugin).to receive(:shell_out).with("pkginfo -l").and_return(mock_shell_out(0, pkginfo_output, ""))
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# License:: Apache License, Version 2.0
|
3
|
+
# Copyright:: 2019 Chef Software, Inc.
|
3
4
|
#
|
4
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
6
|
# you may not use this file except in compliance with the License.
|
@@ -17,40 +18,38 @@
|
|
17
18
|
require "spec_helper"
|
18
19
|
|
19
20
|
describe Ohai::System, "plugin etc", :unix_only do
|
20
|
-
|
21
|
-
@plugin = get_plugin("passwd")
|
22
|
-
end
|
21
|
+
let(:plugin) { get_plugin("passwd") }
|
23
22
|
|
24
23
|
PasswdEntry = Struct.new(:name, :uid, :gid, :dir, :shell, :gecos)
|
25
24
|
GroupEntry = Struct.new(:name, :gid, :mem)
|
26
25
|
|
27
|
-
it "
|
26
|
+
it "includes a list of all users" do
|
28
27
|
expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH"))
|
29
28
|
.and_yield(PasswdEntry.new("www", 800, 800, "/var/www", "/bin/false", "Serving the web since 1970"))
|
30
|
-
|
31
|
-
expect(
|
32
|
-
expect(
|
29
|
+
plugin.run
|
30
|
+
expect(plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
|
31
|
+
expect(plugin[:etc][:passwd]["www"]).to eq(Mash.new(shell: "/bin/false", gecos: "Serving the web since 1970", gid: 800, uid: 800, dir: "/var/www"))
|
33
32
|
end
|
34
33
|
|
35
|
-
it "
|
34
|
+
it "ignores duplicate users" do
|
36
35
|
expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH"))
|
37
36
|
.and_yield(PasswdEntry.new("root", 1, 1, "/", "/bin/false", "I do not belong"))
|
38
|
-
|
39
|
-
expect(
|
37
|
+
plugin.run
|
38
|
+
expect(plugin[:etc][:passwd]["root"]).to eq(Mash.new(shell: "/bin/zsh", gecos: "BOFH", gid: 1, uid: 1, dir: "/root"))
|
40
39
|
end
|
41
40
|
|
42
|
-
it "
|
41
|
+
it "sets the current user" do
|
43
42
|
expect(Process).to receive(:euid).and_return("31337")
|
44
43
|
expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new("chef", 31337, 31337, "/home/chef", "/bin/ksh", "Julia Child"))
|
45
|
-
|
46
|
-
expect(
|
44
|
+
plugin.run
|
45
|
+
expect(plugin[:current_user]).to eq("chef")
|
47
46
|
end
|
48
47
|
|
49
|
-
it "
|
48
|
+
it "sets the available groups" do
|
50
49
|
expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, %w{root chef})).and_yield(GroupEntry.new("www", 800, %w{www deploy}))
|
51
|
-
|
52
|
-
expect(
|
53
|
-
expect(
|
50
|
+
plugin.run
|
51
|
+
expect(plugin[:etc][:group]["admin"]).to eq(Mash.new(gid: 100, members: %w{root chef}))
|
52
|
+
expect(plugin[:etc][:group]["www"]).to eq(Mash.new(gid: 800, members: %w{www deploy}))
|
54
53
|
end
|
55
54
|
|
56
55
|
if "".respond_to?(:force_encoding)
|
@@ -58,8 +57,8 @@ describe Ohai::System, "plugin etc", :unix_only do
|
|
58
57
|
fields = ["root", 1, 1, "/root", "/bin/zsh", "BOFH"]
|
59
58
|
fields.each { |f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) }
|
60
59
|
allow(Etc).to receive(:passwd).and_yield(PasswdEntry.new(*fields))
|
61
|
-
|
62
|
-
root =
|
60
|
+
plugin.run
|
61
|
+
root = plugin[:etc][:passwd]["root"]
|
63
62
|
expect(root["gecos"].encoding).to eq(Encoding.default_external)
|
64
63
|
end
|
65
64
|
end
|
@@ -22,7 +22,7 @@ require "spec_helper"
|
|
22
22
|
describe Ohai::System, "plugin perl" do
|
23
23
|
let(:plugin) { get_plugin("perl") }
|
24
24
|
|
25
|
-
before
|
25
|
+
before do
|
26
26
|
plugin[:languages] = Mash.new
|
27
27
|
@stdout = "version='5.8.8';#{$/}archname='darwin-thread-multi-2level';"
|
28
28
|
allow(plugin).to receive(:shell_out).with("perl -V:version -V:archname").and_return(mock_shell_out(0, @stdout, ""))
|
@@ -19,45 +19,45 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "plugin platform" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("platform")
|
24
24
|
allow(@plugin).to receive(:collect_os).and_return(:default)
|
25
25
|
@plugin[:os] = "monkey"
|
26
26
|
@plugin[:os_version] = "poop"
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "sets the platform and platform family to the os if it was not set earlier" do
|
30
30
|
@plugin.run
|
31
31
|
expect(@plugin[:platform]).to eql("monkey")
|
32
32
|
expect(@plugin[:platform_family]).to eql("monkey")
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "does not set the platform to the os if it was set earlier" do
|
36
36
|
@plugin[:platform] = "lars"
|
37
37
|
@plugin.run
|
38
38
|
expect(@plugin[:platform]).to eql("lars")
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "sets the platform_family to the platform if platform was set earlier but not platform_family" do
|
42
42
|
@plugin[:platform] = "lars"
|
43
43
|
@plugin[:platform_family] = "jack"
|
44
44
|
@plugin.run
|
45
45
|
expect(@plugin[:platform_family]).to eql("jack")
|
46
46
|
end
|
47
47
|
|
48
|
-
it "
|
48
|
+
it "does not set the platform_family if the platform_family was set earlier." do
|
49
49
|
@plugin[:platform] = "lars"
|
50
50
|
@plugin.run
|
51
51
|
expect(@plugin[:platform]).to eql("lars")
|
52
52
|
expect(@plugin[:platform_family]).to eql("lars")
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "sets the platform_version to the os_version if it was not set earlier" do
|
56
56
|
@plugin.run
|
57
57
|
expect(@plugin[:os_version]).to eql("poop")
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "does not set the platform to the os if it was set earlier" do
|
61
61
|
@plugin[:platform_version] = "ulrich"
|
62
62
|
@plugin.run
|
63
63
|
expect(@plugin[:platform_version]).to eql("ulrich")
|
@@ -21,7 +21,7 @@ require "spec_helper"
|
|
21
21
|
describe Ohai::System, "plugin rackspace" do
|
22
22
|
let(:plugin) { get_plugin("rackspace") }
|
23
23
|
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
allow(Resolv).to receive(:getname).and_return("1.2.3.4")
|
26
26
|
|
27
27
|
plugin[:hostname] = "katie"
|
@@ -184,15 +184,15 @@ describe Ohai::System, "plugin rackspace" do
|
|
184
184
|
end
|
185
185
|
|
186
186
|
describe "with rackspace hint file" do
|
187
|
-
|
188
|
-
|
189
|
-
before(:each) do
|
187
|
+
before do
|
190
188
|
allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError)
|
191
189
|
allow(File).to receive(:exist?).with("/etc/resolv.conf").and_return(true)
|
192
190
|
allow(File).to receive(:read).with("/etc/resolv.conf").and_return("")
|
193
191
|
allow(plugin).to receive(:hint?).with("rackspace").and_return(true)
|
194
192
|
end
|
195
193
|
|
194
|
+
it_behaves_like "rackspace"
|
195
|
+
|
196
196
|
describe "with no public interfaces (empty eth0)" do
|
197
197
|
before do
|
198
198
|
# unset public (eth0) addresses
|
@@ -216,55 +216,60 @@ describe Ohai::System, "plugin rackspace" do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
describe "without hint file" do
|
219
|
-
|
220
|
-
|
221
|
-
before(:each) do
|
219
|
+
before do
|
222
220
|
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
223
221
|
end
|
222
|
+
|
223
|
+
it_behaves_like "!rackspace"
|
224
|
+
|
224
225
|
end
|
225
226
|
|
226
227
|
describe "with Rackspace windows manufacturer data" do
|
228
|
+
before do
|
229
|
+
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
230
|
+
allow(plugin).to receive(:has_rackspace_manufacturer?).and_return(true)
|
231
|
+
end
|
232
|
+
|
227
233
|
it "has rackspace attribute" do
|
228
234
|
plugin.run
|
229
235
|
expect(plugin[:rackspace]).not_to be_nil
|
230
236
|
end
|
231
237
|
|
232
|
-
before(:each) do
|
233
|
-
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
234
|
-
allow(plugin).to receive(:has_rackspace_manufacturer?).and_return(true)
|
235
|
-
end
|
236
238
|
end
|
237
239
|
|
238
240
|
describe "xenstore provider returns rackspace" do
|
239
|
-
|
240
|
-
|
241
|
-
before(:each) do
|
241
|
+
before do
|
242
242
|
stdout = "Rackspace\n"
|
243
243
|
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
244
244
|
allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
245
245
|
end
|
246
|
+
|
247
|
+
it_behaves_like "rackspace"
|
248
|
+
|
246
249
|
end
|
247
250
|
|
248
251
|
describe "xenstore provider does not return rackspace" do
|
249
|
-
|
250
|
-
|
251
|
-
before(:each) do
|
252
|
+
before do
|
252
253
|
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
253
254
|
stdout = "cumulonimbus\n"
|
254
255
|
allow(plugin).to receive(:shell_out).with("xenstore-read vm-data/provider_data/provider").and_return(mock_shell_out(0, stdout, "" ))
|
255
256
|
end
|
256
|
-
end
|
257
257
|
|
258
|
-
describe "xenstore provider does not exist" do
|
259
258
|
it_behaves_like "!rackspace"
|
260
259
|
|
261
|
-
|
260
|
+
end
|
261
|
+
|
262
|
+
describe "xenstore provider does not exist" do
|
263
|
+
before do
|
262
264
|
allow(plugin).to receive(:hint?).with("rackspace").and_return(false)
|
263
265
|
allow(plugin)
|
264
266
|
.to receive(:shell_out)
|
265
267
|
.with("xenstore-read vm-data/provider_data/provider")
|
266
268
|
.and_raise(Ohai::Exceptions::Exec)
|
267
269
|
end
|
270
|
+
|
271
|
+
it_behaves_like "!rackspace"
|
272
|
+
|
268
273
|
end
|
269
274
|
|
270
275
|
describe "when private networks shell out fails" do
|
@@ -19,12 +19,12 @@
|
|
19
19
|
require "spec_helper"
|
20
20
|
|
21
21
|
describe Ohai::System, "root_group" do
|
22
|
-
before
|
22
|
+
before do
|
23
23
|
@plugin = get_plugin("root_group")
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "unix platform", :unix_only do
|
27
|
-
before
|
27
|
+
before do
|
28
28
|
# this is deeply intertwingled. unfortunately, the law of demeter
|
29
29
|
# apparently didn't apply to this api. we're just trying to fake
|
30
30
|
# Etc.getgrgid(Etc.getpwnam('root').gid).name
|
@@ -36,30 +36,33 @@ describe Ohai::System, "root_group" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "with wheel group" do
|
39
|
-
before
|
39
|
+
before do
|
40
40
|
allow(@grgid).to receive(:name).and_return("wheel")
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
|
+
it "has a root_group of wheel" do
|
43
44
|
@plugin.run
|
44
45
|
expect(@plugin[:root_group]).to eq("wheel")
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
describe "with root group" do
|
49
|
-
before
|
50
|
+
before do
|
50
51
|
allow(@grgid).to receive(:name).and_return("root")
|
51
52
|
end
|
52
|
-
|
53
|
+
|
54
|
+
it "has a root_group of root" do
|
53
55
|
@plugin.run
|
54
56
|
expect(@plugin[:root_group]).to eq("root")
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
60
|
describe "platform aix with system group" do
|
59
|
-
before
|
61
|
+
before do
|
60
62
|
allow(@grgid).to receive(:name).and_return("system")
|
61
63
|
end
|
62
|
-
|
64
|
+
|
65
|
+
it "has a root_group of system" do
|
63
66
|
@plugin.run
|
64
67
|
expect(@plugin[:root_group]).to eq("system")
|
65
68
|
end
|
@@ -70,11 +73,12 @@ describe Ohai::System, "root_group" do
|
|
70
73
|
|
71
74
|
let(:wmi) { double("wmi", { query: "" }) }
|
72
75
|
|
73
|
-
before
|
76
|
+
before do
|
74
77
|
allow(WmiLite::Wmi).to receive(:new).and_return(wmi)
|
75
78
|
allow(@plugin).to receive(:collect_os).and_return(:windows)
|
76
79
|
end
|
77
|
-
|
80
|
+
|
81
|
+
it "returns the group Administrators" do
|
78
82
|
expect(wmi)
|
79
83
|
.to receive(:query)
|
80
84
|
.with("select * from Win32_Group where sid like 'S-1-5-32-544' and LocalAccount=True")
|
@@ -30,7 +30,7 @@ describe Ohai::System, "plugin ruby" do
|
|
30
30
|
@ruby_ohai_data_pristine = @plugin[:languages][:ruby]
|
31
31
|
end
|
32
32
|
|
33
|
-
before
|
33
|
+
before do
|
34
34
|
@ruby_ohai_data = @ruby_ohai_data_pristine.dup
|
35
35
|
end
|
36
36
|
|
@@ -52,7 +52,7 @@ describe Ohai::System, "plugin ruby" do
|
|
52
52
|
end.find { |bin| ::File.exist? bin },
|
53
53
|
ruby_bin: ruby_bin,
|
54
54
|
}.each do |attribute, value|
|
55
|
-
it "
|
55
|
+
it "has #{attribute} set to #{value.inspect}" do
|
56
56
|
expect(@ruby_ohai_data[attribute]).to eql(value)
|
57
57
|
end
|
58
58
|
end
|
@@ -25,17 +25,17 @@ describe Ohai::System, "plugin rust" do
|
|
25
25
|
plugin
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "gets the rust version" do
|
29
29
|
expect(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(0, stdout, ""))
|
30
30
|
plugin.run
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "sets languages[:rust][:version]" do
|
34
34
|
plugin.run
|
35
35
|
expect(plugin.languages[:rust][:version]).to eql("1.0.0-nightly")
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "does not set the languages[:rust] if rust command fails" do
|
39
39
|
allow(plugin).to receive(:shell_out).with("rustc --version").and_return(mock_shell_out(1, stdout, ""))
|
40
40
|
plugin.run
|
41
41
|
expect(plugin.languages).not_to have_key(:rust)
|