lib/inspec/resources/security_identifier.rb in inspec-4.7.3 vs lib/inspec/resources/security_identifier.rb in inspec-4.7.18
- old
+ new
@@ -13,14 +13,15 @@
its('sid') { should eq 'S-1-1-0' }
end
EXAMPLE
def initialize(opts = {})
- supported_opt_keys = [:user, :group, :unspecified]
+ supported_opt_keys = %i{user group unspecified}
raise ArgumentError, "Invalid security_identifier param '#{opts}'. Please pass a hash with these supported keys: #{supported_opt_keys}" unless opts.respond_to?(:keys)
raise ArgumentError, "Unsupported security_identifier options '#{opts.keys - supported_opt_keys}'. Supported keys: #[supported_opt_keys]" unless (opts.keys - supported_opt_keys).empty?
raise ArgumentError, "Specifying more than one of :user :group or :unspecified for security_identifier is not supported" unless opts.keys && (opts.keys & supported_opt_keys).length == 1
+
if opts[:user]
@type = :user
@name = opts[:user]
end
if opts[:group]
@@ -30,9 +31,10 @@
if opts[:unspecified]
@type = :unspecified
@name = opts[:unspecified]
end
raise ArgumentError, "Specify one of :user :group or :unspecified for security_identifier" unless @name
+
@sids = nil
end
def sid
fetch_sids unless @sids