Resolve case sensitivity issues with group name in group resource for windows platform

Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
Nikita Mathur 2021-09-17 12:20:24 +05:30
parent 3f7d40318b
commit 964fdacbee
2 changed files with 12 additions and 1 deletions

View file

@ -150,7 +150,11 @@ module Inspec::Resources
def group_info
# we need a local copy for the block
group = @group.dup
@groups_cache ||= inspec.groups.where { name == group }
if inspec.os.windows?
@groups_cache ||= inspec.groups.where { name.casecmp?(group) }
else
@groups_cache ||= inspec.groups.where { name == group }
end
end
def empty_value_for_members

View file

@ -66,6 +66,13 @@ describe "Inspec::Resources::Group" do
_(resource.members).must_equal ["Administrators", "Domain Admins"]
end
it "verify administrator group with case insensitivity handling 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