mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
fix(osfamily): use corresponding family or name for bsd/freebsd
Signed-off-by: Felipe Zipitria <fzipitria@perceptyx.com>
This commit is contained in:
parent
08bc5edfaf
commit
d2ae7a7fbf
9 changed files with 16 additions and 14 deletions
|
@ -61,7 +61,7 @@ module Inspec::Resources
|
|||
os = inspec.os
|
||||
if os.linux?
|
||||
LinuxMounts.new(inspec)
|
||||
elsif ["freebsd"].include?(os[:family])
|
||||
elsif os.bsd?
|
||||
BsdMounts.new(inspec)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ module Inspec::Resources
|
|||
WindowsUser.new(inspec)
|
||||
elsif ["darwin"].include?(os[:family])
|
||||
DarwinUser.new(inspec)
|
||||
elsif ["freebsd"].include?(os[:family])
|
||||
elsif ["bsd"].include?(os[:family])
|
||||
FreeBSDUser.new(inspec)
|
||||
elsif ["aix"].include?(os[:family])
|
||||
AixUser.new(inspec)
|
||||
|
|
1
test/fixtures/cmd/id-fzipi
vendored
Normal file
1
test/fixtures/cmd/id-fzipi
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
uid=1000(fzipi) gid=1000(fzipi) groups=1000(fzipi),0(wheel),1007(users)
|
1
test/fixtures/cmd/pw-usershow-fzipi-7
vendored
Normal file
1
test/fixtures/cmd/pw-usershow-fzipi-7
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
fzipi:*:1000:1000:Felipe Zipitria,None,None,None:/home/fzipi:/usr/local/bin/bash
|
1
test/fixtures/cmd/pw-usershow-root-7
vendored
1
test/fixtures/cmd/pw-usershow-root-7
vendored
|
@ -1 +0,0 @@
|
|||
root:*:0:0:Charlie &:/root:/bin/csh
|
|
@ -13,9 +13,9 @@ class MockLoader
|
|||
debian7: { name: "debian", family: "debian", release: "7", arch: "x86_64" },
|
||||
debian8: { name: "debian", family: "debian", release: "8", arch: "x86_64" },
|
||||
debian10: { name: "debian", family: "debian", release: "buster/sid", arch: "x86_64" },
|
||||
freebsd10: { name: "freebsd", family: "freebsd", release: "10", arch: "amd64" },
|
||||
freebsd11: { name: "freebsd", family: "freebsd", release: "11", arch: "amd64" },
|
||||
freebsd12: { name: "freebsd", family: "freebsd", release: "12", arch: "amd64" },
|
||||
freebsd10: { name: "freebsd", family: "bsd", release: "10", arch: "amd64" },
|
||||
freebsd11: { name: "freebsd", family: "bsd", release: "11", arch: "amd64" },
|
||||
freebsd12: { name: "freebsd", family: "bsd", release: "12", arch: "amd64" },
|
||||
macos10_10: { name: "mac_os_x", family: "darwin", release: "10.10.4", arch: nil },
|
||||
macos10_16: { name: "darwin", family: "darwin", release: "10.16", arch: nil },
|
||||
ubuntu1204: { name: "ubuntu", family: "debian", release: "12.04", arch: "x86_64" },
|
||||
|
@ -301,7 +301,8 @@ class MockLoader
|
|||
"id chartmann" => cmd.call("id-chartmann"),
|
||||
"dscl -q . -read /Users/chartmann NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell" => cmd.call("dscl"),
|
||||
# user info for freebsd
|
||||
"pw usershow root -7" => cmd.call("pw-usershow-root-7"),
|
||||
"id fzipi" => cmd.call("id-fzipi"),
|
||||
"pw usershow fzipi -7" => cmd.call("pw-usershow-fzipi-7"),
|
||||
# user info for windows (winrm 1.6.0, 1.6.1)
|
||||
"c603a7d32732390b1ed57ebd56fd176fecdb2035f005d33482de9adb1ddb4447" => cmd.call("adsiusers"),
|
||||
# group info for windows
|
||||
|
|
|
@ -9,7 +9,7 @@ if os.linux?
|
|||
it { should_not exist }
|
||||
its('gid') { should eq nil }
|
||||
end
|
||||
elsif os[:family] == 'freebsd'
|
||||
elsif os.bsd?
|
||||
describe group('wheel') do
|
||||
it { should exist }
|
||||
its('gid') { should eq 0 }
|
||||
|
|
|
@ -12,7 +12,7 @@ if ['centos', 'redhat', 'fedora', 'suse', 'debian', 'ubuntu'].include?(os[:famil
|
|||
# different groupset for centos 5
|
||||
userinfo[:groups] = ["root", "bin", "daemon", "sys", "adm", "disk", "wheel"] \
|
||||
if os[:release].to_i == 5
|
||||
elsif ['freebsd'].include?(os[:family])
|
||||
elsif ['freebsd'].include?(os[:name])
|
||||
userinfo = {
|
||||
username: 'root',
|
||||
groupname: 'wheel',
|
||||
|
|
|
@ -114,12 +114,12 @@ describe "Inspec::Resources::User" do
|
|||
end
|
||||
|
||||
it "read user on freebsd" do
|
||||
resource = MockLoader.new(:freebsd10).load_resource("user", "root")
|
||||
resource = MockLoader.new(:freebsd11).load_resource("user", "fzipi")
|
||||
_(resource.exists?).must_equal true
|
||||
_(resource.group).must_equal "root"
|
||||
_(resource.groups).must_equal ["root"]
|
||||
_(resource.home).must_equal "/root"
|
||||
_(resource.shell).must_equal "/bin/csh"
|
||||
_(resource.group).must_equal "fzipi"
|
||||
_(resource.groups).must_equal %w{fzipi wheel users}
|
||||
_(resource.home).must_equal "/home/fzipi"
|
||||
_(resource.shell).must_equal "/usr/local/bin/bash"
|
||||
_(resource.mindays).must_be_nil
|
||||
_(resource.maxdays).must_be_nil
|
||||
_(resource.warndays).must_be_nil
|
||||
|
|
Loading…
Reference in a new issue