root / spec / classes / rules_out_dns_spec.rb @ 0b7bcb5d
Historique | Voir | Annoter | Télécharger (2,74 ko)
1 |
# frozen_string_literal: true
|
---|---|
2 |
|
3 |
require 'spec_helper'
|
4 |
|
5 |
describe 'nftables' do |
6 |
let(:pre_condition) { 'Exec{path => "/bin"}' } |
7 |
|
8 |
on_supported_os.each do |os, os_facts|
|
9 |
context "on #{os}" do |
10 |
let(:facts) { os_facts }
|
11 |
|
12 |
context 'with standard dns' do |
13 |
let(:pre_condition) do |
14 |
'
|
15 |
include nftables::rules::out::dns
|
16 |
'
|
17 |
end
|
18 |
|
19 |
it { |
20 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnsudp').with(
|
21 |
target: 'nftables-inet-filter-chain-default_out', |
22 |
content: %r{^ udp dport 53 accept$}, |
23 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnsudp-b' |
24 |
) |
25 |
} |
26 |
|
27 |
it { |
28 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnstcp').with(
|
29 |
target: 'nftables-inet-filter-chain-default_out', |
30 |
content: %r{^ tcp dport 53 accept$}, |
31 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnstcp-b' |
32 |
) |
33 |
} |
34 |
end
|
35 |
|
36 |
context 'with custom dns servers' do |
37 |
let(:pre_condition) do |
38 |
"
|
39 |
class{'nftables::rules::out::dns':
|
40 |
dns_server => ['192.0.2.1', '2001:db8::1'],
|
41 |
}
|
42 |
"
|
43 |
end
|
44 |
|
45 |
it { is_expected.to compile } |
46 |
|
47 |
it { |
48 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnsudp-0').with(
|
49 |
target: 'nftables-inet-filter-chain-default_out', |
50 |
content: %r{^ ip daddr 192.0.2.1 udp dport 53 accept$}, |
51 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnsudp-0-b' |
52 |
) |
53 |
} |
54 |
|
55 |
it { |
56 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnstcp-0').with(
|
57 |
target: 'nftables-inet-filter-chain-default_out', |
58 |
content: %r{^ ip daddr 192.0.2.1 tcp dport 53 accept$}, |
59 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnstcp-0-b' |
60 |
) |
61 |
} |
62 |
|
63 |
it { |
64 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnsudp-1').with(
|
65 |
target: 'nftables-inet-filter-chain-default_out', |
66 |
content: %r{^ ip6 daddr 2001:db8::1 udp dport 53 accept$}, |
67 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnsudp-1-b' |
68 |
) |
69 |
} |
70 |
|
71 |
it { |
72 |
expect(subject).to contain_concat__fragment('nftables-inet-filter-chain-default_out-rule-dnstcp-1').with(
|
73 |
target: 'nftables-inet-filter-chain-default_out', |
74 |
content: %r{^ ip6 daddr 2001:db8::1 tcp dport 53 accept$}, |
75 |
order: '50-nftables-inet-filter-chain-default_out-rule-dnstcp-1-b' |
76 |
) |
77 |
} |
78 |
end
|
79 |
end
|
80 |
end
|
81 |
end
|