mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: validate timezone before use
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
f9a5188fb7
commit
cb16f42a27
4 changed files with 40 additions and 4 deletions
|
@ -34,6 +34,7 @@ aurwebdir = $TOPLEVEL
|
|||
aur_location = https://aur.archlinux.org
|
||||
aur_request_ml = aur-requests@lists.archlinux.org
|
||||
enable-maintenance = 0
|
||||
default_timezone = UTC
|
||||
maintenance-exceptions = 127.0.0.1
|
||||
commit_uri = https://aur.archlinux.org/cgit/aur.git/log/?h=%s&id=%s
|
||||
localedir = $TOPLEVEL/web/locale/
|
||||
|
|
|
@ -16,6 +16,7 @@ from aurweb.models.relation_type import PROVIDES_ID, REPLACES_ID
|
|||
from aurweb.templates import (
|
||||
base_template,
|
||||
make_context,
|
||||
make_variable_context,
|
||||
register_filter,
|
||||
register_function,
|
||||
)
|
||||
|
@ -348,3 +349,22 @@ def test_package_details_filled(user: User, package: Package):
|
|||
base = base_template("partials/packages/details.html")
|
||||
body = base.render(context, show_package_details=True)
|
||||
check_package_details(body, package)
|
||||
|
||||
|
||||
def test_make_context_timezone(user: User, package: Package):
|
||||
request = Request(
|
||||
user=user, authenticated=True, url="/packages/test?timezone=foobar"
|
||||
)
|
||||
context = make_context(request, "Test Details")
|
||||
assert context["timezone"] in time.SUPPORTED_TIMEZONES
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_variable_context_timezone(user: User, package: Package):
|
||||
request = Request(
|
||||
user=user, authenticated=True, url="/packages/test?timezone=foobar"
|
||||
)
|
||||
context = await make_variable_context(
|
||||
request, "Test Details", next="/packages/test"
|
||||
)
|
||||
assert context["timezone"] in time.SUPPORTED_TIMEZONES
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue