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): ...@@ -1901,6 +1901,10 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# test_disabled_cookie_list # test_disabled_cookie_list
'disabled-cookie-list': 'Coconut Chocolate Vanilia', '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': 'monitor-ipv4-test', 'monitor-ipv4-test': 'monitor-ipv4-test',
}, },
...@@ -2078,9 +2082,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2078,9 +2082,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address, 'monitor-base-url': 'https://[%s]:8401' % self._ipv6_address,
'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address, 'backend-client-caucase-url': 'http://[%s]:8990' % self._ipv6_address,
'domain': 'example.com', 'domain': 'example.com',
'accepted-slave-amount': '54', 'accepted-slave-amount': '55',
'rejected-slave-amount': '0', 'rejected-slave-amount': '0',
'slave-amount': '54', 'slave-amount': '55',
'rejected-slave-dict': { 'rejected-slave-dict': {
}, },
'warning-slave-dict': { 'warning-slave-dict': {
...@@ -4460,19 +4464,14 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4460,19 +4464,14 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
result.headers['Location'] result.headers['Location']
) )
def test_disabled_cookie_list(self): def _curl(self, domain, ip, port, cookie):
parameter_dict = self.assertSlaveBase('disabled-cookie-list')
replacement_dict = dict( replacement_dict = dict(
domain=parameter_dict['domain'], ip=TEST_IP, port=HTTPS_PORT) domain=domain, ip=TEST_IP, port=HTTPS_PORT)
curl_command = [ curl_command = [
'curl', '-v', '-k', 'curl', '-v', '-k',
'-H', 'Host: %(domain)s' % replacement_dict, '-H', 'Host: %(domain)s' % replacement_dict,
'--resolve', '%(domain)s:%(port)s:%(ip)s' % replacement_dict, '--resolve', '%(domain)s:%(port)s:%(ip)s' % replacement_dict,
'--cookie', '--cookie', 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',
'https://%(domain)s:%(port)s/' % replacement_dict, 'https://%(domain)s:%(port)s/' % replacement_dict,
] ]
prc = subprocess.Popen( prc = subprocess.Popen(
...@@ -4483,6 +4482,16 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4483,6 +4482,16 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
prc.returncode, 0, prc.returncode, 0,
"Problem running %r. Output:\n%s\nError:\n%s" % ( "Problem running %r. Output:\n%s\nError:\n%s" % (
curl_command, out, err)) 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 check - were the cookies sent in required order?
self.assertIn( self.assertIn(
'ookie: Coconut=absent; Chocolate=absent; Coffee=present; ' 'ookie: Coconut=absent; Chocolate=absent; Coffee=present; '
...@@ -4492,6 +4501,21 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4492,6 +4501,21 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqual( self.assertEqual(
'Coffee=present', json.loads(out)['Incoming Headers']['cookie']) '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): def test_https_url(self):
parameter_dict = self.assertSlaveBase('url_https-url') 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 ...@@ -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_access_log
T-2/var/log/httpd/_custom_domain_wildcard_backend_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/_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_access_log
T-2/var/log/httpd/_disabled-cookie-list_backend_log T-2/var/log/httpd/_disabled-cookie-list_backend_log
T-2/var/log/httpd/_disabled-cookie-list_error_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