ohai 15.3.1 → 15.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
- data/lib/ohai/plugins/aix/network.rb +3 -8
- data/lib/ohai/plugins/darwin/network.rb +6 -4
- data/lib/ohai/plugins/filesystem.rb +166 -0
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -4
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- metadata +3 -162
- data/Rakefile +0 -42
- data/lib/ohai/plugins/windows/filesystem.rb +0 -147
- data/spec/data/plugins/dpkg-query.output +0 -4
- data/spec/data/plugins/lslpp.output +0 -50
- data/spec/data/plugins/pacman.output +0 -51
- data/spec/data/plugins/pkg-query.output +0 -58
- data/spec/data/plugins/pkginfo.output +0 -50
- data/spec/data/plugins/pkglist.output +0 -24
- data/spec/data/plugins/rpmquery.output +0 -7
- data/spec/functional/application_spec.rb +0 -107
- data/spec/functional/loader_spec.rb +0 -53
- data/spec/functional/plugins/powershell_spec.rb +0 -88
- data/spec/functional/plugins/root_group_spec.rb +0 -41
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
- data/spec/ohai_spec.rb +0 -27
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -124
- data/spec/support/integration_helper.rb +0 -61
- data/spec/support/platform_helpers.rb +0 -38
- data/spec/unit/application_spec.rb +0 -96
- data/spec/unit/config_spec.rb +0 -57
- data/spec/unit/dsl/plugin_spec.rb +0 -634
- data/spec/unit/hints_spec.rb +0 -65
- data/spec/unit/loader_spec.rb +0 -195
- data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
- data/spec/unit/mixin/command_spec.rb +0 -151
- data/spec/unit/mixin/dmi_decode.rb +0 -75
- data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
- data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
- data/spec/unit/plugin_config_spec.rb +0 -117
- data/spec/unit/plugins/abort_spec.rb +0 -69
- data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
- data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
- data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
- data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
- data/spec/unit/plugins/aix/memory_spec.rb +0 -49
- data/spec/unit/plugins/aix/network_spec.rb +0 -313
- data/spec/unit/plugins/aix/platform_spec.rb +0 -44
- data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
- data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
- data/spec/unit/plugins/azure_spec.rb +0 -243
- data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
- data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
- data/spec/unit/plugins/c_spec.rb +0 -341
- data/spec/unit/plugins/chef_spec.rb +0 -44
- data/spec/unit/plugins/cloud_spec.rb +0 -484
- data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
- data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
- data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
- data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
- data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
- data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
- data/spec/unit/plugins/darwin/network_spec.rb +0 -849
- data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
- data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
- data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
- data/spec/unit/plugins/dmi_spec.rb +0 -156
- data/spec/unit/plugins/docker_spec.rb +0 -100
- data/spec/unit/plugins/ec2_spec.rb +0 -452
- data/spec/unit/plugins/elixir_spec.rb +0 -55
- data/spec/unit/plugins/erlang_spec.rb +0 -71
- data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
- data/spec/unit/plugins/fail_spec.rb +0 -260
- data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
- data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
- data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/gce_spec.rb +0 -81
- data/spec/unit/plugins/go_spec.rb +0 -48
- data/spec/unit/plugins/groovy_spec.rb +0 -66
- data/spec/unit/plugins/haskell_spec.rb +0 -231
- data/spec/unit/plugins/hostname_spec.rb +0 -162
- data/spec/unit/plugins/init_package_spec.rb +0 -60
- data/spec/unit/plugins/java_spec.rb +0 -230
- data/spec/unit/plugins/joyent_spec.rb +0 -100
- data/spec/unit/plugins/kernel_spec.rb +0 -38
- data/spec/unit/plugins/linode_spec.rb +0 -135
- data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
- data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
- data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
- data/spec/unit/plugins/linux/fips_spec.rb +0 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
- data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
- data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
- data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
- data/spec/unit/plugins/linux/memory_spec.rb +0 -256
- data/spec/unit/plugins/linux/network_spec.rb +0 -1392
- data/spec/unit/plugins/linux/platform_spec.rb +0 -812
- data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
- data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
- data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
- data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
- data/spec/unit/plugins/lua_spec.rb +0 -60
- data/spec/unit/plugins/mono_spec.rb +0 -67
- data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
- data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/network_spec.rb +0 -1078
- data/spec/unit/plugins/nodejs_spec.rb +0 -55
- data/spec/unit/plugins/ohai_spec.rb +0 -32
- data/spec/unit/plugins/ohai_time_spec.rb +0 -44
- data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
- data/spec/unit/plugins/openstack_spec.rb +0 -311
- data/spec/unit/plugins/os_spec.rb +0 -115
- data/spec/unit/plugins/packages_spec.rb +0 -353
- data/spec/unit/plugins/passwd_spec.rb +0 -65
- data/spec/unit/plugins/perl_spec.rb +0 -62
- data/spec/unit/plugins/php_spec.rb +0 -97
- data/spec/unit/plugins/platform_spec.rb +0 -65
- data/spec/unit/plugins/powershell_spec.rb +0 -71
- data/spec/unit/plugins/python_spec.rb +0 -51
- data/spec/unit/plugins/rackspace_spec.rb +0 -350
- data/spec/unit/plugins/root_group_spec.rb +0 -90
- data/spec/unit/plugins/ruby_spec.rb +0 -60
- data/spec/unit/plugins/rust_spec.rb +0 -43
- data/spec/unit/plugins/scala_spec.rb +0 -58
- data/spec/unit/plugins/scaleway_spec.rb +0 -93
- data/spec/unit/plugins/scsi_spec.rb +0 -69
- data/spec/unit/plugins/shard_spec.rb +0 -121
- data/spec/unit/plugins/shells_spec.rb +0 -56
- data/spec/unit/plugins/softlayer_spec.rb +0 -60
- data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
- data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
- data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
- data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
- data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
- data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
- data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
- data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
- data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
- data/spec/unit/plugins/sysconf_spec.rb +0 -680
- data/spec/unit/plugins/timezone_spec.rb +0 -30
- data/spec/unit/plugins/vbox_host_spec.rb +0 -14
- data/spec/unit/plugins/virtualbox_spec.rb +0 -375
- data/spec/unit/plugins/vmware_spec.rb +0 -81
- data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
- data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
- data/spec/unit/plugins/windows/fips_spec.rb +0 -60
- data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
- data/spec/unit/plugins/windows/memory_spec.rb +0 -52
- data/spec/unit/plugins/windows/network_spec.rb +0 -137
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
- data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
- data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
- data/spec/unit/plugins/zpools_spec.rb +0 -244
- data/spec/unit/provides_map_spec.rb +0 -208
- data/spec/unit/runner_spec.rb +0 -422
- data/spec/unit/system_spec.rb +0 -416
- data/spec/unit/util/file_helper_spec.rb +0 -47
- data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,115 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Author:: Richard Manyanza (<liseki@nyikacraftsmen.com>)
|
4
|
-
# Author:: Isa Farnik (<isa@chef.io>)
|
5
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
6
|
-
# Copyright:: Copyright (c) 2014 Richard Manyanza.
|
7
|
-
# License:: Apache License, Version 2.0
|
8
|
-
#
|
9
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
-
# you may not use this file except in compliance with the License.
|
11
|
-
# You may obtain a copy of the License at
|
12
|
-
#
|
13
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
-
#
|
15
|
-
# Unless required by applicable law or agreed to in writing, software
|
16
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
|
22
|
-
require "spec_helper"
|
23
|
-
|
24
|
-
ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG["host_os"]
|
25
|
-
|
26
|
-
describe Ohai::System, "plugin os" do
|
27
|
-
before do
|
28
|
-
@plugin = get_plugin("os")
|
29
|
-
@plugin[:kernel] = Mash.new
|
30
|
-
@plugin[:kernel][:release] = "kings of leon"
|
31
|
-
end
|
32
|
-
|
33
|
-
after do
|
34
|
-
::RbConfig::CONFIG["host_os"] = ORIGINAL_CONFIG_HOST_OS
|
35
|
-
end
|
36
|
-
|
37
|
-
it "sets os_version to kernel_release" do
|
38
|
-
@plugin.run
|
39
|
-
expect(@plugin[:os_version]).to eq(@plugin[:kernel][:release])
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "on linux" do
|
43
|
-
before do
|
44
|
-
::RbConfig::CONFIG["host_os"] = "linux"
|
45
|
-
end
|
46
|
-
|
47
|
-
it "sets the os to linux" do
|
48
|
-
@plugin.run
|
49
|
-
expect(@plugin[:os]).to eq("linux")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "on darwin" do
|
54
|
-
before do
|
55
|
-
::RbConfig::CONFIG["host_os"] = "darwin10.0"
|
56
|
-
end
|
57
|
-
|
58
|
-
it "sets the os to darwin" do
|
59
|
-
@plugin.run
|
60
|
-
expect(@plugin[:os]).to eq("darwin")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "on solaris" do
|
65
|
-
before do
|
66
|
-
::RbConfig::CONFIG["host_os"] = "solaris2.42" # heh
|
67
|
-
end
|
68
|
-
|
69
|
-
it "sets the os to solaris2" do
|
70
|
-
@plugin.run
|
71
|
-
expect(@plugin[:os]).to eq("solaris2")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "on AIX" do
|
76
|
-
before do
|
77
|
-
@plugin = get_plugin("os")
|
78
|
-
allow(@plugin).to receive(:collect_os).and_return(:aix)
|
79
|
-
allow(@plugin).to receive(:shell_out).with("oslevel -s").and_return(mock_shell_out(0, "7200-00-01-1543\n", nil))
|
80
|
-
@plugin.run
|
81
|
-
end
|
82
|
-
|
83
|
-
it "sets the top-level os attribute" do
|
84
|
-
expect(@plugin[:os]).to be(:aix)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "sets the top-level os_level attribute" do
|
88
|
-
expect(@plugin[:os_version]).to eql("7200-00-01-1543")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "on FreeBSD" do
|
93
|
-
before do
|
94
|
-
@plugin = get_plugin("os")
|
95
|
-
allow(@plugin).to receive(:shell_out).with("sysctl -n kern.osreldate").and_return(mock_shell_out(0, "902001\n", ""))
|
96
|
-
allow(@plugin).to receive(:collect_os).and_return(:freebsd)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "sets os_version to __FreeBSD_version" do
|
100
|
-
@plugin.run
|
101
|
-
expect(@plugin[:os_version]).to eq("902001")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe "on something we have never seen before, but ruby has" do
|
106
|
-
before do
|
107
|
-
::RbConfig::CONFIG["host_os"] = "tron"
|
108
|
-
end
|
109
|
-
|
110
|
-
it "sets the os to the ruby 'host_os'" do
|
111
|
-
@plugin.run
|
112
|
-
expect(@plugin[:os]).to eq("tron")
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,353 +0,0 @@
|
|
1
|
-
# Author:: Christopher M. Luciano (<cmlucian@us.ibm.com>)
|
2
|
-
# Author:: Shahul Khajamohideen (<skhajamohid1@bloomberg.net>)
|
3
|
-
# Copyright (C) 2015 IBM Corp.
|
4
|
-
# Copyright (C) 2015 Bloomberg Finance L.P.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
describe Ohai::System, "plugin packages" do
|
23
|
-
context "on debian" do
|
24
|
-
let(:plugin) do
|
25
|
-
get_plugin("packages").tap do |plugin|
|
26
|
-
plugin[:platform_family] = "debian"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
let(:format) { '${Package}\t${Version}\t${Architecture}\n' }
|
31
|
-
|
32
|
-
let(:stdout) do
|
33
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output"))
|
34
|
-
end
|
35
|
-
|
36
|
-
before do
|
37
|
-
allow(plugin).to receive(:collect_os).and_return(:linux)
|
38
|
-
allow(plugin).to receive(:shell_out)
|
39
|
-
.with("dpkg-query -W -f='#{format}'")
|
40
|
-
.and_return(mock_shell_out(0, stdout, ""))
|
41
|
-
plugin.run
|
42
|
-
end
|
43
|
-
|
44
|
-
it "calls dpkg query" do
|
45
|
-
expect(plugin).to receive(:shell_out)
|
46
|
-
.with("dpkg-query -W -f='#{format}'")
|
47
|
-
.and_return(mock_shell_out(0, stdout, ""))
|
48
|
-
plugin.run
|
49
|
-
end
|
50
|
-
|
51
|
-
it "gets packages and versions - arch" do
|
52
|
-
expect(plugin[:packages]["libc6"][:version]).to eq("2.19-18+deb8u3")
|
53
|
-
expect(plugin[:packages]["libc6"][:arch]).to eq("amd64")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "gets packages and versions - noarch" do
|
57
|
-
expect(plugin[:packages]["tzdata"][:version]).to eq("2015g-0+deb8u1")
|
58
|
-
expect(plugin[:packages]["tzdata"][:arch]).to eq("all")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "on fedora" do
|
63
|
-
let(:plugin) do
|
64
|
-
get_plugin("packages").tap do |plugin|
|
65
|
-
plugin[:platform_family] = "fedora"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
let(:format) { '%{NAME}\t%|EPOCH?{%{EPOCH}}:{0}|\t%{VERSION}\t%{RELEASE}\t%{INSTALLTIME}\t%{ARCH}\n' }
|
70
|
-
|
71
|
-
let(:stdout) do
|
72
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "rpmquery.output"))
|
73
|
-
end
|
74
|
-
|
75
|
-
before do
|
76
|
-
allow(plugin).to receive(:collect_os).and_return(:linux)
|
77
|
-
allow(plugin).to receive(:shell_out).with("rpm -qa --qf '#{format}'").and_return(mock_shell_out(0, stdout, ""))
|
78
|
-
plugin.run
|
79
|
-
end
|
80
|
-
|
81
|
-
it "calls rpm -qa" do
|
82
|
-
expect(plugin).to receive(:shell_out)
|
83
|
-
.with("rpm -qa --qf '#{format}'")
|
84
|
-
.and_return(mock_shell_out(0, stdout, ""))
|
85
|
-
plugin.run
|
86
|
-
end
|
87
|
-
|
88
|
-
it "gets packages and versions/release - arch" do
|
89
|
-
expect(plugin[:packages]["glibc"][:version]).to eq("2.17")
|
90
|
-
expect(plugin[:packages]["glibc"][:release]).to eq("106.el7_2.6")
|
91
|
-
expect(plugin[:packages]["glibc"][:epoch]).to eq("0")
|
92
|
-
expect(plugin[:packages]["glibc"][:installdate]).to eq("1463486666")
|
93
|
-
expect(plugin[:packages]["glibc"][:arch]).to eq("x86_64")
|
94
|
-
end
|
95
|
-
|
96
|
-
it "gets packages and versions/release - noarch" do
|
97
|
-
expect(plugin[:packages]["tzdata"][:version]).to eq("2016d")
|
98
|
-
expect(plugin[:packages]["tzdata"][:release]).to eq("1.el7")
|
99
|
-
expect(plugin[:packages]["tzdata"][:epoch]).to eq("0")
|
100
|
-
expect(plugin[:packages]["tzdata"][:installdate]).to eq("1463486618")
|
101
|
-
expect(plugin[:packages]["tzdata"][:arch]).to eq("noarch")
|
102
|
-
end
|
103
|
-
|
104
|
-
it "handles multiple packages with the same name" do
|
105
|
-
expect(plugin[:packages]["kernel"][:version]).to eq("3.10.0")
|
106
|
-
expect(plugin[:packages]["kernel"][:release]).to eq("862.el7")
|
107
|
-
expect(plugin[:packages]["kernel"][:epoch]).to eq("0")
|
108
|
-
expect(plugin[:packages]["kernel"][:installdate]).to eq("1521745632")
|
109
|
-
expect(plugin[:packages]["kernel"][:arch]).to eq("x86_64")
|
110
|
-
# and now the version list:
|
111
|
-
expect(plugin[:packages]["kernel"]["versions"].first[:version]).to eq("3.10.0")
|
112
|
-
expect(plugin[:packages]["kernel"]["versions"].first[:release]).to eq("862.2.3.el7")
|
113
|
-
expect(plugin[:packages]["kernel"]["versions"].first[:epoch]).to eq("0")
|
114
|
-
expect(plugin[:packages]["kernel"]["versions"].first[:installdate]).to eq("1526310781")
|
115
|
-
expect(plugin[:packages]["kernel"]["versions"].first[:arch]).to eq("x86_64")
|
116
|
-
expect(plugin[:packages]["kernel"]["versions"].last[:version]).to eq("3.10.0")
|
117
|
-
expect(plugin[:packages]["kernel"]["versions"].last[:release]).to eq("862.el7")
|
118
|
-
expect(plugin[:packages]["kernel"]["versions"].last[:epoch]).to eq("0")
|
119
|
-
expect(plugin[:packages]["kernel"]["versions"].last[:installdate]).to eq("1521745632")
|
120
|
-
expect(plugin[:packages]["kernel"]["versions"].last[:arch]).to eq("x86_64")
|
121
|
-
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context "on arch" do
|
126
|
-
let(:plugin) do
|
127
|
-
get_plugin("packages").tap do |plugin|
|
128
|
-
plugin[:platform_family] = "arch"
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
let(:stdout) do
|
133
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "pacman.output"))
|
134
|
-
end
|
135
|
-
|
136
|
-
before do
|
137
|
-
allow(plugin).to receive(:collect_os).and_return(:linux)
|
138
|
-
allow(plugin).to receive(:shell_out).with("LANG=C pacman -Qi").and_return(mock_shell_out(0, stdout, ""))
|
139
|
-
plugin.run
|
140
|
-
end
|
141
|
-
|
142
|
-
it "calls LANG=C pacman -Qi" do
|
143
|
-
expect(plugin).to receive(:shell_out)
|
144
|
-
.with("LANG=C pacman -Qi")
|
145
|
-
.and_return(mock_shell_out(0, stdout, ""))
|
146
|
-
plugin.run
|
147
|
-
end
|
148
|
-
|
149
|
-
it "gets packages and versions/release - normal case" do
|
150
|
-
expect(plugin[:packages]["acl"][:version]).to eq("2.2.52-3")
|
151
|
-
expect(plugin[:packages]["acl"][:installdate]).to eq("1500780345")
|
152
|
-
expect(plugin[:packages]["acl"][:arch]).to eq("x86_64")
|
153
|
-
end
|
154
|
-
|
155
|
-
it "gets packages and versions/release - multiline optdeps" do
|
156
|
-
expect(plugin[:packages]["abcde"][:version]).to eq("2.8.1-2")
|
157
|
-
expect(plugin[:packages]["abcde"][:installdate]).to eq("1493998583")
|
158
|
-
expect(plugin[:packages]["abcde"][:arch]).to eq("any")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context "on windows", :windows_only do
|
163
|
-
|
164
|
-
let(:plugin) do
|
165
|
-
get_plugin("packages").tap do |plugin|
|
166
|
-
plugin[:platform_family] = "windows"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
let(:win_reg_double) do
|
171
|
-
instance_double("Win32::Registry")
|
172
|
-
end
|
173
|
-
|
174
|
-
let(:win_reg_keys) do
|
175
|
-
[ "{22FA28AB-3C1B-438B-A8B5-E23892C8B567}",
|
176
|
-
"{0D4BCDCD-6225-4BA5-91A3-54AFCECC281E}" ]
|
177
|
-
end
|
178
|
-
|
179
|
-
let(:i386_reg_type) do
|
180
|
-
Win32::Registry::KEY_READ | 0x100
|
181
|
-
end
|
182
|
-
|
183
|
-
let(:x86_64_reg_type) do
|
184
|
-
Win32::Registry::KEY_READ | 0x200
|
185
|
-
end
|
186
|
-
|
187
|
-
let(:win_reg_output) do
|
188
|
-
[{ "DisplayName" => "NXLOG-CE",
|
189
|
-
"DisplayVersion" => "2.8.1248",
|
190
|
-
"Publisher" => "nxsec.com",
|
191
|
-
"InstallDate" => "20150511",
|
192
|
-
},
|
193
|
-
{ "DisplayName" => "Chef Development Kit v0.7.0",
|
194
|
-
"DisplayVersion" => "0.7.0.1",
|
195
|
-
"Publisher" => "\"Chef Software, Inc. <maintainers@chef.io>\"",
|
196
|
-
"InstallDate" => "20150925" }]
|
197
|
-
end
|
198
|
-
|
199
|
-
shared_examples "windows_package_plugin" do
|
200
|
-
it "gets package info" do
|
201
|
-
plugin.run
|
202
|
-
expect(plugin[:packages]["Chef Development Kit v0.7.0"][:version]).to eq("0.7.0.1")
|
203
|
-
expect(plugin[:packages]["Chef Development Kit v0.7.0"][:publisher]).to eq("\"Chef Software, Inc. <maintainers@chef.io>\"")
|
204
|
-
expect(plugin[:packages]["Chef Development Kit v0.7.0"][:installdate]).to eq("20150925")
|
205
|
-
|
206
|
-
expect(plugin[:packages]["NXLOG-CE"][:version]).to eq("2.8.1248")
|
207
|
-
expect(plugin[:packages]["NXLOG-CE"][:publisher]).to eq("nxsec.com")
|
208
|
-
expect(plugin[:packages]["NXLOG-CE"][:installdate]).to eq("20150511")
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
before do
|
213
|
-
allow(plugin).to receive(:collect_os).and_return(:windows)
|
214
|
-
allow(win_reg_double).to receive(:open).with(win_reg_keys[0]).and_return(win_reg_output[0])
|
215
|
-
allow(win_reg_double).to receive(:open).with(win_reg_keys[1]).and_return(win_reg_output[1])
|
216
|
-
allow(win_reg_double).to receive(:each_key).and_yield(win_reg_keys[0], 0).and_yield(win_reg_keys[1], 1)
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "on 32 bit ruby" do
|
220
|
-
before do
|
221
|
-
stub_const("::RbConfig::CONFIG", { "target_cpu" => "i386" } )
|
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
|
-
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
|
-
end
|
225
|
-
|
226
|
-
it_behaves_like "windows_package_plugin"
|
227
|
-
end
|
228
|
-
|
229
|
-
describe "on 64 bit ruby" do
|
230
|
-
before do
|
231
|
-
stub_const("::RbConfig::CONFIG", { "target_cpu" => "x86_64" } )
|
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)
|
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)
|
234
|
-
end
|
235
|
-
|
236
|
-
it_behaves_like "windows_package_plugin"
|
237
|
-
end
|
238
|
-
|
239
|
-
describe "on unknown ruby" do
|
240
|
-
before do
|
241
|
-
stub_const("::RbConfig::CONFIG", { "target_cpu" => nil } )
|
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)
|
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)
|
244
|
-
end
|
245
|
-
|
246
|
-
it_behaves_like "windows_package_plugin"
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
context "on aix" do
|
251
|
-
let(:plugin) { get_plugin("packages") }
|
252
|
-
|
253
|
-
let(:stdout) do
|
254
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "lslpp.output"))
|
255
|
-
end
|
256
|
-
|
257
|
-
before do
|
258
|
-
allow(plugin).to receive(:collect_os).and_return(:aix)
|
259
|
-
allow(plugin).to receive(:shell_out).with("lslpp -L -q -c").and_return(mock_shell_out(0, stdout, ""))
|
260
|
-
plugin.run
|
261
|
-
end
|
262
|
-
|
263
|
-
it "calls lslpp -L -q -c" do
|
264
|
-
expect(plugin).to receive(:shell_out)
|
265
|
-
.with("lslpp -L -q -c")
|
266
|
-
.and_return(mock_shell_out(0, stdout, ""))
|
267
|
-
plugin.run
|
268
|
-
end
|
269
|
-
|
270
|
-
it "gets packages with version" do
|
271
|
-
expect(plugin[:packages]["chef"][:version]).to eq("12.5.1.1")
|
272
|
-
end
|
273
|
-
|
274
|
-
it "properly parses package names for RPMs" do
|
275
|
-
expect(plugin[:packages]["wget"][:version]).to eq("1.9.1-3")
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
context "on freebsd" do
|
280
|
-
let(:plugin) { get_plugin("packages") }
|
281
|
-
|
282
|
-
let(:stdout) do
|
283
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "pkg-query.output"))
|
284
|
-
end
|
285
|
-
|
286
|
-
before do
|
287
|
-
allow(plugin).to receive(:collect_os).and_return(:freebsd)
|
288
|
-
allow(plugin).to receive(:shell_out).with('pkg query -a "%n %v"').and_return(mock_shell_out(0, stdout, ""))
|
289
|
-
plugin.run
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'calls pkg query -a "%n %v"' do
|
293
|
-
expect(plugin).to receive(:shell_out)
|
294
|
-
.with('pkg query -a "%n %v"')
|
295
|
-
.and_return(mock_shell_out(0, stdout, ""))
|
296
|
-
plugin.run
|
297
|
-
end
|
298
|
-
|
299
|
-
it "gets packages with version" do
|
300
|
-
expect(plugin[:packages]["rubygem-chef"][:version]).to eq("12.6.0_1")
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
context "on solaris2" do
|
305
|
-
let(:plugin) { get_plugin("packages") }
|
306
|
-
|
307
|
-
let(:pkglist_output) do
|
308
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "pkglist.output"))
|
309
|
-
end
|
310
|
-
|
311
|
-
let(:pkginfo_output) do
|
312
|
-
File.read(File.join(SPEC_PLUGIN_PATH, "pkginfo.output"))
|
313
|
-
end
|
314
|
-
|
315
|
-
before do
|
316
|
-
allow(plugin).to receive(:collect_os).and_return(:solaris2)
|
317
|
-
allow(plugin).to receive(:shell_out).with("pkg list -H").and_return(mock_shell_out(0, pkglist_output, ""))
|
318
|
-
allow(plugin).to receive(:shell_out).with("pkginfo -l").and_return(mock_shell_out(0, pkginfo_output, ""))
|
319
|
-
plugin.run
|
320
|
-
end
|
321
|
-
|
322
|
-
it "calls pkg list -H" do
|
323
|
-
expect(plugin).to receive(:shell_out)
|
324
|
-
.with("pkg list -H")
|
325
|
-
.and_return(mock_shell_out(0, pkglist_output, ""))
|
326
|
-
plugin.run
|
327
|
-
end
|
328
|
-
|
329
|
-
it "calls pkginfo -l" do
|
330
|
-
expect(plugin).to receive(:shell_out)
|
331
|
-
.with("pkginfo -l")
|
332
|
-
.and_return(mock_shell_out(0, pkginfo_output, ""))
|
333
|
-
plugin.run
|
334
|
-
end
|
335
|
-
|
336
|
-
it "gets ips packages with version" do
|
337
|
-
expect(plugin[:packages]["chef"][:version]).to eq("12.5.1")
|
338
|
-
end
|
339
|
-
|
340
|
-
it "gets ips packages with version and publisher" do
|
341
|
-
expect(plugin[:packages]["system/EMCpower"][:version]).to eq("6.0.0.1.0-3")
|
342
|
-
expect(plugin[:packages]["system/EMCpower"][:publisher]).to eq("emc.com")
|
343
|
-
end
|
344
|
-
|
345
|
-
it "gets sysv packages with version" do
|
346
|
-
expect(plugin[:packages]["chef"][:version]).to eq("12.5.1")
|
347
|
-
end
|
348
|
-
|
349
|
-
it "gets sysv packages with version" do
|
350
|
-
expect(plugin[:packages]["mqm"][:version]).to eq("7.0.1.4")
|
351
|
-
end
|
352
|
-
end
|
353
|
-
end
|