Commit 7005aace authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend/test: Cover interesting disabled-cookie-list case

parent 6da1b957
......@@ -1901,6 +1901,10 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# test_disabled_cookie_list
'disabled-cookie-list': 'Coconut Chocolate Vanilia',
},
'disabled-cookie-list-simple': {
'url': cls.backend_url,
'disabled-cookie-list': 'Chocolate',
},
'monitor-ipv4-test': {
'monitor-ipv4-test': 'monitor-ipv4-test',
},
......@@ -2078,9 +2082,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'domain': 'example.com',
'accepted-slave-amount': '54',
'accepted-slave-amount': '55',
'rejected-slave-amount': '0',
'slave-amount': '54',
'slave-amount': '55',
'rejected-slave-dict': {
},
'warning-slave-dict': {
......@@ -4460,19 +4464,14 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
result.headers['Location']
)
def test_disabled_cookie_list(self):
parameter_dict = self.assertSlaveBase('disabled-cookie-list')
def _curl(self, domain, ip, port, cookie):
replacement_dict = dict(
domain=parameter_dict['domain'], ip=TEST_IP, port=HTTPS_PORT)
domain=domain, ip=TEST_IP, port=HTTPS_PORT)
curl_command = [
'curl', '-v', '-k',
'-H', 'Host: %(domain)s' % replacement_dict,
'--resolve', '%(domain)s:%(port)s:%(ip)s' % replacement_dict,
'--cookie',
# Note: Cookie order is extremely important here, do not change
# or test will start to pass incorrectly
'Coconut=absent; Chocolate=absent; Coffee=present; Vanilia=absent',
'--cookie', cookie,
'https://%(domain)s:%(port)s/' % replacement_dict,
]
prc = subprocess.Popen(
......@@ -4483,6 +4482,16 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
prc.returncode, 0,
"Problem running %r. Output:\n%s\nError:\n%s" % (
curl_command, out, err))
return out, err
def test_disabled_cookie_list(self):
parameter_dict = self.assertSlaveBase('disabled-cookie-list')
out, err = self._curl(
parameter_dict['domain'], TEST_IP, HTTPS_PORT,
# Note: Cookie order is extremely important here, do not change
# or test will start to pass incorrectly
'Coconut=absent; Chocolate=absent; Coffee=present; Vanilia=absent',
)
# self check - were the cookies sent in required order?
self.assertIn(
'ookie: Coconut=absent; Chocolate=absent; Coffee=present; '
......@@ -4492,6 +4501,21 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqual(
'Coffee=present', json.loads(out)['Incoming Headers']['cookie'])
def test_disabled_cookie_list_simple(self):
parameter_dict = self.assertSlaveBase('disabled-cookie-list')
out, err = self._curl(
parameter_dict['domain'], TEST_IP, HTTPS_PORT,
'WhiteChocolate=present; Chocolate=absent; Coffee=present',
)
# self check - were the cookies sent in required order?
self.assertIn(
'ookie: WhiteChocolate=present; Chocolate=absent; Coffee=present',
err.decode())
# real test - all configured cookies are dropped
self.assertEqual(
'WhiteChocolate=present ; Coffee=present',
json.loads(out)['Incoming Headers']['cookie'])
def test_https_url(self):
parameter_dict = self.assertSlaveBase('url_https-url')
......
......@@ -41,6 +41,9 @@ T-2/var/log/httpd/_custom_domain_ssl_crt_ssl_key_ssl_ca_crt_error_log
T-2/var/log/httpd/_custom_domain_wildcard_access_log
T-2/var/log/httpd/_custom_domain_wildcard_backend_log
T-2/var/log/httpd/_custom_domain_wildcard_error_log
T-2/var/log/httpd/_disabled-cookie-list-simple_access_log
T-2/var/log/httpd/_disabled-cookie-list-simple_backend_log
T-2/var/log/httpd/_disabled-cookie-list-simple_error_log
T-2/var/log/httpd/_disabled-cookie-list_access_log
T-2/var/log/httpd/_disabled-cookie-list_backend_log
T-2/var/log/httpd/_disabled-cookie-list_error_log
......
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