mirror of
https://github.com/inspec/inspec
synced 2024-12-02 17:40:00 +00:00
7c58285eb6
* Resource for a Windows Security Identifier (SID) * Integration tests for security_identifier resource * Address rubocop violations * Improve security_identifier from PR feedback * Update security_identifier tests * Improve security_identifier unit tests * Fix unit tests fpr security_identifier resource * More security_identifier unit tests * Add docs page for security_identifier resource * Fix issues with documentation * Improve docs Link to Microsoft reference page, and use their term 'trustee' instead of 'entity' where applicable. * Change exists to exist * Test appveyor file changes. Signed-off-by: Jared Quick <jquick@chef.io>
47 lines
1.8 KiB
Ruby
47 lines
1.8 KiB
Ruby
# encoding: utf-8
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
|
|
describe 'Inspec::Resources::SecurityIdentifier' do
|
|
it 'returns a SID for an existing user' do
|
|
resource = load_resource('security_identifier', { user: 'Alice' })
|
|
_(resource.exist?).must_equal true
|
|
_(resource.sid).must_equal 'S-1-5-21-1601936709-1892662786-3840804712-315762'
|
|
end
|
|
|
|
it 'returns nil for a non-existent user' do
|
|
resource = MockLoader.new(:windows).load_resource('security_identifier', { user: 'Bob' })
|
|
_(resource.exist?).must_equal false
|
|
_(resource.sid).must_be_nil
|
|
end
|
|
|
|
it 'returns a SID for an existing group' do
|
|
resource = load_resource('security_identifier', { group: 'Guests' })
|
|
_(resource.exist?).must_equal true
|
|
_(resource.sid).must_equal 'S-1-5-32-546'
|
|
end
|
|
|
|
it 'returns nil for a non-existent group' do
|
|
resource = MockLoader.new(:windows).load_resource('security_identifier', { group: 'DontExist' })
|
|
_(resource.exist?).must_equal false
|
|
_(resource.sid).must_be_nil
|
|
end
|
|
|
|
it 'returns a SID for an existing entity with type :unspecified' do
|
|
resource = load_resource('security_identifier', { unspecified: 'Guests' })
|
|
_(resource.exist?).must_equal true
|
|
_(resource.sid).must_equal 'S-1-5-32-546'
|
|
end
|
|
|
|
it 'returns nil for a non-existent entity with type :unspecified' do
|
|
resource = MockLoader.new(:windows).load_resource('security_identifier', { unspecified: 'DontExist' })
|
|
_(resource.exist?).must_equal false
|
|
_(resource.sid).must_be_nil
|
|
end
|
|
|
|
it 'raises ArgumentError for an unsupported type' do
|
|
err = proc { MockLoader.new(:windows).load_resource('security_identifier', { yooser: 'Alice' }) }.must_raise ArgumentError
|
|
err.message.must_equal 'Unsupported security_identifier options \'[:yooser]\'. Supported keys: #[supported_opt_keys]'
|
|
end
|
|
end
|