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

Adds ip6tables resource to serverspec #469

Merged
merged 1 commit into from
Aug 31, 2014
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
2 changes: 1 addition & 1 deletion lib/serverspec/helper/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Helper
module Type
types = %w(
base cgroup command cron default_gateway file group host iis_website iis_app_pool interface
ipfilter ipnat iptables kernel_module linux_kernel_parameter lxc mail_alias
ipfilter ipnat iptables ip6tables kernel_module linux_kernel_parameter lxc mail_alias
package php_config port ppa process routing_table selinux service user yumrepo
windows_feature windows_hot_fix windows_registry_key windows_scheduled_task zfs
)
Expand Down
4 changes: 2 additions & 2 deletions lib/serverspec/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
require 'serverspec/matchers/return_stdout'
require 'serverspec/matchers/return_stderr'

# ipfiter, ipnat, iptables
# ipfiter, ipnat, iptables, ip6tables
require 'serverspec/matchers/have_rule'

# cron, routing_table
Expand All @@ -38,4 +38,4 @@
# iis_website
require 'serverspec/matchers/have_site_application'
require 'serverspec/matchers/have_site_bindings'
require 'serverspec/matchers/have_virtual_dir'
require 'serverspec/matchers/have_virtual_dir'
2 changes: 1 addition & 1 deletion lib/serverspec/matchers/have_rule.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec::Matchers.define :have_rule do |rule|
match do |subject|
if subject.class.name == 'Serverspec::Type::Iptables'
if subject.class.name == 'Serverspec::Type::Iptables' || subject.class.name == 'Serverspec::Type::Ip6tables'
subject.has_rule?(rule, @table, @chain)
else
subject.has_rule?(rule)
Expand Down
13 changes: 13 additions & 0 deletions lib/serverspec/type/ip6tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Serverspec
module Type
class Ip6tables < Base
def has_rule?(rule, table, chain)
backend.check_ip6tables_rule(rule, table, chain)
end

def to_s
'ip6tables'
end
end
end
end
21 changes: 21 additions & 0 deletions spec/debian/ip6tables_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

include SpecInfra::Helper::Debian

describe ip6tables do
it { should have_rule '-P INPUT ACCEPT' }
its(:command) { should eq "ip6tables -S | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule 'invalid-rule' }
end

describe ip6tables do
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
its(:command) { should eq "ip6tables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
end
21 changes: 21 additions & 0 deletions spec/fedora/ip6tables_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

include SpecInfra::Helper::Fedora

describe ip6tables do
it { should have_rule '-P INPUT ACCEPT' }
its(:command) { should eq "ip6tables -S | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule 'invalid-rule' }
end

describe ip6tables do
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
its(:command) { should eq "ip6tables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
end
21 changes: 21 additions & 0 deletions spec/gentoo/ip6tables_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

include SpecInfra::Helper::Gentoo

describe ip6tables do
it { should have_rule '-P INPUT ACCEPT' }
its(:command) { should eq "ip6tables -S | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule 'invalid-rule' }
end

describe ip6tables do
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
its(:command) { should eq "ip6tables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
end
21 changes: 21 additions & 0 deletions spec/plamo/ip6tables_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

include SpecInfra::Helper::Plamo

describe ip6tables do
it { should have_rule '-P INPUT ACCEPT' }
its(:command) { should eq "ip6tables -S | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule 'invalid-rule' }
end

describe ip6tables do
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
its(:command) { should eq "ip6tables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
end
21 changes: 21 additions & 0 deletions spec/redhat/ip6tables_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

include SpecInfra::Helper::RedHat

describe ip6tables do
it { should have_rule '-P INPUT ACCEPT' }
its(:command) { should eq "ip6tables -S | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule 'invalid-rule' }
end

describe ip6tables do
it { should have_rule('-P INPUT ACCEPT').with_table('mangle').with_chain('INPUT') }
its(:command) { should eq "ip6tables -t mangle -S INPUT | grep -- -P\\ INPUT\\ ACCEPT || ip6tables-save -t mangle | grep -- -P\\ INPUT\\ ACCEPT" }
end

describe ip6tables do
it { should_not have_rule('invalid-rule').with_table('mangle').with_chain('INPUT') }
end