add tests: override headers generated by mod_md
@@ -318,6 +318,51 @@ class TestDrive :
r = TestEnv.get_meta(name, "/name.txt", useHTTPS=True)
assert r['http_headers']['Strict-Transport-Security'] == 'max-age=15768000'
+ @pytest.mark.skip(reason="mod_alias redirects fail in TCP port-forwarding scenario")
+ def test_500_110(self):
+ # test case: SSL only domain, override headers generated by mod_md
+ # setup: prepare config
+ domain = "test500-110-" + TestDrive.dns_uniq
+ name = "www." + domain
+ conf = HttpdConf( TestDrive.TMP_CONF )
+ conf.add_admin( "admin@" + domain )
+ conf.add_drive_mode( "manual" )
+ conf.add_require_ssl("permanent")
+ conf.add_md( [name] )
+ conf._add_line(" SSLEngine *:" + TestEnv.HTTPS_PORT)
+ conf.add_vhost(TestEnv.HTTPS_PORT + " *:" + TestEnv.HTTP_PORT, name, aliasList=[], withSSL=False)
+ conf.install()
+ assert TestEnv.apache_restart() == 0
+ # drive it
+ assert TestEnv.a2md( [ "drive", name ] )['rv'] == 0
+ assert TestEnv.apache_restart() == 0
+
+ # test overrride HSTS header
+ conf._add_line(' Header set Strict-Transport-Security "max-age=10886400; includeSubDomains; preload"')
+ conf.install()
+ assert TestEnv.apache_restart() == 0
+ r = TestEnv.get_meta(name, "/name.txt", useHTTPS=True)
+ assert r['http_headers']['Strict-Transport-Security'] == 'max-age=10886400; includeSubDomains; preload'
+
+ # test override Location header
+ conf._add_line(' Redirect /a /name.txt')
+ conf._add_line(' Redirect seeother /b /name.txt')
+ conf.install()
+ assert TestEnv.apache_restart() == 0
+ # check: default redirect by mod_md still works
+ expLocation = "https://%s/name.txt" % name
+ r = TestEnv.get_meta(name, "/name.txt", useHTTPS=False)
+ assert r['http_status'] == 301
+ assert r['http_headers']['Location'] == expLocation
+ # check: redirect as given by mod_alias
+ expLocation = "http://%s/name.txt" % name
+ r = TestEnv.get_meta(name, "/a", useHTTPS=False)
+ assert r['http_status'] == 302
+ assert r['http_headers']['Location'] == expLocation # FAIL: mod_alias uses port 5002 (TestEnv.HTTP_PORT)
+ r = TestEnv.get_meta(name, "/b", useHTTPS=False)
+ assert r['http_status'] == 303
+ assert r['http_headers']['Location'] == expLocation # FAIL: mod_alias uses port 5002 (TestEnv.HTTP_PORT)
+
# --------- critical state change -> drive again ---------
