Commit b137f9d5 authored by Łukasz Nowak's avatar Ł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
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 {
......
......@@ -1290,6 +1290,11 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
self.certificate_pem,
der2pem(result.peercert))
self.assertEqual(
httplib.MOVED_PERMANENTLY,
result.status_code
)
self.assertEqual(
'https://typezopedefaultpath.example.com:%s/default-path' % (
HTTPS_PORT,),
......@@ -1544,6 +1549,11 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
parameter_dict['domain'], parameter_dict['public-ipv4'],
'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']
......@@ -1936,6 +1946,11 @@ http://apachecustomhttpsaccepted.example.com:%%(http_port)s {
self.certificate_pem,
der2pem(result.peercert))
self.assertEqual(
httplib.FOUND,
result.status_code
)
self.assertEqual(
'%s/test-path/deeper' % (self.backend_url,),
result.headers['Location']
......@@ -3974,6 +3989,11 @@ https://www.google.com {}""",
self.certificate_pem,
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,),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment