|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'spec_helper' |
| 4 | + |
| 5 | +describe 'unbound::remote' do |
| 6 | + on_supported_os.each do |os, os_facts| |
| 7 | + context "on #{os}" do |
| 8 | + let(:facts) { os_facts.merge(concat_basedir: '/dne', unbound_version: '1.21.0') } |
| 9 | + let(:params) do |
| 10 | + { |
| 11 | + enable: false, |
| 12 | + server_key_file: '/etc/unbound/unbound_server.key', |
| 13 | + server_cert_file: '/etc/unbound/unbound_server.pem', |
| 14 | + control_key_file: '/etc/unbound/unbound_control.key', |
| 15 | + control_cert_file: '/etc/unbound/unbound_control.pem', |
| 16 | + group: 'unbound', |
| 17 | + confdir: '/etc/unbound', |
| 18 | + config_file: '/etc/unbound/unbound.conf', |
| 19 | + control_setup_path: '/usr/sbin/unbound-control-setup', |
| 20 | + } |
| 21 | + end |
| 22 | + |
| 23 | + context 'with disabled params' do |
| 24 | + it { is_expected.to compile.with_all_deps } |
| 25 | + it { is_expected.to contain_class('unbound::remote') } |
| 26 | + |
| 27 | + it do |
| 28 | + is_expected.to contain_concat__fragment('unbound-remote').with_content( |
| 29 | + %r{ |
| 30 | + ^remote-control: |
| 31 | + \s+control-enable:\sno |
| 32 | + \s+control-interface:\s::1 |
| 33 | + \s+control-interface:\s127.0.0.1 |
| 34 | + \s+control-port:\s8953 |
| 35 | + \s+server-key-file:\s/etc/unbound/unbound_server.key |
| 36 | + \s+server-cert-file:\s/etc/unbound/unbound_server.pem |
| 37 | + \s+control-key-file:\s/etc/unbound/unbound_control.key |
| 38 | + \s+control-cert-file:\s/etc/unbound/unbound_control.pem |
| 39 | + }x |
| 40 | + ) |
| 41 | + end |
| 42 | + |
| 43 | + it { is_expected.to contain_exec('unbound-control-setup') } |
| 44 | + |
| 45 | + %w[server.key server.pem control.key control.pem].each do |file| |
| 46 | + it { is_expected.to contain_file("/etc/unbound/unbound_#{file}") } |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + context 'with enable true' do |
| 51 | + let(:params) { super().merge(enable: true) } |
| 52 | + |
| 53 | + it do |
| 54 | + is_expected.to contain_concat__fragment('unbound-remote').with_content( |
| 55 | + %r{control-enable:\syes} |
| 56 | + ) |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + context 'with control_interface' do |
| 61 | + let(:params) { super().merge(interface: ['192.0.2.42']) } |
| 62 | + |
| 63 | + it do |
| 64 | + is_expected.to contain_concat__fragment('unbound-remote').with_content( |
| 65 | + %r{control-interface:\s192.0.2.42} |
| 66 | + ) |
| 67 | + end |
| 68 | + end |
| 69 | + |
| 70 | + context 'with control_use_cert false' do |
| 71 | + let(:params) { super().merge(control_use_cert: false) } |
| 72 | + |
| 73 | + it do |
| 74 | + is_expected.to contain_concat__fragment('unbound-remote'). |
| 75 | + without_content(%r{(server|control)-(key|cert)-file}) |
| 76 | + end |
| 77 | + end |
| 78 | + end |
| 79 | + end |
| 80 | +end |
0 commit comments