forked from voxpupuli/puppet-nftables
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Stdlib::Port everywhere in place of Integer
Use Stdlib::Port in place of Integer for ports Fixes voxpupuli#37
- Loading branch information
1 parent
b1085d8
commit 94a8062
Showing
22 changed files
with
256 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::dns' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'default options' do | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-dns_tcp').with_content('tcp dport {53} accept') } | ||
it { is_expected.to contain_nftables__rule('default_in-dns_udp').with_content('udp dport {53} accept') } | ||
end | ||
|
||
context 'with ports set' do | ||
let(:params) do | ||
{ | ||
ports: [55, 60], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-dns_tcp').with_content('tcp dport {55, 60} accept') } | ||
it { is_expected.to contain_nftables__rule('default_in-dns_udp').with_content('udp dport {55, 60} accept') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::icinga2' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'default options' do | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-icinga2').with_content('tcp dport {5665} accept') } | ||
end | ||
|
||
context 'with ports set' do | ||
let(:params) do | ||
{ | ||
ports: [55, 60], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-icinga2').with_content('tcp dport {55, 60} accept') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::node_exporter' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'default options' do | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-node_exporter').with_content('tcp dport 9100 accept') } | ||
end | ||
|
||
context 'with port set' do | ||
let(:params) do | ||
{ | ||
port: 100, | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-node_exporter').with_content('tcp dport 100 accept') } | ||
context 'with prometheus_server set' do | ||
let(:params) do | ||
super().merge({ prometheus_server: ['127.0.0.1', '::1'] }) | ||
end | ||
|
||
it { is_expected.to contain_nftables__rule('default_in-node_exporter-0').with_content('ip saddr 127.0.0.1 tcp dport 100 accept') } | ||
it { is_expected.to contain_nftables__rule('default_in-node_exporter-1').with_content('ip6 saddr ::1 tcp dport 100 accept') } | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::ssh' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'default options' do | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-ssh').with_content('tcp dport {22} accept') } | ||
end | ||
|
||
context 'with ports set' do | ||
let(:params) do | ||
{ | ||
ports: [55, 60], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-ssh').with_content('tcp dport {55, 60} accept') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::tor' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'default options' do | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-tor').with_content('tcp dport {9001} accept') } | ||
end | ||
|
||
context 'with ports set' do | ||
let(:params) do | ||
{ | ||
ports: [55, 60], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-tor').with_content('tcp dport {55, 60} accept') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::wireguard' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
context 'default options' do | ||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-wireguard').with_content('udp dport {51820} accept') } | ||
end | ||
|
||
context 'with ports set' do | ||
let(:params) do | ||
{ | ||
ports: [55, 60], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-wireguard').with_content('udp dport {55, 60} accept') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::dnat4' do | ||
let(:title) { 'foobar' } | ||
|
||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts | ||
end | ||
|
||
context 'with minumum parameters' do | ||
let(:params) do | ||
{ | ||
daddr: '127.127.127.127', | ||
port: 100, | ||
} | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::masquerade' do | ||
let(:title) { 'foobar' } | ||
|
||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts | ||
end | ||
|
||
context 'with default parameters' do | ||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_nftables__rule('POSTROUTING-foobar').with_content('masquerade') } | ||
end | ||
context 'with dport specified' do | ||
let(:params) do | ||
{ | ||
dport: 1000 | ||
} | ||
end | ||
|
||
it { is_expected.to contain_nftables__rule('POSTROUTING-foobar').with_content('tcp dport 1000 masquerade') } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::snat4' do | ||
let(:title) { 'foobar' } | ||
|
||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts | ||
end | ||
|
||
context 'with snat specified' do | ||
let(:params) do | ||
{ | ||
snat: 'sausage', | ||
} | ||
end | ||
|
||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_nftables__rule('POSTROUTING-foobar').with_content('snat sausage') } | ||
context 'with dport specified' do | ||
let(:params) do | ||
super().merge(dport: 1234) | ||
end | ||
|
||
it { is_expected.to contain_nftables__rule('POSTROUTING-foobar').with_content('tcp dport 1234 snat sausage') } | ||
end | ||
end | ||
end | ||
end | ||
end |