From fa8ff5a76222d7c9e69c1444e44dbd383da0ac79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 19 Jun 2024 13:58:34 -1000 Subject: [PATCH] Add a unit test to ensure bacula::director::console works as expeced --- spec/defines/director_console_spec.rb | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 spec/defines/director_console_spec.rb diff --git a/spec/defines/director_console_spec.rb b/spec/defines/director_console_spec.rb new file mode 100644 index 00000000..5b10695e --- /dev/null +++ b/spec/defines/director_console_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'bacula::director::console' do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) { facts } + + let(:pre_condition) { 'include bacula' } + + context 'with default parameters' do + let(:title) { 'Monitoring' } + + let(:params) do + { + password: 'monitoring_password', + } + end + + it { is_expected.to contain_concat__fragment('bacula-director-console-Monitoring').with(content: <<~FRAGMENT) } + Console { + Name = Monitoring + Password = "monitoring_password" + CatalogACL = *all* + CommandACL = list + } + FRAGMENT + end + + context 'with all parameters set' do + let(:title) { 'restricted-user' } + + let(:params) do + { + password: 'A different UntrustedUser', + jobacl: 'Restricted Client Save', + clientacl: 'restricted-client', + storageacl: 'second-storage', + scheduleacl: 'weekly-schedule', + poolacl: 'backup-pool', + filesetacl: "Restricted Client's FileSet", + catalogacl: 'RestrictedCatalog', + commandacl: %w[run restore], + whereacl: '/', + } + end + + it { is_expected.to contain_concat__fragment('bacula-director-console-restricted-user').with(content: <<~FRAGMENT) } + Console { + Name = restricted-user + Password = "A different UntrustedUser" + JobACL = Restricted Client Save + ClientACL = restricted-client + StorageACL = second-storage + ScheduleACL = weekly-schedule + PoolACL = backup-pool + FileSetACL = Restricted Client's FileSet + CatalogACL = RestrictedCatalog + CommandACL = run, restore + WhereACL = / + } + FRAGMENT + end + end + end +end