Commit b137f9d5 by Łukasz Nowak Committed by Łukasz Nowak

caddy-frontend: Assert and fix HTTP redirect codes

Just asserting Location header is not enough, as http status code value is
important for the implementation, so assert for its value.

Also fix https-only redirect status code value, which supposed to be FOUND,
not default MOVED_PERMANENTLY.

/reviewed-on !485
1 parent c8ef7db5
......@@ -58,7 +58,7 @@ md5sum = f20d6c3d2d94fb685f8d26dfca1e822b
[template-default-slave-virtualhost]
filename = templates/default-virtualhost.conf.in
md5sum = 55d0ca695318d7d6111742f4b37fe1b8
md5sum = 065bdb954a4c05c538d8264b6ad43fba
[template-cached-slave-virtualhost]
filename = templates/cached-virtualhost.conf.in
......
......@@ -198,7 +198,9 @@
{%- if https_only %}
# Enforced redirection to SSL-enabled host
redir / https://{host}{rewrite_uri}
redir 302 {
/ https://{host}{rewrite_uri}
}
{%- elif slave_type == 'redirect' and slave_parameter.get('url', '') %} {#- if https_only #}
# Redirect configuration
redir 302 {
......
......@@ -1291,6 +1291,11 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
der2pem(result.peercert))
self.assertEqual(
httplib.MOVED_PERMANENTLY,
result.status_code
)
self.assertEqual(
'https://typezopedefaultpath.example.com:%s/default-path' % (
HTTPS_PORT,),
result.headers['Location']
......@@ -1545,6 +1550,11 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
'test-path/deep/.././deeper')
self.assertEqual(
httplib.FOUND,
result_http.status_code
)
self.assertEqual(
'https://httpsonly.example.com/test-path/deeper',
result_http.headers['Location']
)
......@@ -1937,6 +1947,11 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
der2pem(result.peercert))
self.assertEqual(
httplib.FOUND,
result.status_code
)
self.assertEqual(
'%s/test-path/deeper' % (self.backend_url,),
result.headers['Location']
)
......@@ -3975,6 +3990,11 @@ https://www.google.com {}""",
der2pem(result.peercert))
self.assertEqual(
httplib.MOVED_PERMANENTLY,
result.status_code
)
self.assertEqual(
'https://defaultpathunsafe.example.com:%s/%%24%%7Bsection%%3Aoption%%7D'
'%%0An%%22%%0Aewline%%0A%%7D%%0A%%7Dproxy%%0A/slashed' % (HTTPS_PORT,),
result.headers['Location']
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!