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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
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):
...
@@ -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'
:
'5
4
'
,
'accepted-slave-amount'
:
'5
5
'
,
'rejected-slave-amount'
:
'0'
,
'rejected-slave-amount'
:
'0'
,
'slave-amount'
:
'5
4
'
,
'slave-amount'
:
'5
5
'
,
'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
\
n
Error:
\
n
%s"
%
(
"Problem running %r. Output:
\
n
%s
\
n
Error:
\
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'
)
...
...
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
...
@@ -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
...
...
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