Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
104
Merge Requests
104
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
7005aace
Commit
7005aace
authored
Jul 21, 2022
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddy-frontend/test: Cover interesting disabled-cookie-list case
parent
6da1b957
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
12 deletions
+51
-12
software/caddy-frontend/test/test.py
software/caddy-frontend/test/test.py
+34
-10
software/caddy-frontend/test/test_data/test.TestSlave.test00cluster_request_instance_parameter_dict.txt
...stSlave.test00cluster_request_instance_parameter_dict.txt
+14
-2
software/caddy-frontend/test/test_data/test.TestSlave.zz_test_file_list_log.txt
...d/test/test_data/test.TestSlave.zz_test_file_list_log.txt
+3
-0
No files found.
software/caddy-frontend/test/test.py
View file @
7005aace
...
...
@@ -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'
:
'5
4
'
,
'accepted-slave-amount'
:
'5
5
'
,
'rejected-slave-amount'
:
'0'
,
'slave-amount'
:
'5
4
'
,
'slave-amount'
:
'5
5
'
,
'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
\
n
Error:
\
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'
)
...
...
software/caddy-frontend/test/test_data/test.TestSlave.test00cluster_request_instance_parameter_dict.txt
View file @
7005aace
This diff is collapsed.
Click to expand it.
software/caddy-frontend/test/test_data/test.TestSlave.zz_test_file_list_log.txt
View file @
7005aace
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment