From b84bdffc08446e02100e36967ce9f77a9bf686ed Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 20 Dec 2021 20:27:33 +0000 Subject: [PATCH] Add mailman Web redirects for the moved staff list While the staff mailing list is hidden and private in production, that configuration is set after creation, so in our deployment tests we can absolutely verify that HTTP and HTTPS redirects for listinfo and archives work anyway. This paves the way for any further rewrites and associated testing we may need to do for other mailing lists which move between domains, as well as testing redirects we may set up as part of the v2 to v3 migration. Change-Id: I68078554a72e3b59d8192ac4339e8654a8351f52 --- .../templates/mailman_multihost.vhost.j2 | 4 ++ testinfra/test_lists_o_o.py | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/playbooks/roles/mailman-site/templates/mailman_multihost.vhost.j2 b/playbooks/roles/mailman-site/templates/mailman_multihost.vhost.j2 index b834c276b7..71d9f40496 100644 --- a/playbooks/roles/mailman-site/templates/mailman_multihost.vhost.j2 +++ b/playbooks/roles/mailman-site/templates/mailman_multihost.vhost.j2 @@ -14,6 +14,8 @@ RewriteEngine on # TODO(fungi): convert this vhost into a blanket redirect to HTTPS when ready RewriteRule ^/$ /cgi-bin/mailman/listinfo [R] +RewriteCond %{HTTP_HOST} ^lists\.openstack\.org$ [nocase] +RewriteRule /(cgi-bin/mailman/listinfo|pipermail)/(staff)(/.*|$) %{REQUEST_SCHEME}://lists.openinfra.dev/$1/$2$3 [last,redirect=permanent] # We can find mailman here: ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/ @@ -81,6 +83,8 @@ Alias /images/mailman/ /usr/share/images/mailman/ RewriteEngine on RewriteRule ^/$ /cgi-bin/mailman/listinfo [R] + RewriteCond %{HTTP_HOST} ^lists\.openstack\.org$ [nocase] + RewriteRule /(cgi-bin/mailman/listinfo|pipermail)/(staff)(/.*|$) %{REQUEST_SCHEME}://lists.openinfra.dev/$1/$2$3 [last,redirect=permanent] ScriptAlias /cgi-bin/mailman/ /usr/lib/cgi-bin/mailman/ Alias /pipermail/ /srv/mailman/{{ mailman_site.name }}/archives/public/ diff --git a/testinfra/test_lists_o_o.py b/testinfra/test_lists_o_o.py index 24ea24d0c9..df2f6ebe4a 100644 --- a/testinfra/test_lists_o_o.py +++ b/testinfra/test_lists_o_o.py @@ -81,6 +81,45 @@ def test_mm_list_site(host): 'https://lists.zuul-ci.org/cgi-bin/mailman/listinfo') assert 'lists.zuul-ci.org Mailing Lists' in cmd.stdout +def test_mm_list_site_redirect_listinfo_http(host): + cmd = host.run('curl ' + '--resolve lists.openstack.org:80:127.0.0.1 ' + 'http://lists.openstack.org/cgi-bin/mailman/listinfo/staff') + assert ('The document has moved here') in cmd.stdout + cmd = host.run('curl --location ' + '--resolve lists.openinfra.dev:80:127.0.0.1 ' + '--resolve lists.openstack.org:80:127.0.0.1 ' + 'http://lists.openstack.org/cgi-bin/mailman/listinfo/staff') + assert 'Staff Info Page' in cmd.stdout + +def test_mm_list_site_redirect_archives_http(host): + cmd = host.run('curl ' + '--resolve lists.openstack.org:80:127.0.0.1 ' + 'http://lists.openstack.org/pipermail/staff/') + assert ('The document has moved here') in cmd.stdout + cmd = host.run('curl --location ' + '--resolve lists.openinfra.dev:80:127.0.0.1 ' + '--resolve lists.openstack.org:80:127.0.0.1 ' + 'http://lists.openstack.org/pipermail/staff/') + assert '

The Staff Archives

' in cmd.stdout + +def test_mm_list_site_redirect_archives_https(host): + cmd = host.run('curl --insecure ' + '--resolve lists.openstack.org:443:127.0.0.1 ' + 'https://lists.openstack.org/pipermail/staff/') + assert ('The document has moved here') in cmd.stdout + cmd = host.run('curl --insecure --location ' + '--resolve lists.openinfra.dev:443:127.0.0.1 ' + '--resolve lists.openstack.org:443:127.0.0.1 ' + 'https://lists.openstack.org/pipermail/staff/') + assert '

The Staff Archives

' in cmd.stdout + def test_domain_aliases(host): domain_aliases = host.file('/etc/aliases.domain') assert domain_aliases.exists