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:
Stephen Hoekstra 2019-07-08 20:30:20 +02:00
parent a6372a8729
commit c2b4bb878b

View file

@ -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