mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Corrected some unit test warnings (#2242)
Signed-off-by: username-is-already-taken2 <gary.bright@niu-solutions.com>
This commit is contained in:
parent
ed0d087e15
commit
fd558b63ac
4 changed files with 16 additions and 2 deletions
|
@ -179,6 +179,8 @@ class MockLoader
|
||||||
'/etc/init/ssh.conf' => mockfile.call('upstart_ssh_enabled.conf'),
|
'/etc/init/ssh.conf' => mockfile.call('upstart_ssh_enabled.conf'),
|
||||||
'/etc/hosts.allow' => mockfile.call('hosts.allow'),
|
'/etc/hosts.allow' => mockfile.call('hosts.allow'),
|
||||||
'/etc/hosts.deny' => mockfile.call('hosts.deny'),
|
'/etc/hosts.deny' => mockfile.call('hosts.deny'),
|
||||||
|
'/fakepath/fakefile' => emptyfile.call,
|
||||||
|
'C:/fakepath/fakefile' => emptyfile.call,
|
||||||
}
|
}
|
||||||
|
|
||||||
# create all mock commands
|
# create all mock commands
|
||||||
|
@ -194,6 +196,18 @@ class MockLoader
|
||||||
cmd_exit_1 = mock.mock_command('', '', '', 1)
|
cmd_exit_1 = mock.mock_command('', '', '', 1)
|
||||||
|
|
||||||
mock.commands = {
|
mock.commands = {
|
||||||
|
'' => empty.call,
|
||||||
|
'sh -c \'find /no/such/mock -type f -maxdepth 1\'' => empty.call,
|
||||||
|
'type "brew"' => empty.call,
|
||||||
|
'bash -c \'type "pip"\'' => empty.call,
|
||||||
|
'bash -c \'type "/test/path/pip"\'' => empty.call,
|
||||||
|
'type "netstat"' => empty.call,
|
||||||
|
'sh -c \'find /etc/apache2/ports.conf -type l -maxdepth 1\'' => empty.call,
|
||||||
|
'sh -c \'find /etc/httpd/conf.d/*.conf -type l -maxdepth 1\'' => empty.call,
|
||||||
|
'sh -c \'find /etc/httpd/mods-enabled/*.conf -type l -maxdepth 1\'' => empty.call,
|
||||||
|
'sh -c \'find /etc/httpd/conf-enabled/*.conf -type f -maxdepth 1\'' => empty.call,
|
||||||
|
'find /sys/class/net/eth1/ -maxdepth 1 -type f -exec sh -c \'echo "[$(basename {})]"; cat {} || echo -n\' \;' => empty.call,
|
||||||
|
'Get-Package -Name \'Not available\' | ConvertTo-Json' => empty.call,
|
||||||
'ps axo pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user,command' => cmd.call('ps-axo'),
|
'ps axo pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user,command' => cmd.call('ps-axo'),
|
||||||
'ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command' => cmd.call('ps-axoZ'),
|
'ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command' => cmd.call('ps-axoZ'),
|
||||||
'ps -o pid,vsz,rss,tty,stat,time,ruser,args' => cmd.call('ps-busybox'),
|
'ps -o pid,vsz,rss,tty,stat,time,ruser,args' => cmd.call('ps-busybox'),
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe Inspec::ShellDetector do
|
||||||
# Small hack to ensure we can test on windows
|
# Small hack to ensure we can test on windows
|
||||||
it "returns nil immediately if running on windows" do
|
it "returns nil immediately if running on windows" do
|
||||||
RbConfig::CONFIG.expects(:[]).with('host_os').returns('mswin')
|
RbConfig::CONFIG.expects(:[]).with('host_os').returns('mswin')
|
||||||
subject.shell!.must_equal(nil)
|
subject.shell!.must_be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "not on windows" do
|
describe "not on windows" do
|
||||||
|
@ -72,7 +72,7 @@ describe Inspec::ShellDetector do
|
||||||
|
|
||||||
it "returns nil if the shell isn't in the whitelist" do
|
it "returns nil if the shell isn't in the whitelist" do
|
||||||
no_proc; with_ps(""); with_env("badshell"); with_pwuid("/usr/bin/badshell")
|
no_proc; with_ps(""); with_env("badshell"); with_pwuid("/usr/bin/badshell")
|
||||||
subject.shell!.must_equal(nil)
|
subject.shell!.must_be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue