boris 1.0.0.beta.1
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.
- data/LICENSE.md +9 -0
- data/README.md +94 -0
- data/boris.gemspec +28 -0
- data/doc/Array.html +437 -0
- data/doc/Boris.html +230 -0
- data/doc/Boris/ConnectionAlreadyActive.html +123 -0
- data/doc/Boris/ConnectionFailed.html +127 -0
- data/doc/Boris/Connector.html +794 -0
- data/doc/Boris/InvalidCredentials.html +131 -0
- data/doc/Boris/InvalidOption.html +123 -0
- data/doc/Boris/InvalidTargetName.html +123 -0
- data/doc/Boris/Lumberjack.html +466 -0
- data/doc/Boris/MissingCredentials.html +123 -0
- data/doc/Boris/NoActiveConnection.html +123 -0
- data/doc/Boris/NoProfileDetected.html +123 -0
- data/doc/Boris/Options.html +783 -0
- data/doc/Boris/Profiles.html +117 -0
- data/doc/Boris/Profiles/Linux.html +1151 -0
- data/doc/Boris/Profiles/RedHat.html +875 -0
- data/doc/Boris/Profiles/Solaris.html +1230 -0
- data/doc/Boris/Profiles/Structure.html +2050 -0
- data/doc/Boris/Profiles/UNIX.html +893 -0
- data/doc/Boris/Profiles/Windows.html +1846 -0
- data/doc/Boris/Profiles/Windows/Windows2003.html +304 -0
- data/doc/Boris/Profiles/Windows/Windows2008.html +379 -0
- data/doc/Boris/Profiles/Windows/Windows2012.html +304 -0
- data/doc/Boris/SNMPConnector.html +512 -0
- data/doc/Boris/SSHConnector.html +633 -0
- data/doc/Boris/Target.html +2002 -0
- data/doc/Boris/WMIConnector.html +1134 -0
- data/doc/BorisLogger.html +217 -0
- data/doc/Hash.html +195 -0
- data/doc/String.html +1246 -0
- data/doc/_index.html +420 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +183 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +183 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1468 -0
- data/doc/top-level-namespace.html +126 -0
- data/lib/boris.rb +30 -0
- data/lib/boris/connectors.rb +47 -0
- data/lib/boris/connectors/snmp.rb +56 -0
- data/lib/boris/connectors/ssh.rb +110 -0
- data/lib/boris/connectors/wmi.rb +186 -0
- data/lib/boris/errors.rb +17 -0
- data/lib/boris/helpers/array.rb +63 -0
- data/lib/boris/helpers/constants.rb +20 -0
- data/lib/boris/helpers/hash.rb +8 -0
- data/lib/boris/helpers/scrubber.rb +51 -0
- data/lib/boris/helpers/string.rb +130 -0
- data/lib/boris/lumberjack.rb +47 -0
- data/lib/boris/options.rb +86 -0
- data/lib/boris/profiles/linux/redhat.rb +77 -0
- data/lib/boris/profiles/linux_core.rb +216 -0
- data/lib/boris/profiles/unix/solaris.rb +307 -0
- data/lib/boris/profiles/unix_core.rb +85 -0
- data/lib/boris/profiles/windows/windows2003.rb +15 -0
- data/lib/boris/profiles/windows/windows2008.rb +23 -0
- data/lib/boris/profiles/windows/windows2012.rb +15 -0
- data/lib/boris/profiles/windows_core.rb +530 -0
- data/lib/boris/structure.rb +167 -0
- data/lib/boris/target.rb +340 -0
- data/test/connector_tests/test_snmp.rb +35 -0
- data/test/connector_tests/test_ssh.rb +51 -0
- data/test/connector_tests/test_wmi.rb +129 -0
- data/test/helper_tests/test_array.rb +25 -0
- data/test/helper_tests/test_hash.rb +10 -0
- data/test/helper_tests/test_string.rb +136 -0
- data/test/profile_tests/test_core_skeleton +107 -0
- data/test/profile_tests/test_linux_core.rb +331 -0
- data/test/profile_tests/test_redhat.rb +134 -0
- data/test/profile_tests/test_solaris.rb +523 -0
- data/test/profile_tests/test_unix_core.rb +117 -0
- data/test/profile_tests/test_windows.rb +536 -0
- data/test/setup_tests.rb +14 -0
- data/test/test_all.rb +8 -0
- data/test/test_options.rb +44 -0
- data/test/test_structure.rb +136 -0
- data/test/test_target.rb +146 -0
- metadata +241 -0
@@ -0,0 +1,331 @@
|
|
1
|
+
require 'setup_tests'
|
2
|
+
|
3
|
+
class LinuxCoreTest < ProfileTestSetup
|
4
|
+
context 'a Linux target' do
|
5
|
+
setup do
|
6
|
+
@connector = @target.connector = instance_of(SSHConnector)
|
7
|
+
@target.stubs(:target_profile).returns(Profiles::Linux)
|
8
|
+
@target.extend(Profiles::Linux)
|
9
|
+
@connector.stubs(:value_at).with('uname -a').returns('GNU/Linux')
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'being scanned' do
|
13
|
+
setup do
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'for file system information' do
|
17
|
+
setup do
|
18
|
+
@file_system_data = [
|
19
|
+
'/dev/md/dsk/d10|1000|500|/',
|
20
|
+
'/dev/md/dsk/d11|2000|1000|/var'
|
21
|
+
]
|
22
|
+
|
23
|
+
@expected_data = [
|
24
|
+
{
|
25
|
+
:capacity_mb=>1000,
|
26
|
+
:file_system=>'/dev/md/dsk/d10',
|
27
|
+
:mount_point=>'/',
|
28
|
+
:san_storage=>nil,
|
29
|
+
:used_space_mb=>500
|
30
|
+
},
|
31
|
+
{
|
32
|
+
:capacity_mb=>2000,
|
33
|
+
:file_system=>'/dev/md/dsk/d11',
|
34
|
+
:mount_point=>'/var',
|
35
|
+
:san_storage=>nil,
|
36
|
+
:used_space_mb=>1000
|
37
|
+
}
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'return file system information via #get_file_systems' do
|
42
|
+
file_system_command = %q{df -P -T | grep "^/" | awk '{print $1 "|" $3 / 1024 "|" $5 / 1024 "|" $7}'}
|
43
|
+
|
44
|
+
@connector.stubs(:values_at).with(file_system_command).returns(@file_system_data)
|
45
|
+
|
46
|
+
@target.get_file_systems
|
47
|
+
|
48
|
+
assert_equal(@expected_data, @target.file_systems)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'for hardware information' do
|
53
|
+
setup do
|
54
|
+
@cpu_arch_command = 'uname -m'
|
55
|
+
@connector.stubs(:value_at).with(@cpu_arch_command).returns('x86_64')
|
56
|
+
|
57
|
+
@memory_command = "cat /proc/meminfo | grep -i memtotal | awk '{print $2 / 1024}'"
|
58
|
+
@connector.stubs(:value_at).with(@memory_command).returns('1024')
|
59
|
+
|
60
|
+
@cpu_command = 'cat /proc/cpuinfo | egrep -i "processor|vendor|mhz|name|cores"'
|
61
|
+
@cpu_data = %q{
|
62
|
+
processor : 0
|
63
|
+
vendor_id : AuthenticAMD
|
64
|
+
model name : AMD Opteron Processor 6174
|
65
|
+
cpu MHz : 2212.0
|
66
|
+
cpu cores : 2
|
67
|
+
processor : 1
|
68
|
+
vendor_id : AuthenticAMD
|
69
|
+
model name : AMD Opteron Processor 6174
|
70
|
+
cpu MHz : 2212.0
|
71
|
+
cpu cores : 2
|
72
|
+
}.split(/\n/)
|
73
|
+
@connector.stubs(:values_at).with(@cpu_command).returns(@cpu_data)
|
74
|
+
|
75
|
+
@dmidecode_command = '/usr/bin/sudo /usr/sbin/dmidecode -t 0,1,4'
|
76
|
+
@dmidecode_data = %q{
|
77
|
+
Version: 6.0
|
78
|
+
Manufacturer: VMware, Inc.
|
79
|
+
Product Name: VMware Virtual Platform
|
80
|
+
Serial Number: VMware-1234
|
81
|
+
Manufacturer: AuthenticAMD
|
82
|
+
Current Speed: 2200 MHz
|
83
|
+
}.split(/\n/)
|
84
|
+
@connector.stubs(:values_at).with(@dmidecode_command, true).returns(@dmidecode_data)
|
85
|
+
|
86
|
+
@expected_data = {
|
87
|
+
:cpu_architecture=>64,
|
88
|
+
:cpu_core_count=>2,
|
89
|
+
:cpu_model=>'AMD Opteron Processor 6174',
|
90
|
+
:cpu_physical_count=>1,
|
91
|
+
:cpu_speed_mhz=>2200,
|
92
|
+
:cpu_vendor=>'AuthenticAMD',
|
93
|
+
:firmware_version=>'6.0',
|
94
|
+
:model=>'VMware Virtual Platform',
|
95
|
+
:memory_installed_mb=>1024,
|
96
|
+
:serial=>'VMware-1234',
|
97
|
+
:vendor=>'VMware, Inc.'
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
should 'return hardware information via #get_hardware' do
|
102
|
+
@target.get_hardware
|
103
|
+
assert_equal(@expected_data, @target.hardware)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# OS SPECIFIC
|
108
|
+
#context 'for hosted shares' do
|
109
|
+
#end
|
110
|
+
|
111
|
+
# OS SPECIFIC
|
112
|
+
#context 'for installed applications' do
|
113
|
+
#end
|
114
|
+
|
115
|
+
# OS SPECIFIC
|
116
|
+
#context 'for installed patches' do
|
117
|
+
#end
|
118
|
+
|
119
|
+
# OS SPECIFIC
|
120
|
+
#context 'for installed services' do
|
121
|
+
#end
|
122
|
+
|
123
|
+
context 'for local users and groups' do
|
124
|
+
setup do
|
125
|
+
@user_data = [
|
126
|
+
'root:x:0:0:Super-User:/root:/sbin/sh',
|
127
|
+
'usera:x:2001:10:User A:/export/home/usera:/bin/bash',
|
128
|
+
'userb:x:2001:10:User B:/export/home/userb:/bin/bash'
|
129
|
+
]
|
130
|
+
@group_data = ['root::0:', 'staff::10:']
|
131
|
+
@expected_data = [{:members=>['root'], :name=>'root'}, {:members=>['usera', 'userb'], :name=>'staff'}]
|
132
|
+
end
|
133
|
+
|
134
|
+
should 'return local user groups and accounts via #get_local_user_groups if the server is not a domain controller' do
|
135
|
+
@connector.stubs(:values_at).with('cat /etc/passwd | grep -v "^#"').returns(@user_data)
|
136
|
+
@connector.stubs(:values_at).with('cat /etc/group | grep -v "^#"').returns(@group_data)
|
137
|
+
|
138
|
+
@target.get_local_user_groups
|
139
|
+
|
140
|
+
assert_equal(@expected_data, @target.local_user_groups)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'for network identification' do
|
145
|
+
should 'return the hostname and domain via #get_network_id when hostname and domain are properly returned' do
|
146
|
+
expected_data = {:domain=>'mydomain.com', :hostname=>'SERVER01'}
|
147
|
+
@connector.stubs(:value_at).with('hostname').returns(expected_data[:hostname])
|
148
|
+
@connector.stubs(:value_at).with('domainname').returns(expected_data[:domain])
|
149
|
+
|
150
|
+
@target.get_network_id
|
151
|
+
|
152
|
+
assert_equal(expected_data, @target.network_id)
|
153
|
+
end
|
154
|
+
|
155
|
+
should 'return the hostname and domain via #get_network_id when hostname and domain in a single string' do
|
156
|
+
expected_data = {:domain=>'mydomain.com', :hostname=>'SERVER01'}
|
157
|
+
@connector.stubs(:value_at).with('hostname').returns("#{expected_data[:hostname]}.#{expected_data[:domain]}")
|
158
|
+
@connector.stubs(:value_at).with('domainname').returns(nil)
|
159
|
+
|
160
|
+
@target.get_network_id
|
161
|
+
|
162
|
+
assert_equal(expected_data, @target.network_id)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'for network interfaces' do
|
167
|
+
setup do
|
168
|
+
@hardware_command = '/sbin/lspci -mmv | egrep -i "class:[[:space:]]*(ethernet controller|fibre channel)" -B1 -A5'
|
169
|
+
@ethernet_mapping_command = %q{ls /sys/class/net | awk '{cmd="readlink -f /sys/class/net/" $1 "/device/"; cmd | getline link; print $1 "|" link}'}
|
170
|
+
@link_properties_command = %q{find -L /sys/class/net/ -mindepth 2 -maxdepth 2 2>/dev/null | awk '{cmd = "cat " $0 " 2>/dev/null"; cmd | getline value; print $0 "|" value;}'}
|
171
|
+
@ip_addr_command = %q{/sbin/ip addr | awk '{if($0 ~ /^[0-9]:/) {print "\n" $0} else {print $0}}'}
|
172
|
+
|
173
|
+
@dns_server_command = "cat /etc/resolv.conf | grep ^nameserver | awk '{print $2}'"
|
174
|
+
@dns_server_data = ['192.168.1.1', '192.168.1.2']
|
175
|
+
@connector.stubs(:values_at).with(@dns_server_command).returns(@dns_server_data)
|
176
|
+
|
177
|
+
@fibre_mapping_command = "find /sys/devices/pci* -regex '.*fc_host/host[0-9]'"
|
178
|
+
@fibre_config_command = %q{find -L /sys/class/fc_host/ -mindepth 2 -maxdepth 2 | awk '{value=""; "cat " $1 " 2>/dev/null" | getline value; print $1 "|" value;}'}
|
179
|
+
end
|
180
|
+
|
181
|
+
should 'return ethernet interface information via #get_network_interfaces' do
|
182
|
+
@expected_data = [
|
183
|
+
@target.network_interface_template.merge({
|
184
|
+
:current_speed_mbps=>1000,
|
185
|
+
:dns_servers=>['192.168.1.1', '192.168.1.2'],
|
186
|
+
:duplex=>'full',
|
187
|
+
:ip_addresses=>[
|
188
|
+
{:ip_address=>'192.168.1.3', :subnet=>'255.255.255.0'},
|
189
|
+
{:ip_address=>'192.168.1.4', :subnet=>'255.255.255.0'},
|
190
|
+
],
|
191
|
+
:mac_address=>'01:01:01:01:01:01',
|
192
|
+
:model=>'VMXNET Ethernet Controller',
|
193
|
+
:mtu=>1500,
|
194
|
+
:name=>'eth0',
|
195
|
+
:status=>'up',
|
196
|
+
:type=>'ethernet',
|
197
|
+
:vendor=>'VMware'
|
198
|
+
}),
|
199
|
+
@target.network_interface_template.merge({
|
200
|
+
:dns_servers=>['192.168.1.1', '192.168.1.2'],
|
201
|
+
:mac_address=>'01:01:01:01:01:01',
|
202
|
+
:model=>'VMXNET Ethernet Controller',
|
203
|
+
:name=>'eth1',
|
204
|
+
:status=>'down',
|
205
|
+
:type=>'ethernet',
|
206
|
+
:vendor=>'VMware'
|
207
|
+
})
|
208
|
+
]
|
209
|
+
|
210
|
+
hardware_data = %q{
|
211
|
+
Slot: 02:00.0
|
212
|
+
Class: Ethernet controller
|
213
|
+
Vendor: VMware
|
214
|
+
Device: VMXNET Ethernet Controller
|
215
|
+
SVendor: VMware
|
216
|
+
SDevice: VMXNET Ethernet Controller
|
217
|
+
PhySlot: 32
|
218
|
+
--
|
219
|
+
Slot: 02:01.0
|
220
|
+
Class: Ethernet controller
|
221
|
+
Vendor: VMware
|
222
|
+
Device: VMXNET Ethernet Controller
|
223
|
+
SVendor: VMware
|
224
|
+
SDevice: VMXNET Ethernet Controller
|
225
|
+
PhySlot: 33
|
226
|
+
}.split(/\n/)
|
227
|
+
@connector.stubs(:values_at).with(@hardware_command).returns(hardware_data)
|
228
|
+
|
229
|
+
ethernet_mapping_data = [
|
230
|
+
'eth0|/sys/devices/pci0000:00/0000:00:11.0/0000:02:00.0',
|
231
|
+
'eth1|/sys/devices/pci0000:00/0000:00:11.0/0000:02:01.0'
|
232
|
+
]
|
233
|
+
@connector.stubs(:values_at).with(@ethernet_mapping_command).returns(ethernet_mapping_data)
|
234
|
+
|
235
|
+
link_properties = %q{
|
236
|
+
/sys/class/net/eth0/address|01:01:01:01:01:01
|
237
|
+
/sys/class/net/eth0/broadcast|ff:ff:ff:ff:ff:ff
|
238
|
+
/sys/class/net/eth0/speed|1000
|
239
|
+
/sys/class/net/eth0/duplex|full
|
240
|
+
/sys/class/net/eth0/carrier|1
|
241
|
+
/sys/class/net/eth0/mtu|1500
|
242
|
+
/sys/class/net/eth1/address|01:01:01:01:01:01
|
243
|
+
/sys/class/net/eth1/broadcast|ff:ff:ff:ff:ff:ff
|
244
|
+
/sys/class/net/eth1/speed|
|
245
|
+
/sys/class/net/eth1/duplex|full
|
246
|
+
/sys/class/net/eth1/carrier|0
|
247
|
+
/sys/class/net/eth1/mtu|1500
|
248
|
+
}.split(/\n/)
|
249
|
+
@connector.stubs(:values_at).with(@link_properties_command).returns(link_properties)
|
250
|
+
|
251
|
+
ip_addr_data = %q{
|
252
|
+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
|
253
|
+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
|
254
|
+
inet 127.0.0.1/8 scope host lo
|
255
|
+
inet6 ::1/128 scope host
|
256
|
+
valid_lft forever preferred_lft forever
|
257
|
+
|
258
|
+
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
|
259
|
+
link/ether 01:01:01:01:01:01 brd ff:ff:ff:ff:ff:ff
|
260
|
+
inet 192.168.1.3/24 brd 192.168.1.255 scope global eth0
|
261
|
+
inet 192.168.1.4/24 brd 192.168.1.255 scope global eth0:1
|
262
|
+
inet6 fe80::250:56ff:fead:37/64 scope link
|
263
|
+
valid_lft forever preferred_lft forever
|
264
|
+
|
265
|
+
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
|
266
|
+
link/ether 01:01:01:01:01:01 brd ff:ff:ff:ff:ff:ff
|
267
|
+
}.strip.split(/\n/)
|
268
|
+
@connector.stubs(:values_at).with(@ip_addr_command).returns(ip_addr_data)
|
269
|
+
|
270
|
+
@target.get_network_interfaces
|
271
|
+
assert_equal(@expected_data, @target.network_interfaces)
|
272
|
+
end
|
273
|
+
|
274
|
+
should 'return fibre channel interface information via #get_network_interfaces' do
|
275
|
+
@expected_data = [{
|
276
|
+
:auto_negotiate=>nil,
|
277
|
+
:current_speed_mbps=>2000,
|
278
|
+
:dns_servers=>[],
|
279
|
+
:duplex=>nil,
|
280
|
+
:fabric_name=>'00000000aaaaaaaa',
|
281
|
+
:ip_addresses=>[],
|
282
|
+
:is_uplink=>nil,
|
283
|
+
:mac_address=>nil,
|
284
|
+
:model=>'ISP2312-based 2Gb Fibre Channel to PCI-X HBA',
|
285
|
+
:model_id=>nil,
|
286
|
+
:mtu=>nil,
|
287
|
+
:name=>'host1',
|
288
|
+
:node_wwn=>'00000000aaaaaaaa',
|
289
|
+
:port_wwn=>'00000000aaaaaaaa',
|
290
|
+
:remote_mac_address=>nil,
|
291
|
+
:status=>'up',
|
292
|
+
:type=>'fibre',
|
293
|
+
:vendor=>'QLogic Corp.',
|
294
|
+
:vendor_id=>nil
|
295
|
+
}]
|
296
|
+
|
297
|
+
hardware_data = %q{
|
298
|
+
Slot: 05:0d.0
|
299
|
+
Class: Fibre Channel
|
300
|
+
Vendor: QLogic Corp.
|
301
|
+
Device: ISP2312-based 2Gb Fibre Channel to PCI-X HBA
|
302
|
+
SVendor: QLogic Corp.
|
303
|
+
SDevice: Device 0149
|
304
|
+
Rev: 02
|
305
|
+
}.split(/\n/)
|
306
|
+
@connector.stubs(:values_at).with(@hardware_command).returns(hardware_data)
|
307
|
+
|
308
|
+
fibre_mapping_data = ['/sys/devices/pci0000:04/0000:04:09.0/0000:05:0d.0/host1/fc_host/host1']
|
309
|
+
@connector.stubs(:values_at).with(@fibre_mapping_command).returns(fibre_mapping_data)
|
310
|
+
|
311
|
+
fibre_config_data = %q{
|
312
|
+
/sys/class/fc_host/host1/node_name|0x00000000aaaaaaaa
|
313
|
+
/sys/class/fc_host/host1/port_name|0x00000000aaaaaaaa
|
314
|
+
/sys/class/fc_host/host1/port_state|Online
|
315
|
+
/sys/class/fc_host/host1/speed|2 Gbit
|
316
|
+
/sys/class/fc_host/host1/fabric_name|0x00000000aaaaaaaa
|
317
|
+
}.strip.split(/\n/)
|
318
|
+
@connector.stubs(:values_at).with(@fibre_config_command).returns(fibre_config_data)
|
319
|
+
|
320
|
+
@target.get_network_interfaces
|
321
|
+
assert_equal(@expected_data, @target.network_interfaces)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
# OS SPECIFIC
|
326
|
+
#context 'for operating system information' do
|
327
|
+
#end
|
328
|
+
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'setup_tests'
|
2
|
+
|
3
|
+
class RedHatCoreTest < ProfileTestSetup
|
4
|
+
context 'a RedHat target' do
|
5
|
+
setup do
|
6
|
+
@connector = @target.connector = instance_of(SSHConnector)
|
7
|
+
@target.stubs(:target_profile).returns(Profiles::RedHat)
|
8
|
+
@target.extend(Profiles::RedHat)
|
9
|
+
@connector.stubs(:values_at).with(%q{ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb|system" | cut -d '/' -f3 | cut -d '-' -f1 | cut -d '_' -f1}).returns(['redhat'])
|
10
|
+
end
|
11
|
+
|
12
|
+
should 'detect when a target should use the RedHat profile' do
|
13
|
+
assert_equal(Profiles::RedHat, @target.target_profile)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'being scanned' do
|
17
|
+
setup do
|
18
|
+
end
|
19
|
+
|
20
|
+
# handled by linux core
|
21
|
+
#context 'for file system information' do
|
22
|
+
#end
|
23
|
+
|
24
|
+
# handled by linux core
|
25
|
+
#context 'for hardware information' do
|
26
|
+
#end
|
27
|
+
|
28
|
+
context 'for hosted shares' do
|
29
|
+
# TODO add code for gathering list of hosted shares from redhat
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'for installed applications' do
|
33
|
+
setup do
|
34
|
+
@application_data = [
|
35
|
+
'zip|2.3.3|Red Hat, Inc.|x86_64|Tue 1 Jan 2013 00:00:00 AM EST',
|
36
|
+
'zlib|2.3.3|Red Hat, Inc.|i386|Tue 1 Jan 2013 00:00:00 AM EST'
|
37
|
+
]
|
38
|
+
|
39
|
+
@expected_data = [
|
40
|
+
{
|
41
|
+
:date_installed=>DateTime.parse('Tue 1 Jan 2013 00:00:00 AM EST'),
|
42
|
+
:install_location=>nil,
|
43
|
+
:license_key=>nil,
|
44
|
+
:name=>'zip',
|
45
|
+
:vendor=>'Red Hat, Inc.',
|
46
|
+
:version=>'2.3.3'
|
47
|
+
},
|
48
|
+
{
|
49
|
+
:date_installed=>DateTime.parse('Tue 1 Jan 2013 00:00:00 AM EST'),
|
50
|
+
:install_location=>nil,
|
51
|
+
:license_key=>nil,
|
52
|
+
:name=>'zlib',
|
53
|
+
:vendor=>'Red Hat, Inc.',
|
54
|
+
:version=>'2.3.3'
|
55
|
+
}
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'return installed applications via #get_installed_applications' do
|
60
|
+
application_command = 'rpm -qa --queryformat "%{NAME}|%{VERSION}|%{VENDOR}|%{ARCH}|%{INSTALLTIME:date}\n" | sort'
|
61
|
+
|
62
|
+
@connector.stubs(:values_at).with(application_command).returns(@application_data)
|
63
|
+
|
64
|
+
@target.get_installed_applications
|
65
|
+
assert_equal(@expected_data, @target.installed_applications)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# n/a for linux
|
70
|
+
#context 'for installed patches' do
|
71
|
+
#end
|
72
|
+
|
73
|
+
context 'for installed services' do
|
74
|
+
setup do
|
75
|
+
@expected_data = [
|
76
|
+
{:name=>'sendmail', :install_location=>nil, :start_mode=>nil},
|
77
|
+
{:name=>'smb', :install_location=>nil, :start_mode=>nil}
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'return service information via #get_installed_services' do
|
82
|
+
@connector.stubs(:values_at).with("/sbin/chkconfig --list | awk {'print $1'}").returns(@expected_data.collect{|svc| svc[:name]})
|
83
|
+
|
84
|
+
@target.get_installed_services
|
85
|
+
assert_equal(@expected_data, @target.installed_services)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# handled by linux core
|
90
|
+
#context 'for local users and groups' do
|
91
|
+
#end
|
92
|
+
|
93
|
+
# handled by linux core
|
94
|
+
#context 'for network identification' do
|
95
|
+
#end
|
96
|
+
|
97
|
+
# handled by linux core
|
98
|
+
#context 'for network interfaces' do
|
99
|
+
#end
|
100
|
+
|
101
|
+
context 'for operating system information' do
|
102
|
+
setup do
|
103
|
+
@kernel_data = '2.6.18-308.16.1.el5'
|
104
|
+
@os_install_date = 'Tue 1 Jan 2013 00:00:00 AM EST'
|
105
|
+
|
106
|
+
@os_data = [
|
107
|
+
'Description: Red Hat Enterprise Linux Server release 5.8 (Tikanga)',
|
108
|
+
'Release: 5.8'
|
109
|
+
]
|
110
|
+
|
111
|
+
@expected_data = {
|
112
|
+
:date_installed=>DateTime.parse(@os_install_date),
|
113
|
+
:features=>[],
|
114
|
+
:kernel=>@kernel_data,
|
115
|
+
:license_key=>nil,
|
116
|
+
:name=>'Red Hat Enterprise Linux',
|
117
|
+
:roles=>[],
|
118
|
+
:service_pack=>nil,
|
119
|
+
:version=>'Server 5.8'
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
should 'return operating system information via #get_operating_system' do
|
124
|
+
@connector.stubs(:value_at).with("rpm -qa basesystem --queryformat '%{INSTALLTIME:date}\n'").returns(@os_install_date)
|
125
|
+
@connector.stubs(:value_at).with('uname -r').returns(@kernel_data)
|
126
|
+
@connector.stubs(:values_at).with('lsb_release -a | egrep -i "description|release"').returns(@os_data)
|
127
|
+
|
128
|
+
@target.get_operating_system
|
129
|
+
assert_equal(@expected_data, @target.operating_system)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|