fix: Skip setting existing context values

When setting up a context with user provided variables,
we should not override any existing values previously set.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-10-12 18:09:07 +02:00
parent 2166426d4c
commit 27cd533654
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 11 additions and 1 deletions

View file

@ -368,3 +368,13 @@ async def test_make_variable_context_timezone(user: User, package: Package):
request, "Test Details", next="/packages/test"
)
assert context["timezone"] in time.SUPPORTED_TIMEZONES
@pytest.mark.asyncio
async def test_make_variable_context_params():
request = Request(url="/test", query_params={"request": "test", "x": "test"})
context = await make_variable_context(request, "Test")
# make sure we can't override our Request object with a query parameter
assert context["request"] != "test"
assert context["x"] == "test"