cherrypy-foundation 1.0.0__py3-none-any.whl → 1.0.0a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cherrypy_foundation/components/ColorModes.jinja +4 -5
- cherrypy_foundation/components/Datatable.jinja +2 -2
- cherrypy_foundation/components/Datatable.js +2 -2
- cherrypy_foundation/components/Field.jinja +2 -4
- cherrypy_foundation/components/Fields.jinja +2 -0
- cherrypy_foundation/components/Typeahead.css +1 -6
- cherrypy_foundation/components/Typeahead.jinja +2 -2
- cherrypy_foundation/components/__init__.py +2 -2
- cherrypy_foundation/components/tests/test_static.py +1 -1
- cherrypy_foundation/error_page.py +3 -3
- cherrypy_foundation/flash.py +15 -17
- cherrypy_foundation/form.py +2 -2
- cherrypy_foundation/logging.py +2 -2
- cherrypy_foundation/passwd.py +2 -2
- cherrypy_foundation/plugins/db.py +1 -1
- cherrypy_foundation/plugins/ldap.py +25 -27
- cherrypy_foundation/plugins/restapi.py +1 -1
- cherrypy_foundation/plugins/scheduler.py +3 -14
- cherrypy_foundation/plugins/smtp.py +2 -8
- cherrypy_foundation/plugins/tests/test_db.py +2 -2
- cherrypy_foundation/plugins/tests/test_ldap.py +3 -76
- cherrypy_foundation/plugins/tests/test_scheduler.py +1 -1
- cherrypy_foundation/plugins/tests/test_smtp.py +1 -31
- cherrypy_foundation/tests/__init__.py +0 -72
- cherrypy_foundation/tests/templates/test_form.html +1 -7
- cherrypy_foundation/tests/test_error_page.py +1 -7
- cherrypy_foundation/tests/test_form.py +11 -40
- cherrypy_foundation/tests/test_passwd.py +2 -2
- cherrypy_foundation/tools/auth.py +27 -31
- cherrypy_foundation/tools/auth_mfa.py +83 -87
- cherrypy_foundation/tools/errors.py +27 -0
- cherrypy_foundation/tools/i18n.py +151 -235
- cherrypy_foundation/tools/jinja2.py +2 -15
- cherrypy_foundation/tools/ratelimit.py +18 -32
- cherrypy_foundation/tools/secure_headers.py +1 -1
- cherrypy_foundation/tools/sessions_timeout.py +21 -23
- cherrypy_foundation/tools/tests/locales/en/LC_MESSAGES/messages.mo +0 -0
- cherrypy_foundation/tools/tests/locales/{de → en}/LC_MESSAGES/messages.po +2 -2
- cherrypy_foundation/tools/tests/templates/test_jinja2.html +1 -2
- cherrypy_foundation/tools/tests/templates/test_jinja2_i18n.html +11 -0
- cherrypy_foundation/tools/tests/templates/test_jinjax.html +2 -3
- cherrypy_foundation/tools/tests/test_auth.py +3 -20
- cherrypy_foundation/tools/tests/test_auth_mfa.py +4 -6
- cherrypy_foundation/tools/tests/test_i18n.py +6 -81
- cherrypy_foundation/tools/tests/test_jinja2.py +5 -35
- cherrypy_foundation/tools/tests/test_ratelimit.py +2 -2
- cherrypy_foundation/url.py +25 -25
- cherrypy_foundation/widgets.py +2 -2
- cherrypy_foundation-1.0.0a2.dist-info/METADATA +42 -0
- {cherrypy_foundation-1.0.0.dist-info → cherrypy_foundation-1.0.0a2.dist-info}/RECORD +53 -64
- {cherrypy_foundation-1.0.0.dist-info → cherrypy_foundation-1.0.0a2.dist-info}/WHEEL +1 -1
- cherrypy_foundation/components/Flash.jinja +0 -13
- cherrypy_foundation/components/LocaleSelection.jinja +0 -13
- cherrypy_foundation/components/LocaleSelection.js +0 -26
- cherrypy_foundation/plugins/tests/test_scheduler_db.py +0 -107
- cherrypy_foundation/sessions.py +0 -93
- cherrypy_foundation/tests/templates/test_flash.html +0 -9
- cherrypy_foundation/tests/templates/test_url.html +0 -15
- cherrypy_foundation/tests/test_flash.py +0 -61
- cherrypy_foundation/tests/test_logging.py +0 -78
- cherrypy_foundation/tests/test_sessions.py +0 -89
- cherrypy_foundation/tests/test_url.py +0 -161
- cherrypy_foundation/tools/tests/locales/de/LC_MESSAGES/messages.mo +0 -0
- cherrypy_foundation/tools/tests/templates/test_jinjax_i18n.html +0 -22
- cherrypy_foundation/tools/tests/test_secure_headers.py +0 -200
- cherrypy_foundation-1.0.0.dist-info/METADATA +0 -71
- {cherrypy_foundation-1.0.0.dist-info → cherrypy_foundation-1.0.0a2.dist-info}/licenses/LICENSE.md +0 -0
- {cherrypy_foundation-1.0.0.dist-info → cherrypy_foundation-1.0.0a2.dist-info}/top_level.txt +0 -0
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# CherryPy
|
|
2
|
-
# Copyright (C) 2026 IKUS Software
|
|
3
|
-
#
|
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
# (at your option) any later version.
|
|
8
|
-
#
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
#
|
|
14
|
-
# You should have received a copy of the GNU General Public License
|
|
15
|
-
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
|
|
17
|
-
import tempfile
|
|
18
|
-
from pathlib import Path
|
|
19
|
-
|
|
20
|
-
import cherrypy
|
|
21
|
-
from cherrypy.test import helper
|
|
22
|
-
|
|
23
|
-
from ..logging import setup_logging
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class Root:
|
|
27
|
-
|
|
28
|
-
@cherrypy.expose
|
|
29
|
-
def index(self):
|
|
30
|
-
return "OK"
|
|
31
|
-
|
|
32
|
-
@cherrypy.expose
|
|
33
|
-
def error(self):
|
|
34
|
-
cherrypy.log('error messages to be logged')
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class LoggingTest(helper.CPWebCase):
|
|
38
|
-
interactive = False
|
|
39
|
-
|
|
40
|
-
@classmethod
|
|
41
|
-
def setup_server(cls):
|
|
42
|
-
cls.tempdir = tempfile.TemporaryDirectory(prefix='cherrypy-foundation-', suffix='-logging')
|
|
43
|
-
cls.log_access_file = f'{cls.tempdir.name}/access.log'
|
|
44
|
-
cls.log_file = f'{cls.tempdir.name}/error.log'
|
|
45
|
-
setup_logging(log_file=cls.log_file, log_access_file=cls.log_access_file, level='DEBUG')
|
|
46
|
-
cherrypy.tree.mount(Root(), '/')
|
|
47
|
-
|
|
48
|
-
@classmethod
|
|
49
|
-
def teardown_class(cls):
|
|
50
|
-
# Delete temp folder
|
|
51
|
-
cls.tempdir.cleanup()
|
|
52
|
-
# Stop server
|
|
53
|
-
super().teardown_class()
|
|
54
|
-
# Reset logging to default.
|
|
55
|
-
# Re-enable screen logging
|
|
56
|
-
cherrypy.config.update({'log.screen': True, 'log.error_file': '', 'log.access_file': ''})
|
|
57
|
-
# Reset internal logger references
|
|
58
|
-
cherrypy.log.error_file = None
|
|
59
|
-
cherrypy.log.access_file = None
|
|
60
|
-
|
|
61
|
-
def test_logging_access(self):
|
|
62
|
-
mtime = Path(self.log_access_file).stat().st_mtime
|
|
63
|
-
# When page get queried
|
|
64
|
-
self.getPage('/')
|
|
65
|
-
# Then access files get updated
|
|
66
|
-
mtime2 = Path(self.log_access_file).stat().st_mtime
|
|
67
|
-
self.assertNotEqual(mtime, mtime2)
|
|
68
|
-
|
|
69
|
-
def test_logging_error(self):
|
|
70
|
-
data = Path(self.log_file).read_text()
|
|
71
|
-
self.assertNotIn('error messages to be logged', data)
|
|
72
|
-
# When page get queried
|
|
73
|
-
self.getPage('/error')
|
|
74
|
-
self.assertStatus(200)
|
|
75
|
-
# Then access files get updated
|
|
76
|
-
data2 = Path(self.log_file).read_text()
|
|
77
|
-
self.assertNotEqual(data, data2)
|
|
78
|
-
self.assertIn('error messages to be logged', data2)
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# Cherrypy-foundation
|
|
2
|
-
# Copyright (C) 2026 IKUS Software
|
|
3
|
-
#
|
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
# (at your option) any later version.
|
|
8
|
-
#
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
#
|
|
14
|
-
# You should have received a copy of the GNU General Public License
|
|
15
|
-
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
|
|
17
|
-
import os
|
|
18
|
-
import tempfile
|
|
19
|
-
|
|
20
|
-
import cherrypy
|
|
21
|
-
from cherrypy.test import helper
|
|
22
|
-
|
|
23
|
-
from cherrypy_foundation.sessions import FileSession, session_lock
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@cherrypy.tools.sessions(on=True, locking='explicit', storage_class=FileSession)
|
|
27
|
-
class Root:
|
|
28
|
-
|
|
29
|
-
@cherrypy.expose
|
|
30
|
-
def index(self, value='OK'):
|
|
31
|
-
if value:
|
|
32
|
-
with session_lock() as s:
|
|
33
|
-
s['value'] = value
|
|
34
|
-
return s['value']
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class FileSessionTest(helper.CPWebCase):
|
|
38
|
-
interactive = False
|
|
39
|
-
|
|
40
|
-
@classmethod
|
|
41
|
-
def setup_class(cls):
|
|
42
|
-
cls.tempdir = tempfile.TemporaryDirectory(prefix='cherrypy-foundation-', suffix='-file-session-test')
|
|
43
|
-
cls.storage_path = cls.tempdir.name
|
|
44
|
-
super().setup_class()
|
|
45
|
-
|
|
46
|
-
@classmethod
|
|
47
|
-
def teardown_class(cls):
|
|
48
|
-
cls.tempdir.cleanup()
|
|
49
|
-
super().teardown_class()
|
|
50
|
-
|
|
51
|
-
@classmethod
|
|
52
|
-
def setup_server(cls):
|
|
53
|
-
cherrypy.config.update(
|
|
54
|
-
{
|
|
55
|
-
'tools.sessions.storage_path': cls.storage_path,
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
cherrypy.tree.mount(Root(), '/')
|
|
59
|
-
|
|
60
|
-
@property
|
|
61
|
-
def _session_id(self):
|
|
62
|
-
"""Return session id from cookie."""
|
|
63
|
-
if hasattr(self, 'cookies') and self.cookies:
|
|
64
|
-
for unused, value in self.cookies:
|
|
65
|
-
for part in value.split(';'):
|
|
66
|
-
key, unused, value = part.partition('=')
|
|
67
|
-
if key == 'session_id':
|
|
68
|
-
return value
|
|
69
|
-
|
|
70
|
-
def test_get_page(self):
|
|
71
|
-
# Given a page with session enabled
|
|
72
|
-
# When the page get queried
|
|
73
|
-
self.getPage("/")
|
|
74
|
-
# Then a session is created with a id
|
|
75
|
-
self.assertStatus(200)
|
|
76
|
-
self.assertTrue(self._session_id)
|
|
77
|
-
# Then this session is created on disk.
|
|
78
|
-
s = FileSession(id=self._session_id, storage_path=self.storage_path)
|
|
79
|
-
self.assertTrue(s._exists())
|
|
80
|
-
# When session timeout and get clean-up
|
|
81
|
-
s.acquire_lock()
|
|
82
|
-
s.load()
|
|
83
|
-
s.timeout = 0
|
|
84
|
-
s.save()
|
|
85
|
-
s.clean_up()
|
|
86
|
-
# Then session get deleted
|
|
87
|
-
self.assertFalse(s._exists())
|
|
88
|
-
# Lock file also get deleted.
|
|
89
|
-
self.assertFalse(os.path.exists(s._get_file_path() + FileSession.LOCK_SUFFIX))
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
# Cherrypy-foundation
|
|
2
|
-
# Copyright (C) 2026 IKUS Software
|
|
3
|
-
#
|
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
# (at your option) any later version.
|
|
8
|
-
#
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
#
|
|
14
|
-
# You should have received a copy of the GNU General Public License
|
|
15
|
-
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
|
|
17
|
-
import cherrypy
|
|
18
|
-
from cherrypy.test import helper
|
|
19
|
-
|
|
20
|
-
import cherrypy_foundation.tools.jinja2 # noqa
|
|
21
|
-
|
|
22
|
-
from ..url import url_for
|
|
23
|
-
|
|
24
|
-
env = cherrypy.tools.jinja2.create_env(
|
|
25
|
-
package_name=__package__,
|
|
26
|
-
globals={
|
|
27
|
-
'url_for': url_for,
|
|
28
|
-
},
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class SubPage:
|
|
33
|
-
|
|
34
|
-
@cherrypy.expose
|
|
35
|
-
@cherrypy.tools.jinja2(template='test_url.html')
|
|
36
|
-
def index(self, **kwargs):
|
|
37
|
-
_relative = cherrypy.request.headers.get('-Relative')
|
|
38
|
-
return {'kwargs': {'_relative': _relative or None}}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
@cherrypy.tools.proxy(base='https://www.example.com')
|
|
42
|
-
class ProxiedPage:
|
|
43
|
-
|
|
44
|
-
@cherrypy.expose
|
|
45
|
-
@cherrypy.tools.jinja2(template='test_url.html')
|
|
46
|
-
def index(self, **kwargs):
|
|
47
|
-
_relative = cherrypy.request.headers.get('-Relative')
|
|
48
|
-
return {'kwargs': {'_relative': _relative or None}}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
@cherrypy.tools.jinja2(env=env)
|
|
52
|
-
class Root:
|
|
53
|
-
sub_page = SubPage()
|
|
54
|
-
proxied = ProxiedPage()
|
|
55
|
-
|
|
56
|
-
@cherrypy.expose
|
|
57
|
-
@cherrypy.tools.jinja2(template='test_url.html')
|
|
58
|
-
def index(self, **kwargs):
|
|
59
|
-
_relative = cherrypy.request.headers.get('-Relative')
|
|
60
|
-
return {'kwargs': {'_relative': _relative or None}}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class UrlTest(helper.CPWebCase):
|
|
64
|
-
default_lang = None
|
|
65
|
-
interactive = False
|
|
66
|
-
|
|
67
|
-
@classmethod
|
|
68
|
-
def setup_server(cls):
|
|
69
|
-
cherrypy.tree.mount(Root(), '/')
|
|
70
|
-
|
|
71
|
-
def test_url_for(self):
|
|
72
|
-
self.assertEqual(url_for("foo", "bar"), 'http://127.0.0.1:54583/foo/bar')
|
|
73
|
-
self.assertEqual(url_for("foo", "bar", _relative='server'), '/foo/bar')
|
|
74
|
-
# Outside a request, relative url doesn't make alot of sens.
|
|
75
|
-
self.assertEqual(url_for("foo", "bar", _relative=1), '127.0.0.1:54583/foo/bar')
|
|
76
|
-
self.assertEqual(url_for("foo", "bar", _base='http://test.com'), 'http://test.com/foo/bar')
|
|
77
|
-
|
|
78
|
-
def test_get_page(self):
|
|
79
|
-
# Given a form
|
|
80
|
-
# When querying the page that include this form
|
|
81
|
-
self.getPage("/")
|
|
82
|
-
self.assertStatus(200)
|
|
83
|
-
# Then each field is render properly.
|
|
84
|
-
# 1. Check title
|
|
85
|
-
self.assertInBody('test-url')
|
|
86
|
-
# 2. Check user field
|
|
87
|
-
self.assertInBody(f'Empty: http://{self.HOST}:{self.PORT}/')
|
|
88
|
-
self.assertInBody(f'Dot: http://{self.HOST}:{self.PORT}/')
|
|
89
|
-
self.assertInBody(f'Dot page: http://{self.HOST}:{self.PORT}/my-page')
|
|
90
|
-
self.assertInBody(f'Slash: http://{self.HOST}:{self.PORT}/')
|
|
91
|
-
self.assertInBody(f'Page: http://{self.HOST}:{self.PORT}/my-page')
|
|
92
|
-
self.assertInBody(f'Slash page: http://{self.HOST}:{self.PORT}/my-page')
|
|
93
|
-
self.assertInBody(f'Query: http://{self.HOST}:{self.PORT}/my-page?bar=test+with+space&foo=1')
|
|
94
|
-
|
|
95
|
-
def test_get_page_relative_true(self):
|
|
96
|
-
# Given a form
|
|
97
|
-
# When querying the page that include this form
|
|
98
|
-
self.getPage("/", headers=[('_relative', '1')])
|
|
99
|
-
self.assertStatus(200)
|
|
100
|
-
# Then each field is render properly.
|
|
101
|
-
# 1. Check title
|
|
102
|
-
self.assertInBody('test-url')
|
|
103
|
-
# 2. Check user field
|
|
104
|
-
self.assertInBody('Empty: <br/>')
|
|
105
|
-
self.assertInBody('Dot: <br/>')
|
|
106
|
-
self.assertInBody('Dot page: my-page<br/>')
|
|
107
|
-
self.assertInBody('Slash: <br/>')
|
|
108
|
-
self.assertInBody('Page: my-page<br/>')
|
|
109
|
-
self.assertInBody('Slash page: my-page<br/>')
|
|
110
|
-
self.assertInBody('Query: my-page?bar=test+with+space&foo=1<br/>')
|
|
111
|
-
|
|
112
|
-
def test_get_page_relative_server(self):
|
|
113
|
-
# Given a form
|
|
114
|
-
# When querying the page that include this form
|
|
115
|
-
self.getPage("/", headers=[('_relative', 'server')])
|
|
116
|
-
self.assertStatus(200)
|
|
117
|
-
# Then each field is render properly.
|
|
118
|
-
# 1. Check title
|
|
119
|
-
self.assertInBody('test-url')
|
|
120
|
-
# 2. Check user field
|
|
121
|
-
self.assertInBody('Empty: /<br/>')
|
|
122
|
-
self.assertInBody('Dot: /<br/>')
|
|
123
|
-
self.assertInBody('Dot page: /my-page<br/>')
|
|
124
|
-
self.assertInBody('Slash: /<br/>')
|
|
125
|
-
self.assertInBody('Page: /my-page<br/>')
|
|
126
|
-
self.assertInBody('Slash page: /my-page<br/>')
|
|
127
|
-
self.assertInBody('Query: /my-page?bar=test+with+space&foo=1<br/>')
|
|
128
|
-
|
|
129
|
-
def test_get_page_proxied(self):
|
|
130
|
-
# Given a form
|
|
131
|
-
# When querying the page that include this form
|
|
132
|
-
self.getPage("/proxied/")
|
|
133
|
-
self.assertStatus(200)
|
|
134
|
-
# Then each field is render properly.
|
|
135
|
-
# 1. Check title
|
|
136
|
-
self.assertInBody('test-url')
|
|
137
|
-
# 2. Check user field
|
|
138
|
-
self.assertInBody('Empty: https://www.example.com/')
|
|
139
|
-
self.assertInBody('Dot: https://www.example.com/proxied/')
|
|
140
|
-
self.assertInBody('Dot page: https://www.example.com/proxied/my-page<br/>')
|
|
141
|
-
self.assertInBody('Slash: https://www.example.com/')
|
|
142
|
-
self.assertInBody('Page: https://www.example.com/my-page')
|
|
143
|
-
self.assertInBody('Slash page: https://www.example.com/my-page')
|
|
144
|
-
self.assertInBody('Query: https://www.example.com/my-page?bar=test+with+space&foo=1')
|
|
145
|
-
|
|
146
|
-
def test_get_sub_page(self):
|
|
147
|
-
# Given a form
|
|
148
|
-
# When querying the page that include this form
|
|
149
|
-
self.getPage("/sub-page/")
|
|
150
|
-
self.assertStatus(200)
|
|
151
|
-
# Then each field is render properly.
|
|
152
|
-
# 1. Check title
|
|
153
|
-
self.assertInBody('test-url')
|
|
154
|
-
# 2. Check user field
|
|
155
|
-
self.assertInBody(f'Empty: http://{self.HOST}:{self.PORT}/sub-page/')
|
|
156
|
-
self.assertInBody(f'Dot: http://{self.HOST}:{self.PORT}/sub-page/')
|
|
157
|
-
self.assertInBody(f'Dot page: http://{self.HOST}:{self.PORT}/sub-page/my-page')
|
|
158
|
-
self.assertInBody(f'Slash: http://{self.HOST}:{self.PORT}/')
|
|
159
|
-
self.assertInBody(f'Page: http://{self.HOST}:{self.PORT}/my-page')
|
|
160
|
-
self.assertInBody(f'Slash page: http://{self.HOST}:{self.PORT}/my-page')
|
|
161
|
-
self.assertInBody(f'Query: http://{self.HOST}:{self.PORT}/my-page?bar=test+with+space&foo=1')
|
|
Binary file
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="{{ get_translation().locale }}">
|
|
3
|
-
<head>
|
|
4
|
-
<title>test-jinja2</title>
|
|
5
|
-
{{ catalog.render_assets() }}
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<!-- Selector -->
|
|
9
|
-
<div class="dropdown">
|
|
10
|
-
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
11
|
-
Dropdown button
|
|
12
|
-
</button>
|
|
13
|
-
<ul class="dropdown-menu">
|
|
14
|
-
<LocaleSelection />
|
|
15
|
-
</ul>
|
|
16
|
-
</div>
|
|
17
|
-
{{ get_language_name(get_translation().locale) }}<br/>
|
|
18
|
-
{% trans %}Some text to translate{% endtrans %}<br/>
|
|
19
|
-
{{ my_datetime | format_datetime(format='full') }}<br/>
|
|
20
|
-
{{ my_date | format_date(format='full') }}
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
# Cherrypy-foundation
|
|
2
|
-
# Copyright (C) 2026 IKUS Software
|
|
3
|
-
#
|
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
# (at your option) any later version.
|
|
8
|
-
#
|
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
# GNU General Public License for more details.
|
|
13
|
-
#
|
|
14
|
-
# You should have received a copy of the GNU General Public License
|
|
15
|
-
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
|
|
17
|
-
import cherrypy
|
|
18
|
-
from cherrypy.test import helper
|
|
19
|
-
|
|
20
|
-
from cherrypy_foundation.tools import secure_headers # noqa
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
@cherrypy.tools.secure_headers(
|
|
24
|
-
csp={
|
|
25
|
-
"default-src": "'self'",
|
|
26
|
-
"style-src": ("'self'", "'unsafe-inline'"),
|
|
27
|
-
"script-src": ("'self'", "'unsafe-inline'"),
|
|
28
|
-
"img-src": ("'self'", "data:"),
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
@cherrypy.tools.proxy(local=None, remote='X-Real-IP')
|
|
32
|
-
class Root:
|
|
33
|
-
|
|
34
|
-
@cherrypy.expose
|
|
35
|
-
@cherrypy.tools.sessions(locking='explicit')
|
|
36
|
-
def index(self):
|
|
37
|
-
return {'var1': 'test-jinja2'}
|
|
38
|
-
|
|
39
|
-
@cherrypy.expose
|
|
40
|
-
@cherrypy.tools.sessions(locking='explicit')
|
|
41
|
-
def logout(self, **kwargs):
|
|
42
|
-
raise cherrypy.HTTPRedirect('/')
|
|
43
|
-
|
|
44
|
-
@cherrypy.expose
|
|
45
|
-
@cherrypy.tools.secure_headers(on=False)
|
|
46
|
-
@cherrypy.tools.sessions(on=False)
|
|
47
|
-
def static(self, value=None):
|
|
48
|
-
return 'OK'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class SecureHeaderTest(helper.CPWebCase):
|
|
52
|
-
interactive = False
|
|
53
|
-
|
|
54
|
-
@classmethod
|
|
55
|
-
def setup_server(cls):
|
|
56
|
-
cherrypy.tree.mount(Root(), '/')
|
|
57
|
-
|
|
58
|
-
def test_cookie_samesite_lax(self):
|
|
59
|
-
# Given a request made to rdiffweb
|
|
60
|
-
# When receiving the response
|
|
61
|
-
self.getPage('/')
|
|
62
|
-
# Then the header contains Set-Cookie with SameSite=Lax
|
|
63
|
-
cookie = self.assertHeader('Set-Cookie')
|
|
64
|
-
self.assertIn('SameSite=Lax', cookie)
|
|
65
|
-
|
|
66
|
-
def test_cookie_samesite_lax_without_session(self):
|
|
67
|
-
# Given not a client sending no cookie
|
|
68
|
-
self.cookies = None
|
|
69
|
-
# When a query is made to a static path (without session)
|
|
70
|
-
self.getPage('/static/blue.css')
|
|
71
|
-
# Then Set-Cookie is not defined.
|
|
72
|
-
self.assertNoHeader('Set-Cookie')
|
|
73
|
-
|
|
74
|
-
def test_cookie_with_https(self):
|
|
75
|
-
# Given an https request made to rdiffweb
|
|
76
|
-
self.getPage('/', headers=[('X-Forwarded-Proto', 'https')])
|
|
77
|
-
# When receiving the response
|
|
78
|
-
self.assertStatus(200)
|
|
79
|
-
# Then the header contains Set-Cookie with Secure
|
|
80
|
-
cookie = self.assertHeader('Set-Cookie')
|
|
81
|
-
self.assertIn('Secure', cookie)
|
|
82
|
-
|
|
83
|
-
def test_cookie_with_http(self):
|
|
84
|
-
# Given an https request made to rdiffweb
|
|
85
|
-
self.getPage('/')
|
|
86
|
-
# When receiving the response
|
|
87
|
-
# Then the header contains Set-Cookie with Secure
|
|
88
|
-
cookie = self.assertHeader('Set-Cookie')
|
|
89
|
-
self.assertNotIn('Secure', cookie)
|
|
90
|
-
|
|
91
|
-
def test_get_with_wrong_origin(self):
|
|
92
|
-
# Given a GET request made to rdiffweb
|
|
93
|
-
# When the request is made using a different origin
|
|
94
|
-
self.getPage('/', headers=[('Origin', 'http://www.examples.com')])
|
|
95
|
-
# Then the response status it 200 OK.
|
|
96
|
-
self.assertStatus(200)
|
|
97
|
-
|
|
98
|
-
def test_post_with_wrong_origin(self):
|
|
99
|
-
# Given a POST request made to rdiffweb
|
|
100
|
-
# When the request is made using a different origin
|
|
101
|
-
self.getPage('/logout', headers=[('Origin', 'http://www.examples.com')], method='POST')
|
|
102
|
-
# Then the request is refused with 403 Forbiden
|
|
103
|
-
self.assertStatus(403)
|
|
104
|
-
self.assertInBody('Unexpected Origin header')
|
|
105
|
-
|
|
106
|
-
def test_post_with_prefixed_origin(self):
|
|
107
|
-
# Given a POST request made to rdiffweb
|
|
108
|
-
# When the request is made using a different origin
|
|
109
|
-
base = 'http://%s:%s' % (self.HOST + 'anything.com', self.PORT)
|
|
110
|
-
self.getPage('/logout', headers=[('Origin', base)], method='POST')
|
|
111
|
-
# Then the request is accepted with 200 OK
|
|
112
|
-
self.assertStatus(403)
|
|
113
|
-
self.assertInBody('Unexpected Origin header')
|
|
114
|
-
|
|
115
|
-
def test_post_with_valid_origin(self):
|
|
116
|
-
# Given a POST request made to rdiffweb
|
|
117
|
-
# When the request is made using a different origin
|
|
118
|
-
base = 'http://%s:%s' % (self.HOST, self.PORT)
|
|
119
|
-
self.getPage('/logout', headers=[('Origin', base)], method='POST')
|
|
120
|
-
# Then the request is accepted with 200 OK
|
|
121
|
-
self.assertStatus(303)
|
|
122
|
-
|
|
123
|
-
def test_post_without_origin(self):
|
|
124
|
-
# Given a POST request made to rdiffweb
|
|
125
|
-
# When the request is made without an origin
|
|
126
|
-
self.getPage('/logout', method='POST')
|
|
127
|
-
# Then the request is accepted with 200 OK
|
|
128
|
-
self.assertStatus(303)
|
|
129
|
-
|
|
130
|
-
def test_clickjacking_defense(self):
|
|
131
|
-
# Given a POST request made to rdiffweb
|
|
132
|
-
# When the request is made without an origin
|
|
133
|
-
self.getPage('/')
|
|
134
|
-
# Then the request is accepted with 200 OK
|
|
135
|
-
self.assertStatus(200)
|
|
136
|
-
self.assertHeaderItemValue('X-Frame-Options', 'DENY')
|
|
137
|
-
|
|
138
|
-
def test_no_cache(self):
|
|
139
|
-
# Given a POST request made to rdiffweb
|
|
140
|
-
# When the request is made without an origin
|
|
141
|
-
self.getPage('/')
|
|
142
|
-
# Then the request is accepted with 200 OK
|
|
143
|
-
self.assertStatus(200)
|
|
144
|
-
self.assertHeaderItemValue('Cache-control', 'no-cache')
|
|
145
|
-
self.assertHeaderItemValue('Cache-control', 'no-store')
|
|
146
|
-
self.assertHeaderItemValue('Cache-control', 'must-revalidate')
|
|
147
|
-
self.assertHeaderItemValue('Cache-control', 'max-age=0')
|
|
148
|
-
self.assertHeaderItemValue('Pragma', 'no-cache')
|
|
149
|
-
self.assertHeaderItemValue('Expires', '0')
|
|
150
|
-
|
|
151
|
-
def test_no_cache_with_static(self):
|
|
152
|
-
self.getPage('/static')
|
|
153
|
-
# Then the request is accepted with 200 OK
|
|
154
|
-
self.assertStatus(200)
|
|
155
|
-
self.assertNoHeader('Cache-control')
|
|
156
|
-
self.assertNoHeader('Pragma')
|
|
157
|
-
self.assertNoHeader('Expires')
|
|
158
|
-
|
|
159
|
-
def test_referrer_policy(self):
|
|
160
|
-
# Given a POST request made to rdiffweb
|
|
161
|
-
# When the request is made without an origin
|
|
162
|
-
self.getPage('/')
|
|
163
|
-
# Then the request is accepted with 200 OK
|
|
164
|
-
self.assertStatus(200)
|
|
165
|
-
self.assertHeaderItemValue('Referrer-Policy', 'same-origin')
|
|
166
|
-
|
|
167
|
-
def test_nosniff(self):
|
|
168
|
-
# Given a POST request made to rdiffweb
|
|
169
|
-
# When the request is made without an origin
|
|
170
|
-
self.getPage('/')
|
|
171
|
-
# Then the request is accepted with 200 OK
|
|
172
|
-
self.assertStatus(200)
|
|
173
|
-
self.assertHeaderItemValue('X-Content-Type-Options', 'nosniff')
|
|
174
|
-
|
|
175
|
-
def test_xss_protection(self):
|
|
176
|
-
# Given a POST request made to rdiffweb
|
|
177
|
-
# When the request is made without an origin
|
|
178
|
-
self.getPage('/')
|
|
179
|
-
# Then the request is accepted with 200 OK
|
|
180
|
-
self.assertStatus(200)
|
|
181
|
-
self.assertHeaderItemValue('X-XSS-Protection', '1; mode=block')
|
|
182
|
-
|
|
183
|
-
def test_content_security_policy(self):
|
|
184
|
-
# Given a POST request made to rdiffweb
|
|
185
|
-
# When the request is made without an origin
|
|
186
|
-
self.getPage('/')
|
|
187
|
-
# Then the request is accepted with 200 OK
|
|
188
|
-
self.assertStatus(200)
|
|
189
|
-
self.assertHeaderItemValue(
|
|
190
|
-
'Content-Security-Policy',
|
|
191
|
-
"default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; img-src 'self' data:",
|
|
192
|
-
)
|
|
193
|
-
|
|
194
|
-
def test_strict_transport_security(self):
|
|
195
|
-
# Given a POST request made to rdiffweb
|
|
196
|
-
# When the request is made without an origin
|
|
197
|
-
self.getPage('/', headers=[('X-Forwarded-Proto', 'https')])
|
|
198
|
-
# Then the request is accepted with 200 OK
|
|
199
|
-
self.assertStatus(200)
|
|
200
|
-
self.assertHeaderItemValue('Strict-Transport-Security', 'max-age=31536000; includeSubDomains')
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: cherrypy-foundation
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Cherrypy-foundation
|
|
5
|
-
Author-email: Patrik Dufresne <patrik@ikus-soft.com>
|
|
6
|
-
License: GPLv3
|
|
7
|
-
Project-URL: Homepage, https://gitlab.com/ikus-soft/cherrypy-foundation
|
|
8
|
-
Classifier: Development Status :: 4 - Beta
|
|
9
|
-
Classifier: Framework :: CherryPy
|
|
10
|
-
Classifier: Intended Audience :: System Administrators
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
-
Requires-Python: <4,>=3.11
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENSE.md
|
|
17
|
-
Requires-Dist: babel
|
|
18
|
-
Requires-Dist: CherryPy
|
|
19
|
-
Requires-Dist: Jinja2
|
|
20
|
-
Requires-Dist: jinjax
|
|
21
|
-
Requires-Dist: pytz
|
|
22
|
-
Requires-Dist: WTForms>=3.2.1
|
|
23
|
-
Provides-Extra: test
|
|
24
|
-
Requires-Dist: apscheduler; extra == "test"
|
|
25
|
-
Requires-Dist: argon2-cffi; extra == "test"
|
|
26
|
-
Requires-Dist: ldap3; extra == "test"
|
|
27
|
-
Requires-Dist: parameterized; extra == "test"
|
|
28
|
-
Requires-Dist: pytest; extra == "test"
|
|
29
|
-
Requires-Dist: requests_oauthlib; extra == "test"
|
|
30
|
-
Requires-Dist: selenium; extra == "test"
|
|
31
|
-
Requires-Dist: sqlalchemy; extra == "test"
|
|
32
|
-
Provides-Extra: ldap
|
|
33
|
-
Requires-Dist: ldap3; extra == "ldap"
|
|
34
|
-
Provides-Extra: oauth
|
|
35
|
-
Requires-Dist: requests_oauthlib; extra == "oauth"
|
|
36
|
-
Provides-Extra: passwd
|
|
37
|
-
Requires-Dist: argon2-cffi; extra == "passwd"
|
|
38
|
-
Provides-Extra: scheduler
|
|
39
|
-
Requires-Dist: apscheduler; extra == "scheduler"
|
|
40
|
-
Dynamic: license-file
|
|
41
|
-
|
|
42
|
-
# Cherrypy-foundation
|
|
43
|
-
|
|
44
|
-
<p align="center">
|
|
45
|
-
<a href="LICENSE"><img alt="License" src="https://img.shields.io/badge/license-GPL--3.0-orange"></a>
|
|
46
|
-
<a href="https://gitlab.com/ikus-soft/cherrypy-foundation/pipelines"><img alt="Build" src="https://gitlab.com/ikus-soft/cherrypy-foundation/badges/master/pipeline.svg"></a>
|
|
47
|
-
<a href="https://sonar.ikus-soft.com/dashboard?id=cherrypy-foundation"><img alt="Quality Gate" src="https://sonar.ikus-soft.com/api/project_badges/measure?project=cherrypy-foundation&metric=alert_status"></a>
|
|
48
|
-
<a href="https://sonar.ikus-soft.com/dashboard?id=cherrypy-foundation"><img alt="Coverage" src="https://sonar.ikus-soft.com/api/project_badges/measure?project=cherrypy-foundation&metric=coverage"></a>
|
|
49
|
-
</p>
|
|
50
|
-
|
|
51
|
-
Cherrypy-foundation is a comprehensive toolkit that accelerates web application development with CherryPy. It provides a curated collection of utilities and integrations that handle common web development tasks, allowing you to focus on building your application's unique features.
|
|
52
|
-
|
|
53
|
-
## What's Included
|
|
54
|
-
|
|
55
|
-
- **Database Integration**: Seamless SQLAlchemy integration for database operations
|
|
56
|
-
- **Template Engine**: Jinja2 and JinjaX support for flexible, component-based templating
|
|
57
|
-
- **Form Handling**: Enhanced WTForms integration with automatic validation and Bootstrap rendering
|
|
58
|
-
- **URL Management**: Flexible URL generation with `url_for` utility
|
|
59
|
-
- **Error Handling**: Smart error pages that adapt to response content type (HTML, JSON, plain text)
|
|
60
|
-
- **UI Components**: Bootstrap-ready components for rapid interface development
|
|
61
|
-
|
|
62
|
-
## Who Is This For?
|
|
63
|
-
|
|
64
|
-
Cherrypy-foundation is designed for developers who:
|
|
65
|
-
|
|
66
|
-
- Want to build modern web applications with CherryPy without reinventing the wheel
|
|
67
|
-
- Need a lightweight alternative to full-stack frameworks while maintaining flexibility
|
|
68
|
-
- Prefer convention over configuration but value customization options
|
|
69
|
-
- Want battle-tested components that integrate seamlessly with CherryPy's architecture
|
|
70
|
-
|
|
71
|
-
This documentation will guide you through all available features, from basic utilities to advanced integrations, with practical examples to help you get started quickly.
|
{cherrypy_foundation-1.0.0.dist-info → cherrypy_foundation-1.0.0a2.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|