Commit 47750da0 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

caddy-frontend: Defened against duplicated name

If server alias duplicates name of the server or another alias, simply
ignore it.
parent f0b87c7c
......@@ -58,11 +58,11 @@ md5sum = f20d6c3d2d94fb685f8d26dfca1e822b
[template-default-slave-virtualhost]
filename = templates/default-virtualhost.conf.in
md5sum = 7bccd8b63121821131e7a5117e7bb73b
md5sum = 9e00b6d981b9f93a486ef06a47345ebd
[template-cached-slave-virtualhost]
filename = templates/cached-virtualhost.conf.in
md5sum = f149ab15334d7d15d8c525f02fc4d968
md5sum = 7cbcadc295860821ac9d3aaa3cca72c5
[template-log-access]
filename = templates/template-log-access.conf.in
......
{%- set TRUE_VALUES = ['y', 'yes', '1', 'true'] %}
{%- set server_alias_list = slave_parameter.get('server-alias', '').split() %}
{%- set ssl_proxy_verify = ('' ~ slave_parameter.get('ssl-proxy-verify', '')).lower() in TRUE_VALUES %}
{%- set host_list = [slave_parameter.get('custom_domain')] + server_alias_list %}
{%- set host_list = [] %}
{%- for host in [slave_parameter.get('custom_domain')] + server_alias_list %}
{%- if host not in host_list %}
{%- do host_list.append(host) %}
{%- endif %}
{%- endfor %}
{%- set http_backend_host_list = [] %}
{%- set https_backend_host_list = [] %}
{%- for host in host_list %}
......
......@@ -12,7 +12,12 @@
{%- set disabled_cookie_list = slave_parameter.get('disabled-cookie-list', '').split() %}
{%- set https_only = ('' ~ slave_parameter.get('https-only', '')).lower() in TRUE_VALUES %}
{%- set slave_type = slave_parameter.get('type', '') %}
{%- set host_list = [slave_parameter.get('custom_domain')] + server_alias_list %}
{%- set host_list = [] %}
{%- for host in [slave_parameter.get('custom_domain')] + server_alias_list %}
{%- if host not in host_list %}
{%- do host_list.append(host) %}
{%- endif %}
{%- endfor %}
{%- set backend_url = slave_parameter.get('https-url', slave_parameter.get('url', '')) %}
{%- set http_host_list = [] %}
{%- set https_host_list = [] %}
......
......@@ -3042,6 +3042,10 @@ class TestSlaveBadParameters(SlaveHttpFrontendTestCase, TestDataMixin):
'server-alias-unsafe': {
'server-alias': '${section:option} afterspace',
},
'server-alias-same': {
'url': cls.backend_url,
'server-alias': 'serveraliassame.example.com',
},
'virtualhostroot-http-port-unsafe': {
'type': 'zope',
'url': cls.backend_url,
......@@ -3076,9 +3080,9 @@ class TestSlaveBadParameters(SlaveHttpFrontendTestCase, TestDataMixin):
expected_parameter_dict = {
'monitor-base-url': None,
'domain': 'example.com',
'accepted-slave-amount': '7',
'accepted-slave-amount': '8',
'rejected-slave-amount': '3',
'slave-amount': '10',
'slave-amount': '11',
'rejected-slave-list':
'["_server-alias-unsafe", "_custom_domain-unsafe", '
'"_ssl_key-ssl_crt-unsafe"]'}
......@@ -3088,6 +3092,31 @@ class TestSlaveBadParameters(SlaveHttpFrontendTestCase, TestDataMixin):
parameter_dict
)
def test_server_alias_same(self):
parameter_dict = self.slave_connection_parameter_dict_dict[
'server-alias-same']
self.assertLogAccessUrlWithPop(parameter_dict, 'server-alias-same')
self.assertEqual(
parameter_dict,
{
'domain': 'serveraliassame.example.com',
'replication_number': '1',
'url': 'http://serveraliassame.example.com',
'site_url': 'http://serveraliassame.example.com',
'secure_access': 'https://serveraliassame.example.com',
'public-ipv4': LOCAL_IPV4,
}
)
result = self.fakeHTTPSResult(
parameter_dict['domain'], parameter_dict['public-ipv4'], 'test-path')
self.assertEqual(
der2pem(result.peercert),
open('wildcard.example.com.crt').read())
self.assertEqualResultJson(result, 'Path', '/test-path')
def test_re6st_optimal_test_unsafe(self):
parameter_dict = self.slave_connection_parameter_dict_dict[
're6st-optimal-test-unsafe']
......
......@@ -11,6 +11,8 @@ TestSlaveBadParameters-1/var/log/httpd/_re6st-optimal-test-nocomma_access_log
TestSlaveBadParameters-1/var/log/httpd/_re6st-optimal-test-nocomma_error_log
TestSlaveBadParameters-1/var/log/httpd/_re6st-optimal-test-unsafe_access_log
TestSlaveBadParameters-1/var/log/httpd/_re6st-optimal-test-unsafe_error_log
TestSlaveBadParameters-1/var/log/httpd/_server-alias-same_access_log
TestSlaveBadParameters-1/var/log/httpd/_server-alias-same_error_log
TestSlaveBadParameters-1/var/log/httpd/_virtualhostroot-http-port-unsafe_access_log
TestSlaveBadParameters-1/var/log/httpd/_virtualhostroot-http-port-unsafe_error_log
TestSlaveBadParameters-1/var/log/httpd/_virtualhostroot-https-port-unsafe_access_log
......
......@@ -11,6 +11,8 @@ TestSlaveBadParameters-1/etc/monitor-promise/check-_re6st-optimal-test-nocomma-e
TestSlaveBadParameters-1/etc/monitor-promise/check-_re6st-optimal-test-unsafe-error-log-last-day
TestSlaveBadParameters-1/etc/monitor-promise/check-_re6st-optimal-test-unsafe-error-log-last-hour
TestSlaveBadParameters-1/etc/monitor-promise/check-_re6st-optimal-test-unsafe-re6st-optimal-test
TestSlaveBadParameters-1/etc/monitor-promise/check-_server-alias-same-error-log-last-day
TestSlaveBadParameters-1/etc/monitor-promise/check-_server-alias-same-error-log-last-hour
TestSlaveBadParameters-1/etc/monitor-promise/check-_virtualhostroot-http-port-unsafe-error-log-last-day
TestSlaveBadParameters-1/etc/monitor-promise/check-_virtualhostroot-http-port-unsafe-error-log-last-hour
TestSlaveBadParameters-1/etc/monitor-promise/check-_virtualhostroot-https-port-unsafe-error-log-last-day
......
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