mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
dada8ea074
macOS 11 Big Sur will be released later this year. Current beta versions return 10.16 as the version, but the product name has changed from 'Mac OS X' to 'macOS'. Train probably needs to be modified to deprecate 'mac_os_x' as a platform in favor of 'macos' but that would be a significant downstream change. Train does fall back to 'darwin' on macOS 10.16, so by adding darwin to the list of platform names for the service resource we are able to work around this for the moment. This is the only location where mac_os_x is currently being used in InSpec. Because we're in a case statement on platform rather than the more generic platform family, we can't simply remove mac_os_x in favor of darwin. Signed-off-by: Bryan McLellan <btm@loftninjas.org>
84 lines
2.6 KiB
Ruby
84 lines
2.6 KiB
Ruby
require "helper"
|
|
require "inspec/resources/groups"
|
|
|
|
describe "Inspec::Resources::Group" do
|
|
|
|
# ubuntu 14.04
|
|
it "verify group on ubuntu" do
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("group", "root")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.gid).must_equal 0
|
|
end
|
|
|
|
it "verify group on ubuntu with mixed case" do
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("group", "GroupWithCaps")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.gid).must_equal 999
|
|
end
|
|
|
|
it "verify group on ubuntu with members" do
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("group", "www-data")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.members).must_equal "www-data,root"
|
|
end
|
|
|
|
# ubuntu with non-existent group
|
|
it "verify group on ubuntu" do
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("group", "nogroup")
|
|
_(resource.exists?).must_equal false
|
|
_(resource.gid).must_be_nil
|
|
end
|
|
|
|
# mac
|
|
it "verify group on mac" do
|
|
resource = MockLoader.new(:macos10_10).load_resource("group", "root")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.gid).must_equal 0
|
|
end
|
|
|
|
if osx?
|
|
it "actually verifies group on mac" do
|
|
resource = quick_resource(:group, :macos10_10, "staff")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.members).must_include "root"
|
|
_(resource.members).must_include ENV["LOGNAME"]
|
|
end
|
|
end
|
|
|
|
# freebsd
|
|
it "verify group on freebsd" do
|
|
resource = MockLoader.new(:freebsd10).load_resource("group", "root")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.gid).must_equal 0
|
|
end
|
|
|
|
# windows with local group
|
|
it "verify administrator group on windows" do
|
|
resource = MockLoader.new(:windows).load_resource("group", "Administrators")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.gid).must_equal "S-1-5-32-544"
|
|
_(resource.members).must_equal ["Administrators", "Domain Admins"]
|
|
end
|
|
|
|
it "verify power users group on windows" do
|
|
resource = MockLoader.new(:windows).load_resource("group", "Power Users")
|
|
_(resource.exists?).must_equal true
|
|
_(resource.gid).must_equal "S-1-5-32-547"
|
|
_(resource.members).must_equal []
|
|
end
|
|
|
|
# windows non-existent group
|
|
it "verify non-existing group on windows" do
|
|
resource = MockLoader.new(:windows).load_resource("group", "dhcp")
|
|
_(resource.exists?).must_equal false
|
|
_(resource.gid).must_be_nil
|
|
_(resource.members).must_be_nil
|
|
end
|
|
|
|
# undefined
|
|
it "verify package handling on unsupported os" do
|
|
resource = MockLoader.new(:undefined).load_resource("group", "root")
|
|
_(resource.exists?).must_equal false
|
|
_(resource.gid).must_be_nil
|
|
end
|
|
end
|