mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +00:00
Add allowed users example to Users resource
This example shows how to check for expected users and to flag any other users that should not be present. Signed-off-by: Stephen Hoekstra <stephenhoekstra@gmail.com>
This commit is contained in:
parent
a6372a8729
commit
c2b4bb878b
1 changed files with 14 additions and 0 deletions
|
@ -58,6 +58,20 @@ The following examples show how to use this Chef InSpec audit resource.
|
|||
it { should exist }
|
||||
end
|
||||
|
||||
### Test only allowed users exist
|
||||
|
||||
allowed_users = %w(user1 user2 user3)
|
||||
|
||||
users.where { uid > 1000 && uid < 65534 }.usernames.sort.each do |u|
|
||||
describe user(u) do
|
||||
if allowed_users.include?(u)
|
||||
it { should exist }
|
||||
else
|
||||
it { should_not exist }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
<br>
|
||||
|
||||
## Matchers
|
||||
|
|
Loading…
Add table
Reference in a new issue