From caf7b56fa4013239070be52ab691a013483b80b8 Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 9 May 2018 15:18:22 -0700 Subject: [PATCH] Add beaker tests Add functional tests to verify that the mailman functionality, both single host and multihost, works correctly and generates the expected virtualhost config. Change-Id: Ie3f23cf918f3575e0403626d94a8a0f1f68ae831 --- spec/acceptance/basic_spec.rb | 93 ++++++++++++++++++++++++++ spec/acceptance/fixtures/default.pp | 6 ++ spec/acceptance/fixtures/multihost.pp | 12 ++++ spec/acceptance/multihost_spec.rb | 95 +++++++++++++++++++++++++++ 4 files changed, 206 insertions(+) create mode 100644 spec/acceptance/basic_spec.rb create mode 100644 spec/acceptance/fixtures/default.pp create mode 100644 spec/acceptance/fixtures/multihost.pp create mode 100644 spec/acceptance/multihost_spec.rb diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb new file mode 100644 index 0000000..6880b98 --- /dev/null +++ b/spec/acceptance/basic_spec.rb @@ -0,0 +1,93 @@ +require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance' + +describe 'basic mailman', :if => ['debian', 'ubuntu'].include?(os[:family]) do + + def pp_path + base_path = File.dirname(__FILE__) + File.join(base_path, 'fixtures') + end + + def puppet_manifest + module_path = File.join(pp_path, 'default.pp') + File.read(module_path) + end + + it 'should work with no errors' do + apply_manifest(puppet_manifest, catch_failures: true) + end + + it 'should be idempotent' do + apply_manifest(puppet_manifest, catch_changes: true) + end + + describe command("curl http://localhost/cgi-bin/mailman/listinfo") do + its(:stdout) { should contain('Mailing Lists') } + end + + expected_vhost = < + ServerName lists.openstack.org + + ErrorLog \${APACHE_LOG_DIR}/lists.openstack.org-error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog \${APACHE_LOG_DIR}/lists.openstack.org-access.log combined + + DocumentRoot /var/www + +RewriteEngine on +RewriteRule ^/$ /cgi-bin/mailman/listinfo [R] + +# We can find mailman here: +ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/ +# And the public archives: +Alias /pipermail/ /var/lib/mailman/archives/public/ +# Logos: +Alias /images/mailman/ /usr/share/images/mailman/ + +# Use this if you don't want the "cgi-bin" component in your URL: +# In case you want to access mailman through a shorter URL you should enable +# this: +#ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/ +# In this case you need to set the DEFAULT_URL_PATTERN in +# /etc/mailman/mm_cfg.py to http://%s/mailman/ for the cookie +# authentication code to work. Note that you need to change the base +# URL for all the already-created lists as well. + + + AllowOverride None + Options ExecCGI + AddHandler cgi-script .cgi + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + Options FollowSymlinks + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + +EOF + describe file('/etc/apache2/sites-enabled/50-lists.openstack.org.conf') do + its(:content) { should eq expected_vhost } + end +end diff --git a/spec/acceptance/fixtures/default.pp b/spec/acceptance/fixtures/default.pp new file mode 100644 index 0000000..b55708b --- /dev/null +++ b/spec/acceptance/fixtures/default.pp @@ -0,0 +1,6 @@ +file { '/srv/mailman': + ensure => directory, +} +class { 'mailman': + vhost_name => 'lists.openstack.org', +} diff --git a/spec/acceptance/fixtures/multihost.pp b/spec/acceptance/fixtures/multihost.pp new file mode 100644 index 0000000..9214a1c --- /dev/null +++ b/spec/acceptance/fixtures/multihost.pp @@ -0,0 +1,12 @@ +file { '/srv/mailman': + ensure => directory, +} +class { 'mailman': + multihost => true, +} +mailman::site { 'openstack': + default_email_host => 'lists.openstack.org', + default_url_host => 'lists.openstack.org', + install_languages => ['de', 'fr', 'it', 'ko', 'ru', 'vi', 'zh_TW'], + require => Class['mailman'], +} diff --git a/spec/acceptance/multihost_spec.rb b/spec/acceptance/multihost_spec.rb new file mode 100644 index 0000000..b507981 --- /dev/null +++ b/spec/acceptance/multihost_spec.rb @@ -0,0 +1,95 @@ +require 'puppet-openstack_infra_spec_helper/spec_helper_acceptance' + +describe 'multihost mailman', :if => ['debian', 'ubuntu'].include?(os[:family]) do + + def pp_path + base_path = File.dirname(__FILE__) + File.join(base_path, 'fixtures') + end + + def puppet_manifest + module_path = File.join(pp_path, 'multihost.pp') + File.read(module_path) + end + + it 'should work with no errors' do + apply_manifest(puppet_manifest, catch_failures: true) + end + + it 'should be idempotent' do + apply_manifest(puppet_manifest, catch_changes: true) + end + + describe command("curl http://localhost/cgi-bin/mailman/listinfo") do + its(:stdout) { should contain('Mailing Lists') } + end + + expected_vhost = < + ServerName lists.openstack.org + + ErrorLog \${APACHE_LOG_DIR}/lists.openstack.org-error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog \${APACHE_LOG_DIR}/lists.openstack.org-access.log combined + + DocumentRoot /var/www + +RewriteEngine on +RewriteRule ^/$ /cgi-bin/mailman/listinfo [R] + +# We can find mailman here: +ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/ +# And the public archives: +Alias /pipermail/ /srv/mailman/openstack/archives/public/ +# Logos: +Alias /images/mailman/ /usr/share/images/mailman/ + +# Use this if you don't want the "cgi-bin" component in your URL: +# In case you want to access mailman through a shorter URL you should enable +# this: +#ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/ +# In this case you need to set the DEFAULT_URL_PATTERN in +# /etc/mailman/mm_cfg.py to http://%s/mailman/ for the cookie +# authentication code to work. Note that you need to change the base +# URL for all the already-created lists as well. + + + AllowOverride None + Options ExecCGI + AddHandler cgi-script .cgi + SetEnv MAILMAN_SITE_DIR /srv/mailman/openstack + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + Options FollowSymlinks + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + AllowOverride None + Order allow,deny + Allow from all + = 2.4> + Require all granted + + + + +EOF + + describe file('/etc/apache2/sites-enabled/50-lists.openstack.org.conf') do + its(:content) { should eq expected_vhost } + end +end