mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
Add additional example for matching crontab commands
As raised in #1526, adding an additional example showing how a user can use the `where` accessor to find commands matching a pattern and write a test using the results. Signed-off-by: Adam Leff <adam@leff.co>
This commit is contained in:
parent
ab9e258112
commit
8155357d0a
2 changed files with 10 additions and 0 deletions
|
@ -60,3 +60,9 @@ The following examples show how to use this InSpec audit resource.
|
|||
describe crontab.where({'hour' => '*', 'minute' => '*'}) do
|
||||
its('entries.length') { should cmp '0' }
|
||||
end
|
||||
|
||||
### Test that the logged-in user's crontab contains a single command that matches a mattern
|
||||
|
||||
describe crontab.where { command =~ /a partial command string/ } do
|
||||
its('entries.length') { should cmp 1 }
|
||||
end
|
||||
|
|
|
@ -21,6 +21,10 @@ module Inspec::Resources
|
|||
describe crontab.where({'hour' => '*', 'minute' => '*'}) do
|
||||
its('entries.length') { should cmp '0' }
|
||||
end
|
||||
|
||||
describe crontab.where { command =~ /a partial command string/ } do
|
||||
its('entries.length') { should cmp 1 }
|
||||
end
|
||||
"
|
||||
|
||||
attr_reader :params
|
||||
|
|
Loading…
Reference in a new issue