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/ca_params_spec.rb | 8 +++ spec/classes/config_spec.rb | 114 ++++++++++++++++++++++++++++++++++++++ spec/classes/master_hiera_spec.rb | 11 ++++ spec/classes/master_spec.rb | 52 +++++++++++++++++ spec/classes/params_spec.pp | 8 +++ spec/classes/yaml_spec.rb | 39 +++++++++++++ spec/spec_helper.rb | 13 +++++ 7 files changed, 245 insertions(+) create mode 100644 spec/classes/ca_params_spec.rb create mode 100644 spec/classes/config_spec.rb create mode 100644 spec/classes/master_hiera_spec.rb create mode 100644 spec/classes/master_spec.rb create mode 100644 spec/classes/params_spec.pp create mode 100644 spec/classes/yaml_spec.rb create mode 100644 spec/spec_helper.rb (limited to 'spec') diff --git a/spec/classes/ca_params_spec.rb b/spec/classes/ca_params_spec.rb new file mode 100644 index 0000000..5277972 --- /dev/null +++ b/spec/classes/ca_params_spec.rb @@ -0,0 +1,8 @@ +require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) + +describe 'trocla::ca::params', :type => 'class' do + context 'with default params' do + it { should compile.with_all_deps } + end +end + 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 + diff --git a/spec/classes/master_hiera_spec.rb b/spec/classes/master_hiera_spec.rb new file mode 100644 index 0000000..62112fb --- /dev/null +++ b/spec/classes/master_hiera_spec.rb @@ -0,0 +1,11 @@ +require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) + +describe 'trocla::master::hiera', :type => 'class' do + context 'with default params' do + it { should compile.with_all_deps } + it { should contain_package('rubygem-hiera-backend-trocla').with( + :ensure => 'present', + )} + end +end + diff --git a/spec/classes/master_spec.rb b/spec/classes/master_spec.rb new file mode 100644 index 0000000..ad99c86 --- /dev/null +++ b/spec/classes/master_spec.rb @@ -0,0 +1,52 @@ +require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) + +describe 'trocla::master', :type => 'class' do + context 'with default params' do + context 'on RedHat' do + let(:facts) { + { + :osfamily => 'RedHat', + } + } + it { should contain_package('trocla').with( + :name => 'rubygem-trocla', + :ensure => 'installed' + )} + it { should compile.with_all_deps } + end + context 'on Debian' do + let(:facts) { + { + :osfamily => 'Debian', + } + } + it { should contain_package('trocla').with( + :ensure => 'installed' + )} + it { should compile.with_all_deps } + end + end + context 'with gem provider' do + let(:params){ + { + :provider => 'gem' + } + } + it { should contain_package('trocla').with( + :ensure => 'installed', + :provider => 'gem' + )} + + it { should compile.with_all_deps } + context 'on RedHat' do + it { should contain_package('trocla').with( + :name => 'trocla', + :ensure => 'installed', + :provider => 'gem' + )} + + it { should compile.with_all_deps } + end + end +end + diff --git a/spec/classes/params_spec.pp b/spec/classes/params_spec.pp new file mode 100644 index 0000000..4d05e1f --- /dev/null +++ b/spec/classes/params_spec.pp @@ -0,0 +1,8 @@ +require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) + +describe 'trocla::params', :type => 'class' do + context 'with default params' do + it { should compile.with_all_deps } + end +end + diff --git a/spec/classes/yaml_spec.rb b/spec/classes/yaml_spec.rb new file mode 100644 index 0000000..c5912f2 --- /dev/null +++ b/spec/classes/yaml_spec.rb @@ -0,0 +1,39 @@ +require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) + +describe 'trocla::yaml', :type => 'class' do + let(:facts){ + { + :domain => 'example.com', + } + } + context 'with default params' do + it { should contain_class('trocla::config').with( + 'store' => 'moneta', + 'store_options' => { + 'adapter' => 'YAML', + 'adapter_options' => { + 'file' => '/var/lib/trocla/trocla_data.yaml', + } + } + )} + it { should contain_file('/etc/puppet/troclarc.yaml').with_content("--- +profiles: + sysdomain_nc: + name_constraints: + - example.com +store: :moneta +store_options: + adapter: :YAML + adapter_options: + :file: /var/lib/trocla/trocla_data.yaml +") } + it { should contain_file('/var/lib/trocla/trocla_data.yaml').with( + :ensure => 'file', + :owner => 'puppet', + :group => 0, + :mode => '0600' + )} + it { should compile.with_all_deps } + end +end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..381f972 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,13 @@ +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rake' + +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) + +RSpec.configure do |c| + c.module_path = File.join(fixture_path, 'modules') + c.manifest_dir = File.join(fixture_path, 'manifests') + c.pattern = FileList[c.pattern].exclude(/^spec\/fixtures/) +end + +Puppet::Util::Log.level = :warning +Puppet::Util::Log.newdestination(:console) -- cgit v1.2.3 From b478a4eb162d5a3a117c44ef9b49f20462facf50 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 29 Jan 2016 19:14:12 +0100 Subject: also manage directory as puppet user needs write perms as well --- spec/classes/yaml_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'spec') diff --git a/spec/classes/yaml_spec.rb b/spec/classes/yaml_spec.rb index c5912f2..53ee507 100644 --- a/spec/classes/yaml_spec.rb +++ b/spec/classes/yaml_spec.rb @@ -27,6 +27,12 @@ store_options: adapter_options: :file: /var/lib/trocla/trocla_data.yaml ") } + it { should contain_file('/var/lib/trocla').with( + :ensure => 'directory', + :owner => 'puppet', + :group => 0, + :mode => '0600' + )} it { should contain_file('/var/lib/trocla/trocla_data.yaml').with( :ensure => 'file', :owner => 'puppet', -- cgit v1.2.3 From 9af8b4274e47b9c89be3368fa6981fd6ab464cb9 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 29 Jan 2016 19:33:23 +0100 Subject: make sure we manage things after the package --- spec/classes/yaml_spec.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/classes/yaml_spec.rb b/spec/classes/yaml_spec.rb index 53ee507..9ded270 100644 --- a/spec/classes/yaml_spec.rb +++ b/spec/classes/yaml_spec.rb @@ -28,16 +28,18 @@ store_options: :file: /var/lib/trocla/trocla_data.yaml ") } it { should contain_file('/var/lib/trocla').with( - :ensure => 'directory', - :owner => 'puppet', - :group => 0, - :mode => '0600' + :ensure => 'directory', + :owner => 'puppet', + :group => 0, + :mode => '0600', + :require => 'Package[trocla]', )} it { should contain_file('/var/lib/trocla/trocla_data.yaml').with( - :ensure => 'file', - :owner => 'puppet', - :group => 0, - :mode => '0600' + :ensure => 'file', + :owner => 'puppet', + :group => 0, + :mode => '0600', + :require => 'Package[trocla]', )} it { should compile.with_all_deps } end -- cgit v1.2.3 From b19db630c21678afa2c9b7a7b67b9773f5a3e4d5 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 27 Mar 2016 12:32:49 +0200 Subject: make it 1.8.7 compatible --- spec/classes/master_hiera_spec.rb | 2 +- spec/classes/yaml_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/classes/master_hiera_spec.rb b/spec/classes/master_hiera_spec.rb index 62112fb..287abaa 100644 --- a/spec/classes/master_hiera_spec.rb +++ b/spec/classes/master_hiera_spec.rb @@ -4,7 +4,7 @@ describe 'trocla::master::hiera', :type => 'class' do context 'with default params' do it { should compile.with_all_deps } it { should contain_package('rubygem-hiera-backend-trocla').with( - :ensure => 'present', + :ensure => 'present' )} end end diff --git a/spec/classes/yaml_spec.rb b/spec/classes/yaml_spec.rb index 9ded270..49d2cb5 100644 --- a/spec/classes/yaml_spec.rb +++ b/spec/classes/yaml_spec.rb @@ -32,14 +32,14 @@ store_options: :owner => 'puppet', :group => 0, :mode => '0600', - :require => 'Package[trocla]', + :require => 'Package[trocla]' )} it { should contain_file('/var/lib/trocla/trocla_data.yaml').with( :ensure => 'file', :owner => 'puppet', :group => 0, :mode => '0600', - :require => 'Package[trocla]', + :require => 'Package[trocla]' )} it { should compile.with_all_deps } end -- cgit v1.2.3