mirror of
https://github.com/inspec/inspec
synced 2024-12-18 00:53:22 +00:00
7a1cd660c3
processes('bash').user does not actually make much sense for a resource that is a list -- different entries can belong to different users. Analogous for processes('bash').state. The attributes 'users' and 'states' expose the unique values corresponding to that property of entries in the process list. Fixes #295.
38 lines
901 B
Ruby
38 lines
901 B
Ruby
# encoding: utf-8
|
|
# author: Christoph Hartmann
|
|
# author: Dominik Richter
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
|
|
describe 'Inspec::Resources::Processes' do
|
|
it 'handles empty process results' do
|
|
resource = load_resource('processes', 'nothing')
|
|
_(resource.list).must_equal []
|
|
end
|
|
|
|
it 'verify processes resource' do
|
|
resource = load_resource('processes', '/bin/bash')
|
|
_(resource.list).must_equal [{
|
|
user: 'root',
|
|
pid: '1',
|
|
cpu: '0.0',
|
|
mem: '0.0',
|
|
vsz: '18084',
|
|
rss: '3228',
|
|
tty: '?',
|
|
stat: 'Ss',
|
|
start: '14:15',
|
|
time: '0:00',
|
|
command: '/bin/bash',
|
|
}]
|
|
|
|
_(resource.list.length).must_equal 1
|
|
end
|
|
|
|
it 'retrieves the users and states as arrays' do
|
|
resource = load_resource('processes', 'svc')
|
|
_(resource.users.sort).must_equal ['noot']
|
|
_(resource.states.sort).must_equal ['S', 'Ss']
|
|
end
|
|
end
|