summaryrefslogtreecommitdiff
path: root/spec/classes/config_spec.rb
blob: fc0a33a39eb6f9b38ea19005a76c7b85127ed10b (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))

describe 'trocla::config', :type => 'class' do
  let(:facts){
    {
      :domain => 'example.com',
    }
  }
  context 'with default params' do
    it { should contain_class('trocla::params') }
    it { should contain_class('trocla::master') }
    it { should contain_file('/etc/puppet/troclarc.yaml').with(
      :owner => 'root',
      :group => 'puppet',
      :mode  => '0640'
    )}
    it { should contain_file('/etc/puppet/troclarc.yaml').with_content("---
profiles:
  sysdomain_nc:
    name_constraints:
    - example.com
") }
    it { should contain_file('/etc/troclarc.yaml').with(
      :ensure => 'link',
      :target => '/etc/puppet/troclarc.yaml'
    )}

    it { should compile.with_all_deps }
  end

  context 'with other params' do
    let(:params) {
      {
        :options => {
          'length'   => 24,
          'profiles' => 'mydefaultprofile',
          'random'   => false,
          'expires'  => 60*60*24, #1day
        },
        :profiles => {
          'mydefaultprofile' => {
            'length' => 20,
          },
          'anotherprofile' => {
            'random' => true,
            'expires' => false,
          },
        },
        :x509_profile_domain_constraints => ['domain1.com','domain2.com'],
        :store => 'moneta',
        :store_options => {
          'adapter' => 'Sequel',
          'adapter_options' => {
            'db'       => 'mysql://db.server.name',
            'user'     => 'trocla',
            'password' => 'secret_password',
            'database' => 'trocladb',
            'table'    => 'trocla',
          },
        },
        :encryption => 'ssl',
        :encryption_options => {
          'private_key' => '/var/lib/puppet/ssl/private_keys/trocla.pem',
          'public_key'  => '/var/lib/puppet/ssl/public_keys/trocla.pem',
        },
        :manage_dependencies => false,
      }
    }
    it { should contain_class('trocla::params') }
    it { should_not contain_class('trocla::master') }
    it { should contain_file('/etc/puppet/troclarc.yaml').with(
      :owner => 'root',
      :group => 'puppet',
      :mode  => '0640'
    )}
    it { should contain_file('/etc/puppet/troclarc.yaml').with_content("---
encryption: :ssl
encryption_options:
  :private_key: /var/lib/puppet/ssl/private_keys/trocla.pem
  :public_key: /var/lib/puppet/ssl/public_keys/trocla.pem
options:
  expires: 86400
  length: 24
  profiles: mydefaultprofile
  random: false
profiles:
  anotherprofile:
    expires: false
    random: true
  mydefaultprofile:
    length: 20
  sysdomain_nc:
    name_constraints:
    - domain1.com
    - domain2.com
store: :moneta
store_options:
  adapter: :Sequel
  adapter_options:
    :database: trocladb
    :db: mysql://db.server.name
    :password: secret_password
    :table: trocla
    :user: trocla
") }
    it { should contain_file('/etc/troclarc.yaml').with(
      :ensure => 'link',
      :target => '/etc/puppet/troclarc.yaml'
    )}

    it { should compile.with_all_deps }
  end
end