Révision 77abc10b
Implement nftables::simplerule::sport
spec/defines/simplerule_spec.rb | ||
---|---|---|
19 | 19 |
} |
20 | 20 |
end |
21 | 21 |
|
22 |
describe 'port without protocol' do |
|
22 |
describe 'dport without protocol' do
|
|
23 | 23 |
let(:params) do |
24 | 24 |
{ |
25 | 25 |
dport: 333, |
... | ... | |
29 | 29 |
it { is_expected.not_to compile } |
30 | 30 |
end |
31 | 31 |
|
32 |
describe 'sport without protocol' do |
|
33 |
let(:params) do |
|
34 |
{ |
|
35 |
sport: 333, |
|
36 |
} |
|
37 |
end |
|
38 |
|
|
39 |
it { is_expected.not_to compile } |
|
40 |
end |
|
41 |
|
|
32 | 42 |
describe 'all parameters provided' do |
33 | 43 |
let(:title) { 'my_big_rule' } |
34 | 44 |
let(:params) do |
... | ... | |
37 | 47 |
comment: 'this is my rule', |
38 | 48 |
counter: true, |
39 | 49 |
dport: 333, |
50 |
sport: 444, |
|
40 | 51 |
proto: 'udp', |
41 | 52 |
chain: 'default_out', |
42 | 53 |
daddr: '2001:1458::/32', |
... | ... | |
46 | 57 |
it { is_expected.to compile } |
47 | 58 |
it { |
48 | 59 |
is_expected.to contain_nftables__rule('default_out-my_big_rule').with( |
49 |
content: 'udp dport {333} ip6 daddr 2001:1458::/32 counter accept comment "this is my rule"', |
|
60 |
content: 'udp sport {444} udp dport {333} ip6 daddr 2001:1458::/32 counter accept comment "this is my rule"',
|
|
50 | 61 |
order: '50', |
51 | 62 |
) |
52 | 63 |
} |
... | ... | |
56 | 67 |
let(:params) do |
57 | 68 |
{ |
58 | 69 |
dport: '333-334', |
70 |
sport: '1-2', |
|
59 | 71 |
proto: 'tcp', |
60 | 72 |
} |
61 | 73 |
end |
... | ... | |
63 | 75 |
it { is_expected.to compile } |
64 | 76 |
it { |
65 | 77 |
is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with( |
66 |
content: 'tcp dport {333-334} accept', |
|
78 |
content: 'tcp sport {1-2} tcp dport {333-334} accept',
|
|
67 | 79 |
) |
68 | 80 |
} |
69 | 81 |
end |
... | ... | |
72 | 84 |
let(:params) do |
73 | 85 |
{ |
74 | 86 |
dport: [333, 335], |
87 |
sport: [433, 435], |
|
88 |
proto: 'tcp', |
|
89 |
} |
|
90 |
end |
|
91 |
|
|
92 |
it { is_expected.to compile } |
|
93 |
it { |
|
94 |
is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with( |
|
95 |
content: 'tcp sport {433, 435} tcp dport {333, 335} accept', |
|
96 |
) |
|
97 |
} |
|
98 |
end |
|
99 |
|
|
100 |
describe 'only sport TCP traffic' do |
|
101 |
let(:params) do |
|
102 |
{ |
|
103 |
sport: 555, |
|
75 | 104 |
proto: 'tcp', |
76 | 105 |
} |
77 | 106 |
end |
... | ... | |
79 | 108 |
it { is_expected.to compile } |
80 | 109 |
it { |
81 | 110 |
is_expected.to contain_nftables__rule('default_in-my_default_rule_name').with( |
82 |
content: 'tcp dport {333, 335} accept',
|
|
111 |
content: 'tcp sport {555} accept',
|
|
83 | 112 |
) |
84 | 113 |
} |
85 | 114 |
end |
Formats disponibles : Unified diff