Commit 2c4227e2 authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Reject empty url and https-url

parent 409a6823
......@@ -26,7 +26,7 @@ md5sum = 23237969bbd9e974ac674b2052e8d67c
[template-caddy-replicate]
filename = instance-apache-replicate.cfg.in
md5sum = e2d9c782835ea9816539ce7b4f924ca9
md5sum = 19debfbc27c464f451b1eb5bb5ce3c84
[template-slave-list]
_update_hash_filename_ = templates/apache-custom-slave-list.cfg.in
......
......@@ -138,13 +138,12 @@ context =
{% do slave.__setitem__('server-alias', ' '.join(slave_server_alias_unclashed)) %}
{% endif %}
{% for url_key in ['url', 'https-url'] %}
{% if slave.get(url_key) %}
{% if url_key in slave %}
{% set url = (slave[url_key] or '').strip() %}
{% if url != slave[url_key] %}
{% do slave_warning_list.append('slave %s %r has been converted to %r' % (url_key, slave[url_key], url)) %}
{% endif %}
{% if subprocess_module.call([caddy_backend_url_validator, url]) == 1 or not validators.url(url) %}
{% do slave_error_list.append('slave %s %r invalid' % (url_key, url)) %}
{% elif url != slave[url_key] %}
{% do slave_warning_list.append('slave %s %r has been converted to %r' % (url_key, slave[url_key], url)) %}
{% endif %}
{% endif %}
{% endfor %}
......
......@@ -6075,6 +6075,10 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
'url': 'http://1:2:3:4',
'https-url': 'http://host.domain:badport',
},
'empty-backend': {
'url': '',
'https-url': '',
},
'custom_domain-unsafe': {
'custom_domain': '${section:option} afterspace\nafternewline',
},
......@@ -6143,8 +6147,8 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '7',
'rejected-slave-amount': '12',
'slave-amount': '19',
'rejected-slave-amount': '13',
'slave-amount': '20',
'rejected-slave-dict': {
'_https-url': ['slave https-url "https://[fd46::c2ae]:!py!u\'123123\'"'
' invalid'],
......@@ -6173,6 +6177,9 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
'_bad-backend': [
"slave url 'http://1:2:3:4' invalid",
"slave https-url 'http://host.domain:badport' invalid"],
'_empty-backend': [
"slave url '' invalid",
"slave https-url '' invalid"],
},
'warning-slave-dict': {
'_ssl_ca_crt_only': [
......@@ -6535,3 +6542,14 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
},
parameter_dict
)
def test_empty_backend(self):
parameter_dict = self.parseSlaveParameterDict('empty-backend')
self.assertEqual(
{
'request-error-list': [
"slave url '' invalid",
"slave https-url '' invalid"],
},
parameter_dict
)
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