root / spec / defines / simplerule_spec.rb @ 3a52fb41
Historique | Voir | Annoter | Télécharger (1,79 ko)
1 | 83382bb5 | Nacho Barrientos | require 'spec_helper'
|
---|---|---|---|
2 | |||
3 | describe 'nftables::simplerule' do |
||
4 | let(:pre_condition) { 'include nftables' } |
||
5 | |||
6 | let(:title) { 'my_default_rule_name' } |
||
7 | |||
8 | on_supported_os.each do |os, os_facts|
|
||
9 | context "on #{os}" do |
||
10 | let(:facts) { os_facts }
|
||
11 | |||
12 | describe 'minimum instantiation' do |
||
13 | it { is_expected.to compile } |
||
14 | it { |
||
15 | is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
|
||
16 | content: 'accept', |
||
17 | 3a52fb41 | Nacho Barrientos | order: '50', |
18 | 83382bb5 | Nacho Barrientos | ) |
19 | } |
||
20 | end
|
||
21 | |||
22 | describe 'all parameters provided' do |
||
23 | let(:title) { 'my_big_rule' } |
||
24 | let(:params) do |
||
25 | { |
||
26 | action: 'accept', |
||
27 | comment: 'this is my rule', |
||
28 | dport: 333, |
||
29 | proto: 'udp', |
||
30 | chain: 'default_out', |
||
31 | } |
||
32 | end
|
||
33 | |||
34 | it { is_expected.to compile } |
||
35 | it { |
||
36 | is_expected.to contain_nftables__rule('default_out-my_big_rule').with(
|
||
37 | content: 'udp dport 333 comment "this is my rule" accept', |
||
38 | 3a52fb41 | Nacho Barrientos | order: '50', |
39 | ) |
||
40 | } |
||
41 | end
|
||
42 | |||
43 | describe 'port range' do |
||
44 | let(:params) do |
||
45 | { |
||
46 | dport: '333-334', |
||
47 | proto: 'tcp', |
||
48 | } |
||
49 | end
|
||
50 | |||
51 | it { is_expected.to compile } |
||
52 | it { |
||
53 | is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
|
||
54 | content: 'tcp dport 333-334 accept', |
||
55 | ) |
||
56 | } |
||
57 | end
|
||
58 | |||
59 | describe 'port array' do |
||
60 | let(:params) do |
||
61 | { |
||
62 | dport: [333, 335], |
||
63 | proto: 'tcp', |
||
64 | } |
||
65 | end
|
||
66 | |||
67 | it { is_expected.to compile } |
||
68 | it { |
||
69 | is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with(
|
||
70 | content: 'tcp dport {333, 335} accept', |
||
71 | 83382bb5 | Nacho Barrientos | ) |
72 | } |
||
73 | end
|
||
74 | end
|
||
75 | end
|
||
76 | end |