diff --git a/spec/classes/foreman_proxy__plugin__abrt_spec.rb b/spec/classes/foreman_proxy__plugin__abrt_spec.rb deleted file mode 100644 index f4771d3f..00000000 --- a/spec/classes/foreman_proxy__plugin__abrt_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe 'foreman_proxy::plugin::abrt' do - on_plugin_os.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - let(:pre_condition) { 'include foreman_proxy' } - - describe 'with default settings' do - it { should contain_foreman_proxy__plugin__module('abrt') } - it 'should configure abrt.yml' do - should contain_file('/etc/foreman-proxy/settings.d/abrt.yml'). - with({ - :ensure => 'file', - :owner => 'root', - :group => 'foreman-proxy', - :mode => '0640', - :content => /:enabled: https/ - }) - end - end - - describe 'with faf_ssl_* set' do - let :params do { - :faf_server_ssl_cert => '/faf_cert.pem', - :faf_server_ssl_key => '/faf_key.pem', - } end - - it 'should set server_ssl_cert and _key' do - should contain_file('/etc/foreman-proxy/settings.d/abrt.yml'). - with_content(%r{^:server_ssl_cert:\s+/faf_cert.pem$}). - with_content(%r{^:server_ssl_key:\s+/faf_key.pem$}) - end - end - end - end -end diff --git a/spec/classes/foreman_proxy__plugin__acd_spec.rb b/spec/classes/foreman_proxy__plugin__acd_spec.rb deleted file mode 100644 index c8eec325..00000000 --- a/spec/classes/foreman_proxy__plugin__acd_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe 'foreman_proxy::plugin::acd' do - on_plugin_os.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - let(:pre_condition) { 'include foreman_proxy' } - - describe 'with default settings' do - it { should contain_foreman_proxy__plugin__module('acd') } - it 'acd.yml should contain the correct configuration' do - verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/acd.yml', [ - '---', - ':enabled: https', - ]) - end - end - end - end -end diff --git a/spec/classes/foreman_proxy__plugin__ansible_spec.rb b/spec/classes/foreman_proxy__plugin__ansible_spec.rb deleted file mode 100644 index 2ce1652e..00000000 --- a/spec/classes/foreman_proxy__plugin__ansible_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'spec_helper' - -describe 'foreman_proxy::plugin::ansible' do - on_plugin_os.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - let(:pre_condition) { 'include foreman_proxy' } - - describe 'with default settings' do - it { should contain_class('foreman_proxy::plugin::dynflow') } - it { should contain_foreman_proxy__plugin__module('ansible') } - - case os - when 'debian-10-x86_64' - it 'should cleanup old ansible-runner upstream repo' do - should contain_apt__source('ansible-runner').with_ensure('absent') - end - it { should contain_package('python3-ansible-runner').with_ensure('installed') } - when 'redhat-7-x86_64' - it 'should include ansible-runner upstream repo' do - should contain_yumrepo('ansible-runner') - .with_baseurl("https://releases.ansible.com/ansible-runner/rpm/epel-7-$basearch/") - .with_gpgcheck(true) - .with_gpgkey('https://releases.ansible.com/keys/RPM-GPG-KEY-ansible-release.pub') - .with_enabled('1') - .that_comes_before('Package[ansible-runner]') - end - it { should contain_package('ansible-runner').with_ensure('installed') } - end - - - it 'should configure ansible.yml' do - should contain_file('/etc/foreman-proxy/settings.d/ansible.yml'). - with_content(/:enabled: https/). - with_content(%r{:ansible_dir: /usr/share/foreman-proxy}) - end - - it 'should configure ansible.cfg' do - callback = facts[:os]['family'] == 'RedHat' ? 'theforeman.foreman.foreman' : 'foreman' - verify_exact_contents(catalogue, '/etc/foreman-proxy/ansible.cfg', [ - '[defaults]', - "callback_whitelist = #{callback}", - 'local_tmp = /tmp', - 'host_key_checking = False', - 'stdout_callback = yaml', - '[callback_foreman]', - 'url = https://foo.example.com', - 'ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/foo.example.com.pem', - 'ssl_cert = /etc/puppetlabs/puppet/ssl/certs/foo.example.com.pem', - 'verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem', - 'roles_path = /etc/ansible/roles:/usr/share/ansible/roles', - 'collections_paths = /etc/ansible/collections:/usr/share/ansible/collections', - '[ssh_connection]', - 'ssh_args = -o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s', - ]) - end - end - - describe 'with override parameters' do - let :params do - { - enabled: true, - ansible_dir: '/etc/ansible-test', - working_dir: '/tmp/ansible', - host_key_checking: true, - stdout_callback: 'debug', - manage_runner_repo: false, - } - end - - it { should contain_class('foreman_proxy::plugin::dynflow') } - - case os - when 'debian-10-x86_64' - it { should_not contain_apt__source('ansible-runner') } - it { should contain_package('python3-ansible-runner').with_ensure('installed') } - when 'redhat-7-x86_64' - it { should_not contain_yumrepo('ansible-runner') } - it { should contain_package('ansible-runner').with_ensure('installed') } - end - - it 'should configure ansible.yml' do - should contain_file('/etc/foreman-proxy/settings.d/ansible.yml'). - with_content(/:enabled: https/). - with_content(%r{:ansible_dir: /etc/ansible-test}). - with_content(%r{:working_dir: /tmp/ansible}) - end - - it 'should configure ansible.cfg' do - callback = facts[:os]['family'] == 'RedHat' ? 'theforeman.foreman.foreman' : 'foreman' - verify_exact_contents(catalogue, '/etc/foreman-proxy/ansible.cfg', [ - '[defaults]', - "callback_whitelist = #{callback}", - 'local_tmp = /tmp/ansible', - 'host_key_checking = True', - 'stdout_callback = debug', - '[callback_foreman]', - 'url = https://foo.example.com', - 'ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/foo.example.com.pem', - 'ssl_cert = /etc/puppetlabs/puppet/ssl/certs/foo.example.com.pem', - 'verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem', - 'roles_path = /etc/ansible/roles:/usr/share/ansible/roles', - 'collections_paths = /etc/ansible/collections:/usr/share/ansible/collections', - '[ssh_connection]', - 'ssh_args = -o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s', - ]) - end - end - - describe 'with disabled ansible-runner install' do - let :params do - { install_runner: false } - end - - it 'should not contain ansible-runner' do - should_not contain_class('foreman_proxy::plugin::ansible::runner') - should_not contain_apt__source('ansible-runner') - should_not contain_yumrepo('ansible-runner') - should_not contain_package('ansible-runner') - should_not contain_package('python3-ansible-runner') - end - end - end - end -end diff --git a/spec/classes/foreman_proxy__plugin__chef__spec.rb b/spec/classes/foreman_proxy__plugin__chef__spec.rb deleted file mode 100644 index a9bd2e0e..00000000 --- a/spec/classes/foreman_proxy__plugin__chef__spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' - -describe 'foreman_proxy::plugin::chef' do - on_plugin_os.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - let(:pre_condition) { 'include foreman_proxy' } - - context 'chef plugin is enabled' do - let :params do - { - :enabled => true - } - end - - it { should compile.with_all_deps } - - it 'should call the plugin' do - should contain_foreman_proxy__plugin__module('chef').with_enabled(true).with_listen_on('https') - end - - it 'should install configuration file' do - should contain_foreman_proxy__settings_file('chef') - verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/chef.yml', [ - '---', - ':enabled: https', - ':chef_authenticate_nodes: true', - ':chef_server_url: https://foo.example.com', - ':chef_smartproxy_clientname: foo.example.com', - ':chef_smartproxy_privatekey: /etc/chef/client.pem', - ':chef_ssl_verify: true' - ]) - end - end - - context 'chef plugin is disabled' do - let :params do - { - :enabled => false - } - end - - it { should compile.with_all_deps } - - it 'should call the plugin' do - should contain_foreman_proxy__plugin__module('chef').with_enabled(false) - end - - it 'should install configuration file' do - should contain_file('/etc/foreman-proxy/settings.d/chef.yml').with_content(/:enabled: false/) - end - end - end - end -end diff --git a/spec/classes/foreman_proxy__plugin__container_gateway_spec.rb b/spec/classes/foreman_proxy__plugin__container_gateway_spec.rb deleted file mode 100644 index 82281db0..00000000 --- a/spec/classes/foreman_proxy__plugin__container_gateway_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'spec_helper' - -describe 'foreman_proxy::plugin::container_gateway' do - on_plugin_os.each do |os, os_facts| - context "on #{os}" do - let(:facts) { os_facts } - let(:pre_condition) { 'include foreman_proxy' } - - describe 'with default settings' do - it { should contain_foreman_proxy__plugin__module('container_gateway') } - it 'container_gateway.yml should contain the correct configuration' do - verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/container_gateway.yml', [ - '---', - ':enabled: https', - ":pulp_endpoint: https://#{facts[:fqdn]}", - ':sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db' - ]) - end - end - - describe 'with overwritten parameters' do - let :params do { - :pulp_endpoint => 'https://test.example.com', - :sqlite_db_path => '/dev/null.db', - } end - - it 'container_gateway.yml should contain the correct configuration' do - verify_exact_contents(catalogue, '/etc/foreman-proxy/settings.d/container_gateway.yml', [ - '---', - ':enabled: https', - ':pulp_endpoint: https://test.example.com', - ':sqlite_db_path: /dev/null.db' - ]) - end - end - end - end -end diff --git a/spec/classes/plugin/abrt_spec.rb b/spec/classes/plugin/abrt_spec.rb new file mode 100644 index 00000000..a281255a --- /dev/null +++ b/spec/classes/plugin/abrt_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe_plugin 'foreman_proxy::plugin::abrt' do + describe 'with default settings' do + include_examples 'a plugin with a settings file', 'abrt' do + let(:expected_config) { /:enabled: https/ } + end + end + + describe 'with faf_ssl_* set' do + let :params do { + :faf_server_ssl_cert => '/faf_cert.pem', + :faf_server_ssl_key => '/faf_key.pem', + } end + + include_examples 'a plugin with a settings file', 'abrt' do + # TODO: this is weaker than it was + let(:expected_config) { %r{:server_ssl_(cert|key): /faf_\1\.pem} } + end + end +end diff --git a/spec/classes/plugin/acd_spec.rb b/spec/classes/plugin/acd_spec.rb new file mode 100644 index 00000000..9cdb59ec --- /dev/null +++ b/spec/classes/plugin/acd_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe_plugin 'foreman_proxy::plugin::acd' do + describe 'with default settings' do + include_examples 'a plugin with a settings file', 'acd' do + let(:expected_config) { "---\n:enabled: https\n" } + end + end +end diff --git a/spec/classes/plugin/ansible_spec.rb b/spec/classes/plugin/ansible_spec.rb new file mode 100644 index 00000000..5f0721f0 --- /dev/null +++ b/spec/classes/plugin/ansible_spec.rb @@ -0,0 +1,125 @@ +require 'spec_helper' + +describe_plugin 'foreman_proxy::plugin::ansible' do + describe 'with default settings' do + it { should contain_class('foreman_proxy::plugin::dynflow') } + + include_examples 'a plugin with a settings file', 'ansible' do + let(:expected_config) do + <<~CONFIG + --- + :enabled: https + :ansible_dir: /usr/share/foreman-proxy + :working_dir: /tmp + CONFIG + end + end + + case os + when 'debian-10-x86_64' + it 'should cleanup old ansible-runner upstream repo' do + should contain_apt__source('ansible-runner').with_ensure('absent') + end + it { should contain_package('python3-ansible-runner').with_ensure('installed') } + when 'redhat-7-x86_64' + it 'should include ansible-runner upstream repo' do + should contain_yumrepo('ansible-runner') + .with_baseurl("https://releases.ansible.com/ansible-runner/rpm/epel-7-$basearch/") + .with_gpgcheck(true) + .with_gpgkey('https://releases.ansible.com/keys/RPM-GPG-KEY-ansible-release.pub') + .with_enabled('1') + .that_comes_before('Package[ansible-runner]') + end + it { should contain_package('ansible-runner').with_ensure('installed') } + end + + it 'should configure ansible.cfg' do + callback = facts[:os]['family'] == 'RedHat' ? 'theforeman.foreman.foreman' : 'foreman' + verify_exact_contents(catalogue, '/etc/foreman-proxy/ansible.cfg', [ + '[defaults]', + "callback_whitelist = #{callback}", + 'local_tmp = /tmp', + 'host_key_checking = False', + 'stdout_callback = yaml', + '[callback_foreman]', + 'url = https://foo.example.com', + 'ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/foo.example.com.pem', + 'ssl_cert = /etc/puppetlabs/puppet/ssl/certs/foo.example.com.pem', + 'verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem', + 'roles_path = /etc/ansible/roles:/usr/share/ansible/roles', + 'collections_paths = /etc/ansible/collections:/usr/share/ansible/collections', + '[ssh_connection]', + 'ssh_args = -o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s', + ]) + end + end + + describe 'with override parameters' do + let :params do + { + enabled: true, + ansible_dir: '/etc/ansible-test', + working_dir: '/tmp/ansible', + host_key_checking: true, + stdout_callback: 'debug', + manage_runner_repo: false, + } + end + + it { should contain_class('foreman_proxy::plugin::dynflow') } + + include_examples 'a plugin with a settings file', 'ansible' do + let(:expected_config) do + <<~CONFIG + --- + :enabled: https + :ansible_dir: /etc/ansible-test + :working_dir: /tmp/ansible + CONFIG + end + end + + case os + when 'debian-10-x86_64' + it { should_not contain_apt__source('ansible-runner') } + it { should contain_package('python3-ansible-runner').with_ensure('installed') } + when 'redhat-7-x86_64' + it { should_not contain_yumrepo('ansible-runner') } + it { should contain_package('ansible-runner').with_ensure('installed') } + end + + it 'should configure ansible.cfg' do + callback = facts[:os]['family'] == 'RedHat' ? 'theforeman.foreman.foreman' : 'foreman' + verify_exact_contents(catalogue, '/etc/foreman-proxy/ansible.cfg', [ + '[defaults]', + "callback_whitelist = #{callback}", + 'local_tmp = /tmp/ansible', + 'host_key_checking = True', + 'stdout_callback = debug', + '[callback_foreman]', + 'url = https://foo.example.com', + 'ssl_key = /etc/puppetlabs/puppet/ssl/private_keys/foo.example.com.pem', + 'ssl_cert = /etc/puppetlabs/puppet/ssl/certs/foo.example.com.pem', + 'verify_certs = /etc/puppetlabs/puppet/ssl/certs/ca.pem', + 'roles_path = /etc/ansible/roles:/usr/share/ansible/roles', + 'collections_paths = /etc/ansible/collections:/usr/share/ansible/collections', + '[ssh_connection]', + 'ssh_args = -o ProxyCommand=none -C -o ControlMaster=auto -o ControlPersist=60s', + ]) + end + end + + describe 'with disabled ansible-runner install' do + let :params do + { install_runner: false } + end + + it 'should not contain ansible-runner' do + should_not contain_class('foreman_proxy::plugin::ansible::runner') + should_not contain_apt__source('ansible-runner') + should_not contain_yumrepo('ansible-runner') + should_not contain_package('ansible-runner') + should_not contain_package('python3-ansible-runner') + end + end +end diff --git a/spec/classes/plugin/chef_spec.rb b/spec/classes/plugin/chef_spec.rb new file mode 100644 index 00000000..1372c5d7 --- /dev/null +++ b/spec/classes/plugin/chef_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +describe_plugin 'foreman_proxy::plugin::chef' do + context 'chef plugin is enabled' do + let :params do + { + :enabled => true + } + end + + include_examples 'a plugin with a settings file', 'chef' do + let(:expected_config) do + <<~CONFIG + --- + :enabled: https + :chef_authenticate_nodes: true + :chef_server_url: https://foo.example.com + # smart-proxy client node needs to have some admin right on chef-server + # in order to retrive all nodes public keys + # e.g. 'host.example.net' + :chef_smartproxy_clientname: foo.example.com + # e.g. /etc/chef/client.pem + :chef_smartproxy_privatekey: /etc/chef/client.pem + + # turning of chef_ssl_verify is not recommended as it turn off authentication + # you can try set path to chef server certificate by chef_ssl_pem_file + # before setting chef_ssl_verify to false + # note that chef_ssl_pem_file must contain both private key and certificate + # because chef-api 0.5 requires it + :chef_ssl_verify: true + # :chef_ssl_pem_file: /path + CONFIG + end + end + end + + context 'chef plugin is disabled' do + let :params do + { + :enabled => false + } + end + + include_examples 'a plugin with a settings file', 'chef' do + let(:expected_config) { /:enabled: false/ } + let(:expected_enabled) { false } + end + end +end diff --git a/spec/classes/plugin/container_gateway_spec.rb b/spec/classes/plugin/container_gateway_spec.rb new file mode 100644 index 00000000..8c3228f1 --- /dev/null +++ b/spec/classes/plugin/container_gateway_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe_plugin 'foreman_proxy::plugin::container_gateway' do + describe 'with default settings' do + include_examples 'a plugin with a settings file', 'container_gateway' do + let(:expected_config) do + <<~CONFIG + --- + # Container Gateway for Katello + :enabled: https + :pulp_endpoint: https://#{facts[:fqdn]} + :sqlite_db_path: /var/lib/foreman-proxy/smart_proxy_container_gateway.db + CONFIG + end + end + end + + describe 'with overwritten parameters' do + let :params do { + :pulp_endpoint => 'https://test.example.com', + :sqlite_db_path => '/dev/null.db', + } end + + include_examples 'a plugin with a settings file', 'container_gateway' do + let(:expected_config) do + <<~CONFIG + --- + # Container Gateway for Katello + :enabled: https + :pulp_endpoint: https://test.example.com + :sqlite_db_path: /dev/null.db + CONFIG + end + end + end +end diff --git a/spec/classes/foreman_proxy__plugin__dhcp__infoblox_spec.rb b/spec/classes/plugin/dhcp__infoblox_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__dhcp__infoblox_spec.rb rename to spec/classes/plugin/dhcp__infoblox_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__dhcp__remote_isc_spec.rb b/spec/classes/plugin/dhcp__remote_isc_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__dhcp__remote_isc_spec.rb rename to spec/classes/plugin/dhcp__remote_isc_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__discovery_spec.rb b/spec/classes/plugin/discovery_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__discovery_spec.rb rename to spec/classes/plugin/discovery_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__dns__infoblox_spec.rb b/spec/classes/plugin/dns__infoblox_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__dns__infoblox_spec.rb rename to spec/classes/plugin/dns__infoblox_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__dns__powerdns_spec.rb b/spec/classes/plugin/dns__powerdns_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__dns__powerdns_spec.rb rename to spec/classes/plugin/dns__powerdns_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__dns__route53_spec.rb b/spec/classes/plugin/dns__route53_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__dns__route53_spec.rb rename to spec/classes/plugin/dns__route53_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__dynflow_spec.rb b/spec/classes/plugin/dynflow_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__dynflow_spec.rb rename to spec/classes/plugin/dynflow_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__monitoring__icinga2_spec.rb b/spec/classes/plugin/monitoring__icinga2_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__monitoring__icinga2_spec.rb rename to spec/classes/plugin/monitoring__icinga2_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__monitoring__icingadirector_spec.rb b/spec/classes/plugin/monitoring__icingadirector_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__monitoring__icingadirector_spec.rb rename to spec/classes/plugin/monitoring__icingadirector_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__monitoring_spec.rb b/spec/classes/plugin/monitoring_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__monitoring_spec.rb rename to spec/classes/plugin/monitoring_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__omaha_spec.rb b/spec/classes/plugin/omaha_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__omaha_spec.rb rename to spec/classes/plugin/omaha_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__openscap_spec.rb b/spec/classes/plugin/openscap_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__openscap_spec.rb rename to spec/classes/plugin/openscap_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__pulp_spec.rb b/spec/classes/plugin/pulp_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__pulp_spec.rb rename to spec/classes/plugin/pulp_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__realm__ad_spec.rb b/spec/classes/plugin/realm__ad_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__realm__ad_spec.rb rename to spec/classes/plugin/realm__ad_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__remote_execution__ssh_spec.rb b/spec/classes/plugin/remote_execution__ssh_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__remote_execution__ssh_spec.rb rename to spec/classes/plugin/remote_execution__ssh_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__remote_execution__ssh_user_spec.rb b/spec/classes/plugin/remote_execution__ssh_user_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__remote_execution__ssh_user_spec.rb rename to spec/classes/plugin/remote_execution__ssh_user_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__salt_spec.rb b/spec/classes/plugin/salt_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__salt_spec.rb rename to spec/classes/plugin/salt_spec.rb diff --git a/spec/classes/foreman_proxy__plugin__shellhooks_spec.rb b/spec/classes/plugin/shellhooks_spec.rb similarity index 100% rename from spec/classes/foreman_proxy__plugin__shellhooks_spec.rb rename to spec/classes/plugin/shellhooks_spec.rb diff --git a/spec/support/plugin.rb b/spec/support/plugin.rb index 3df2b5c0..0ba3c654 100644 --- a/spec/support/plugin.rb +++ b/spec/support/plugin.rb @@ -11,3 +11,39 @@ def on_plugin_os ] on_supported_os(supported_os: supported_os) end + +def describe_plugin(name, &block) + describe name do + on_plugin_os.each do |os, os_facts| + context("on #{os}") do + let(:facts) { os_facts } + let(:pre_condition) { 'include foreman_proxy' } + + class_exec(&block) + end + end + end +end + +shared_examples 'a plugin with a settings file' do |plugin| + let(:expected_enabled) { true } + let(:expected_lisen_on) { 'https' } + + it { is_expected.to compile.with_all_deps } + + it 'contains the plugin' do + is_expected.to contain_foreman_proxy__plugin__module(plugin) + .with_enabled(expected_enabled) + .with_listen_on('https') + end + + it 'includes a configuration file' do + is_expected.to contain_foreman_proxy__settings_file(plugin) + is_expected.to contain_file("/etc/foreman-proxy/settings.d/#{plugin}.yml") + .with_ensure('file') + .with_owner('root') + .with_group('foreman-proxy') + .with_mode('0640') + .with_content(expected_config) + end +end