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,118 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Salim Alam (<salam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2015 Chef Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
shared_examples "a cpu" do |cpu_no|
|
22
|
-
describe "cpu #{cpu_no}" do
|
23
|
-
it "sets physical_id to CPU#{cpu_no}" do
|
24
|
-
expect(@plugin[:cpu][cpu_no.to_s][:physical_id]).to eq("CPU#{cpu_no}")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets mhz to 2793" do
|
28
|
-
expect(@plugin[:cpu][cpu_no.to_s][:mhz]).to eq("2793")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets vendor_id to GenuineIntel" do
|
32
|
-
expect(@plugin[:cpu][cpu_no.to_s][:vendor_id]).to eq("GenuineIntel")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sets model_name to Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz" do
|
36
|
-
expect(@plugin[:cpu][cpu_no.to_s][:model_name])
|
37
|
-
.to eq("Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz")
|
38
|
-
end
|
39
|
-
|
40
|
-
it "sets description to Intel64 Family 6 Model 70 Stepping 1" do
|
41
|
-
expect(@plugin[:cpu][cpu_no.to_s][:description])
|
42
|
-
.to eq("Intel64 Family 6 Model 70 Stepping 1")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "sets model to 17921" do
|
46
|
-
expect(@plugin[:cpu][cpu_no.to_s][:model]).to eq("17921")
|
47
|
-
end
|
48
|
-
|
49
|
-
it "sets family to 2" do
|
50
|
-
expect(@plugin[:cpu][cpu_no.to_s][:family]).to eq("2")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "sets stepping to 9" do
|
54
|
-
expect(@plugin[:cpu][cpu_no.to_s][:stepping]).to eq(9)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "sets cache_size to 64 KB" do
|
58
|
-
expect(@plugin[:cpu][cpu_no.to_s][:cache_size]).to eq("64 KB")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe Ohai::System, "Windows cpu plugin" do
|
64
|
-
before do
|
65
|
-
@plugin = get_plugin("cpu")
|
66
|
-
allow(@plugin).to receive(:collect_os).and_return(:windows)
|
67
|
-
|
68
|
-
@double_wmi_instance = instance_double(WmiLite::Wmi)
|
69
|
-
|
70
|
-
@processors = [{ "description" => "Intel64 Family 6 Model 70 Stepping 1",
|
71
|
-
"name" => "Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz",
|
72
|
-
"deviceid" => "CPU0",
|
73
|
-
"family" => 2,
|
74
|
-
"manufacturer" => "GenuineIntel",
|
75
|
-
"maxclockspeed" => 2793,
|
76
|
-
"numberofcores" => 1,
|
77
|
-
"numberoflogicalprocessors" => 2,
|
78
|
-
"revision" => 17_921,
|
79
|
-
"stepping" => 9,
|
80
|
-
"l2cachesize" => 64 },
|
81
|
-
|
82
|
-
{ "description" => "Intel64 Family 6 Model 70 Stepping 1",
|
83
|
-
"name" => "Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz",
|
84
|
-
"deviceid" => "CPU1",
|
85
|
-
"family" => 2,
|
86
|
-
"manufacturer" => "GenuineIntel",
|
87
|
-
"maxclockspeed" => 2793,
|
88
|
-
"numberofcores" => 1,
|
89
|
-
"numberoflogicalprocessors" => 2,
|
90
|
-
"revision" => 17_921,
|
91
|
-
"stepping" => 9,
|
92
|
-
"l2cachesize" => 64 }]
|
93
|
-
|
94
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(@double_wmi_instance)
|
95
|
-
|
96
|
-
allow(@double_wmi_instance).to receive(:instances_of)
|
97
|
-
.with("Win32_Processor")
|
98
|
-
.and_return(@processors)
|
99
|
-
|
100
|
-
@plugin.run
|
101
|
-
end
|
102
|
-
|
103
|
-
it "sets total cpu to 2" do
|
104
|
-
expect(@plugin[:cpu][:total]).to eq(4)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "sets real cpu to 2" do
|
108
|
-
expect(@plugin[:cpu][:real]).to eq(2)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "sets 2 distinct cpus numbered 0 and 1" do
|
112
|
-
expect(@plugin[:cpu]).to have_key("0")
|
113
|
-
expect(@plugin[:cpu]).to have_key("1")
|
114
|
-
end
|
115
|
-
|
116
|
-
it_behaves_like "a cpu", 0
|
117
|
-
it_behaves_like "a cpu", 1
|
118
|
-
end
|
@@ -1,226 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Nimesh Pathi <nimesh.patni@msystechnologies.com>
|
3
|
-
# Copyright:: Copyright (c) 2018 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
require "wmi-lite/wmi"
|
21
|
-
|
22
|
-
describe Ohai::System, "Windows Filesystem Plugin", :windows_only do
|
23
|
-
let(:plugin) { get_plugin("windows/filesystem") }
|
24
|
-
|
25
|
-
let(:success) { true }
|
26
|
-
|
27
|
-
let(:logical_disks_instances) do
|
28
|
-
[
|
29
|
-
{
|
30
|
-
"caption" => "C:",
|
31
|
-
"deviceid" => "C:",
|
32
|
-
"size" => "10000000",
|
33
|
-
"filesystem" => "NTFS",
|
34
|
-
"freespace" => "100000",
|
35
|
-
"name" => "C:",
|
36
|
-
"volumename " => "",
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"caption" => "D:",
|
40
|
-
"deviceid" => "D:",
|
41
|
-
"size" => "10000000",
|
42
|
-
"filesystem" => "FAT32",
|
43
|
-
"freespace" => "100000",
|
44
|
-
"name" => "D:",
|
45
|
-
# Lets not pass "volumename" for this drive
|
46
|
-
},
|
47
|
-
]
|
48
|
-
end
|
49
|
-
|
50
|
-
let(:encryptable_volume_instances) do
|
51
|
-
[
|
52
|
-
{
|
53
|
-
"conversionstatus" => 0,
|
54
|
-
"driveletter" => "C:",
|
55
|
-
},
|
56
|
-
{
|
57
|
-
"conversionstatus" => 2,
|
58
|
-
"driveletter" => "D:",
|
59
|
-
},
|
60
|
-
]
|
61
|
-
end
|
62
|
-
|
63
|
-
let(:wmi_exception) do
|
64
|
-
namespace = "Exception while testing"
|
65
|
-
exception = WIN32OLERuntimeError.new(namespace)
|
66
|
-
WmiLite::WmiException.new(exception, :ConnectServer, @namespace)
|
67
|
-
end
|
68
|
-
|
69
|
-
before do
|
70
|
-
allow(plugin).to receive(:collect_os).and_return(:windows)
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#logical_properties" do
|
74
|
-
let(:disks) { logical_disks_instances }
|
75
|
-
let(:logical_props) { %i{kb_size kb_available kb_used percent_used mount fs_type volume_name} }
|
76
|
-
|
77
|
-
it "Returns a mash" do
|
78
|
-
expect(plugin.logical_properties(disks)).to be_a(Mash)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "Returns an empty mash when blank array is passed" do
|
82
|
-
expect(plugin.logical_properties([])).to be_a(Mash)
|
83
|
-
expect(plugin.logical_properties([])).to be_empty
|
84
|
-
end
|
85
|
-
|
86
|
-
it "Returns properties without values when there is no disk information" do
|
87
|
-
data = plugin.logical_properties([{}])
|
88
|
-
expect(data[nil].symbolize_keys.keys).to eq(logical_props)
|
89
|
-
expect(data[nil]["kb_used"]).to eq(0)
|
90
|
-
expect(data[nil]["fs_type"]).to be_empty
|
91
|
-
end
|
92
|
-
|
93
|
-
it "Refines required logical properties out of given instance" do
|
94
|
-
data = plugin.logical_properties(disks)
|
95
|
-
expect(data["C:"].symbolize_keys.keys).to eq(logical_props)
|
96
|
-
expect(data["D:"].symbolize_keys.keys).to eq(logical_props)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "Calculates logical properties out of given instance" do
|
100
|
-
data = plugin.logical_properties(disks)
|
101
|
-
expect(data["C:"]["kb_used"]).to eq(data["D:"]["kb_used"]).and eq(9900)
|
102
|
-
expect(data["C:"]["percent_used"]).to eq(data["D:"]["percent_used"]).and eq(99)
|
103
|
-
expect(data["C:"]["fs_type"]).to eq("ntfs")
|
104
|
-
expect(data["D:"]["fs_type"]).to eq("fat32")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "#logical_info" do
|
109
|
-
it "Returns an empty mash when wmi namespace does not exists" do
|
110
|
-
allow(WmiLite::Wmi).to receive(:new).and_raise(wmi_exception)
|
111
|
-
expect(plugin.logical_info).to be_a(Mash)
|
112
|
-
expect(plugin.logical_info).to be_empty
|
113
|
-
end
|
114
|
-
|
115
|
-
it "Returns an empty mash when Win32_LogicalDisk could not be processed" do
|
116
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(success)
|
117
|
-
allow(success)
|
118
|
-
.to receive(:instances_of)
|
119
|
-
.with("Win32_LogicalDisk")
|
120
|
-
.and_raise(wmi_exception)
|
121
|
-
expect(plugin.logical_info).to be_a(Mash)
|
122
|
-
expect(plugin.logical_info).to be_empty
|
123
|
-
end
|
124
|
-
|
125
|
-
it "Returns a Mash loaded with logical details" do
|
126
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(success)
|
127
|
-
allow(success)
|
128
|
-
.to receive(:instances_of)
|
129
|
-
.with("Win32_LogicalDisk")
|
130
|
-
.and_return(logical_disks_instances)
|
131
|
-
expect(plugin.logical_info).to be_a(Mash)
|
132
|
-
expect(plugin.logical_info).not_to be_empty
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "#encryption_properties" do
|
137
|
-
let(:disks) { encryptable_volume_instances }
|
138
|
-
let(:encryption_props) { [:encryption_status] }
|
139
|
-
|
140
|
-
it "Returns a mash" do
|
141
|
-
expect(plugin.encryption_properties(disks)).to be_a(Mash)
|
142
|
-
end
|
143
|
-
|
144
|
-
it "Returns an empty mash when blank array is passed" do
|
145
|
-
expect(plugin.encryption_properties([])).to be_a(Mash)
|
146
|
-
expect(plugin.encryption_properties([])).to be_empty
|
147
|
-
end
|
148
|
-
|
149
|
-
it "Returns properties without values when there is no disk information" do
|
150
|
-
data = plugin.encryption_properties([{}])
|
151
|
-
expect(data[nil].symbolize_keys.keys).to eq(encryption_props)
|
152
|
-
expect(data[nil]["encryption_status"]).to be_empty
|
153
|
-
end
|
154
|
-
|
155
|
-
it "Refines required encryption properties out of given instance" do
|
156
|
-
data = plugin.encryption_properties(disks)
|
157
|
-
expect(data["C:"].symbolize_keys.keys).to eq(encryption_props)
|
158
|
-
expect(data["D:"].symbolize_keys.keys).to eq(encryption_props)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "Calculates encryption properties out of given instance" do
|
162
|
-
data = plugin.encryption_properties(disks)
|
163
|
-
expect(data["C:"]["encryption_status"]).to eq("FullyDecrypted")
|
164
|
-
expect(data["D:"]["encryption_status"]).to eq("EncryptionInProgress")
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#encryptable_info" do
|
169
|
-
it "Returns an empty mash when wmi namespace does not exists" do
|
170
|
-
allow(WmiLite::Wmi).to receive(:new).and_raise(wmi_exception)
|
171
|
-
expect(plugin.encryptable_info).to be_a(Mash)
|
172
|
-
expect(plugin.encryptable_info).to be_empty
|
173
|
-
end
|
174
|
-
|
175
|
-
it "Returns an empty mash when Win32_EncryptableVolume could not be processed" do
|
176
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(success)
|
177
|
-
allow(success)
|
178
|
-
.to receive(:instances_of)
|
179
|
-
.with("Win32_EncryptableVolume")
|
180
|
-
.and_raise(wmi_exception)
|
181
|
-
expect(plugin.encryptable_info).to be_a(Mash)
|
182
|
-
expect(plugin.encryptable_info).to be_empty
|
183
|
-
end
|
184
|
-
|
185
|
-
it "Returns a Mash loaded with encryption details" do
|
186
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(success)
|
187
|
-
allow(success)
|
188
|
-
.to receive(:instances_of)
|
189
|
-
.with("Win32_EncryptableVolume")
|
190
|
-
.and_return(encryptable_volume_instances)
|
191
|
-
expect(plugin.encryptable_info).to be_a(Mash)
|
192
|
-
expect(plugin.encryptable_info).not_to be_empty
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
describe "#merge_info" do
|
197
|
-
let(:info1) do
|
198
|
-
{ "drive1" => { "x" => 10, "y" => "test1" },
|
199
|
-
"drive2" => { "x" => 20, "z" => "test2" } }
|
200
|
-
end
|
201
|
-
let(:info2) do
|
202
|
-
{ "drive1" => { "k" => 10, "l" => "test1" },
|
203
|
-
"drive2" => { "l" => 20, "m" => "test2" } }
|
204
|
-
end
|
205
|
-
let(:info3) { { "drive1" => { "o" => 10, "p" => "test1" } } }
|
206
|
-
let(:info4) { { "drive2" => { "q" => 10, "r" => "test1" } } }
|
207
|
-
|
208
|
-
it "Returns an empty mash when no info is passed" do
|
209
|
-
expect(plugin.merge_info([])).to be_a(Mash)
|
210
|
-
expect(plugin.merge_info([])).to be_empty
|
211
|
-
end
|
212
|
-
|
213
|
-
it "Merges all the various properties of filesystems" do
|
214
|
-
expect(plugin.merge_info([info1, info2, info3, info4]))
|
215
|
-
.to eq("drive1" => { "x" => 10, "y" => "test1", "k" => 10, "l" => "test1", "o" => 10, "p" => "test1" },
|
216
|
-
"drive2" => { "x" => 20, "z" => "test2", "l" => 20, "m" => "test2", "q" => 10, "r" => "test1" })
|
217
|
-
end
|
218
|
-
|
219
|
-
it "Does not affect any core information after processing" do
|
220
|
-
expect(plugin.merge_info([info3, info4])).to eq("drive1" => { "o" => 10, "p" => "test1" },
|
221
|
-
"drive2" => { "q" => 10, "r" => "test1" })
|
222
|
-
expect(info3).to eq("drive1" => { "o" => 10, "p" => "test1" })
|
223
|
-
expect(info4).to eq("drive2" => { "q" => 10, "r" => "test1" })
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Matt Wrock (<matt@mattwrock.com>)
|
3
|
-
# Copyright:: Copyright (c) 2016-2018 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
require "openssl"
|
21
|
-
|
22
|
-
describe Ohai::System, "plugin fips" do
|
23
|
-
subject do
|
24
|
-
plugin.run
|
25
|
-
plugin["fips"]["kernel"]["enabled"]
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:enabled) { 0 }
|
29
|
-
let(:plugin) { get_plugin("windows/fips") }
|
30
|
-
let(:openssl_test_mode) { false }
|
31
|
-
|
32
|
-
before do
|
33
|
-
allow(plugin).to receive(:collect_os).and_return(:windows)
|
34
|
-
end
|
35
|
-
|
36
|
-
around do |ex|
|
37
|
-
|
38
|
-
$FIPS_TEST_MODE = openssl_test_mode
|
39
|
-
ex.run
|
40
|
-
ensure
|
41
|
-
$FIPS_TEST_MODE = false
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with OpenSSL.fips_mode == false" do
|
46
|
-
before { allow(OpenSSL).to receive(:fips_mode).and_return(false) }
|
47
|
-
|
48
|
-
it "does not set fips plugin" do
|
49
|
-
expect(subject).to be(false)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "with OpenSSL.fips_mode == true" do
|
54
|
-
before { allow(OpenSSL).to receive(:fips_mode).and_return(true) }
|
55
|
-
|
56
|
-
it "sets fips plugin" do
|
57
|
-
expect(subject).to be(true)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2018 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
|
-
|
20
|
-
describe Ohai::System, "Windows kernel plugin", :windows_only do
|
21
|
-
let(:plugin) { get_plugin("kernel") }
|
22
|
-
|
23
|
-
before do
|
24
|
-
require "wmi-lite/wmi"
|
25
|
-
|
26
|
-
# Mock a Win32_OperatingSystem OLE32 WMI object
|
27
|
-
caption = double("WIN32OLE", name: "Caption")
|
28
|
-
version = double("WIN32OLE", name: "Version")
|
29
|
-
build_number = double("WIN32OLE", name: "BuildNumber")
|
30
|
-
csd_version = double("WIN32OLE", name: "CsdVersion")
|
31
|
-
os_type = double("WIN32OLE", name: "OsType")
|
32
|
-
product_type = double("WIN32OLE", name: "ProductType")
|
33
|
-
operating_system_sku = double("WIN32OLE", name: "OperatingSystemSKU")
|
34
|
-
os_properties = [ caption, version, build_number, csd_version, os_type, product_type, operating_system_sku ]
|
35
|
-
|
36
|
-
os = double( "WIN32OLE",
|
37
|
-
properties_: os_properties)
|
38
|
-
|
39
|
-
allow(os).to receive(:invoke).with(build_number.name).and_return("7601")
|
40
|
-
allow(os).to receive(:invoke).with(csd_version.name).and_return("Service Pack 1")
|
41
|
-
allow(os).to receive(:invoke).with(os_type.name).and_return(18)
|
42
|
-
allow(os).to receive(:invoke).with(caption.name).and_return("Microsoft Windows 7 Ultimate")
|
43
|
-
allow(os).to receive(:invoke).with(version.name).and_return("6.1.7601")
|
44
|
-
allow(os).to receive(:invoke).with(product_type.name).and_return(1)
|
45
|
-
allow(os).to receive(:invoke).with(operating_system_sku.name).and_return(48)
|
46
|
-
|
47
|
-
os_wmi = WmiLite::Wmi::Instance.new(os)
|
48
|
-
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_OperatingSystem").and_return(os_wmi)
|
49
|
-
|
50
|
-
system_type = double("WIN32OLE", name: "SystemType")
|
51
|
-
pc_system_type = double("WIN32OLE", name: "PCSystemType")
|
52
|
-
free_virtual_memory = double("WIN32OLE", name: "FreeVirtualMemory")
|
53
|
-
cs_properties = [ system_type, pc_system_type, free_virtual_memory]
|
54
|
-
|
55
|
-
cs = double("WIN32OLE",
|
56
|
-
properties_: cs_properties)
|
57
|
-
|
58
|
-
allow(cs).to receive(:invoke).with(system_type.name).and_return("x64-based PC")
|
59
|
-
allow(cs).to receive(:invoke).with(pc_system_type.name).and_return(2)
|
60
|
-
allow(cs).to receive(:invoke).with(free_virtual_memory.name).and_return("Why would you want this data here?")
|
61
|
-
|
62
|
-
cs_wmi = WmiLite::Wmi::Instance.new(cs)
|
63
|
-
expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_ComputerSystem").and_return(cs_wmi)
|
64
|
-
|
65
|
-
plugin.run
|
66
|
-
end
|
67
|
-
|
68
|
-
it "sets the correct system information" do
|
69
|
-
expect(plugin[:kernel][:name]).to eq("Microsoft Windows 7 Ultimate")
|
70
|
-
expect(plugin[:kernel][:release]).to eq("6.1.7601")
|
71
|
-
expect(plugin[:kernel][:version]).to eq("6.1.7601 Service Pack 1 Build 7601")
|
72
|
-
expect(plugin[:kernel][:os]).to eq("WINNT")
|
73
|
-
expect(plugin[:kernel][:machine]).to eq("x86_64")
|
74
|
-
expect(plugin[:kernel][:system_type]).to eq("Mobile")
|
75
|
-
expect(plugin[:kernel][:product_type]).to eq("Workstation")
|
76
|
-
expect(plugin[:kernel][:server_core]).to eq(false)
|
77
|
-
expect(plugin[:kernel]).not_to have_key(:free_virtual_memory)
|
78
|
-
end
|
79
|
-
end
|