From 4bbf9aefa60555604384745fe8c35ad884fd1fd1 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 9 Jun 2015 11:46:14 +0200 Subject: [PATCH] Add spec tests for config::roles --- .../defines/icingaweb2__config__roles_spec.rb | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 spec/defines/icingaweb2__config__roles_spec.rb diff --git a/spec/defines/icingaweb2__config__roles_spec.rb b/spec/defines/icingaweb2__config__roles_spec.rb new file mode 100644 index 0000000..354ccde --- /dev/null +++ b/spec/defines/icingaweb2__config__roles_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe 'icingaweb2::config::roles' do + + context 'with no set values' do + + let(:title) { 'admins' } + + it 'should absent all settings' do + + should contain_ini_setting('icingaweb2 roles admins users').with_ensure('absent') + should contain_ini_setting('icingaweb2 roles admins groups').with_ensure('absent') + should contain_ini_setting('icingaweb2 roles admins permissions').with_ensure('absent') + should contain_ini_setting('icingaweb2 roles admins host filter').with_ensure('absent') + should contain_ini_setting('icingaweb2 roles admins service filter').with_ensure('absent') + end + + end + + context 'with values' do + + let(:title) { 'Test' } + + let(:params) do + { + :role_name => 'test', + :role_users => 'icingaadmin,icingauser', + :role_groups => 'icingaadmins', + :role_permissions => '*', + :role_host_filter => '*', + :role_service_filter => '*', + } + end + + it 'should add settings' do + + should contain_ini_setting('icingaweb2 roles Test users').with({ + :ensure => :present, + :section => 'test', + :setting => 'users', + :value => '"icingaadmin,icingauser"', + }) + should contain_ini_setting('icingaweb2 roles Test groups').with({ + :ensure => :present, + :section => 'test', + :setting => 'groups', + :value => '"icingaadmins"', + }) + should contain_ini_setting('icingaweb2 roles Test permissions').with({ + :ensure => :present, + :section => 'test', + :setting => 'permissions', + :value => '"*"', + }) + should contain_ini_setting('icingaweb2 roles Test host filter').with({ + :ensure => :present, + :section => 'test', + :setting => 'monitoring/hosts/filter', + :value => '"*"', + }) + should contain_ini_setting('icingaweb2 roles Test service filter').with({ + :ensure => :present, + :section => 'test', + :setting => 'monitoring/services/filter', + :value => '"*"', + }) + end + + end +end \ No newline at end of file