File: userlist_spec.rb

package info (click to toggle)
puppet-module-puppetlabs-haproxy 8.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 816 kB
  • sloc: ruby: 3,979; sh: 14; makefile: 4
file content (66 lines) | stat: -rw-r--r-- 1,719 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true

require 'spec_helper'

describe 'haproxy::userlist' do
  let(:pre_condition) { 'include haproxy' }
  let(:title) { 'admins' }
  let(:facts) do
    {
      networking: {
        ip: '1.1.1.1'
      },
      os: {
        family: 'Redhat'
      },
      concat_basedir: '/dne'
    }
  end

  context 'when users and groups are passed' do
    let(:params) do
      {
        name: 'admins',
        users: [
          'scott insecure-password elgato',
          sensitive('kitchen insecure-password foobar'),
        ],
        groups: [
          'superadmins users kitchen scott',
          'megaadmins users kitchen',
        ]
      }
    end

    it {
      is_expected.to contain_concat__fragment('haproxy-admins_userlist_block').with(
        'order' => '12-admins-00',
        'target' => '/etc/haproxy/haproxy.cfg',
        '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",
      )
    }
  end

  context 'when a non-default config file is used' do
    let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
    let(:params) do
      {
        name: 'bar',
        users: [
          'scott insecure-password elgato',
        ],
        groups: [
          'superuser users scott',
        ]
      }
    end

    it {
      is_expected.to contain_concat__fragment('haproxy-bar_userlist_block').with(
        'order' => '12-bar-00',
        'target' => '/etc/non-default.cfg',
        'content' => "\nuserlist bar\n  group superuser users scott\n  user scott insecure-password elgato\n",
      )
    }
  end
end