Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selinux: adding new matcher with_policy #530

Merged
merged 1 commit into from
Aug 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/serverspec/matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
# package
require 'serverspec/matcher/be_installed'

# selinux
require 'serverspec/matcher/be_enforcing'
require 'serverspec/matcher/be_permissive'

# service
require 'serverspec/matcher/be_enabled'
require 'serverspec/matcher/be_running'
Expand Down
10 changes: 10 additions & 0 deletions lib/serverspec/matcher/be_enforcing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RSpec::Matchers.define :be_enforcing do
match do |selinux|
selinux.enforcing?(@with_policy)
end

chain :with_policy do |with_policy|
@with_policy = with_policy
end

end
10 changes: 10 additions & 0 deletions lib/serverspec/matcher/be_permissive.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RSpec::Matchers.define :be_permissive do
match do |selinux|
selinux.permissive?(@with_policy)
end

chain :with_policy do |with_policy|
@with_policy = with_policy
end

end
8 changes: 4 additions & 4 deletions lib/serverspec/type/selinux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ def disabled?
@runner.check_selinux_has_mode('disabled')
end

def enforcing?
@runner.check_selinux_has_mode('enforcing')
def enforcing?(with_policy)
@runner.check_selinux_has_mode('enforcing', with_policy)
end

def permissive?
@runner.check_selinux_has_mode('permissive')
def permissive?(with_policy)
@runner.check_selinux_has_mode('permissive', with_policy)
end

def to_s
Expand Down