misc: add required parameter when native 404 is called explicitely (#61816)

This commit is contained in:
Frédéric Péters 2022-03-23 15:53:55 +01:00
parent 749bcddd8f
commit 07d52f797c
2 changed files with 6 additions and 0 deletions

View File

@ -584,6 +584,9 @@ def publish_page(request, page, status=200, template_name=None):
def error404(request, *args, **kwargs):
if not args and 'exception' not in kwargs:
# happens when /404 is called on portal agent
kwargs['exception'] = Exception()
if not hasattr(request, 'user'):
# this happens when the 404 handler is called early on, for example
# when the given hostname doesn't exist as a tenant

View File

@ -555,6 +555,9 @@ def test_404(app):
assert 'Custom 404 Text' not in resp.text
assert "This page doesn't exist" not in resp.text
# check access using its /404/ slug
resp = app.get('/404', status=404)
# check 404 skeleton when all pages are private
resp = app.get('/__skeleton__/?source=404')
assert 'Custom 404 Text' not in resp.text