mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Renamed the matcher to be_inherited.
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
96249f24af
commit
56c388f099
3 changed files with 10 additions and 10 deletions
|
@ -597,10 +597,10 @@ return `true` if your file has a mode with greater permissions than specified.
|
|||
it { should be_more_permissive_than('0000') }
|
||||
end
|
||||
|
||||
### `be_inherit`
|
||||
### `be_inherited`
|
||||
|
||||
`be_inherit` matcher returns the `Boolean`. It will return `true` if file or foler has inheritance enabled in Windows. This matcher only works for Windows OS.
|
||||
`be_inherited` matcher returns the `Boolean`. It will return `true` if file or foler has inheritance enabled in Windows. This matcher only works for Windows OS.
|
||||
|
||||
describe file('C://Example') do
|
||||
it { should be_inherit }
|
||||
it { should be_inherited }
|
||||
end
|
||||
|
|
|
@ -71,12 +71,12 @@ module Inspec::Resources
|
|||
end
|
||||
|
||||
# returns true if inheritance is enabled on file or folder
|
||||
def inherit?
|
||||
def inherited?
|
||||
return false unless exist?
|
||||
|
||||
return skip_resource "`inherit?` is not supported on your OS yet." unless inspec.os.windows?
|
||||
return skip_resource "`inherited?` is not supported on your OS yet." unless inspec.os.windows?
|
||||
|
||||
@perms_provider.inherit?(file)
|
||||
@perms_provider.inherited?(file)
|
||||
end
|
||||
|
||||
def contain(*_)
|
||||
|
@ -277,7 +277,7 @@ module Inspec::Resources
|
|||
JSON.load(result.stdout).inject(&:merge) unless result.stdout.empty?
|
||||
end
|
||||
|
||||
def inherit?(file)
|
||||
def inherited?(file)
|
||||
cmd = inspec.command("(Get-Acl -Path #{file.path}).access| Where-Object {$_.IsInherited -eq $true} | measure | % { $_.Count }")
|
||||
cmd.stdout.chomp == "0" ? false : true
|
||||
end
|
||||
|
|
|
@ -61,10 +61,10 @@ describe Inspec::Resources::FileResource do
|
|||
_(resource.user_permissions).must_equal({ "NT AUTHORITY\\SYSTEM" => "FullControl", "NT AUTHORITY\\Authenticated Users" => "ReadAndExecute", "BUILTIN\\Administrators" => "FullControl" })
|
||||
end
|
||||
|
||||
it "returns true if file has inherit enabled on Windows." do
|
||||
it "returns true if file has inheritance enabled on Windows." do
|
||||
resource = MockLoader.new(:windows).load_resource("file", "C:/fakepath/fakefile")
|
||||
resource.stubs(:exist?).returns(true)
|
||||
_(resource.inherit?).must_equal true
|
||||
_(resource.inherited?).must_equal true
|
||||
end
|
||||
|
||||
it "does not support Windows-style ACL on Ubuntu" do
|
||||
|
@ -90,7 +90,7 @@ describe Inspec::Resources::FileResource do
|
|||
_(resource.writable?("by_usergroup", "by_specific_user")).must_equal "`writable?` is not supported on your OS yet."
|
||||
_(resource.executable?("by_usergroup", "by_specific_user")).must_equal "`executable?` is not supported on your OS yet."
|
||||
_(resource.allowed?("permission", by: "by_usergroup", by_user: "by_specific_user")).must_equal "`allowed?` is not supported on your OS yet."
|
||||
_(resource.inherit?).must_equal "`inherit?` is not supported on your OS yet."
|
||||
_(resource.inherited?).must_equal "`inherited?` is not supported on your OS yet."
|
||||
_(proc { resource.send(:contain, nil) }).must_raise(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue