Debian Codegraph @

spec/defines/userlist_spec.rb

raw
1 # frozen_string_literal: true
2
3 require 'spec_helper'
4
5 describe 'haproxy::userlist' do
6 let(:pre_condition) { 'include haproxy' }
7 let(:title) { 'admins' }
8 let(:facts) do
9 {
10 networking: {
11 ip: '1.1.1.1'
12 },
13 os: {
14 family: 'Redhat'
15 },
16 concat_basedir: '/dne'
17 }
18 end
19
20 context 'when users and groups are passed' do
21 let(:params) do
22 {
23 name: 'admins',
24 users: [
25 'scott insecure-password elgato',
26 sensitive('kitchen insecure-password foobar'),
27 ],
28 groups: [
29 'superadmins users kitchen scott',
30 'megaadmins users kitchen',
31 ]
32 }
33 end
34
35 it {
36 is_expected.to contain_concat__fragment('haproxy-admins_userlist_block').with(
37 'order' => '12-admins-00',
38 'target' => '/etc/haproxy/haproxy.cfg',
39 'content' => "\nuserlist admins\n group superadmins users kitchen scott\n group megaadmins users kitchen\n user scott insecure-password elgato\n user kitchen insecure-password foobar\n",
40 )
41 }
42 end
43
44 context 'when a non-default config file is used' do
45 let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
46 let(:params) do
47 {
48 name: 'bar',
49 users: [
50 'scott insecure-password elgato',
51 ],
52 groups: [
53 'superuser users scott',
54 ]
55 }
56 end
57
58 it {
59 is_expected.to contain_concat__fragment('haproxy-bar_userlist_block').with(
60 'order' => '12-bar-00',
61 'target' => '/etc/non-default.cfg',
62 'content' => "\nuserlist bar\n group superuser users scott\n user scott insecure-password elgato\n",
63 )
64 }
65 end
66 end