From 8ca75f6d074b83ee48d9ce713cdb3e28e57d2cf8 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 28 Jan 2016 00:55:26 +0100 Subject: update module to make it work with all the new features of trocla 0.2.2 --- spec/classes/config_spec.rb | 114 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 spec/classes/config_spec.rb (limited to 'spec/classes/config_spec.rb') diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb new file mode 100644 index 0000000..fc0a33a --- /dev/null +++ b/spec/classes/config_spec.rb @@ -0,0 +1,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 + -- cgit v1.2.3